Ejemplo n.º 1
0
        public ShipInstance(Position pos, Rotation r, Ship ship)
        {
            this.pos = pos;
            this.rotation = r;
            this.ship = ship;

            this.sunken = false;
        }
Ejemplo n.º 2
0
 public ShotType FireAtShip(Position pos)
 {
     ShipInstance hit = HitsShip(pos);
     if (hit != null)
     {
         shots[pos.x + (pos.y * boardSize)] = ShotType.HIT;
     }
     else
     {
         shots[pos.x + (pos.y * boardSize)] = ShotType.MISS;
     }
     return shots[pos.x + (pos.y * boardSize)];
 }
Ejemplo n.º 3
0
        public List<Position> GetPath()
        {
            List<Position> path = new List<Position>();

            Position shippos = pos;
            Position rotpos = new Position(rotation);

            for (int i = 0; i < ship.length; i++)
            {
                path.Add(shippos);

                shippos += rotpos;
            }

            return path;
        }
Ejemplo n.º 4
0
 public ShipInstance HitsShip(Position pos)
 {
     foreach(ShipInstance shipinst in ships)
     {
         List<Position> shipPath = shipinst.GetPath ();
         if (shipPath.Contains (pos))
             return shipinst;
     }
     return null;
 }
Ejemplo n.º 5
0
 public ShotType Fire(int playerId, Position pos)
 {
     gb.SendMessage(new ChatMessage("SYSTEM", "TURN:"+(1-playerId)));
     ShotType stype = gb.games[1 - playerId].FireAtShip(pos);
     return stype;
 }