/// <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(); } }
/// <summary> /// Tell the form that the game is over /// Update the score label, stop the update and view the end screen form /// </summary> public void GameOver() { endScreenScoreLabel.Text = "Score: " + (mGame.GetMap().GetMaxFood() - mGame.GetMap().GetFoodLeft()).ToString() + "/" + mGame.GetMap().GetMaxFood().ToString(); endScreenGroupBox.Visible = true; mIsRunning = false; }