コード例 #1
0
ファイル: SpecialFeed.cs プロジェクト: Dariusz-L/Snake2D
 /// <summary>
 /// Check if lifetime expired. If yes then dispatch an event.
 /// </summary>
 private void CheckIfExpired()
 {
     if (_expireStopwatch.Elapsed.Seconds >= LIFE_TIME_SECONDS)
     {
         UnityScene.GetController <EventController>().Dispatch <SpecialFeedExpiredEvent>(new EventArgs());
     }
 }
コード例 #2
0
ファイル: GameController.cs プロジェクト: Dariusz-L/Snake2D
        /// <summary>
        /// Called once after constructor
        /// </summary>
        public void OnStart()
        {
            _snakeController.OnStart();
            _cameraController.OnStart();
            foodSpawningController.OnStart();

            IEventController e = UnityScene.GetController <EventController>();

            foodSpawningController.Subscribe(e);
        }
コード例 #3
0
ファイル: SnakeController.cs プロジェクト: Dariusz-L/Snake2D
        /// <summary>
        /// Subscribes events and init parts and moveController.
        /// </summary>
        public void OnStart()
        {
            _moveController.OnStart();
            _parts.OnStart();

            IEventController e = UnityScene.GetController <EventController>();

            _moveController.Subscribe(e);
            _snakeEatingSystem.Subscribe(e);
            _snakeGrowingSystem.Subscribe(e);
            _snakeCollisionController.Subscribe(e);
        }
コード例 #4
0
 /// <summary>
 /// Sets _foodSpawningController and event controller reference. Adds SnakeMoveEvent listener.
 /// </summary>
 public void Subscribe(IEventController eventController)
 {
     _foodSpawningController = UnityScene.GetController <GameController>().foodSpawningController;
     eventController.AddListener <SnakeMoveEvent>(OnSnakeMove);
     _eventController = eventController;
 }
コード例 #5
0
 /// <summary>
 /// Init score to zero and subscribes events.
 /// </summary>
 public void OnStart()
 {
     score = 0;
     Subscribe(UnityScene.GetController <EventController>());
 }
コード例 #6
0
        /// <summary>
        /// Subscribe scoreText.
        /// </summary>
        public override void OnStart()
        {
            var ec = UnityScene.GetController <EventController>();

            scoreText.Subscribe(ec);
        }
コード例 #7
0
 /// <summary>
 /// Sets reference to event controller.
 /// </summary>
 public void OnStart()
 {
     eventController = UnityScene.GetController <EventController>();
 }