using Microsoft.Xna.Framework; class ScoreGameObject : TextGameObject { protected int score; public ScoreGameObject(GameWorld gameWorld, int layer = 0, string id = "") : base(gameWorld, "Fonts/Hud", layer, id) { } public override void HandleInput(InputHelper inputHelper, GameWorld gameWorld) { Duck duck = gameWorld.Find("Duck") as Duck; Player player = gameWorld.Find("Cursor") as Player; if (duck.Shooting) //If you hit the target, the 2 Bool values will switch to false, making the duck behave differently. { if (inputHelper.MouseBoundingRectangle.Intersects(duck.BoundingRectangle) && inputHelper.MouseLeftButtonPressed()) { LevelGameObject levelGameObject = gameWorld.Find("level") as LevelGameObject; if (player.ShotCount == 1) this.Score += 25 * levelGameObject.Level; // adds 25 points to the current score. Multiplied by the current level. if (player.ShotCount == 2) this.Score += 15 * levelGameObject.Level; // adds 15 points to the current score. Multiplied by the current level. if (player.ShotCount == 3) this.Score += 10 * levelGameObject.Level; // adds 10 points to the current score. Multiplied by the current level. } } base.HandleInput(inputHelper, gameWorld); } public override void Update(GameTime gameTime, GameWorld gameWorld) { this.Text = "SCORE: " + Score; } public override void Reset() { base.Reset(); score = 0; this.Position = new Vector2(120, 85); } public int Score { get { return score; } set { score = value; } } }