Ejemplo n.º 1
0
        private void setUpPowerUp(int key)
        {
            if(key == PowerUps.NONE)
            {
                return;
            }

            switch (key)
            {
                case PowerUps.NONE:
                    return;
                case PowerUps.BERSERKER:
                    isInBerserk = true;
                    powerUpAction = berserk;
                    powerUpTriggered = true;
                    break;
                default:
                    return;
            }
        }
Ejemplo n.º 2
0
        private void berserk(GameTime gameTime)
        {
            if(powerUpTriggered)
            {
                Board.Instance.ReleasePowerUp(tileX, tileY);
                alpha = 255;
                powerUpTriggered = false;
                powerUpTime = gameTime.TotalGameTime;
            }

            const int ALPHA_DELTA = 20;

            alpha += (byte)delta;
            if (alpha > 255 - ALPHA_DELTA)
            {
                delta = -ALPHA_DELTA;
            }
            else if (alpha < ALPHA_DELTA)
            {
                delta = ALPHA_DELTA;
            }

            effectColor = Color.FromNonPremultiplied(255, 20, 20, alpha);

            effectAccumulator += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (effectAccumulator > powerUpDuration)
            {
                effectColor = Color.FromNonPremultiplied(0, 0, 0, 0);
            }
            if (effectAccumulator > powerUpDuration + powerUpOfffsetDuration)
            {
                effectAccumulator = 0;
                powerUpAction = null;
                isInBerserk = false;
            }
        }
Ejemplo n.º 3
0
 public bool Has(PowerUpAction action)
 {
     return(powerUps.Contains(action.source.id));
 }
Ejemplo n.º 4
0
 public bool Remove(PowerUpAction action)
 {
     return(powerUps.Remove(action.source.id));
 }
Ejemplo n.º 5
0
 void Invoke(PowerUpAction action)
 {
     action.action.Invoke(action);
     powerUps.Add(action.source.id);
 }