예제 #1
0
        public ShipInstance(Position pos, Rotation r, Ship ship)
        {
            this.pos = pos;
            this.rotation = r;
            this.ship = ship;

            this.sunken = false;
        }
예제 #2
0
파일: Board.cs 프로젝트: ylt/Battleships
 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)];
 }
예제 #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;
        }
예제 #4
0
파일: Board.cs 프로젝트: ylt/Battleships
 public ShipInstance HitsShip(Position pos)
 {
     foreach(ShipInstance shipinst in ships)
     {
         List<Position> shipPath = shipinst.GetPath ();
         if (shipPath.Contains (pos))
             return shipinst;
     }
     return null;
 }
예제 #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;
 }