using Microsoft.Xna.Framework; class HitCounter : TextGameObject { protected int hitCount; protected string name; protected bool doUpdate; public HitCounter(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; if (doUpdate) { 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()) hitCount++; } } base.HandleInput(inputHelper, gameWorld); } public override void Update(GameTime gameTime, GameWorld gameWorld) { GameModeHandler gmHandler = gameWorld.Find("gmHandler") as GameModeHandler; Duck duck = gameWorld.Find("Duck") as Duck; this.Text = name + hitCount; } public override void Reset() { hitCount = 0; } public int HitCount { get { return hitCount; } set { hitCount = value; } } public string Name { get { return name; } set { name = value; } } public bool DoUpdate { get { return doUpdate; } set { doUpdate = value; } } }