Пример #1
0
 private static void AddBullet(Player player)
 {
     Map.Point deltaCoords = MovableObject.GetDeltaCoords(player.direction);
     bullets[player.team].Add(
         new Bullet(
             player.team,
             player.direction,
             new Map.Point(player.coords.X + deltaCoords.X, player.coords.Y + deltaCoords.Y)));
 }
Пример #2
0
 public Bullet(int team, MovableObject.Direction direction, Map.Point coords)
 {
     deltaCoords    = GetDeltaCoords(direction);
     this.team      = team;
     this.direction = direction;
     this.coords    = new Map.Point(coords.X, coords.Y);
     newCoords      = new Map.Point(coords.X, coords.Y);
     isAlive        = true;
     moveFrequency  = StartingSpeed;
 }
Пример #3
0
        public bool Move(MovableObject.Direction direction)
        {
            if (beforeMoving == 0)
            {
                if (direction == this.direction)
                {
                    Map.Point deltaCoords = GetDeltaCoords(direction);
                    newCoords = new Map.Point(coords.X + deltaCoords.X, coords.Y + deltaCoords.Y);
                }
                else
                {
                    this.direction = direction;
                }

                beforeMoving = moveFrequency;
                key          = 0;
                return(true);
            }
            return(false);
        }
Пример #4
0
 static public Map.Point GetDeltaCoords(Direction direction)
 {
     Map.Point deltaCoords = new Map.Point();
     if (direction == Direction.left)
     {
         deltaCoords.X -= 1;
     }
     if (direction == Direction.right)
     {
         deltaCoords.X += 1;
     }
     if (direction == Direction.up)
     {
         deltaCoords.Y -= 1;
     }
     if (direction == Direction.down)
     {
         deltaCoords.Y += 1;
     }
     return(deltaCoords);
 }
Пример #5
0
 public Player(int team, Map.Point coords)
 {
     this.team     = team;
     this.coords   = coords;
     moveFrequency = StartingSpeed;
 }