Exemplo n.º 1
0
        bool Allocate(MilitaryUnitType type, int amount)
        {
            var troop         = GetTroop(type);
            var previousValue = troop == null ? 0 : troop.count;

            if (troop == null)
            {
                Debug.Log("No previous deployment for " + type + " on current order.");
                troop = Military.Allocate(Game.GetParticipant(data.participantId), Game.Map.GetProvince(data.pathByRegionNames[0]), type, amount);
                if (troop == null)
                {
                    Debug.LogWarning("Can't fulfill allocation!");
                    return(false);
                }
                var newUnits = new MilitaryUnit[data.troops.Length + 1];
                Array.Copy(data.troops, newUnits, data.troops.Length);
                newUnits[newUnits.Length - 1] = troop;
                data.troops = newUnits;
            }
            else
            {
                Military.AllocateInto(ref troop, Game.GetParticipant(data.participantId), Game.Map.GetProvince(data.pathByRegionNames[0]), type, amount);
            }

            return(previousValue != troop.count);
        }