Пример #1
0
        public virtual void Destruct()
        {
            if (this.m_functions != null)
            {
                for (int i = this.m_functions.Size() - 1; i >= 0; i--)
                {
                    this.m_functions[i].Destruct();
                    this.m_functions.Remove(i);
                }

                this.m_functions = null;
            }

            if (this.m_buildingBoostCost != null)
            {
                while (this.m_buildingBoostCost.Size() > 0)
                {
                    this.m_buildingBoostCost[0].Destruct();
                    this.m_buildingBoostCost.Remove(0);
                }

                this.m_troopDiscount = null;
            }

            if (this.m_troopDiscount != null)
            {
                while (this.m_troopDiscount.Size() > 0)
                {
                    this.m_troopDiscount[0].Destruct();
                    this.m_troopDiscount.Remove(0);
                }

                this.m_troopDiscount = null;
            }

            if (this.m_freeTroops != null)
            {
                while (this.m_freeTroops.Size() > 0)
                {
                    this.m_freeTroops[0].Destruct();
                    this.m_freeTroops.Remove(0);
                }

                this.m_freeTroops = null;
            }

            this.m_enabledData = null;
            this.m_useTroops   = null;

            this.m_clashBoxEntryName = null;
            this.m_notificationTid   = null;
            this.m_image             = null;
            this.m_sc           = null;
            this.m_localization = null;

            this.m_eventEntryData = null;
            this.m_targeting      = null;
            this.m_errorHandler   = null;
        }
Пример #2
0
 public void SetEventEntryData(LogicEventEntryData value)
 {
     this.m_eventEntryData = value;
 }
Пример #3
0
        public virtual void Load(LogicJSONObject jsonObject)
        {
            if (jsonObject == null)
            {
                this.m_errorHandler.Error(this, "Json cannot be null");
            }

            this.m_id      = LogicJSONHelper.GetInt(jsonObject, "id", -1);
            this.m_version = LogicJSONHelper.GetInt(jsonObject, "version", 0);

            this.m_newTrainingBoostBarracksCost = LogicDataTables.GetGlobals().GetNewTrainingBoostBarracksCost();
            this.m_newTrainingBoostSpellCost    = LogicDataTables.GetGlobals().GetNewTrainingBoostLaboratoryCost();

            this.m_startTime = LogicCalendarEvent.ConvertStringToTimestamp(LogicJSONHelper.GetString(jsonObject, "startTime"), false);
            this.m_endTime   = LogicCalendarEvent.ConvertStringToTimestamp(LogicJSONHelper.GetString(jsonObject, "endTime"), true);

            if (this.m_startTime >= this.m_endTime)
            {
                this.m_errorHandler.ErrorField(this, "endTime", "End time must be after start time.");
            }

            LogicJSONString visibleTimeString = jsonObject.GetJSONString("visibleTime");

            if (visibleTimeString != null)
            {
                this.m_visibleTime = LogicCalendarEvent.ConvertStringToTimestamp(visibleTimeString.GetStringValue(), false);

                if (this.m_visibleTime > this.m_startTime)
                {
                    this.m_errorHandler.ErrorField(this, "visibleTime", "Visible time must be before or at start time.");
                }
            }
            else
            {
                this.m_visibleTime = 0;
            }

            this.m_clashBoxEntryName = jsonObject.GetJSONString("clashBoxEntryName").GetStringValue();

            LogicJSONString eventEntryNameString = jsonObject.GetJSONString("eventEntryName");

            this.m_eventEntryData = LogicDataTables.GetEventEntryByName(eventEntryNameString.GetStringValue(), null);

            if (eventEntryNameString.GetStringValue().Length > 0)
            {
                if (this.m_eventEntryData == null)
                {
                    this.m_errorHandler.ErrorField(this, "eventEntryName", string.Format("Invalid event entry name: {0}.", eventEntryNameString.GetStringValue()));
                }

                if (this.m_visibleTime == 0)
                {
                    this.m_errorHandler.ErrorField(this, "visibleTime", "Visible time must be set if event entry name is set.");
                }
            }

            if (this.m_visibleTime != 0)
            {
                if (this.m_eventEntryData == null)
                {
                    this.m_errorHandler.ErrorField(this, "eventEntryName", "Event entry name must be set if visible time is set.");
                }
            }

            this.m_inboxEntryId    = LogicJSONHelper.GetInt(jsonObject, "inboxEntryId", -1);
            this.m_notificationTid = LogicJSONHelper.GetString(jsonObject, "notificationTid");
            this.m_image           = LogicJSONHelper.GetString(jsonObject, "image");
            this.m_sc           = LogicJSONHelper.GetString(jsonObject, "sc");
            this.m_localization = LogicJSONHelper.GetString(jsonObject, "localization");

            LogicJSONObject targetingObject = jsonObject.GetJSONObject("targeting");

            if (targetingObject != null)
            {
                this.m_targeting = new LogicCalendarTargeting(jsonObject);
            }

            LogicJSONArray functionArray = jsonObject.GetJSONArray("functions");

            if (functionArray != null)
            {
                for (int i = 0; i < functionArray.Size(); i++)
                {
                    this.m_functions.Add(new LogicCalendarFunction(this, i, functionArray.GetJSONObject(i), this.m_errorHandler));
                }
            }
        }