public Powerup Generate_Powerup(Vector2 position) { Powerup newPowerup = new Powerup(position, new Vector2(0, 3), Content.Load<Texture2D>("powerup1.png")); return newPowerup; }
public bool PowerupPlayerCollisionDetection(Powerup powerup) { foreach (Player player in Players) { float playerMinX = player.position.X; float playerMaxX = (player.position.X + player.texture.Bounds.Width); float playerMinY = player.position.Y; float playerMaxY = (player.position.Y + player.texture.Bounds.Height); float powerupMinY = powerup.position.Y; float powerupMaxY = (powerup.position.Y + powerup.texture.Bounds.Height); float powerupMinX = powerup.position.X; float powerupMaxX = (powerup.position.X + powerup.texture.Bounds.Width); float midpowerX = (powerupMinX + ((powerupMaxX - powerupMinX) / 2)); float midpowerY = (powerupMinY + ((powerupMaxY - powerupMinY) / 2)); if (midpowerX > playerMinX && midpowerX < playerMaxX) { if (midpowerY > playerMinY && midpowerY < playerMaxY) { if (player.powerupcounter == 0) player.powerupcounter++; else if (player.powerupcounter == 1) player.powerupcounter++; else if (player.powerupcounter == 2) player.powerupcounter++; else if (player.powerupcounter == 3) player.powerupcounter++; else if (player.powerupcounter == 4) player.powerupcounter++; PowerupChecker(); return true; } } } return false; }
public void AddPowerup(Powerup powerup) { _powerups.Add(powerup); }