Beispiel #1
0
    // Use this for initialization
    void CreateSystemsDirectly()
    {
        RootSystems systems = new RootSystems(Contexts.sharedInstance);
        //systems.E

        //BEST PRACTICE: Contexts.sharedInstance is a useful way to get contexts and expose them to monobehavior scripts as well using a static modifier as op0osed to just createing new Contexts();
        Contexts contexts = Contexts.sharedInstance;

        //STANDARD PRACTICE:this is the standard way of creating contexts at start
        //var contexts = new Contexts();

        ///EXAMPLE ZERO: Initialize entities by using a system as opposed to creating the object in the start or update method
        //BEST PRACTICE: It's best to use systems for all logic, including creating Entities using ?Initialize
        m_TestPlayerCreateSystem = new CreatePlayerSystem(contexts);
        m_TestPlayerCreateSystem.Initialize();
        //STANDARD PRACTICE: this is a simple way to create an entity without using a system to do it

        /*  var e = contexts.game.CreateEntity();
         * //No AddComponent with ECS, instead we use the Add method and constructor form the generated IComponent script
         * e.AddHealth(100);
         */

        ///EXAMPLE ONE: ExecuteSystems: simply perform when execute method is called
        //Execution logic is generally contained in systems that need to be executed
        var system = new LogHealthSystem(contexts);

        system.Execute();

        ///EXAMPLE TWO: ReactiveSystems: Execute in reaction to some component changing
        m_TestReactiveSystem = new ReactLogHealthSystem(contexts);
    }
Beispiel #2
0
    private void Start()
    {
        // var contexts = new Contexts();
        var contexts = Contexts.sharedInstance;

        _systems = new RootSystems(contexts);
        _systems.Initialize();
    }
Beispiel #3
0
    //private RootFixedSystems _rootFixedSystems;

    private void Awake()
    {
        _contexts = Contexts.sharedInstance;

        _rootServices = new RootServices();
        _rootSystems  = new RootSystems(_contexts, _rootServices);
        //_rootFixedSystems = new RootFixedSystems(_contexts);

        AddEntitiesIds();

        _rootSystems.Initialize();
        //_rootFixedSystems.Initialize();
    }
Beispiel #4
0
    /*
     * There are 5 different types of Systems:
     *
     * IInitializeSystem: Executes once, before the game begins (system.Initialize()).
     * IExecuteSystem: Executes every frame (system.Execute())
     * ICleanupSystem: Executes every frame after the other systems are finished (system.Cleanup())
     * ITearDownSystem: Executes once, after the game ends (system.TearDown())
     * ReactiveSystem<Entity>: Executes when the observed group changed (system.Execute(Entity[]))
     * */

    private void Start()
    {
        if (m_UsingFeatureClasses == false)
        {//NOTE: READ THROUGH THIS FOR TUTORIAL LOGIC on how to use systems
            CreateSystemsDirectly();
        }
        else
        {
            m_Systems = new RootSystems(Contexts.sharedInstance);


            m_Systems.Initialize();
        }
    }
Beispiel #5
0
    private void Awake()
    {
        var contexts = Contexts.sharedInstance;

        var menuManager = new MenuManager(contexts);

        _globalConfig.Initialize(contexts);
        _hudController.Initialize(contexts);

        _rootSystems = new RootSystems(contexts);
        _viewSystems = new ViewSystems(contexts);

        _rootSystems.Initialize();
        _viewSystems.Initialize();
    }
Beispiel #6
0
    void Awake()
    {
        Pool pool = Pools.pool;

        rootSystems = new RootSystems(pool);

        pool.CreateEntity().AddCamera(Camera.main).AddGameObject(Camera.main.gameObject.transform.parent.gameObject).AddCameraSettings(CameraDampTime, CameraScreenEdgeBuffer, CameraMinSize);

        for (int i = 0; i < Tanks.Length; i++)
        {
            TankSetupInfo info = Tanks[i];
            pool.CreateEntity().IsPlayer(true).AddId(i + 1).AddColour(info.PlayerColor).AddWins(0);
            CreateTank(pool, i + 1, info);
        }

        pool.CreateEntity().IsRound(true).AddRoundNumber(0).AddRoundPhase(RoundPhase.Start).AddRoundMessage(MessageText).AddRequiredToWin(NumRoundsToWin);
    }
    private void Awake()
    {
        _contexts = Contexts.sharedInstance;

        Configure(_contexts);

        //How to live without DI?
        _services = new Services
        {
            ViewService    = new UnityViewService(_contexts),
            InputService   = new UnityInputService(_contexts, Camera.main),
            TimeService    = new UnityTimeService(_contexts),
            ElementService = new ElementService(_contexts),
        };

        _rootSystems = new RootSystems(_contexts, _services);
        _rootSystems.Initialize();
    }
Beispiel #8
0
    private void Awake()
    {
        Contexts = Contexts.Instance;

        Contexts.EnableVisualDebugging();

        Configure(Contexts);

        _services = new Services
        {
            ViewService    = new UnityViewService(Contexts),
            InputService   = new UnityInputService(Contexts, Camera.main),
            TimeService    = new UnityTimeService(Contexts),
            ElementService = new UnityElementService(Contexts),
        };

        _rootSystems = new RootSystems(Contexts, _services);
        _rootSystems.Initialize();
    }
Beispiel #9
0
    // Start is called before the first frame update
    void Awake()
    {
        Application.targetFrameRate = 60;
        _contexts = Contexts.sharedInstance;

        var gamplayServices = new GameplayServices.GameplayServices()
        {
            InputService  = new UnityInputService(_contexts),
            ViewService   = new UnityViewService(),
            RandomService = new RngFast(),
            TimeService   = new UnityTimeService(),
            BtService     = new BTService(),
        };

        var regService = new ServiceRegistrationSystems(_contexts, gamplayServices);

        regService.Initialize();

        _rootSystems = new RootSystems(_contexts);
        _rootSystems.Initialize();
    }
        public void Awake()
        {
            _contexts = Contexts.Instance;

            Configure(_viewModel, _contexts);

            // The difference between a 'View' and an 'EntityListener' is that listeners are created to monitor a specific (already created) entity
            // whereas Views are being initialized once here and can monitor against any entity that may be created at any point.

            _viewModel.Views.Add <UIScoreView>();
            _viewModel.Views.Add <UIRewardView>();
            _viewModel.Views.Add <UIActionCountView>();
            _viewModel.Views.Add <UIRestartView>();
            _viewModel.Views.Add <UIGameOverView>();
            _viewModel.Views.Add <UIComboView>();
            _viewModel.Views.Add <UISettingsSync>();

            _factories = new TestFactories
            {
                ElementFactory = new ElementPool()
            };

            _services = new TestServices
            {
                ViewService    = new TestViewService(_contexts, _viewModel, _factories),
                InputService   = new TestInputService(_contexts, _viewModel, _factories),
                TimeService    = new TestTimeService(_contexts, _viewModel, _factories),
                ElementService = new TestElementService(_contexts, _viewModel, _factories),
            };

            _rootSystems = new RootSystems(_contexts, _services);
            _rootSystems.Initialize();

            StartUpdateTimer();

            StartGame();
        }
Beispiel #11
0
 // Use this for initialization
 void Start()
 {
     s = new RootSystems(Contexts.sharedInstance);
     s.Initialize();
 }
Beispiel #12
0
 public override void Dispose()
 {
     RootSystems.Destroy();
     RootSystems = null;
 }