Exemple #1
0
    private void DropPlaceable()
    {
        if (lastCellCollidedWith)
        {
            Soldier  thisSoldier    = transform.GetComponent <Soldier>();
            CellData targetCellData = lastCellCollidedWith.GetComponent <Cell>().GetBehaviour().GetCellData();
            Unit     placedUnit     = new Unit(targetCellData, new UnitData(thisSoldier.GetUnitType()));

            if (targetCellData.IsEmpty())
            {
                float yModifier = 0.5f;
                transform.localPosition = new Vector3(
                    lastCellCollidedWith.transform.position.x,
                    lastCellCollidedWith.transform.position.y + yModifier,
                    lastCellCollidedWith.transform.position.z
                    );

                this.followCursorComponent.StopMoving();

                TeamData team = GameController.Get().GetPlayerTeamData();
                thisSoldier.SetUnit(placedUnit);
                team.AddSoldier(thisSoldier);
                thisSoldier.SetTeam(team);
                PlayerController.Get().AddUnitToFormation(placedUnit);
                targetCellData.SetEmpty(false);
                draggingUnit = false;
            }
        }
    }
Exemple #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);
        }
    }