Пример #1
0
        public ReadyToPlayState(BoardSetup _setup)
        {
            setup         = _setup;
            opponentSetup = new BoardSetup();

            handler = new ChatHandler();
            setupExchangeHandler = new SetupExchangeHandler(_setup, opponentSetup);
            handler.SetSuccessor(setupExchangeHandler).SetSuccessor(new UserHandler()).SetSuccessor(new HelpHandler());
        }
Пример #2
0
        public Board(BoardSetup setup)
        {
            tileMap = new Tile[Globals.boardSize, Globals.boardSize];
            for (int i = 0; i < Globals.boardSize; i++)
            {
                for (int j = 0; j < Globals.boardSize; j++)
                {
                    tileMap[i, j] = new Tile(i, j);
                }
            }

            unitsList = new List <Unit>();
            shipsList = new List <Ship>();

            var unitDataIterator = new UnitDataContainer(setup.placedEntities).GetIterator();

            while (unitDataIterator.HasNext())
            {
                UnitData    unitData  = (UnitData)unitDataIterator.Next();
                List <Tile> unitTiles = new List <Tile>();
                for (int j = 0; j < unitData.positions.Count; j += 2)
                {
                    unitTiles.Add(tileMap[unitData.positions[j], unitData.positions[j + 1]]);
                }

                Ship ship = null;
                switch (unitData.layout.type)
                {
                case UnitLayout.Type.SShip:
                    ship = new SShip(unitTiles);
                    break;

                case UnitLayout.Type.MShip:
                    ship = new MShip(unitTiles);
                    break;

                case UnitLayout.Type.LShip:
                    ship = new LShip(unitTiles);
                    break;

                case UnitLayout.Type.XLShip:
                    ship = new XLShip(unitTiles);
                    break;
                }

                shipsList.Add(ship);
                unitsList.Add(ship);
            }
        }
Пример #3
0
 public GameInstance(BoardSetup yourBoardSetup, BoardSetup opponentBoardSetup, bool _yourTurn)
 {
     yourBoard     = new Board(yourBoardSetup);
     opponentBoard = new Board(opponentBoardSetup);
     yourTurn      = _yourTurn;
 }
Пример #4
0
 public GameSetupHandler(BoardSetup _setup)
 {
     setup = _setup;
 }
 public Memento(BoardSetup setup)
 {
     unplacedUnits = setup.unplacedEntities.ToList();
     placedUnits   = setup.placedEntities.ToList();
 }
 public SetupExchangeHandler(BoardSetup _setup, BoardSetup _opponentSetup)
 {
     setup         = _setup;
     opponentSetup = _opponentSetup;
 }