/// <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()); } }
/// <summary> /// Called once after constructor /// </summary> public void OnStart() { _snakeController.OnStart(); _cameraController.OnStart(); foodSpawningController.OnStart(); IEventController e = UnityScene.GetController <EventController>(); foodSpawningController.Subscribe(e); }
/// <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); }
/// <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; }
/// <summary> /// Init score to zero and subscribes events. /// </summary> public void OnStart() { score = 0; Subscribe(UnityScene.GetController <EventController>()); }
/// <summary> /// Subscribe scoreText. /// </summary> public override void OnStart() { var ec = UnityScene.GetController <EventController>(); scoreText.Subscribe(ec); }
/// <summary> /// Sets reference to event controller. /// </summary> public void OnStart() { eventController = UnityScene.GetController <EventController>(); }