Beispiel #1
0
    private void Update()
    {
        for (int i = activePowerupList.Count - 1; i >= 0; i--)
        {
            ActivePowerUp activePowerup = activePowerupList[i];
            activePowerup.timer -= Time.deltaTime;

            if (activePowerup.timer <= 0f)
            {
                activePowerup.Remove(this);
                activePowerup.timer = 0f;
                activePowerupList.RemoveAt(i);
            }
        }
    }
        public void AddPowerUpTest()
        {
            // GameItem-Liste initialisieren
            GameItem.GameItemList = new System.Collections.Generic.LinkedList <IGameItem>();

            // Neuen Spieler erzeugen
            Player target = CreatePlayer();

            // Neues PowerUp und ActivePowerUp erzeugen
            MultiShot     multiShot = new MultiShot(Vector2.Zero, Vector2.Zero);
            ActivePowerUp powerUp   = new ActivePowerUp(15.0f, PowerUpEnum.MultiShot, multiShot.Apply, multiShot.Remove); // TODO: Passenden Wert initialisieren


            target.AddPowerUp(powerUp);

            Assert.AreEqual(target.ActivePowerUps.Count, 1);

            // GameItem-Liste zurüksetzen
            GameItem.GameItemList = null;
        }