private bool IsBuildingValid(BuildingTypeVO vo) { if (vo.Type == BuildingType.Clearable) { return(false); } if (this.any) { return(true); } if (vo.Lvl >= this.level) { ConditionMatchType conditionMatchType = this.matchType; if (conditionMatchType == ConditionMatchType.Uid) { return(vo.Uid == this.buildingId); } if (conditionMatchType == ConditionMatchType.Id) { return(vo.UpgradeGroup == this.buildingId); } if (conditionMatchType == ConditionMatchType.Type) { return(vo.Type == StringUtils.ParseEnum <BuildingType>(this.buildingId)); } } return(false); }
private bool IsBuildingValid(BuildingComponent component) { BuildingTypeVO buildingType = component.BuildingType; if (this.any && GameUtils.IsBuildingTypeValidForBattleConditions(component.BuildingType.Type)) { return(true); } if (buildingType.Lvl >= this.level) { ConditionMatchType conditionMatchType = this.matchType; if (conditionMatchType == ConditionMatchType.Uid) { return(buildingType.Uid == this.buildingId); } if (conditionMatchType == ConditionMatchType.Id) { return(buildingType.UpgradeGroup == this.buildingId); } if (conditionMatchType == ConditionMatchType.Type) { return(buildingType.Type == StringUtils.ParseEnum <BuildingType>(this.buildingId)); } } return(false); }
private bool IsTroopValid(TroopComponent component) { if (component.Entity.Get <TeamComponent>().TeamType != this.teamMatchType) { return(false); } if (this.any) { return(true); } ITroopDeployableVO troopType = component.TroopType; if (troopType.Lvl >= this.level) { ConditionMatchType conditionMatchType = this.matchType; if (conditionMatchType == ConditionMatchType.Uid) { return(troopType.Uid == this.unitMatchId); } if (conditionMatchType == ConditionMatchType.Id) { return(troopType.UpgradeGroup == this.unitMatchId); } if (conditionMatchType == ConditionMatchType.Type) { return(troopType.Type == StringUtils.ParseEnum <TroopType>(this.unitMatchId)); } } return(false); }
public RetainBuildingCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent) { this.matchType = matchType; this.buildingId = this.prepareArgs[1]; this.any = (this.buildingId == "any"); if (matchType == ConditionMatchType.Uid) { this.level = Service.StaticDataController.Get <BuildingTypeVO>(this.buildingId).Lvl; } else if (!this.any && this.prepareArgs.Length > 2) { this.level = Convert.ToInt32(this.prepareArgs[2]); } else { this.level = 0; } this.buildingsDestroyed = 0; this.buildingsToDestroy = 0; EntityController entityController = Service.EntityController; NodeList <BuildingNode> nodeList = entityController.GetNodeList <BuildingNode>(); BuildingNode buildingNode = nodeList.Head; int num = 0; while (buildingNode != null) { if (this.IsBuildingValid(buildingNode.BuildingComp)) { num++; } buildingNode = buildingNode.Next; } if (this.prepareArgs[0].Contains("%")) { this.byPercent = true; string text = this.prepareArgs[0]; text = text.Substring(0, text.Length - 1); int percent = 100 - Convert.ToInt32(text); if (this.any && this.byPercent) { this.buildingsToDestroy = percent; return; } this.buildingsToDestroy = IntMath.GetPercent(percent, num); } else { this.buildingsToDestroy = num - Convert.ToInt32(this.prepareArgs[0]); } }
public OwnBuildingCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent) { this.threshold = Convert.ToInt32(this.prepareArgs[0], CultureInfo.InvariantCulture); this.buildingId = this.prepareArgs[1]; this.matchType = matchType; this.any = (this.buildingId == "any"); if (matchType == ConditionMatchType.Uid) { this.level = Service.Get <IDataController>().Get <BuildingTypeVO>(this.buildingId).Lvl; return; } if (!this.any && this.prepareArgs.Length > 2) { this.level = Convert.ToInt32(this.prepareArgs[2], CultureInfo.InvariantCulture); return; } this.level = 0; }
public RetainUnitCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent) { this.matchType = matchType; this.unitMatchId = this.prepareArgs[1]; this.unitsToKill = Convert.ToInt32(this.prepareArgs[0], CultureInfo.InvariantCulture); this.unitsKilled = 0; this.any = (this.unitMatchId == "any"); if (matchType == ConditionMatchType.Uid) { this.level = Service.Get <IDataController>().Get <TroopTypeVO>(this.unitMatchId).Lvl; return; } if (!this.any && this.prepareArgs.Length > 2) { this.level = Convert.ToInt32(this.prepareArgs[2], CultureInfo.InvariantCulture); return; } this.level = 0; }
public OwnBuildingCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent) { this.threshold = Convert.ToInt32(this.prepareArgs[0]); this.buildingId = this.prepareArgs[1]; this.matchType = matchType; this.any = (this.buildingId == "any"); if (matchType == ConditionMatchType.Uid) { this.level = Service.StaticDataController.Get <BuildingTypeVO>(this.buildingId).Lvl; } else if (!this.any && this.prepareArgs.Length > 2) { this.level = Convert.ToInt32(this.prepareArgs[2]); } else { this.level = 0; } }
public TrainUnitCondition(ConditionVO vo, IConditionParent parent, int startingValue, ConditionMatchType matchType) : base(vo, parent) { this.matchType = matchType; this.unitMatch = this.prepareArgs[1]; this.unitsToTrain = Convert.ToInt32(this.prepareArgs[0]); this.unitsTrained = startingValue; if (this.unitMatch == "any") { this.any = true; } if (matchType == ConditionMatchType.Uid) { this.level = Service.StaticDataController.Get <TroopTypeVO>(this.unitMatch).Lvl; } else if (!this.any) { this.level = Convert.ToInt32(this.prepareArgs[2]); } }
public TrainUnitCondition(ConditionVO vo, IConditionParent parent, int startingValue, ConditionMatchType matchType) : base(vo, parent) { this.matchType = matchType; this.unitMatch = this.prepareArgs[1]; this.unitsToTrain = Convert.ToInt32(this.prepareArgs[0], CultureInfo.InvariantCulture); this.unitsTrained = startingValue; if (this.unitMatch == "any") { this.any = true; } if (matchType == ConditionMatchType.Uid) { this.level = Service.Get <IDataController>().Get <TroopTypeVO>(this.unitMatch).Lvl; return; } if (!this.any) { this.level = Convert.ToInt32(this.prepareArgs[2], CultureInfo.InvariantCulture); } }
public RetainUnitCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent) { this.matchType = matchType; this.unitMatchId = this.prepareArgs[1]; this.unitsToKill = Convert.ToInt32(this.prepareArgs[0]); this.unitsKilled = 0; this.any = (this.unitMatchId == "any"); if (matchType == ConditionMatchType.Uid) { this.level = Service.StaticDataController.Get <TroopTypeVO>(this.unitMatchId).Lvl; } else if (!this.any && this.prepareArgs.Length > 2) { this.level = Convert.ToInt32(this.prepareArgs[2]); } else { this.level = 0; } }
private bool IsTroopValid(TroopTypeVO troop) { if (this.any) { return(true); } if (troop.Lvl >= this.level) { ConditionMatchType conditionMatchType = this.matchType; if (conditionMatchType == ConditionMatchType.Uid) { return(troop.Uid == this.unitMatch); } if (conditionMatchType == ConditionMatchType.Id) { return(troop.TroopID == this.unitMatch); } if (conditionMatchType == ConditionMatchType.Type) { return(troop.Type == StringUtils.ParseEnum <TroopType>(this.unitMatch)); } } return(false); }
public override void GetProgress(out int current, out int total) { current = 0; total = this.threshold; CurrentPlayer currentPlayer = Service.CurrentPlayer; TroopType troopType = this.troopType; InventoryStorage inventoryStorage; if (troopType != TroopType.Hero) { if (troopType != TroopType.Champion) { inventoryStorage = currentPlayer.Inventory.Troop; } else { inventoryStorage = currentPlayer.Inventory.Champion; } } else { inventoryStorage = currentPlayer.Inventory.Hero; } if (!this.any) { List <TroopTypeVO> list = new List <TroopTypeVO>(); ConditionMatchType conditionMatchType = this.matchType; if (conditionMatchType != ConditionMatchType.Id) { if (conditionMatchType != ConditionMatchType.Uid) { if (conditionMatchType == ConditionMatchType.Type) { StaticDataController staticDataController = Service.StaticDataController; TroopType troopType2 = StringUtils.ParseEnum <TroopType>(this.unitId); foreach (TroopTypeVO current2 in staticDataController.GetAll <TroopTypeVO>()) { if (current2.Type == troopType2 && current2.Lvl >= this.level && inventoryStorage.HasItem(current2.Uid)) { current += inventoryStorage.GetItemAmount(current2.Uid); } } } } else { TroopTypeVO troopTypeVO = Service.StaticDataController.Get <TroopTypeVO>(this.unitId); list = Service.TroopUpgradeCatalog.GetUpgradeGroupLevels(troopTypeVO.UpgradeGroup); } } else { list = Service.TroopUpgradeCatalog.GetUpgradeGroupLevels(this.unitId); } int i = 0; int count = list.Count; while (i < count) { if (list[i].Lvl >= this.level && inventoryStorage.HasItem(list[i].Uid)) { current += inventoryStorage.GetItemAmount(list[i].Uid); } i++; } } else { Dictionary <string, InventoryEntry> internalStorage = inventoryStorage.GetInternalStorage(); foreach (InventoryEntry current3 in internalStorage.Values) { current += current3.Amount; } } }