Exemplo n.º 1
0
        /// <summary>
        /// Override the set position of this object
        /// </summary>
        /// <param name="pPosition">The new position</param>
        public override void SetPosition(Point pPosition)
        {
            base.SetPosition(pPosition);

            // Find any food at the new position
            Food food = Game.GetMap().GetFoodAtPos(pPosition);

            // If food has been found
            if (food != null)
            {
                // Eat it
                food.Eat();

                // If the food is a superfood
                if (food.Type == Food.FoodType.Super)
                {
                    // Add a speedbuff
                    SpeedMultiplier = 2.0f;

                    // Reset timer if a buff is already active
                    mBuffTimer.Stop();
                    mBuffTimer.Start();
                }
            }

            // End the game if all food has been taken
            if (Game.GetMap().GetFoodLeft() <= 0)
            {
                Game.GameOver();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Override the set position to check for the player
        /// </summary>
        /// <param name="pPosition">The new possition</param>
        public override void SetPosition(Point pPosition)
        {
            base.SetPosition(pPosition);

            // CHeck if there is a player at the new position
            if (Game.IsPlayerAtPosition(pPosition))
            {
                // End the game if so
                Game.GameOver();
            }

            // Instantly move to a possible new direction
            FindDirection();
            Move();
        }