using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; /* * For any questions or help, contact me: * Zepharis Lubrano, 3861368 * zepharislubrano@hotmail.com */ class Bullets : GameObjectList { public Bullets(GameWorld gameWorld, int layer = 0, string id = "") : base(layer, id) { //Fills the list with Bullet Sprites and each on a different position. for (int i = 0; i < 3; i++) { Add(new SpriteGameObject(gameWorld, "Sprites/Bullet", 2, "Bullet")); Objects[i].Position = new Vector2(60 + i * 40, 600); } } //Method to easily make the Bullets visible again. public void ResetBullets() { Objects[0].Color = Color.White; Objects[1].Color = Color.White; Objects[2].Color = Color.White; } public override void Update(GameTime gameTime, GameWorld gameWorld) { Player player = gameWorld.Find("Cursor") as Player; //Makes the Bullet-objects transparent (not visible) //Switch method makes use of the ShotCount property in the Player class. switch (player.ShotCount) { case 1: Objects[2].Color = Color.Transparent; break; case 2: Objects[1].Color = Color.Transparent; Objects[2].Color = Color.Transparent; break; case 3: Objects[0].Color = Color.Transparent; Objects[1].Color = Color.Transparent; Objects[2].Color = Color.Transparent; break; default: ResetBullets(); break; } base.Update(gameTime, gameWorld); } }