In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "introduction to Unity Development intermediary pattern". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
0. Preface
A game may contain many subsystems
Event system
Checkpoint system
Role management system
Achievement system
Game status interface
Role information interface
Pause interface
If the interaction between subsystems is not planned, there will be cross-references.
The intermediary mode can be used to decouple the internal subsystems in game development.
1. An introduction to the intermediary model
The intermediary pattern (Mediator) is stated in GoF as follows:
An interface is defined to encapsulate the interactive behavior of a group of objects. Intermediaries reduce the coupling between objects by removing references between them, and can change the interactive independence between them.
To illustrate the intermediary model in terms of housing transactions, it can be explained as follows:
The intermediary company is an information center (corresponding to the intermediary), and all buyers and sellers (all subsystems) handle the sale of houses through the intermediary company.
two。 The way of implementation in game development
This is how we implement the intermediary model in game development.
First of all, the game will have two major system categories: "game system class" and "interface class".
We define these two abstract classes, define some lifecycle-related methods, and then pass in an instance of the intermediary in the constructor. Each time you create a new system class, you inherit one of the abstract classes. In this way, each system will hold an intermediary. When we do the subsystem function, we do not need to care about which system this function will be associated with, we just need to inform the intermediary what function the current subsystem wants to accomplish through the instance of the intermediary, and leave the rest to the intermediary to deal with the reference logic between subsystems. Of course, the construction of all subsystems is done in the intermediary, who has access to all subsystems.
Advantages
Through this operation, we uncouple the subsystems, and the external dependence of all subsystems is reduced to one class.
Shortcoming
It should be noted that because the intermediary class acts as the information exchange and communication between all game systems and the UI interface, it is easy to have an explosive operation interface, so we also need to cooperate with other design patterns to avoid this situation and to reduce the burden on the intermediary class.
This is the end of the introduction to the Unity Development Mediator Model. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.