Exemplo n.º 1
0
        public override void Register(HistoryParameter Param)
        {
            parameter = Param as ArmyChangeHistoryParameter;
            Army      = parameter.CurrentArmy;

            ArmyName = Army.Name;
            NoRushX  = Army.NoRush.X;
            NoRushY  = Army.NoRush.Y;

            Mass   = Army.Data.Economy.mass;
            Energy = Army.Data.Economy.energy;

            personality          = Army.Data.personality;
            plans                = Army.Data.plans;
            color                = Army.Data.color;
            faction              = Army.Data.faction;
            nextPlatoonBuilderId = Army.Data.nextPlatoonBuilderId;

            Alliances = new SaveLua.Army.Aliance[Army.Data.Alliances.Count];
            for (int i = 0; i < Alliances.Length; i++)
            {
                Alliances[i] = new SaveLua.Army.Aliance();
                Alliances[i].AllianceType  = Army.Data.Alliances[i].AllianceType;
                Alliances[i].ConnectedArmy = Army.Data.Alliances[i].ConnectedArmy;
            }
        }
Exemplo n.º 2
0
    public void OnAllianceChange(int i, MapLua.SaveLua.Army.AllianceTypes NewValue)
    {
        if (Repainting)
        {
            return;
        }

        Undo.RegisterUndo(new UndoHistory.HistoryArmyChange(), new UndoHistory.HistoryArmyChange.ArmyChangeHistoryParameter(SelectedArmy));

        bool Found = false;

        for (int a = 0; a < SelectedArmy.Data.Alliances.Count; a++)
        {
            if (SelectedArmy.Data.Alliances[a].ConnectedArmy == AllianceValues[i])
            {
                if (NewValue == SaveLua.Army.AllianceTypes.None)
                {
                    SelectedArmy.Data.Alliances.RemoveAt(a);
                }
                else
                {
                    SelectedArmy.Data.Alliances[a].AllianceType = GetAllianceString(NewValue);
                }
                Found = true;
            }
        }

        if (!Found && NewValue != SaveLua.Army.AllianceTypes.None)
        {
            SaveLua.Army.Aliance NewAlliance = new SaveLua.Army.Aliance();
            NewAlliance.ConnectedArmy = AllianceValues[i];
            NewAlliance.AllianceType  = GetAllianceString(NewValue);

            SelectedArmy.Data.Alliances.Add(NewAlliance);
        }

        //RepaintArmy();
    }