public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (level.GetVillageType() == 1) { LogicGameMode gameMode = level.GetGameMode(); if (!gameMode.IsInAttackPreparationMode()) { if (gameMode.GetState() != 5) { return(-9); } } if (this.m_oldUnitData != null && this.m_newUnitData != null && gameMode.GetCalendar().IsProductionEnabled(this.m_newUnitData)) { if (!this.m_newUnitData.IsUnlockedForBarrackLevel(playerAvatar.GetVillage2BarrackLevel())) { if (gameMode.GetState() != 7) { return(-7); } } int oldUnitCount = playerAvatar.GetUnitCountVillage2(this.m_oldUnitData); int oldUnitsInCamp = this.m_oldUnitData.GetUnitsInCamp(playerAvatar.GetUnitUpgradeLevel(this.m_oldUnitData)); if (oldUnitCount >= oldUnitsInCamp) { int newUnitCount = playerAvatar.GetUnitCountVillage2(this.m_newUnitData); int newUnitsInCamp = this.m_newUnitData.GetUnitsInCamp(playerAvatar.GetUnitUpgradeLevel(this.m_newUnitData)); playerAvatar.SetUnitCountVillage2(this.m_oldUnitData, oldUnitCount - oldUnitsInCamp); playerAvatar.SetUnitCountVillage2(this.m_newUnitData, newUnitCount + newUnitsInCamp); LogicArrayList <LogicDataSlot> unitsNew = playerAvatar.GetUnitsNewVillage2(); for (int i = 0; i < unitsNew.Size(); i++) { LogicDataSlot slot = unitsNew[i]; if (slot.GetCount() > 0) { playerAvatar.CommodityCountChangeHelper(8, slot.GetData(), -slot.GetCount()); } } return(0); } return(-23); } return(-7); } return(-10); }
/// <summary> /// Executes this instance. /// </summary> public override int Execute(LogicLevel level) { if (true) { int tileX = this._x >> 9; int tileY = this._y >> 9; if (level.GetTileMap().GetTile(tileX, tileY) != null) { // if (level.GetTileMap().IsPassablePathFinder(this._x >> 8, this._y >> 8)) { if (level.GetTileMap().IsValidAttackPos(tileX, tileY)) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { int unitCount = level.GetVillageType() == 1 ? playerAvatar.GetUnitCountVillage2(this._data) : playerAvatar.GetUnitCount(this._data); if (unitCount > 0) { if (level.GetBattleLog() != null) { // ? } if (level.GetGameMode().IsInAttackPreparationMode()) { level.GetGameMode().EndAttackPreparation(); } LogicCharacter character = LogicPlaceAttackerCommand.PlaceAttacker(playerAvatar, this._data, level, this._x, this._y); if (character != null) { // TODO: Finish this. } return(0); } return(-7); } return(-5); } return(-4); } // return -2; } return(-3); } return(-1); }
public override int Execute(LogicLevel level) { if (level.IsReadyForAttack()) { int tileX = this.m_x >> 9; int tileY = this.m_y >> 9; if (level.GetTileMap().GetTile(tileX, tileY) != null) { if (level.GetTileMap().IsPassablePathFinder(this.m_x >> 8, this.m_y >> 8)) { if (level.GetTileMap().IsValidAttackPos(tileX, tileY)) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { int unitCount = level.GetVillageType() == 1 ? playerAvatar.GetUnitCountVillage2(this.m_data) : playerAvatar.GetUnitCount(this.m_data); if (unitCount > 0) { if (level.GetBattleLog() != null) { if (!level.GetBattleLog().HasDeployedUnits() && level.GetTotalAttackerHeroPlaced() == 0) { level.UpdateLastUsedArmy(); } } if (level.GetGameMode().IsInAttackPreparationMode()) { level.GetGameMode().EndAttackPreparation(); } LogicCharacter character = LogicPlaceAttackerCommand.PlaceAttacker(playerAvatar, this.m_data, level, this.m_x, this.m_y); if (character != null && character.HasSpecialAbility()) { if (this.m_data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_START_RAGE) { LogicSpellData specialAbilitySpellData = this.m_data.GetSpecialAbilitySpell(); level.BoostGameObject(character, specialAbilitySpellData.GetSpeedBoost(0), specialAbilitySpellData.GetSpeedBoost2(0), specialAbilitySpellData.GetDamageBoostPercent(0), specialAbilitySpellData.GetAttackSpeedBoost(0), 60 * this.m_data.GetSpecialAbilityAttribute(character.GetUpgradeLevel()), specialAbilitySpellData.GetBoostLinkedToPoison()); } else if (this.m_data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_START_CLOAK) { character.SetStealthTime(15 * this.m_data.GetSpecialAbilityAttribute(character.GetUpgradeLevel())); } } return(0); } return(-7); } return(-5); } return(-4); } return(-2); } return(-3); } return(-1); }