public override void Process() { var ca = Device.Player.Avatar; var bd = (Decos)CSV.Tables.Get(Gamefile.Decos).GetDataWithID(BuildingId); if (!ca.Variables.IsBuilderVillage) { var b = new Deco(bd, Device.Player); if (ca.HasEnoughResources(bd.GetBuildResource().GetGlobalId(), bd.GetBuildCost())) { ca.Resources.Minus(bd.GetGlobalId(), bd.GetBuildCost()); b.SetPosition(X, Y); Device.Player.GameObjectManager.AddGameObject(b); } } else { var b = new Builder_Deco(bd, Device.Player); if (ca.HasEnoughResources(bd.GetBuildResource().GetGlobalId(), bd.GetBuildCost())) { ca.Resources.Minus(bd.GetGlobalId(), bd.GetBuildCost()); b.SetPosition(X, Y); Device.Player.GameObjectManager.AddGameObject(b); } } }
public void Load(JObject jsonObject) { var jsonBuildings = (JArray) jsonObject["buildings"]; foreach (JObject jsonBuilding in jsonBuildings) { var bd = CSV.Tables.Get(Gamefile.Buildings) .GetDataWithID(jsonBuilding["data"].ToObject<int>()) as Buildings; var b = new Building(bd, Level); AddGameObject(b); b.Load(jsonBuilding); } var jsonObstacles = (JArray) jsonObject["obstacles"]; foreach (JObject jsonObstacle in jsonObstacles) { var dd = CSV.Tables.Get(Gamefile.Obstacles).GetDataWithID(jsonObstacle["data"].ToObject<int>()) as Obstacles; var d = new Obstacle(dd, Level); AddGameObject(d); d.Load(jsonObstacle); } var jsonTraps = (JArray) jsonObject["traps"]; foreach (JObject jsonTrap in jsonTraps) { var td = CSV.Tables.Get(Gamefile.Traps).GetDataWithID(jsonTrap["data"].ToObject<int>()) as Traps; var t = new Trap(td, Level); AddGameObject(t); t.Load(jsonTrap); } var jsonDecos = (JArray) jsonObject["decos"]; foreach (JObject jsonDeco in jsonDecos) { var dd = CSV.Tables.GetWithGlobalID(jsonDeco["data"].ToObject<int>()) as Decos; var d = new Deco(dd, Level); AddGameObject(d); d.Load(jsonDeco); } var villageObjects = (JArray) jsonObject["vobjs"]; foreach (JObject villageObject in villageObjects) { var dd = CSV.Tables.GetWithGlobalID(villageObject["data"].ToObject<int>()) as Village_Objects; var d = new Village_Object(dd, Level); AddGameObject(d); d.Load(villageObject); } var jsonBuildings2 = (JArray) jsonObject["buildings2"]; foreach (JObject jsonBuilding2 in jsonBuildings2) { var bd = CSV.Tables.Get(Gamefile.Buildings) .GetDataWithID(jsonBuilding2["data"].ToObject<int>()) as Buildings; var b = new Builder_Building(bd, Level); AddGameObject(b); b.Load(jsonBuilding2); } var jsonObstacles2 = (JArray) jsonObject["obstacles2"]; foreach (JObject jsonObstacle2 in jsonObstacles2) { var dd = CSV.Tables.Get(Gamefile.Obstacles) .GetDataWithID(jsonObstacle2["data"].ToObject<int>()) as Obstacles; var d = new Builder_Obstacle(dd, Level); AddGameObject(d); d.Load(jsonObstacle2); } var jsonTraps2 = (JArray) jsonObject["traps2"]; foreach (JObject jsonTrap2 in jsonTraps2) { var td = CSV.Tables.Get(Gamefile.Traps).GetDataWithID(jsonTrap2["data"].ToObject<int>()) as Traps; var t = new Builder_Trap(td, Level); AddGameObject(t); t.Load(jsonTrap2); } var jsonDecos2 = (JArray) jsonObject["decos2"]; foreach (JObject jsonDeco2 in jsonDecos2) { var dd = CSV.Tables.GetWithGlobalID(jsonDeco2["data"].ToObject<int>()) as Decos; var d = new Builder_Deco(dd, Level); AddGameObject(d); d.Load(jsonDeco2); } var jsonObjects2 = (JArray) jsonObject["vobjs2"]; foreach (JObject jsonObject2 in jsonObjects2) { var dd = CSV.Tables.GetWithGlobalID(jsonObject2["data"].ToObject<int>()) as Village_Objects; var d = new Builder_Village_Object(dd, Level); AddGameObject(d); d.Load(jsonObject2); } }