Beispiel #1
0
    public void MoveUnitToOtherArmy(int unitIndex, Army targetArmy, int amount)
    {
        if ((units.Count - 1) < unitIndex)
        {
            UnityEngine.Debug.LogError("Unit which you want to move to other army is null! count: " + (units.Count - 1) + " index: " + unitIndex);
            return;
        }

        if (amount > units[unitIndex].amount)
        {
            UnityEngine.Debug.LogError("There aren't enough units to move!");
            return;
        }

        targetArmy.AddUnit(new UnitInstance(units[unitIndex].GetUnit(), amount));
        RemoveUnitAtIndex(unitIndex, amount);

        if (ArmyUI.GetCurrentWorldAgentArmy() != null)
        {
            UIManager.instance.WorldAgentPanel.GetArmyUI().Refresh(ArmyUI.GetCurrentWorldAgentArmy());
        }

        if (CityUI.GetCurrentBuildingArmy() != null)
        {
            CityUI.instance.GetArmyUI().Refresh(CityUI.GetCurrentBuildingArmy());
        }
        else if (UtilityBuildingUI.GetCurrentBuildingArmy() != null)
        {
            UtilityBuildingUI.instance.GetArmyUI().Refresh(UtilityBuildingUI.GetCurrentBuildingArmy());
        }
    }
Beispiel #2
0
    public void MoveUnitToSecondArmy()
    {
        Army worldAgentArmy   = ArmyUI.GetCurrentWorldAgentArmy();
        Army currBuildingArmy = null;

        if (UIManager.instance.ExchangePanel.IsOpened())
        {
            worldAgentArmy   = UIManager.instance.ExchangePanel.GetEnteredAgent().GetArmy();
            currBuildingArmy = UIManager.instance.ExchangePanel.GetDockAgent().GetArmy();
        }
        else if (CityUI.GetCurrentBuildingArmy() != null)
        {
            if (CityUI.instance.IsSelectedWorldAgentDockedInThisCity())
            {
                currBuildingArmy = CityUI.GetCurrentBuildingArmy();
            }
        }
        else if (UtilityBuildingUI.GetCurrentBuildingArmy() != null)
        {
            if (UtilityBuildingUI.instance.IsSelectedWorldAgentDockedInThisUtilityBuilding())
            {
                currBuildingArmy = UtilityBuildingUI.GetCurrentBuildingArmy();
            }
        }

        if (worldAgentArmy != null && currBuildingArmy != null)
        {
            CloseInfoWindow();

            if (myArmyUI.isItCity)
            {
                currBuildingArmy.MoveUnitToOtherArmy(index, worldAgentArmy);
            }
            else
            {
                worldAgentArmy.MoveUnitToOtherArmy(index, currBuildingArmy);
            }

            if (UIManager.instance.ExchangePanel.IsOpened())
            {
                UIManager.instance.ExchangePanel.Refresh();
            }
        }

        AudioManager.instance.ClickButton();
    }