public void EndAttackPreparation() { if (this.m_battleTimer != null) { int attackLength = LogicDataTables.GetGlobals().GetAttackLengthSecs(); int battleRemainingSecs = this.m_battleTimer.GetRemainingSeconds(this.m_level.GetLogicTime()); if (battleRemainingSecs > attackLength) { int remainingPrepSecs = battleRemainingSecs - attackLength; if (this.m_replay != null) { this.m_replay.RecordPreparationSkipTime(remainingPrepSecs); } this.m_skipPreparationSecs = remainingPrepSecs; this.m_battleTimer.StartTimer(attackLength, this.m_level.GetLogicTime(), false, -1); } if (this.m_level.GetPlayerAvatar() != null) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); if (playerAvatar.GetChangeListener() != null) { playerAvatar.GetChangeListener().BattleFeedback(5, 0); } } } }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null && this.m_achievementData != null) { if (playerAvatar.IsAchievementCompleted(this.m_achievementData) && !playerAvatar.IsAchievementRewardClaimed(this.m_achievementData)) { playerAvatar.XpGainHelper(this.m_achievementData.GetExpReward()); if (this.m_achievementData.GetDiamondReward() > 0) { int diamondReward = this.m_achievementData.GetDiamondReward(); playerAvatar.SetDiamonds(playerAvatar.GetDiamonds() + diamondReward); playerAvatar.SetFreeDiamonds(playerAvatar.GetFreeDiamonds() + diamondReward); playerAvatar.GetChangeListener().FreeDiamondsAdded(diamondReward, 4); } playerAvatar.SetAchievementRewardClaimed(this.m_achievementData, true); playerAvatar.GetChangeListener().CommodityCountChanged(1, this.m_achievementData, 1); return(0); } } return(-1); }
public void DebugCompleteAllTutorials(bool onlyHomeMissions, bool completeNameMission, bool completeWarMissions) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); LogicDataTable table = LogicDataTables.GetTable(LogicDataType.MISSION); bool restartMission = false; for (int i = 0; i < table.GetItemCount(); i++) { LogicMissionData data = (LogicMissionData)table.GetItemAt(i); if (!completeWarMissions && data.GetMissionCategory() == 1) { continue; } if (onlyHomeMissions) { if (data.GetMissionCategory() != 0) { continue; } } else if (data.GetMissionCategory() == 2 && this.m_level.GetGameObjectManagerAt(0).GetShipyard().GetUpgradeLevel() == 0 && this.m_level.GetVillageType() == 0) { continue; } if (restartMission) { playerAvatar.SetMissionCompleted(data, false); playerAvatar.GetChangeListener().CommodityCountChanged(0, data, 0); } if (!completeNameMission) { if (data.GetMissionType() == 6) { restartMission = true; continue; } } playerAvatar.SetMissionCompleted(data, true); playerAvatar.GetChangeListener().CommodityCountChanged(0, data, 1); } this.RefreshOpenMissions(); }
public void RefreshAchievementProgress(LogicClientAvatar avatar, LogicAchievementData data, int value) { if (this.m_level.GetState() != 5) { int currentValue = avatar.GetAchievementProgress(data); int newValue = LogicMath.Min(value, 2000000000); if (currentValue < newValue) { avatar.SetAchievementProgress(data, value); avatar.GetChangeListener().CommodityCountChanged(0, data, newValue); } int tmp = LogicMath.Min(newValue, data.GetActionCount()); if (currentValue < tmp) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); if (playerAvatar == avatar) { if (tmp == data.GetActionCount()) { this.m_level.GetGameListener().AchievementCompleted(data); } else { this.m_level.GetGameListener().AchievementProgress(data); } } } } }
public int SpeedUpNewTrainingUnit(LogicLevel level) { if (LogicDataTables.GetGlobals().UseNewTraining()) { LogicUnitProduction unitProduction = this.m_spellProduction ? level.GetGameObjectManager().GetSpellProduction() : level.GetGameObjectManager().GetUnitProduction(); LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); int remainingSecs = unitProduction.GetTotalRemainingSeconds(); int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(remainingSecs, this.m_spellProduction ? 1 : 4, level.GetVillageType()); if (!level.GetMissionManager().IsTutorialFinished()) { if (speedUpCost > 0 && LogicDataTables.GetGlobals().GetTutorialTrainingSpeedUpCost() >= 0) { speedUpCost = LogicDataTables.GetGlobals().GetTutorialTrainingSpeedUpCost(); } } if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, level)) { playerAvatar.UseDiamonds(speedUpCost); unitProduction.SpeedUp(); playerAvatar.GetChangeListener().DiamondPurchaseMade(unitProduction.GetUnitProductionType() == LogicDataType.CHARACTER ? 2 : 7, 0, 0, speedUpCost, level.GetVillageType()); return(0); } return(-1); } return(-99); }
/// <summary> /// Called when the mission is finished. /// </summary> public void Finished() { LogicClientAvatar playerAvatar = this._level.GetPlayerAvatar(); if (!playerAvatar.IsMissionCompleted(this._data)) { Debugger.Print("Mission " + this._data.GetName() + " finished"); playerAvatar.SetMissionCompleted(this._data, true); playerAvatar.GetChangeListener().CommodityCountChanged(0, this._data.GetRewardResourceData(), 1); this.AddRewardUnits(); LogicResourceData rewardResourceData = this._data.GetRewardResourceData(); if (rewardResourceData != null) { playerAvatar.AddMisisonResourceReward(rewardResourceData, this._data.GetRewardResourceCount()); } int rewardXp = this._data.GetRewardXp(); if (rewardXp > 0) { playerAvatar.XpGainHelper(rewardXp); } } }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { if (playerAvatar.IsInAlliance()) { if (playerAvatar.GetAllianceId().Equals(this.m_allianceId)) { playerAvatar.SetAllianceId(null); playerAvatar.SetAllianceName(null); playerAvatar.SetAllianceBadgeId(-1); playerAvatar.SetAllianceLevel(-1); playerAvatar.GetChangeListener().AllianceLeft(); } } level.GetGameListener().AllianceLeft(); return(0); } return(-1); }
public override int Execute(LogicLevel level) { LogicArrayList <LogicComponent> components = level.GetComponentManager().GetComponents(LogicComponentType.VILLAGE2_UNIT); int remainingSecs = 0; for (int i = 0; i < components.Size(); i++) { remainingSecs += ((LogicVillage2UnitComponent)components[i]).GetRemainingSecs(); } LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(remainingSecs, 4, 1); if (!playerAvatar.HasEnoughDiamonds(speedUpCost, true, level)) { return(-1); } playerAvatar.UseDiamonds(speedUpCost); for (int i = 0; i < components.Size(); i++) { LogicVillage2UnitComponent component = (LogicVillage2UnitComponent)components[i]; if (component.GetCurrentlyTrainedUnit() != null && component.GetRemainingSecs() > 0) { component.ProductionCompleted(); } } playerAvatar.GetChangeListener().DiamondPurchaseMade(16, 0, 0, speedUpCost, 1); return(0); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { playerAvatar.SetLeagueType(this.m_leagueType); if (this.m_leagueType != 0) { playerAvatar.SetLeagueInstanceId(this.m_leagueInstanceId.Clone()); } else { playerAvatar.SetLeagueInstanceId(null); playerAvatar.SetAttackWinCount(0); playerAvatar.SetAttackLoseCount(0); playerAvatar.SetDefenseWinCount(0); playerAvatar.SetDefenseLoseCount(0); } playerAvatar.GetChangeListener().LeagueChanged(this.m_leagueType, this.m_leagueInstanceId); return(0); } return(-1); }
public bool SpeedUp() { if (this.m_timer != null) { int remainingSecs = this.m_timer.GetRemainingSeconds(this.m_parent.GetLevel().GetLogicTime()); int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(remainingSecs, 0, this.m_parent.GetVillageType()); LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); if (homeOwnerAvatar.IsClientAvatar()) { LogicClientAvatar clientAvatar = (LogicClientAvatar)homeOwnerAvatar; if (clientAvatar.HasEnoughDiamonds(speedUpCost, true, this.m_parent.GetLevel())) { clientAvatar.UseDiamonds(speedUpCost); clientAvatar.GetChangeListener().DiamondPurchaseMade(10, this.m_hero.GetGlobalID(), clientAvatar.GetUnitUpgradeLevel(this.m_hero) + 1, speedUpCost, this.m_parent.GetLevel().GetVillageType()); this.FinishUpgrading(true); return(true); } } } return(false); }
public override int Execute(LogicLevel level) { if (this.m_decoData != null) { if (this.m_decoData.GetVillageType() == level.GetVillageType()) { if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, this.m_decoData.GetWidth(), this.m_decoData.GetHeight(), null)) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); LogicResourceData buildResourceData = this.m_decoData.GetBuildResource(); int buildCost = this.m_decoData.GetBuildCost(); if (playerAvatar.HasEnoughResources(buildResourceData, buildCost, true, this, false) && !level.IsDecoCapReached(this.m_decoData, true)) { if (buildResourceData.IsPremiumCurrency()) { playerAvatar.UseDiamonds(buildCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(1, this.m_decoData.GetGlobalID(), 0, buildCost, level.GetVillageType()); } else { playerAvatar.CommodityCountChangeHelper(0, buildResourceData, -buildCost); } LogicDeco deco = (LogicDeco)LogicGameObjectFactory.CreateGameObject(this.m_decoData, level, level.GetVillageType()); deco.SetInitialPosition(this.m_x << 9, this.m_y << 9); level.GetGameObjectManager().AddGameObject(deco, -1); int width = deco.GetWidthInTiles(); int height = deco.GetHeightInTiles(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { LogicObstacle tallGrass = level.GetTileMap().GetTile(this.m_x + i, this.m_y + j).GetTallGrass(); if (tallGrass != null) { level.GetGameObjectManager().RemoveGameObject(tallGrass); } } } return(0); } } return(-1); } return(-32); } return(-1); }
public void StateChangeConfirmed() { switch (this.m_data.GetMissionType()) { case 1: if (this.m_progress == 0) { this.m_level.GetGameMode().StartDefendState(LogicNpcAvatar.GetNpcAvatar(this.m_data.GetDefendNpcData())); this.m_progress = 1; } break; case 7: case 8: case 9: case 10: case 11: case 20: case 21: this.m_progress = 1; this.Finished(); break; case 16: if (this.m_progress == 0) { // ? } this.m_progress += 1; break; case 19: if (this.m_progress == 1) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); int duelScoreGain = LogicDataTables.GetGlobals().GetVillage2FirstVictoryTrophies(); playerAvatar.AddDuelReward(LogicDataTables.GetGlobals().GetVillage2FirstVictoryGold(), LogicDataTables.GetGlobals().GetVillage2FirstVictoryElixir(), 0, 0, null); playerAvatar.SetDuelScore(playerAvatar.GetDuelScore() + LogicDataTables.GetGlobals().GetVillage2FirstVictoryTrophies()); playerAvatar.GetChangeListener().DuelScoreChanged(playerAvatar.GetAllianceId(), duelScoreGain, -1, false); this.m_progress = 2; this.Finished(); } break; } }
public int CollectResources(bool updateListener) { if (this.m_parent.GetLevel().GetHomeOwnerAvatar() != null) { int resourceCount = this.GetResourceCount(); if (this.m_parent.GetLevel().GetHomeOwnerAvatar().IsNpcAvatar()) { Debugger.Error("LogicResourceProductionComponent::collectResources() called for Npc avatar"); } else { LogicClientAvatar clientAvatar = (LogicClientAvatar)this.m_parent.GetLevel().GetHomeOwnerAvatar(); if (resourceCount != 0) { if (this.m_resourceData.IsPremiumCurrency()) { this.DecreaseResources(resourceCount); clientAvatar.SetDiamonds(clientAvatar.GetDiamonds() + resourceCount); clientAvatar.SetFreeDiamonds(clientAvatar.GetFreeDiamonds() + resourceCount); clientAvatar.GetChangeListener().FreeDiamondsAdded(resourceCount, 10); } else { int unusedResourceCap = clientAvatar.GetUnusedResourceCap(this.m_resourceData); if (unusedResourceCap != 0) { if (resourceCount > unusedResourceCap) { resourceCount = unusedResourceCap; } this.DecreaseResources(resourceCount); clientAvatar.CommodityCountChangeHelper(0, this.m_resourceData, resourceCount); } else { resourceCount = 0; } } return(resourceCount); } } } return(0); }
public override int Execute(LogicLevel level) { level.SetWarTroopRequestMessage(this.m_message); LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { playerAvatar.GetChangeListener().WarTroopRequestMessageChanged(this.m_message); } return(0); }
public override int Execute(LogicLevel level) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId); if (gameObject != null) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicBuilding building = (LogicBuilding)gameObject; if (building.CanSell()) { playerAvatar.CommodityCountChangeHelper(0, building.GetSellResource(), building.GetSellPrice()); building.OnSell(); level.GetGameObjectManager().RemoveGameObject(building); return(0); } } else if (gameObject.GetGameObjectType() == LogicGameObjectType.DECO) { LogicDeco deco = (LogicDeco)gameObject; LogicDecoData data = deco.GetDecoData(); LogicResourceData buildResourceData = data.GetBuildResource(); int sellPrice = data.GetSellPrice(); if (buildResourceData.IsPremiumCurrency()) { playerAvatar.SetDiamonds(playerAvatar.GetDiamonds() + sellPrice); playerAvatar.SetFreeDiamonds(playerAvatar.GetFreeDiamonds() + sellPrice); playerAvatar.GetChangeListener().FreeDiamondsAdded(sellPrice, 6); } else { playerAvatar.CommodityCountChangeHelper(0, buildResourceData, sellPrice); } level.GetGameObjectManager().RemoveGameObject(deco); return(0); } } return(-1); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { int lootLimitCooldown = playerAvatar.GetVariableByName("LootLimitCooldown"); if (lootLimitCooldown == 1) { LogicConfiguration configuration = level.GetGameMode().GetConfiguration(); if (configuration != null) { LogicCalendar calendar = level.GetGameMode().GetCalendar(); if (calendar != null) { int remainingSecs = playerAvatar.GetRemainingLootLimitTime(); int totalSecs = LogicCalendar.GetDuelLootLimitCooldownInMinutes(calendar, configuration) * 60; int maxDiamondsCostPercent = LogicCalendar.GetDuelBonusMaxDiamondCostPercent(calendar, configuration); int speedUpCost = LogicMath.Max( LogicGamePlayUtil.GetLeagueVillage2(playerAvatar.GetDuelScore()).GetMaxDiamondCost() * maxDiamondsCostPercent * remainingSecs / totalSecs / 100, 1); if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, level)) { playerAvatar.UseDiamonds(speedUpCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(18, 0, remainingSecs, speedUpCost, level.GetVillageType()); playerAvatar.FastForwardLootLimit(remainingSecs); return(0); } return(-3); } return(-5); } return(-4); } return(-3); } return(-2); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null && playerAvatar.IsInAlliance()) { playerAvatar.SetAllianceLevel(this.m_allianceExpLevel); if (this.m_callListener) { playerAvatar.GetChangeListener().AllianceLevelChanged(this.m_allianceExpLevel); } return(0); } return(-1); }
public override int Execute(LogicLevel level) { if (level.GetVillageType() == 0) { if (level.GetState() == 2 || level.GetState() == 1) { if (this.m_buyResourceData != null) { if (this.m_buyResourceCount > 0 && !this.m_buyResourceData.IsPremiumCurrency()) { int cost = LogicGamePlayUtil.GetResourceDiamondCost(this.m_buyResourceCount, this.m_buyResourceData); LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar.GetUnusedResourceCap(this.m_buyResourceData) >= this.m_buyResourceCount) { if (playerAvatar.HasEnoughDiamonds(cost, true, level)) { playerAvatar.UseDiamonds(cost); playerAvatar.GetChangeListener() .DiamondPurchaseMade(5, this.m_buyResourceData.GetGlobalID(), this.m_buyResourceCount, cost, level.GetVillageType()); playerAvatar.CommodityCountChangeHelper(0, this.m_buyResourceData, this.m_buyResourceCount); } else { return(-2); } } else { return(-1); } } } level.GetGameListener().MatchmakingCommandExecuted(); return(0); } return(-3); } return(-32); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { if (this.m_allianceCreate) { LogicGlobals globals = LogicDataTables.GetGlobals(); LogicResourceData resource = globals.GetAllianceCreateResourceData(); int removeCount = LogicMath.Min(globals.GetAllianceCreateCost(), playerAvatar.GetResourceCount(resource)); playerAvatar.CommodityCountChangeHelper(0, resource, -removeCount); } playerAvatar.SetAllianceId(this.m_allianceId.Clone()); playerAvatar.SetAllianceName(this.m_allianceName); playerAvatar.SetAllianceBadgeId(this.m_allianceBadgeId); playerAvatar.SetAllianceLevel(this.m_allianceExpLevel); playerAvatar.SetAllianceRole(this.m_allianceCreate ? LogicAvatarAllianceRole.LEADER : LogicAvatarAllianceRole.MEMBER); playerAvatar.GetChangeListener().AllianceJoined(playerAvatar.GetAllianceId(), this.m_allianceName, this.m_allianceBadgeId, this.m_allianceExpLevel, playerAvatar.GetAllianceRole()); LogicGameListener gameListener = level.GetGameListener(); if (gameListener != null) { if (this.m_allianceCreate) { gameListener.AllianceCreated(); } else { gameListener.AllianceJoined(); } } return(0); } return(-1); }
public bool SpeedUpClearing() { if (this.m_clearTimer != null) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(this.m_clearTimer.GetRemainingSeconds(this.m_level.GetLogicTime()), 0, this.m_villageType); if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, this.m_level)) { playerAvatar.UseDiamonds(speedUpCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(3, this.m_data.GetGlobalID(), 0, speedUpCost, this.m_level.GetVillageType()); this.ClearingFinished(false); return(true); } } return(false); }
public override int Execute(LogicLevel level) { if (level.GetVillageType() == 1) { if (level.IsUnitsTrainedVillage2()) { if (level.GetState() == 1) { if (this.m_buyResourceCount > 0) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar.GetUnusedResourceCap(LogicDataTables.GetGold2Data()) < this.m_buyResourceCount) { return(-1); } int buyResourceCost = LogicGamePlayUtil.GetResourceDiamondCost(this.m_buyResourceCount, LogicDataTables.GetGold2Data()); if (playerAvatar.HasEnoughDiamonds(buyResourceCost, true, level)) { return(-2); } playerAvatar.UseDiamonds(buyResourceCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(5, LogicDataTables.GetGold2Data().GetGlobalID(), this.m_buyResourceCount, buyResourceCost, level.GetVillageType()); playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetGold2Data(), this.m_buyResourceCount); } level.GetGameListener().MatchmakingVillage2CommandExecuted(); return(0); } return(-3); } return(-24); } return(-32); }
public override int Execute(LogicLevel level) { if (LogicDataTables.GetGlobals().UseTroopRequestSpeedUp()) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); LogicGameObjectManager gameObjectManager = level.GetGameObjectManagerAt(0); LogicBuilding allianceCastle = gameObjectManager.GetAllianceCastle(); if (allianceCastle != null) { LogicBunkerComponent bunkerComponent = allianceCastle.GetBunkerComponent(); if (bunkerComponent != null) { if (playerAvatar.GetAllianceCastleUsedCapacity() < playerAvatar.GetAllianceCastleTotalCapacity() || playerAvatar.GetAllianceCastleUsedSpellCapacity() < playerAvatar.GetAllianceCastleTotalSpellCapacity()) { int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(bunkerComponent.GetRequestCooldownTime(), 3, 0); if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, level)) { playerAvatar.UseDiamonds(speedUpCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(11, 0, 0, speedUpCost, level.GetVillageType()); bunkerComponent.StopRequestCooldownTime(); return(0); } return(-6); } return(-5); } return(-4); } return(-3); } return(-1); }
public void DebugResetAllTutorials() { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); LogicDataTable table = LogicDataTables.GetTable(LogicDataType.MISSION); for (int i = 0; i < table.GetItemCount(); i++) { LogicMissionData data = (LogicMissionData)table.GetItemAt(i); playerAvatar.SetMissionCompleted(data, false); playerAvatar.GetChangeListener().CommodityCountChanged(0, data, 0); } while (this.m_missions.Size() > 0) { this.m_missions[0].Destruct(); this.m_missions.Remove(0); } this.RefreshOpenMissions(); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { playerAvatar.SetLeagueType(0); playerAvatar.SetLeagueInstanceId(null); playerAvatar.SetAttackWinCount(0); playerAvatar.SetAttackLoseCount(0); playerAvatar.SetDefenseWinCount(0); playerAvatar.SetDefenseLoseCount(0); level.SetLastLeagueShuffle(true); playerAvatar.GetChangeListener().LeagueChanged(0, null); return(0); } return(-1); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { if (this.m_unitData != null) { playerAvatar.AddAllianceUnit(this.m_unitData, this.m_upgLevel); playerAvatar.GetChangeListener().AllianceUnitAdded(this.m_unitData, this.m_upgLevel); level.GetGameListener().UnitReceivedFromAlliance(this.m_senderName, this.m_unitData, this.m_upgLevel); if (level.GetState() == 1 || level.GetState() == 3) { level.GetComponentManagerAt(0).AddAvatarAllianceUnitsToCastle(); } return(0); } } return(-1); }
public bool SpeedUpConstruction() { if (this.m_constructionTimer != null) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); int remainingSecs = this.m_constructionTimer.GetRemainingSeconds(this.m_level.GetLogicTime()); int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(remainingSecs, 0, this.m_villageType); if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, this.m_level)) { playerAvatar.UseDiamonds(speedUpCost); playerAvatar.GetChangeListener().DiamondPurchaseMade(4, this.m_data.GetGlobalID(), this.m_upgLevel + (this.m_upgrading ? 2 : 1), speedUpCost, this.m_level.GetVillageType()); this.FinishConstruction(false); return(true); } } return(false); }
public bool SpeedUpHealth() { LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); if (homeOwnerAvatar.IsClientAvatar()) { LogicClientAvatar clientAvatar = (LogicClientAvatar)homeOwnerAvatar; int speedUpCost = this.GetSpeedUpHealthCost(); if (clientAvatar.HasEnoughDiamonds(speedUpCost, true, this.m_parent.GetLevel())) { clientAvatar.UseDiamonds(speedUpCost); clientAvatar.GetChangeListener().DiamondPurchaseMade(9, this.m_hero.GetGlobalID(), clientAvatar.GetUnitUpgradeLevel(this.m_hero) + 1, speedUpCost, this.m_parent.GetLevel().GetVillageType()); this.SetFullHealth(); return(true); } } return(false); }
public override int Execute(LogicLevel level) { if (LogicDataTables.GetGlobals().UseNewTraining()) { if (level.GetVillageType() == 0) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); LogicUnitProduction unitProduction = this.m_productionType == 1 ? level.GetGameObjectManagerAt(0).GetSpellProduction() : level.GetGameObjectManagerAt(0).GetUnitProduction(); if (unitProduction.CanBeBoosted()) { int cost = unitProduction.GetBoostCost(); if (playerAvatar.HasEnoughDiamonds(cost, true, level)) { playerAvatar.UseDiamonds(cost); playerAvatar.GetChangeListener().DiamondPurchaseMade(15, 0, 0, cost, level.GetVillageType()); unitProduction.Boost(); return(0); } return(-2); } return(-1); } return(-32); } return(-99); }
public void ClearingFinished(bool ignoreState) { int state = this.m_level.GetState(); if (state == 1 || !LogicDataTables.GetGlobals().CompleteConstructionOnlyHome() && ignoreState) { if (this.m_level.GetHomeOwnerAvatar().IsClientAvatar()) { LogicClientAvatar homeOwnerAvatar = (LogicClientAvatar)this.m_level.GetHomeOwnerAvatar(); LogicObstacleData obstacleData = this.GetObstacleData(); LogicResourceData lootResourceData = obstacleData.GetLootResourceData(); int lootCount = obstacleData.GetLootCount(); if (obstacleData.IsLootCart()) { LogicLootCartComponent lootCartComponent = (LogicLootCartComponent)this.GetComponent(LogicComponentType.LOOT_CART); if (lootCartComponent != null) { LogicDataTable resourceTable = LogicDataTables.GetTable(LogicDataType.RESOURCE); bool empty = true; for (int i = 0; i < resourceTable.GetItemCount(); i++) { LogicResourceData resourceData = (LogicResourceData)resourceTable.GetItemAt(i); if (!resourceData.IsPremiumCurrency() && resourceData.GetWarResourceReferenceData() == null) { int resourceCount = lootCartComponent.GetResourceCount(i); int rewardCount = LogicMath.Min(homeOwnerAvatar.GetUnusedResourceCap(resourceData), resourceCount); int remainingCount = resourceCount - rewardCount; if (rewardCount > 0) { homeOwnerAvatar.CommodityCountChangeHelper(0, resourceData, rewardCount); lootCartComponent.SetResourceCount(i, remainingCount); } if (remainingCount > 0) { empty = false; } } } if (!empty) { return; } } } if (!obstacleData.IsTombstone() && !obstacleData.IsLootCart()) { this.m_level.GetAchievementManager().ObstacleCleared(); } this.m_level.GetWorkerManagerAt(this.m_villageType).DeallocateWorker(this); this.XpGainHelper(LogicGamePlayUtil.TimeToExp(obstacleData.GetClearTime()), homeOwnerAvatar, ignoreState || state == 1); if (lootResourceData != null && lootCount > 0) { if (homeOwnerAvatar != null) { if (lootResourceData.IsPremiumCurrency()) { int lootMultipler = 1; if (this.m_lootMultiplyVersion >= 2) { lootMultipler = obstacleData.GetLootMultiplierVersion2(); } int diamondsCount = obstacleData.GetName().Equals("Bonus Gembox") ? lootCount * lootMultipler : this.m_level.GetGameObjectManagerAt(this.m_villageType).IncreaseObstacleClearCounter(lootMultipler); if (diamondsCount > 0) { homeOwnerAvatar.SetDiamonds(homeOwnerAvatar.GetDiamonds() + diamondsCount); homeOwnerAvatar.SetFreeDiamonds(homeOwnerAvatar.GetFreeDiamonds() + diamondsCount); homeOwnerAvatar.GetChangeListener().FreeDiamondsAdded(diamondsCount, 6); } } else { int gainCount = LogicMath.Min(homeOwnerAvatar.GetUnusedResourceCap(lootResourceData), lootCount); if (gainCount > 0) { homeOwnerAvatar.CommodityCountChangeHelper(0, lootResourceData, gainCount); } } } else { Debugger.Error("LogicObstacle::clearingFinished - Home owner avatar is NULL!"); } } if (obstacleData.IsEnabledInVillageType(this.m_level.GetVillageType())) { // ? } if (this.m_clearTimer != null) { this.m_clearTimer.Destruct(); this.m_clearTimer = null; } this.m_fadeTime = 1; } } }
/// <summary> /// Called when the clearing of this <see cref="LogicObstacle"/> instance is finished. /// </summary> public void ClearingFinished(bool ignoreState) { int state = this._level.GetState(); if (state == 1 || !LogicDataTables.GetGlobals().CompleteConstructionOnlyHome() && ignoreState) { if (this._level.GetHomeOwnerAvatar().IsClientAvatar()) { LogicClientAvatar homeOwnerAvatar = (LogicClientAvatar)this._level.GetHomeOwnerAvatar(); LogicObstacleData obstacleData = this.GetObstacleData(); LogicResourceData lootResourceData = obstacleData.GetLootResourceData(); int lootCount = obstacleData.GetLootCount(); if (obstacleData.IsLootCart()) { LogicComponent component = this.GetComponent(14); LogicDataTable resourceTable = LogicDataTables.GetTable(2); if (component != null && resourceTable.GetItemCount() > 0) { for (int i = 0; i < resourceTable.GetItemCount(); i++) { // TODO: Implement LootCart. } } } if (!obstacleData.IsTombstone && !obstacleData.IsLootCart()) { this._level.GetAchievementManager().ObstacleCleared(); } this._level.GetWorkerManagerAt(this._villageType).DeallocateWorker(this); this.XpGainHelper(LogicGamePlayUtil.TimeToExp(obstacleData.GetClearTime()), homeOwnerAvatar, ignoreState || state == 1); if (lootResourceData != null && lootCount > 0) { if (homeOwnerAvatar != null) { if (lootResourceData.PremiumCurrency) { int lootMultipler = 1; if (this._lootMultiplyVersion >= 2) { lootMultipler = obstacleData.GetLootMultiplierVersion2(); } int diamondsCount = obstacleData.GetName().Equals("Bonus Gembox") ? lootCount * lootMultipler : this._level.GetGameObjectManagerAt(this._villageType).IncreaseObstacleClearCounter(lootMultipler); if (diamondsCount > 0) { Debugger.Print("LogicObstacle::clearingFinished diamonds reward: " + diamondsCount); homeOwnerAvatar.SetDiamonds(homeOwnerAvatar.GetDiamonds() + diamondsCount); homeOwnerAvatar.SetFreeDiamonds(homeOwnerAvatar.GetFreeDiamonds() + diamondsCount); homeOwnerAvatar.GetChangeListener().FreeDiamondsAdded(diamondsCount); } } else { int gainCount = LogicMath.Min(homeOwnerAvatar.GetUnusedResourceCap(lootResourceData), lootCount); if (gainCount > 0) { homeOwnerAvatar.CommodityCountChangeHelper(0, lootResourceData, gainCount); } } } else { Debugger.Error("LogicObstacle::clearingFinished - Home owner avatar is NULL!"); } } if (obstacleData.GetVillageType() == this._level.GetVillageType()) { // ? } if (this._clearTimer != null) { this._clearTimer.Destruct(); this._clearTimer = null; } this._fadeTime = 1; } } }