public int ChangeVillage(LogicLevel level, bool force) { if (this.m_villageType != 0 && !force) { LogicVillageObject ship = level.GetGameObjectManagerAt(0).GetShipyard(); if (ship == null || ship.GetUpgradeLevel() <= 0) { return(-23); } } if (level.GetGameObjectManagerAt(1).GetTownHall() != null) { level.SetVillageType(this.m_villageType); if (level.GetState() == 1) { level.GetPlayerAvatar().SetVariableByName("VillageToGoTo", this.m_villageType); } level.GetGameObjectManager().RespawnObstacles(); } return(0); }
public bool IsOpenTutorialMission() { if (this.m_data.GetVillageType() == this.m_level.GetVillageType()) { if (this.m_data.GetMissionCategory() == 2) { LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); if (homeOwnerAvatar == null || !homeOwnerAvatar.IsNpcAvatar() || this.m_level.GetVillageType() != 1) { LogicGameObjectManager gameObjectManager = this.m_level.GetGameObjectManagerAt(0); LogicVillageObject shipyard = gameObjectManager.GetShipyard(); if (shipyard == null || shipyard.GetUpgradeLevel() != 0) { int missionType = this.m_data.GetMissionType(); if ((missionType == 16 || missionType == 14) && this.m_level.GetState() == 1 && this.m_level.GetVillageType() == 0) { if (gameObjectManager.GetShipyard().IsConstructing()) { return(false); } } return(this.m_data.GetMissionCategory() != 1); } return(false); } return(true); } return(this.m_data.GetMissionCategory() != 1); } return(false); }
/// <summary> /// Refreshes the mission progress. /// </summary> public void RefreshProgress() { LogicGameObjectManager gameObjectManager = this._level.GetGameObjectManager(); switch (this._data.GetMissionType()) { case 0: case 5: this._progress = 0; if (this._level.GetState() == 1) { LogicArrayList <LogicGameObject> gameObjects = gameObjectManager.GetGameObjects(0); for (int i = 0; i < gameObjects.Count; i++) { LogicBuilding building = (LogicBuilding)gameObjects[i]; if (building.GetBuildingData() == this._data.GetBuildBuildingData()) { if (!building.IsConstructing() || building.IsUpgrading()) { if (building.GetUpgradeLevel() >= this._data.GetBuildBuildingLevel()) { ++this._progress; } } } } } break; case 4: this._progress = this._level.GetPlayerAvatar().GetUnitsTotalCapacity(); break; case 6: this._progress = this._level.GetPlayerAvatar().GetNameSetByUser() ? 1 : 0; break; case 13: this._progress = 0; if (this._level.GetState() == 1) { LogicArrayList <LogicGameObject> gameObjects = gameObjectManager.GetGameObjects(8); for (int i = 0; i < gameObjects.Count; i++) { LogicVillageObject villageObject = (LogicVillageObject)gameObjects[i]; if (villageObject.GetVillageObjectData() == this._data.GetFixVillageObjectData() && villageObject.GetUpgradeLevel() >= this._data.GetBuildBuildingLevel()) { ++this._progress; } } } break; case 14: this._progress = 0; if (this._level.GetState() == 1 && this._level.GetVillageType() == 1) { ++this._progress; } break; case 15: this._progress = 0; if (this._level.GetState() == 1) { LogicArrayList <LogicGameObject> gameObjects = gameObjectManager.GetGameObjects(0); for (int i = 0; i < gameObjects.Count; i++) { LogicBuilding building = (LogicBuilding)gameObjects[i]; if (building.GetBuildingData() == this._data.GetBuildBuildingData()) { if (!building.IsLocked()) { ++this._progress; } } } } break; case 17: this._progress = 0; if (this._level.GetState() == 1 && this._level.GetVillageType() == 1) { if (this._level.GetPlayerAvatar().GetUnitUpgradeLevel(this._data.GetCharacterData()) > 0) { ++this._progress; } } break; } if (this._progress >= this._requireProgress) { this._progress = this._requireProgress; this.Finished(); } }
public override int Execute(LogicLevel level) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId); if (gameObject != null) { if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicBuilding building = (LogicBuilding)gameObject; LogicBuildingData buildingData = building.GetBuildingData(); if (buildingData.IsTownHallVillage2()) { if (!LogicUpgradeBuildingCommand.CanUpgradeTHV2(level)) { return(-76); } } if (buildingData.GetVillageType() == level.GetVillageType()) { if (level.GetGameObjectManager().GetAvailableBuildingUpgradeCount(building) <= 0) { return(-34); } if (building.GetWallIndex() == 0) { if (building.CanUpgrade(true)) { int nextUpgradeLevel = building.GetUpgradeLevel() + 1; int buildCost = buildingData.GetBuildCost(nextUpgradeLevel, level); LogicResourceData buildResourceData = this.m_useAltResource ? buildingData.GetAltBuildResource(nextUpgradeLevel) : buildingData.GetBuildResource(nextUpgradeLevel); if (buildResourceData != null) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar.HasEnoughResources(buildResourceData, buildCost, true, this, false)) { if (buildingData.GetConstructionTime(nextUpgradeLevel, level, 0) != 0 || LogicDataTables.GetGlobals().WorkerForZeroBuilTime()) { if (!level.HasFreeWorkers(this, -1)) { return(-1); } } playerAvatar.CommodityCountChangeHelper(0, buildResourceData, -buildCost); building.StartUpgrading(true, false); return(0); } } } return(-1); } return(-35); } return(-32); } if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP) { LogicTrap trap = (LogicTrap)gameObject; if (trap.CanUpgrade(true)) { LogicTrapData data = trap.GetTrapData(); LogicResourceData buildResourceData = data.GetBuildResource(); LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); int buildCost = data.GetBuildCost(trap.GetUpgradeLevel() + 1); if (playerAvatar.HasEnoughResources(buildResourceData, buildCost, true, this, false)) { if (data.GetBuildTime(trap.GetUpgradeLevel() + 1) != 0 || LogicDataTables.GetGlobals().WorkerForZeroBuilTime()) { if (!level.HasFreeWorkers(this, -1)) { return(-1); } } playerAvatar.CommodityCountChangeHelper(0, buildResourceData, -buildCost); trap.StartUpgrading(); return(0); } } } else if (gameObject.GetGameObjectType() == LogicGameObjectType.VILLAGE_OBJECT) { if (!this.m_useAltResource) { LogicVillageObject villageObject = (LogicVillageObject)gameObject; if (villageObject.CanUpgrade(true)) { LogicVillageObjectData data = villageObject.GetVillageObjectData(); LogicResourceData buildResourceData = data.GetBuildResource(); int buildCost = data.GetBuildCost(villageObject.GetUpgradeLevel() + 1); if (buildResourceData != null) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar.HasEnoughResources(buildResourceData, buildCost, true, this, false)) { if (data.GetBuildTime(villageObject.GetUpgradeLevel() + 1) != 0 || LogicDataTables.GetGlobals().WorkerForZeroBuilTime()) { if (!level.HasFreeWorkers(this, -1)) { return(-1); } } playerAvatar.CommodityCountChangeHelper(0, buildResourceData, -buildCost); villageObject.StartUpgrading(true); return(0); } } } return(-1); } return(-31); } } return(-1); }