internal void FinishConstruction() { IsConstructing = false; if (BuilderVillage) { Level.BuilderWorkerManager.DeallocateWorker(this); } else { Level.VillageWorkerManager.DeallocateWorker(this); } SetUpgradeLevel(GetUpgradeLevel + 1); if (GetResourceProductionComponent() != null) { GetResourceProductionComponent().Reset(); } var constructionTime = GetConstructionItemData.GetConstructionTime(GetUpgradeLevel); Level.Avatar.AddExperience((int)Math.Pow(constructionTime, 0.5f)); if (GetHeroBaseComponent(true) != null) { Buildings data = (Buildings)Data; Heroes hd = CSV.Tables.Get(Gamefile.Heroes).GetData(data.HeroType) as Heroes; Level.Avatar.SetUnitUpgradeLevel(hd, 0); Level.Avatar.SetHeroHealth(hd, 0); Level.Avatar.SetHeroState(hd, 3); } }
internal void StartConstructing(int[] xy, bool buildervillage = false, bool instant = false) { X = xy[0]; Y = xy[1]; BuilderVillage = buildervillage; var constructionTime = instant ? 0 : GetConstructionItemData.GetConstructionTime(0); if (constructionTime < 1) { FinishConstruction(); } else { Timer = new Timer(); Timer.StartTimer(Level.Avatar.LastTick, constructionTime); if (buildervillage) { Level.BuilderWorkerManager.AllocateWorker(this); } else { Level.VillageWorkerManager.AllocateWorker(this); } IsConstructing = true; } }
internal void StartUpgrading(bool buildervillage = false) { BuilderVillage = buildervillage; var constructionTime = GetConstructionItemData.GetConstructionTime(UpgradeLevel + 1); if (constructionTime < 1) { FinishConstruction(); } else { IsConstructing = true; Timer = new Timer(); Timer.StartTimer(Level.Avatar.LastTick, constructionTime); if (buildervillage) { Level.BuilderWorkerManager.AllocateWorker(this); } else { Level.VillageWorkerManager.AllocateWorker(this); } } }