public override void Save(LogicJSONObject jsonObject, int villageType) { LogicTimer.SetLogicTimer(jsonObject, this.m_timer, this.m_parent.GetLevel(), "spawn_timer"); jsonObject.Put("initial_spawn_done", new LogicJSONBoolean(this.m_initialSpawnDone)); jsonObject.Put("lifetime_spawns", new LogicJSONNumber(this.m_lifeTimeSpawns)); LogicJSONArray jsonArray = new LogicJSONArray(); for (int i = 0; i < this.m_spawned.Size(); i++) { jsonArray.Add(new LogicJSONNumber(this.m_spawned[i])); } jsonObject.Put("spawned", jsonArray); }
public void Save(LogicJSONObject root) { if (this.m_offerObject != null && this.m_level.GetState() != 1) { root.Put("offer", this.m_offerObject); } else { LogicJSONObject jsonObject = new LogicJSONObject(); LogicTimer.SetLogicTimer(jsonObject, this.m_timer, this.m_level, "pct"); if (this.m_terminate) { jsonObject.Put("t", new LogicJSONBoolean(true)); } LogicJSONArray offerArray = new LogicJSONArray(); for (int i = 0; i < this.m_offers.Size(); i++) { LogicJSONObject obj = this.m_offers[i].Save(); if (obj != null) { offerArray.Add(obj); } } if (this.m_offerObject != null) { LogicJSONArray oldArray = this.m_offerObject.GetJSONArray("offers"); if (oldArray != null) { for (int i = 0; i < oldArray.Size(); i++) { LogicJSONObject obj = (LogicJSONObject)oldArray.Get(i); if (obj != null) { int data = LogicJSONHelper.GetInt(jsonObject, "data", -1); if (this.GetOfferById(data) == null) { offerArray.Add(obj); } } } } } root.Put("offers", offerArray); for (int i = 0; i < 2; i++) { if (this.m_topOffer[i] != null) { root.Put(i == 1 ? "top2" : "top", new LogicJSONNumber(this.m_topOffer[i].GetData().GetId())); } } root.Put("offer", jsonObject); } }