Exemplo n.º 1
0
    public void AddUnitToFormation(Unit u)
    {
        if (playerFormation is null)
        {
            playerFormation = new ArmyAction(AIController.Get().GetMaxUnitsInTeam());
        }

        if (choosenUnitsCount < (playerFormation.GetUnits().Length))
        {
            playerFormation.GetUnits()[choosenUnitsCount] = u;
            ++choosenUnitsCount;
        }
    }
Exemplo n.º 2
0
    void InterpretatePlayerFormation()
    {
        ArmyAction formation = GameController.Get().playerController.GetPlayerFormation();

        foreach (Unit unit in formation.GetUnits())
        {
            int cellDataRelativeX = unit.GetPosition().GetX();
            int cellDataRelativeY = unit.GetPosition().GetY();

            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().GetPlayerTeamData();

            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.position = new Vector3(cellDataWorldPosition.x, cellDataWorldPosition.y + 0.5f, cellDataWorldPosition.z);
        }
    }