GithubHelp home page GithubHelp logo

oddmax / match3-mvc-ecs-example Goto Github PK

View Code? Open in Web Editor NEW
46.0 5.0 6.0 2.89 MB

A simple match-3 game made in Unity demonstrating hybrid architecture (Zenject-based MVC and DOTS ECS)

License: Apache License 2.0

C# 95.01% ShaderLab 4.38% HLSL 0.61%
dots unity mvc zenject

match3-mvc-ecs-example's Introduction

Match3 example game

How to test

Open MainScene.scene and press 'Play'. Game was optimized for mobile portait mode so it will look best with a landscape aspect ratio.

Description

A simple game to demonstraite a clean and robust architecture for the match-3 game which can be easily extended with any extra functionality. Uses a hybrid architecture - as foundation I use MVC-like architecture based on Zenject with Command pattern, but for match3 mechanics I used Unity DOTS Entity Component System as it works very well with this kind of logic.

Built with Unity 2020.1.13f

Funcionality

Has base match-3 mechanics and different levels. All levels and settings could be setup as Scriptable Objects.

General structure

  • Uses very simple MVC/MVP architecture and Command pattern for main application logic
  • Uses Unity DOTS Entity Component System for match-3 gameplay mechanics.
  • Uses Zenject of inversion of control and dependencies injections
  • Uses SignalBus from Zenject to decouple communication between different classes
  • Implemented a custom State Machine to switch between global states (Boot -> LevelMap -> GameBoard) with a support of more complex State Charts
  • Same State Chart is used to flow through match-3 states with a State pattern (PlyaerTurn -> Swap -> MatchesDestuction -> etc)
  • Implemented a simple Pooling class for optimizing board gems usage
  • Scripts/Core folder holds all core funtionality (Main state machine, Main Context installer)
  • Scripts/Features folder holds feature related logic

Main classes and their descriptions

Models

  • Is Plain C# class
  • Holds application state
  • Injectable into Presenters, Commands and Services (in case of adding backend). Not injectable to other models.
  • Usually doesn't have injected dependencies
  • Serialiazable for both sending to the backend or to be saved on the device

Views

  • Is Subclass of MonoBehaviour
  • Can have references to a group of View Elements and child Views that share the same purpose
  • Listens to user input on the view elements and forwards them to the Presenter
  • Not injectable
  • Doesn't have injected dependencies

Presenter

Has references to Views

  • Listens to changes in Models and updates the Views it is responsible for
  • Has injected dependencies to Models, SignalBus, and Services.
  • Listens to user inputs passed from the views or directly and executes commands

Configs located in Config folder

  • Is a ScriptableObject assets
  • Gets serialized
  • Holds static information of the objects which doesn't change such as levels, how much score points for different matches to give, etc

Signals

  • Is Plain C# class
  • Used to notify other parts of the system of models updates or to execute a command

Command

  • Is Plain C# class
  • Micro controller responsible to execute one action and update all necessary models based on result of this action

DOTS Components

  • Data container for ECS systems

DOTS Systems

  • Base on archetype of entity will execute some data changes to components and can notify about them via signals.

match3-mvc-ecs-example's People

Contributors

oddmax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

match3-mvc-ecs-example's Issues

Doesn't run on Android

I am using Unity 2020.3.13f1 which is the version this project was originally created for.
In the Build Settings, Texture Compression was set to ASTC.
The game turns into a black screen after the made with Unity logo disappears.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.