Beispiel #1
0
 public int GetPlayerZone()
 {
     if (_gridPosition.x < _myBoard.GetBoardWidth() / 2)
     {
         return(1);
     }
     else
     {
         return(2);
     }
 }
Beispiel #2
0
    public void StartGame()
    {
        UnitController newUnit;

        string configFilePath = Application.streamingAssetsPath + "/grid.csv";

        string[] gridFile = File.ReadAllLines(configFilePath);
        _myGrid      = new BoardGrid(gridFile, _tilePrefabs, _designerTileSize, _tileWidth, _tileHeight);
        _myGameState = new BeginTurnState(_startingPlayer);
        int i = 0;

        foreach (GameObject unitPrefab in _unitPrefabsPlayer1)
        {
            newUnit = Instantiate(unitPrefab, new Vector3(100.0f, 100.0f, 0.0f), Quaternion.identity).GetComponent <UnitController>();
            newUnit.InitializeUnit();
            if (newUnit.IsKing())
            {
                newUnit.DeployUnit(_myGrid.GetTile(0, _myGrid.GetBoardHeight() - 1));
            }
            _units.Add(newUnit);
            i++;
        }
        i = 0;
        foreach (GameObject unitPrefab in _unitPrefabsPlayer2)
        {
            newUnit = Instantiate(unitPrefab, new Vector3(100.0f, 100.0f, 0.0f), Quaternion.identity).GetComponent <UnitController>();
            newUnit.InitializeUnit();
            if (newUnit.IsKing())
            {
                newUnit.DeployUnit(_myGrid.GetTile(_myGrid.GetBoardWidth() - 1, 0));
            }
            _units.Add(newUnit);
            i++;
        }
        foreach (UnitController unit in _units)
        {
            IEnterTile[] unitEnterTileReactors;
            if (unit._isDeployed)
            {
                unitEnterTileReactors = unit.gameObject.GetComponents <IEnterTile>();
                foreach (IEnterTile reactor in unitEnterTileReactors)
                {
                    reactor.EnterTileAction(unit._myTile);
                }
            }
        }
        _myUIController.InitializeUnitsPanel(_units, _startingPlayer, this, _timeLimit);
    }