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))); }
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; }
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); }
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); }
public Player(int team, Map.Point coords) { this.team = team; this.coords = coords; moveFrequency = StartingSpeed; }