Пример #1
0
        /// <summary>
        /// If snake moves then check is feed is near. If yes then dispatch FeedEatenEvent.
        /// </summary>
        private void OnSnakeMove(EventArgs args)
        {
            Type type = _foodSpawningController.IsFeedAvailable(_snakeParts.head.transform.position);

            if (type == null)
            {
                return;
            }

            _eventController.Dispatch <FeedEatenEvent>(new FeedEatenEventArgs(type));
        }
Пример #2
0
        /// <summary>
        /// Adds score points when snake has eaten feed.
        /// </summary>
        private void OnFeedEaten(EventArgs args)
        {
            FeedEatenEventArgs feedArgs = args as FeedEatenEventArgs;

            if (feedArgs.eatenFeedType == typeof(NormalFeed))
            {
                score += 1;
            }
            else if (feedArgs.eatenFeedType == typeof(SpecialFeed))
            {
                score += 10;
            }

            _eventController.Dispatch <ScoreChangedEvent>(new ScoreChangedEventArgs(score));
        }
Пример #3
0
 /// <summary>
 /// Moves snake.
 /// </summary>
 private void ProcessMovement()
 {
     Move(CheckMoveDir());
     _eventController.Dispatch <SnakeMoveEvent>(new SnakeMoveEventArgs(_snakeParts));
 }