"Summary" Game framework and architecture design (unity as an example)

Source: Internet
Author: User
Tags unity 5

developing games with framesAdvantages: Low coupling, high reusability, fast deployment, high maintainability and convenient management. Improve development efficiency, reduce the difficulty of development disadvantage: increase the complexity of the system structure and implementation, need to spend extra effort to maintain, not suitable for small programs, easy to affect the operational efficiency   Common Frameworks MVC
    • Presentation Layer (View): Game screen. Ui
    • Logic Layer (Controller): Data interface, operation control, AI
    • Data Layer (Model): Data storage, image, sound and other resources
In my sframework, the view layer is separate, the model I put in the base class, the controller in the derived class, the implementation of the MVC separation (if you want to refactor I might use a combination instead of inheritance) Example: playerhud+ Playerctrl (Playeryuka) +iplayer Note the call relationship in the graph MVC advantages: The realization of hierarchical design, is a basic common framework disadvantage: MVC if not used well, prone to a certain layer of excessive phenomenon (such as view). MVC is more suitable for cross-ply projects. The game (not the UI part) is not appropriate. MVVMThe MVVM model renamed the MVP Presenter to ViewModel, which is basically exactly the same as the MVP model. MVP, the View and Model do not occur in contact, are passed through the Presenter. The only difference is that it uses two-way binding (data-binding): The change of view is automatically reflected in the ViewModel sframework, and view cannot modify the model directly between them through event communication uframe& The Mvvmuframe framework mimics the schema pattern of MVVM (which in fact does not contain the model part, and the controller part is more) in Uframe, using the concept of element to split the business into three parts:
    • ViewModel: Saves data structures for objects in the game, such as blood, experience, money, and so on.
    • Controller: Handles game business logic. For example, blood, blood loss, and the like.
    • View: The object that can be seen in the game world, and ViewModel bindings to show in the game.
Uframe is visualized, the function seems convenient and practical, but because of the charge, I did not go into, inconvenience too much evaluation PureMVCThe PureMVC framework introduces a variety of design patterns, message mechanisms (using the observer pattern, publish/Subscribe mode) to decouple each module
I have used the PUREMVC framework to develop a demo that uses Applicationfacade,mediator,proxy,command to set up a project and interact with the SendNotification () with the advantage of strong decoupling, Realize the MVC height separation disadvantage: Increase the code amount, reduce the execution efficiency, the function call level is deep, it is easy to find the message sending source. Facade as a single-instance interface, should be managed Mvc,model, View, controller but provides a getinstance () method, it makes people strange MVCSThe framework and schema STRANGEIOC support dependency injection (i.e. control inversion (inversion of controls, abbreviated IOC), which can effectively reduce coupling but the IOC is complex and slow, and is mono-based, so I didn't choose ECSEntity Component System Unity itself component development is the ECS framework, ECS is very suitable for game development, in the game engine is more common, Google once on GitHub released a name of the ECS framework called Entitas, below we will introduce
    • An entity is a Gameobject object that has only data, and does not include methods
    • Each entity has a component component that is responsible for Entity data processing
    • Group is an entity collection with the same component
    • Context is the creation of a factory that destroys entity
    • The Collector Collector provides a simple way to handle the response of entity changes in group.
ECS tutorials are still relatively small, detailed I also inconvenient to introduce, interested in these frameworks can choose a deep other Trap FrameworkTrap is a senior production of a stand-alone game, he in this game using their own original framework, Sframework also from the reference to a lot of design ideas. The trap has a partial UI section and a game section that encapsulates unity events and input controls, uses Singleton, manager, and Notificationcenter for message transmission, but is not currently open source gameframeworkUnity 5.3+ engine based game framework, Chinese original, open source details can go to the official website to see the introduction and more excellent framework can be found in GitHub ~

"Summary" Game framework and architecture design (unity as an example)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.