using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Audio; /* * For any questions or help, contact me: * Zepharis Lubrano, 3861368 * zepharislubrano@hotmail.com */ class SmallDucks : GameObjectList { int count = 0; //count for going through all the indices int Duckhits = 0; //integer to see how many ducks have been hit. bool filled; //if this is true, we can know that the count has passed the 10 (and no shots are available). public SmallDucks(GameWorld gameWorld, int layer = 0, string id = "") : base(layer, id) { //Fills the list with Duck Sprites and each on a different position. for (int i = 0; i < 10; i++) { Add(new SpriteGameObject(gameWorld, "Sprites/DuckSmall", 2, "SmallDuck")); Objects[i].Position = new Vector2(435 + i * 40, 600); } } public void ResetColors() { for (int i = 0; i < 10; i++) Objects[i].Color = Color.White; } public override void HandleInput(InputHelper inputHelper, GameWorld gameWorld) { Duck duck = gameWorld.Find("Duck") as Duck; Player player = gameWorld.Find("Cursor") as Player; HighScore highscore = gameWorld.Find("Highscore") as HighScore; if (count < 10) { //if player shoots duck, turn green, duckhits-counter++ and move to next index number. if (!duck.DuckAlive && duck.Shooting && inputHelper.MouseLeftButtonPressed()) { Objects[count].Color = Color.Green; Duckhits++; count++; duck.VliegTimer = new TimeSpan(0, 0, 0); } //if player misses all three shots, turn red and move to next index number. if (duck.DuckAlive && player.ShotCount == 2 && duck.Shooting && inputHelper.MouseLeftButtonPressed()) { Objects[count].Color = Color.Red; count++; duck.VliegTimer = new TimeSpan(0, 0, 0); } if (duck.VliegTimer.Seconds > 10) { Objects[count].Color = Color.Red; count++; duck.VliegTimer = new TimeSpan(0, 0, 0); } } if (count >= 10) //after 10 ducks the bar resets and turns all miniducks yellow. { filled = true; count = 0; } base.HandleInput(inputHelper, gameWorld); } public int Count { get { return count; } } public int DuckHits { get { return Duckhits; } set { Duckhits = value; } } public bool Filled { get { return filled; } set { filled = value; } } }