Ejemplo n.º 1
0
 public void FillPowerup(Powerup pwr, int id)
 {
     int r = pwr.size / 2;
     for (int i = -r; i <= r; i++)
         for (int j = -r; j <= r; j++)
             if ((i * i) + (j * j) <= r * r)
                 // disallow snake overriding
                 if (!pointsHistory.ContainsKey(field[pwr.x + i, pwr.y + j]))
                     field[pwr.x + i, pwr.y + j] = id;
 }
Ejemplo n.º 2
0
        public void AddPowerup(Powerup p)
        {
            int powerupId = findPowerup(p);

            if ((powerupId == -1) || (p.unique == false))
            {
                PowerupEffects.Start(this, p);
                powerups.Add(p);
            }
            else
                powerups[powerupId].expirationTime = p.expirationTime;
        }
Ejemplo n.º 3
0
 public static void Start(Snake s, Powerup p)
 {
     switch (p.effect)
     {
         case Effects.greenSpeed:
             s.speed *= 2;
             s.turningSpeed *= 1.5;
             break;
         case Effects.redSpeed:
             s.speed *= 2;
             break;
         case Effects.greenSlow:
             s.speed /= 2;
             break;
         case Effects.redSlow:
             s.speed /= 2;
             s.turningSpeed /= 1.5;
             break;
         case Effects.greenThin:
             s.size /= 2;
             s.RecreateTrailingPen();
             break;
         case Effects.redThick:
             s.size *= 2;
             s.RecreateTrailingPen();
             break;
         case Effects.greenTurns:
             s.turningSpeed *= 1.5;
             break;
         case Effects.redTurns:
             s.turningSpeed /= 1.5;
             break;
         case Effects.greenRightAngle:
         case Effects.redRightAngle:
             s.rightAngleTurns = !s.rightAngleTurns;
             break;
         case Effects.greenInvisibility:
             s.isDrawing = false;
             break;
         case Effects.redInverse:
             s.inverse *= -1;
             break;
         default:
             break;
     }
 }
Ejemplo n.º 4
0
 int findPowerup(Powerup pwr)
 {
     for (int i = 0; i < powerups.Count; i++)
         if (powerups[i].effect == pwr.effect)
             return i;
     return -1;
 }