/// <summary> /// Trains the unit with new training. /// </summary> public int NewTrainingUnit(LogicLevel level) { if (LogicDataTables.GetGlobals().UseNewTraining()) { LogicUnitProduction unitProduction = this._spellProduction ? level.GetGameObjectManager().GetSpellProduction() : level.GetGameObjectManager().GetUnitProduction(); LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); Int32 remainingSecs = unitProduction.GetTotalRemainingSeconds(); Int32 speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(remainingSecs, this._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(); return(0); } return(-1); } return(-99); }
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); }