/// <summary> /// Generate position. /// </summary> /// <returns> the pair </returns> private Pair <int, int> generatePosition() { Random random = new Random(); int xP = Clamp.clamp(random.Next(GameImpl.ARENA_WIDTH), 0 + PowerUpImpl.WIDTH / 2, GameImpl.ARENA_WIDTH - PowerUpImpl.WIDTH / 2); const int yP = 0; return(new Pair <int, int>(xP, yP)); }
/// <summary> /// Update. /// </summary> public override void update() { this.Position.SetX(this.Position.GetX() + this.Speed.GetX()); this.Position.SetY(this.Position.GetY() + this.Speed.GetY()); this.Position.SetX(Clamp.clamp(this.Position.GetX(), WIDTH / 2, GameImpl.ARENA_WIDTH - WIDTH / 2)); this.Position.SetY(Clamp.clamp(this.Position.GetY(), HEIGHT / 2, GameImpl.ARENA_HEIGHT - HEIGHT / 2)); this.Hitbox = new Rectangle(this.Position.GetX() - WIDTH / 2, this.Position.GetY() - HEIGHT / 2, WIDTH, HEIGHT); }
private void FadeOut() { if (m_isFadeOut == true) { return; } float time = (1 * m_time) / Time.deltaTime; m_a -= 1 / time; m_a = Clamp.clamp(m_a, 0, 1); }
/// <summary> /// 更新 /// </summary> public void Update() { if (m_isWorking == false) { return; } float time = 1 * m_fadeTime; m_alpha += 1 / time; m_alpha = Clamp.clamp(m_alpha, 0, 1); }
/// <summary> /// Insert effect. /// </summary> protected internal override void InsertEffect() { PlayerImpl player = this.EntityStrategy; if (this.Type.Equals(PowerUpT.HEALTH)) { player.Health = Clamp.clamp(player.Health + this.strategy.multiplyEffect(STANDARD_HEALTH), 0, 100); } else if (this.Type.Equals(PowerUpT.FIRE_BOOST)) { player.CoolDown = player.CoolDown - this.strategy.multiplyEffect(STANDARD_FIRE_RATE_BOOST); } else { if (this.GetActivated() == false) { player.SHield = this.strategy.multiplyEffect(SHIELD_S); } else if (player.Shield == 0) { this.setDead(); } } }