public override void Execute(Level level) { ClientAvatar ca = level.GetPlayerAvatar(); DecoData dd = (DecoData)ObjectManager.DataTables.GetDataById(DecoId); if (ca.HasEnoughResources(dd.GetBuildResource(), dd.GetBuildCost())) { ResourceData rd = dd.GetBuildResource(); ca.CommodityCountChangeHelper(0, rd, -dd.GetBuildCost()); Deco d = new Deco(dd, level); d.SetPositionXY(X, Y); level.GameObjectManager.AddGameObject(d); } }
public void Load(JObject jsonObject) { JArray jsonBuildings = (JArray)jsonObject["buildings"]; foreach(JObject jsonBuilding in jsonBuildings) { BuildingData bd = (BuildingData)ObjectManager.DataTables.GetDataById(jsonBuilding["data"].ToObject<int>()); Building b = new Building(bd, m_vLevel); AddGameObject(b); b.Load(jsonBuilding); } JArray jsonTraps = (JArray)jsonObject["traps"]; foreach (JObject jsonTrap in jsonTraps) { TrapData td = (TrapData)ObjectManager.DataTables.GetDataById(jsonTrap["data"].ToObject<int>()); Trap t = new Trap(td, m_vLevel); AddGameObject(t); t.Load(jsonTrap); } JArray jsonDecos = (JArray)jsonObject["decos"]; foreach (JObject jsonDeco in jsonDecos) { DecoData dd = (DecoData)ObjectManager.DataTables.GetDataById(jsonDeco["data"].ToObject<int>()); Deco d = new Deco(dd, m_vLevel); AddGameObject(d); d.Load(jsonDeco); } }