private void HandlePowerups(GameTime gameTime) { _countdownToPowerup -= gameTime.ElapsedGameTime.Milliseconds; if ((gameTimer > 60000 && _minCountdownToPowerup == 10000) || (gameTimer > 120000 && _minCountdownToPowerup == 5000)) { _minCountdownToPowerup /= 2; _maxCountdownToPowerup /= 2; } if (_countdownToPowerup <= 0) { _countdownToPowerup = random.Next(_minCountdownToPowerup, _maxCountdownToPowerup); Tile randTile = null; bool foundTile = false; do { randTile = _currentMap.GetRandomWalkableTile(); if (randTile == null) { break; } foundTile = true; for (int i = 0; i < _powerups.Count; i++) { if (randTile.position == _powerups[i].position) { foundTile = false; break; } } } while (!foundTile); int startRange = GameRules.selectedGameType == GameRules.GameType.CollectToWin ? 0 : 1; Powerup newPower = new Powerup((int)randTile.position.X, (int)randTile.position.Y, (Powerup.PowerupType)random.Next(startRange, 3)); newPower.LoadContent(_contentManager); _powerups.Add(newPower); } }
public void GetPowerup(Powerup powerup) { powerUpInSlot = powerup; powerUpInSlot.position = powerupRectangle.position; powerUpInSlot.position.X += 2; powerUpInSlot.position.Y += 2; }
private void RemovePowerup() { switch (activePowerup.Type) { case Powerup.PowerupType.Speed: _movementSpeed = 3f; break; case Powerup.PowerupType.BigAmmo: _hasBigAmmo = false; if (_chargeLevel == 1) { _scale = 1f; cannon.SetScale(1f); } break; case Powerup.PowerupType.AttackSpeed: _hasFastAttack = false; coolDownTime = 300; break; } activePowerup = null; }
public void ActivatePowerup() { switch (powerUpInSlot.Type) { case Powerup.PowerupType.Speed: _movementSpeed = 5f; break; case Powerup.PowerupType.AttackSpeed: _hasFastAttack = true; coolDownTime = 100f; break; case Powerup.PowerupType.BigAmmo: _hasBigAmmo = true; _scale = 1.2f; cannon.SetScale(1.2f); break; case Powerup.PowerupType.Mines: break; } activePowerup = powerUpInSlot; activePowerup.position = powerUpInSlot.position; activePowerup.position.X+= 32 + 16; powerUpInSlot = null; _powerupTimer = 5000; }