public override void Execute(Level level) { ClientAvatar avatar = level.GetPlayerAvatar(); foreach (var buildingId in BuildingIds) { ConstructionItem gameObjectById = (ConstructionItem)level.GameObjectManager.GetGameObjectByID(buildingId); int diamondCount = ((BuildingData)gameObjectById.GetConstructionItemData()).BoostCost[gameObjectById.UpgradeLevel]; if (avatar.HasEnoughDiamonds(diamondCount)) { gameObjectById.BoostBuilding(); avatar.SetDiamonds(avatar.GetDiamonds() - diamondCount); } } }
public override void Execute(Level level) { ClientAvatar ca = level.GetPlayerAvatar(); foreach (int buildingId in BuildingIds) { GameObject go = level.GameObjectManager.GetGameObjectByID(buildingId); ConstructionItem b = (ConstructionItem)go; int costs = ((BuildingData)b.GetConstructionItemData()).BoostCost[b.UpgradeLevel]; if (ca.HasEnoughDiamonds(costs)) { b.BoostBuilding(); ca.SetDiamonds(ca.GetDiamonds() - costs); } } }
internal override void Process() { ClientAvatar ca = this.Device.Player.Avatar; foreach (int buildingId in BuildingIds) { GameObject go = this.Device.Player.GameObjectManager.GetGameObjectByID(buildingId); ConstructionItem b = (ConstructionItem)go; int costs = ((BuildingData)b.GetConstructionItemData()).BoostCost[b.UpgradeLevel]; if (ca.HasEnoughDiamonds(costs)) { b.BoostBuilding(); ca.m_vCurrentGems = ca.m_vCurrentGems - costs; } } }
public override void Execute(Level level) { ClientAvatar avatar = level.GetPlayerAvatar(); GameObject gameObjectById = level.GameObjectManager.GetGameObjectByID(BuildingId); if (gameObjectById == null) { return; } ConstructionItem constructionItem = (ConstructionItem)gameObjectById; if (!constructionItem.CanUpgrade()) { return; } ConstructionItemData constructionItemData = constructionItem.GetConstructionItemData(); if (!avatar.HasEnoughResources(constructionItemData.GetBuildResource(constructionItem.GetUpgradeLevel() + 1), constructionItemData.GetBuildCost(constructionItem.GetUpgradeLevel() + 1)) || !level.HasFreeWorkers()) { return; } string name = level.GameObjectManager.GetGameObjectByID(BuildingId).GetData().GetName(); Logger.Write("Building To Upgrade : " + name + " (" + BuildingId + ')'); if (string.Equals(name, "Alliance Castle")) { avatar.IncrementAllianceCastleLevel(); BuildingData buildingData = ((Building)level.GameObjectManager.GetGameObjectByID(BuildingId)).GetBuildingData(); avatar.SetAllianceCastleTotalCapacity(buildingData.GetUnitStorageCapacity(avatar.GetAllianceCastleLevel())); } else if (string.Equals(name, "Town Hall")) { avatar.IncrementTownHallLevel(); } ResourceData buildResource = constructionItemData.GetBuildResource(constructionItem.GetUpgradeLevel() + 1); avatar.SetResourceCount(buildResource, avatar.GetResourceCount(buildResource) - constructionItemData.GetBuildCost(constructionItem.GetUpgradeLevel() + 1)); constructionItem.StartUpgrading(); }
public override void Execute(Level level) { ClientAvatar ca = level.GetPlayerAvatar(); GameObject go = level.GameObjectManager.GetGameObjectByID(BuildingId); ConstructionItem b = (ConstructionItem)go; if (b.CanUpgrade()) { var bd = b.GetConstructionItemData(); if (ca.HasEnoughResources(bd.GetBuildResource(b.GetUpgradeLevel() + 1), bd.GetBuildCost(b.GetUpgradeLevel() + 1))) { if (level.HasFreeWorkers()) { ResourceData rd = bd.GetBuildResource(b.GetUpgradeLevel() + 1); ca.SetResourceCount(rd, ca.GetResourceCount(rd) - bd.GetBuildCost(b.GetUpgradeLevel() + 1)); b.StartUpgrading(); } } } }
public override void Execute(Level level) { ClientAvatar avatar = level.GetPlayerAvatar(); ConstructionItem gameObjectById = (ConstructionItem)level.GameObjectManager.GetGameObjectByID(BuildingId); BuildingData constructionItemData = (BuildingData)gameObjectById.GetConstructionItemData(); if (!avatar.HasEnoughResources(constructionItemData.GetBuildResource(gameObjectById.GetUpgradeLevel()), constructionItemData.GetBuildCost(gameObjectById.GetUpgradeLevel()))) { return; } string name = level.GameObjectManager.GetGameObjectByID(BuildingId).GetData().GetName(); Logger.Write("Unlocking Building: " + name + " (" + BuildingId + ')'); if (string.Equals(name, "Alliance Castle")) { avatar.IncrementAllianceCastleLevel(); BuildingData buildingData = ((Building)level.GameObjectManager.GetGameObjectByID(BuildingId)).GetBuildingData(); avatar.SetAllianceCastleTotalCapacity(buildingData.GetUnitStorageCapacity(avatar.GetAllianceCastleLevel())); } ResourceData buildResource = constructionItemData.GetBuildResource(gameObjectById.GetUpgradeLevel()); avatar.SetResourceCount(buildResource, avatar.GetResourceCount(buildResource) - constructionItemData.GetBuildCost(gameObjectById.GetUpgradeLevel())); gameObjectById.Unlock(); }