public void Update(GameTime gameTime) // just for collision detection { hitbox = new Rectangle((int)position.X, (int)position.Y, sprite.Width, sprite.Height); //color change if (oldHealth > currentHealth) { color = Color.Red; } else if (currentHealth <= 0) { color = Color.DarkGray; //TODO: dying sequence } else { color = Color.LightBlue; } oldHealth = currentHealth; //update timers on stat multipliers for (int stat = 0; stat < activeEffects.Length; stat++) { for (int effect = 0; effect < activeEffects[stat].Count; effect++) { //decrement each effect's timer (the Y coordinate) as needed activeEffects[stat][effect] = new Vector2(activeEffects[stat][effect].X, activeEffects[stat][effect].Y - (float)gameTime.ElapsedGameTime.TotalSeconds); //remove the effects that have expired if (activeEffects[stat][effect].Y <= 0) { activeEffects[stat].RemoveAt(effect); effect--; } } } //check repulsor if (repulsor != null) { if (repulsor.Enabled) { repulsor.Update(); } else { repulsor = null; } } }
//constructor public Player(int myHealth, int myFuel, Vector2 myPosition, Vector2 myVelocity, Texture2D mySprite) { maxHealth = myHealth; currentHealth = myHealth; oldHealth = myHealth; maxFuel = myFuel; currentFuel = myFuel; position = myPosition; velocity = myVelocity; sprite = mySprite; activeEffects = new List <Vector2> [7]; for (int i = 0; i < 7; i++) { activeEffects[i] = new List <Vector2>(); } color = Color.LightBlue; repulsor = null; enabled = true; }