Ejemplo n.º 1
0
    void InterpretateFormation()
    {
        ArmyAction formation = selfFormation;

        foreach (Unit unit in formation.GetUnits())
        {
            int cellDataRelativeX = BoardData.Get().GetColumns() - unit.GetPosition().GetX() - 1;
            int cellDataRelativeY = BoardData.Get().GetRows() - unit.GetPosition().GetY() - 1;

            CellData relativeCellData      = BoardData.Get().GetCellDataAt(cellDataRelativeX, cellDataRelativeY);
            Vector3  cellDataWorldPosition = boardBehaviour.GetWorldPositionOfCell(relativeCellData);

            UnitType   AI_unitUnitType = unit.GetUnitData().GetType();
            GameObject AI_unit         = GameController.Get().unitsPool.GetUnitInstance(AI_unitUnitType);

            relativeCellData.SetEmpty(false);

            AI_unit.SetActive(true);

            Soldier  AI_unitSoldier = AI_unit.GetComponent <Soldier>();
            TeamData team           = GameController.Get().GetAITeamData();

            AI_unitSoldier.SetUnitType(AI_unitUnitType);
            team.AddSoldier(AI_unitSoldier);
            AI_unitSoldier.SetTeam(team);
            AI_unitSoldier.SetUnit(new Unit(unit));
            AI_unitSoldier.Start();
            AI_unit.GetComponent <DraggeableUnit>().enabled = false;

            AI_unit.transform.localPosition = new Vector3(cellDataWorldPosition.x, cellDataWorldPosition.y + 0.5f, cellDataWorldPosition.z);
        }
    }
Ejemplo n.º 2
0
    public void OnPlayerDecideFormation()
    {
        playerController.ResetChoosenUnits();
        boardBehaviour.ResetCells();
        // Center the camera in the player board
        BoardData boardData = BoardData.Get();
        Vector3   playerCenterCellPosition = boardBehaviour.GetWorldPositionOfCell(boardData.GetPlayerCellsCenterCell());

        cameraBehaviour.CenterToPosition(playerCenterCellPosition);

        // Hide all cells but player's
        HideCells();
    }