internal void FinishConstruction() { VillageObjectData Data = this.VillageObjectData; if (this.UpgradeLevel + 1 > Data.MaxLevel) { Logging.Error(this.GetType(), "Unable to upgrade the building because the level is out of range! - " + Data.Name + "."); this.SetUpgradeLevel(Data.MaxLevel); } else { this.SetUpgradeLevel(this.UpgradeLevel + 1); } if (this.VillageType == 0) { this.Level.WorkerManager.DeallocateWorker(this); } else { this.Level.WorkerManagerV2.DeallocateWorker(this); } this.Level.Player.AddExperience(GamePlayUtil.TimeToXp(Data.GetBuildTime(this.UpgradeLevel))); this.ConstructionTimer = null; }
internal void AddGameObject(GameObject GameObject) { int GType = GameObject.Type; if (GType == 0) { Building Building = (Building)GameObject; BuildingData Data = Building.BuildingData; if (Data.IsTownHall) { this.TownHall = Building; } if (Data.IsTownHall2) { this.TownHall2 = Building; } if (Data.IsWorker) { this.Level.WorkerManager.WorkerCount++; } if (Data.IsWorker2) { this.Level.WorkerManagerV2.WorkerCount++; } if (Data.IsAllianceCastle) { this.Bunker = Building; } } else if (GType == 8) { VillageObject VillageObject = (VillageObject)GameObject; VillageObjectData Data = VillageObject.VillageObjectData; if (Data.GlobalId == 39000000) { this.Boat = VillageObject; } } GameObject.Id = GlobalId.Create(500 + GType, this.GameObjects[GType][GameObject.VillageType].Count); this.GameObjects[GType][GameObject.VillageType].Add(GameObject); }
/// <summary> /// Creates the data for the specified row. /// </summary> /// <param name="Row">The row.</param> internal Data Create(Row Row) { Data Data; switch (this.Index) { case 1: { Data = new BuildingData(Row, this); break; } case 2: { Data = new LocaleData(Row, this); break; } case 3: { Data = new ResourceData(Row, this); break; } case 4: { Data = new CharacterData(Row, this); break; } case 6: { Data = new ProjectileData(Row, this); break; } case 7: { Data = new BuildingClassData(Row, this); break; } case 8: { Data = new ObstacleData(Row, this); break; } case 9: { Data = new EffectData(Row, this); break; } case 10: { Data = new ParticleEmitterData(Row, this); break; } case 11: { Data = new ExperienceLevelData(Row, this); break; } case 12: { Data = new TrapData(Row, this); break; } case 13: { Data = new AllianceBadgeData(Row, this); break; } case 14: { Data = new GlobalData(Row, this); break; } case 15: { Data = new TownhallLevelData(Row, this); break; } case 16: { Data = new AlliancePortalData(Row, this); break; } case 17: { Data = new NpcData(Row, this); break; } case 18: { Data = new DecoData(Row, this); break; } case 19: { Data = new ResourcePackData(Row, this); break; } case 20: { Data = new ShieldData(Row, this); break; } case 21: { Data = new MissionData(Row, this); break; } case 22: { Data = new BillingPackageData(Row, this); break; } case 23: { Data = new AchievementData(Row, this); break; } case 25: { Data = new FaqData(Row, this); break; } case 26: { Data = new SpellData(Row, this); break; } case 27: { Data = new HintData(Row, this); break; } case 28: { Data = new HeroData(Row, this); break; } case 29: { Data = new LeagueData(Row, this); break; } case 30: { Data = new NewData(Row, this); break; } case 34: { Data = new AllianceBadgeLayerData(Row, this); break; } case 37: { Data = new VariableData(Row, this); break; } case 38: { Data = new GemBundleData(Row, this); break; } case 39: { Data = new VillageObjectData(Row, this); break; } default: { Data = new Data(Row, this); break; } } return(Data); }
internal Data Create(Row _Row) { Data _Data; switch ((Gamefile)this.Index) { case Gamefile.Buildings: _Data = new BuildingData(_Row, this); break; case Gamefile.Locales: _Data = new LocaleData(_Row, this); break; case Gamefile.Resources: _Data = new ResourceData(_Row, this); break; case Gamefile.Characters: _Data = new CharacterData(_Row, this); break; case Gamefile.Building_Classes: _Data = new BuildingClassData(_Row, this); break; case Gamefile.Obstacles: _Data = new ObstacleData(_Row, this); break; case Gamefile.Traps: _Data = new TrapData(_Row, this); break; case Gamefile.Globals: _Data = new GlobalData(_Row, this); break; case Gamefile.Experience_Levels: _Data = new ExperienceLevelData(_Row, this); break; case Gamefile.Townhall_Levels: _Data = new TownhallLevelData(_Row, this); break; case Gamefile.Npcs: _Data = new NpcData(_Row, this); break; case Gamefile.Decos: _Data = new DecoData(_Row, this); break; case Gamefile.Shields: _Data = new ShieldData(_Row, this); break; case Gamefile.Missions: _Data = new MissionData(_Row, this); break; case Gamefile.Achievements: _Data = new AchievementData(_Row, this); break; case Gamefile.Spells: _Data = new SpellData(_Row, this); break; case Gamefile.Heroes: _Data = new HeroData(_Row, this); break; case Gamefile.Leagues: _Data = new LeagueData(_Row, this); break; case Gamefile.Regions: _Data = new RegionData(_Row, this); break; case Gamefile.AllianceBadgeLayer: _Data = new AllianceBadgeLayerData(_Row, this); break; case Gamefile.Variables: _Data = new VariableData(_Row, this); break; case Gamefile.Village_Objects: _Data = new VillageObjectData(_Row, this); break; default: _Data = new Data(_Row, this); break; } return(_Data); }
internal override void Execute() { Level Level = this.Device.GameMode.Level; GameObject GameObject = Level.GameObjectManager.Filter.GetGameObjectById(this.Id); if (GameObject != null) { if (GameObject is Building) { Building Building = (Building)GameObject; if (Building.UpgradeAvailable) { BuildingData Data = (BuildingData)Building.Data; ResourceData ResourceData = this.UseAltResource ? Data.AltBuildResourceData(Building.GetUpgradeLevel() + 1) : Data.BuildResourceData; if (ResourceData != null) { if (Level.Player.Resources.GetCountByData(ResourceData) >= Data.BuildCost[Building.GetUpgradeLevel() + 1]) { if (Data.VillageType == 0 ? Level.WorkerManager.FreeWorkers > 0 : Level.WorkerManagerV2.FreeWorkers > 0) { Level.Player.Resources.Remove(ResourceData, Data.BuildCost[Building.GetUpgradeLevel() + 1]); Building.StartUpgrade(); if (Data.IsTownHall2) { if (Level.Player.TownHallLevel2 == 0) { foreach (var gameObject in Level.GameObjectManager.GameObjects[0][1]) { Building building2 = (Building)gameObject; BuildingData data2 = building2.BuildingData; if (building2.Locked) { if (!data2.Locked) { #if DEBUG Logging.Info(this.GetType(), $"Builder Building: Unlocking {data2.Name} with ID {gameObject.Id}"); #endif building2.Locked = false; } } } } } } } else { Logging.Error(this.GetType(), "Unable to upgrade the building. The player doesn't have enough resources."); } } else { Logging.Error(this.GetType(), "Unable to upgrade the building. The resource data is null"); } } else { Logging.Error(this.GetType(), "Unable to upgrade the building. Upgrade is not available."); } } else if (GameObject is Trap) { Trap Trap = (Trap)GameObject; if (Trap.UpgradeAvailable) { TrapData Data = Trap.TrapData; ResourceData ResourceData = Data.BuildResourceData; if (ResourceData != null) { if (Level.Player.Resources.GetCountByData(ResourceData) >= Data.BuildCost[Trap.GetUpgradeLevel() + 1]) { if (Data.VillageType == 0 ? Level.WorkerManager.FreeWorkers > 0 : Level.WorkerManagerV2.FreeWorkers > 0) { Level.Player.Resources.Remove(ResourceData, Data.BuildCost[Trap.GetUpgradeLevel() + 1]); Trap.StartUpgrade(); } } else { Logging.Error(this.GetType(), "Unable to upgrade the Trap. The player doesn't have enough resources."); } } else { Logging.Error(this.GetType(), "Unable to start upgrade the Trap. The resources data is null."); } } else { Logging.Error(this.GetType(), "Unable to upgrade the building. Upgrade is not available."); } } else if (GameObject is VillageObject) { VillageObject VillageObject = (VillageObject)GameObject; VillageObjectData Data = VillageObject.VillageObjectData; ResourceData ResourceData = Data.BuildResourceData; if (ResourceData != null) { if (Level.Player.Resources.GetCountByData(ResourceData) >= Data.BuildCost[VillageObject.GetUpgradeLevel() + 1]) { if (Data.VillageType == 0 ? Level.WorkerManager.FreeWorkers > 0 : Level.WorkerManagerV2.FreeWorkers > 0) { Level.Player.Resources.Remove(ResourceData, Data.BuildCost[VillageObject.GetUpgradeLevel() + 1]); VillageObject.StartUpgrade(); } } else { Logging.Error(this.GetType(), "Unable to upgrade the VillageObject. The player doesn't have enough resources."); } } else { Logging.Error(this.GetType(), "Unable to start upgrade the VillageObject. The resources data is null."); } } else { Logging.Error(this.GetType(), $"Unable to determined Game Object type. Game Object type {GameObject.Type}."); } } else { Logging.Error(this.GetType(), "Unable to upgrade the gameObject. GameObject is null"); #if COMMAND_DEBUG Device.Account.Player.Debug.Dump(); #endif } }