//uses ghost powerup if conditions are right public void UseGhost() { foreach (Well well in ParentGame.UnstableWells.ToList()) { if (Math.Pow(Xcoor - well.Xcoor, 2) + Math.Pow(Ycoor - well.Ycoor, 2) < 30000) { GamePowerup.Ghost(); } } }
//uses neutralize powerup if conditions are right public void UseNeutralize() { foreach (Well well in ParentGame.StableWells.ToList()) { if (Math.Pow(Xcoor - well.Xcoor, 2) + Math.Pow(Ycoor - well.Ycoor, 2) < 30000) { GamePowerup.Neutralize(); } } }
//AI uses the destabilize powerup if a well is in range public void UseDestabilize() { if (GamePowerup.CarryingDestabilize) { foreach (Well well in ParentGame.UnstableWells.ToList()) { if (Math.Pow(Xcoor - well.Xcoor, 2) + Math.Pow(Ycoor - well.Ycoor, 2) < 30000) { GamePowerup.Destabilize(this); } } } }
//This method deals with a keypress. It either updates the user directional input, does a speed boost, or uses a powerup. public void KeyPressed(char c) { switch (c) { case 'w': VerticalInput = -1; break; case 'a': HorizontalInput = -1; break; case 's': VerticalInput = 1; break; case 'd': HorizontalInput = 1; break; case ' ': SpeedBoost(); break; case 'q': GamePowerup.Neutralize(); break; case 'f': GamePowerup.Destabilize(); break; case 'e': GamePowerup.Ghost(); break; } }