private void ArmyUpgradeFinished(ArmyType type) { this.m_PlayerModule.UpgradeArmy(type); this.m_ArmyModule.FinishUpgrade(type); this.m_TaskModule.OnUpgradeArmy(type, this.m_PlayerModule.Data.GetArmyLevel(type)); }
public void GenerateArmyInCamp(ArmyType armyType, int level, IBuildingInfo campInfo) { GameObject army = this.GenerateArmy(armyType, level); ArmyAI ai = army.GetComponent <ArmyAI>(); ai.GenerateArmyInCamp(campInfo); }
public void buyUnit(string unit) { ArmyType type = ArmyType.cutter; //galley, frigate, destroyer, A1, A2, A3, artillery, bomber if (unit.Equals("frigate")) { type = ArmyType.frigate; } else if (unit.Equals("galley")) { type = ArmyType.cutter; } else if (unit.Equals("A1")) { type = ArmyType.A1; } else if (unit.Equals("A2")) { type = ArmyType.A2; } else if (unit.Equals("artillery")) { type = ArmyType.artillery; } else if (unit.Equals("bomber")) { type = ArmyType.bomber; } if (VillageManager.instance.buy(type)) { recruitment.Add(new RecruitmentOrder(type, 1)); } }
public void AddAction(string playerA, string playerB, ActionType actionType, ModifierType modifyer, Weapon weapon, WhereType where, ArmyType teamA, ArmyType teamB) { Player playerGet = getPlayer(playerA, teamA); Player playerDo = null; //damage from the world (harrier, falling) will not be considered in this version if (playerB == string.Empty) { playerDo = playerGet; } else { playerDo = getPlayer(playerB, teamB); } switch (actionType) { case ActionType.Kill: playerGet.AddAction(playerDo, ActionType.Die, modifyer, weapon, where); playerDo.AddAction(playerGet, ActionType.Kill, modifyer, weapon, where); break; case ActionType.Damage: playerGet.AddAction(playerDo, ActionType.Damage, modifyer, weapon, where); playerDo.AddAction(playerGet, ActionType.Damage, modifyer, weapon, where); break; } }
public async Task <bool> TrainArmy(string authenticationToken, ArmyType armyType, int value, int townId) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(RestConstants.Url); var queries = new Dictionary <string, string> { { "token", authenticationToken }, { "armyId", ((int)armyType).ToString() }, { "value", value.ToString() }, { "townId", townId.ToString() } }; var json = JsonConvert.SerializeObject(queries); var data = new StringContent(json, Encoding.UTF8, "application/json"); var result = await client.PostAsync("/army/train", data); switch (result.StatusCode) { case HttpStatusCode.OK: return(true); case HttpStatusCode.Unauthorized: throw new AuthenticationException("Token is invalid."); case HttpStatusCode.BadRequest: throw new ArgumentException("Something went wrong on the server."); } } throw new InvalidOperationException("Reached invalid state."); }
private void FinishArmyUpgraded(ArmyType type) { if (this.ArmyUpgradeFinished != null) { this.ArmyUpgradeFinished(type); } }
public void UpgradeArmy(ArmyType type, BuildingIdentity laboratoryID, int currentLevel) { BuildingLogicObject laboratory = this.m_Buildings[laboratoryID.buildingType][laboratoryID.buildingNO]; laboratory.UpgradeArmy(type, currentLevel); this.ReCalculateResource(); }
public void UpgradeArmy(ArmyType type, int currentLevel) { int workload = ConfigInterface.Instance.ArmyConfigHelper.GetUpgradeWorkload(type, currentLevel); ObjectUpgrade <ArmyType> upgrade = new ObjectUpgrade <ArmyType>(type, workload); this.m_Upgrades.Add(type, upgrade); }
public void SendCancelUpgradeArmyRequest(ArmyType type) { ArmyUpgradeCancelRequestParameter request = new ArmyUpgradeCancelRequestParameter(); request.ArmyType = type; CommunicationUtility.Instance.CancelArmyUpgrade(request); }
public static IEnumerable <Group> LoadGroups(string path) { Regex regex = new Regex(@"(?<units>\d+) units each with (?<hitpoints>\d+) hit points( \((((weak to (?<weakness>\w+(, \w+)*))|(immune to (?<immunity>\w+(, \w+)*)))(; )?)+\))? with an attack that does (?<damage>\d+) (?<attacktype>\w+) damage at initiative (?<initiative>\d+)"); ArmyType currentArmy = ArmyType.Immunity; foreach (string line in File.ReadLines(path)) { Match match = regex.Match(line); if (match.Success) { yield return new Group() { ArmyType = currentArmy, Units = int.Parse(match.Groups["units"].Value), UnitHitPoints = int.Parse(match.Groups["hitpoints"].Value), Damage = int.Parse(match.Groups["damage"].Value), AttackType = match.Groups["attacktype"].Value.ToEnum <AttackType>(), Weaknesses = match.Groups["weakness"].Success ? match.Groups["weakness"].Value.Split(',').Select(y => y.Trim().ToEnum <AttackType>()).ToHashSet() : new HashSet <AttackType>(), Immunity = match.Groups["immunity"].Success ? match.Groups["immunity"].Value.Split(',').Select(y => y.Trim().ToEnum <AttackType>()).ToHashSet() : new HashSet <AttackType>(), Initiative = int.Parse(match.Groups["initiative"].Value), } } ; else if (line == "Immune System:") { currentArmy = ArmyType.Immunity; } else if (line == "Infection:") { currentArmy = ArmyType.Infection; } } }
public ProduceArmyCondition(TaskConditionConfigData conditionConfigData, Task task, int conditionID, int startValue, int currentValue) : base(conditionConfigData, task, conditionID, startValue, currentValue) { this.m_ArmyType = (ArmyType)conditionConfigData.Value1; this.m_Count = conditionConfigData.Value2; this.IsComplete = (this.Progress >= this.m_Count); }
public void SendFinishUpgradeArmyRequest(ArmyType type, float remainingSecond) { ArmyUpgradeSuccessRequestParameter request = new ArmyUpgradeSuccessRequestParameter(); request.ArmyType = type; request.OperateTick = LogicTimer.Instance.GetServerTick(remainingSecond); CommunicationUtility.Instance.FinishArmyUpgrade(request); }
public override void OnUpgradeArmy(ArmyType armyType, int newLevel) { if (armyType == this.m_ArmyType) { this.CurrentValue = newLevel; this.IsComplete = (this.Progress >= this.m_Level); } }
public void CancelUpgradeArmy(ArmyType type, BuildingIdentity laboratoryID) { int currentLevel = this.m_PlayerModule.Data.GetArmyLevel(type); CostConfigData cost = ConfigInterface.Instance.ArmyConfigHelper.GetUpgradeCostData(type, currentLevel); this.m_PlayerModule.Receive(cost.CostGold, cost.CostFood, cost.CostOil, cost.CostGem); this.m_BuildingModule.CancelArmyUpgrade(laboratoryID); }
public Attack(string name, double time, ArmyType type, CardEffect card, bool active) { Name = name; Time = time; Card = card; armytype = type; Active = active; }
public void CancelProduceArmy(ArmyType type, BuildingIdentity factoryID) { CostConfigData cost = ConfigInterface.Instance.ArmyConfigHelper.GetProduceCostData(type, this.PlayerData.GetArmyLevel(type)); this.m_PlayerModule.Receive(cost.CostGold, cost.CostFood, cost.CostOil, cost.CostGem); this.m_BuildingModule.CancelArmyProduce(type, factoryID); this.m_BuildingModule.ReCalculateResource(); }
public override void OnProduceArmy(ArmyType armyType) { if (armyType == this.m_ArmyType) { this.CurrentValue++; this.IsComplete = (this.Progress >= this.m_Count); } }
public List <ICombatant> GetCombatantsByArmy(ArmyType army) { if (!_combatants.Contains(army)) { return(new List <ICombatant>()); } return(_combatants[army].ToList()); }
public void SendFinishUpgradeArmyInstantlyRequest(ArmyType armyType, int gem) { ArmyUpgradeFinishInstantlyRequestParameter parameter = new ArmyUpgradeFinishInstantlyRequestParameter(); parameter.ArmyType = armyType; parameter.CostGem = gem; parameter.OperateTick = LogicTimer.Instance.GetServerTick(); CommunicationUtility.Instance.FinishArmyUpgradeInstantly(parameter); }
protected Army(ArmyType armyType, PlayerType playerType, ArmyComposition armyComposition) { this.armyType = armyType; PlayerType = playerType; ArmyComposition = armyComposition; if (!CheckValidTypes()) { throw new Exception("In Army constructor incompatible types were received"); } }
public void OnUpgradeArmy(ArmyType armyType, int level) { foreach (Task task in this.m_TaskList) { if (task.Status == TaskStatus.Opened) { task.OnUpgradeArmy(armyType, level); } } }
public void SendUpgradeArmyRequest(ArmyType type, BuildingIdentity laboratoryID) { ArmyUpgradeRequestParameter request = new ArmyUpgradeRequestParameter(); request.ArmyType = type; request.LaboratoryBuildingType = laboratoryID.buildingType; request.LaboratoryBuildingNO = laboratoryID.buildingNO; request.OperateTick = LogicTimer.Instance.GetServerTick(); CommunicationUtility.Instance.UpgradeArmy(request); }
public void OnProduceArmy(ArmyType armyType) { foreach (Task task in this.m_TaskList) { if (task.Status == TaskStatus.Opened) { task.OnProduceArmy(armyType); } } }
public void SendArmyToCamp(ArmyType armyType, int level, IBuildingInfo campInfo, IBuildingInfo factoryInfo) { GameObject army = this.GenerateArmy(armyType, level); TilePosition initialPoint = BorderPointHelper.FindValidInflateOneBorderPoint(factoryInfo); army.transform.position = PositionConvertor.GetWorldPositionFromActorTileIndex(initialPoint); ArmyAI ai = army.GetComponent <ArmyAI>(); ai.SendArmyToCamp(campInfo); }
public Army(int turn, Territory sourceTerritory, Territory targetTerritory, Player sourcePlayer, Player targetPlayer, int numTroops, bool isWaterMovement) { Turn = turn; SourceTerritory = sourceTerritory; TargetTerritory = targetTerritory; SourcePlayer = sourcePlayer; TargetPlayer = targetPlayer; Type = sourcePlayer == targetPlayer ? ArmyType.Support : ArmyType.Attack; NumTroops = numTroops; IsWaterArmy = isWaterMovement; }
public bool IsUnitInArmy(Unit p_Unit, ArmyType p_Type) { for (int cptPart = 0; cptPart < m_Armies.Count; cptPart++) { if (m_Armies[cptPart][p_Type].Contains(p_Unit)) { return(true); } } return(false); }
public bool canAfford(ArmyType unit) { if ((float)UnitKnowledge.resourcesCosts[unit][0] <= Wood) { if ((float)UnitKnowledge.resourcesCosts[unit][1] <= Copper) { return(true); } } return(false); }
public void SetArmyType(ArmyType type) { armyType = type; if (type == ArmyType.Offensive) { transform.Find("ArmyMesh").GetComponent <Renderer>().material.color = Color.red; } else { transform.Find("ArmyMesh").GetComponent <Renderer>().material.color = Color.blue; } }
void Awake() { List <KeyValuePair <PropsType, List <int> > > availableProps = new List <KeyValuePair <PropsType, List <int> > >(); foreach (int propsNo in LogicController.Instance.AvailableBattleProps) { PropsLogicData logicData = LogicController.Instance.GetProps(propsNo); List <int> noList = new List <int>(); availableProps.Add(new KeyValuePair <PropsType, List <int> >(logicData.PropsType, noList)); for (int i = 0; i < logicData.RemainingUseTime; i++) { noList.Add(logicData.PropsNo); } } ArmyMenuPopulator.Instance.AvailableProps = availableProps; ArmyMenuPopulator.Instance.AvailableArmies = LogicController.Instance.AvailableArmies; ArmyMenuPopulator.Instance.ArmyLevel = new Dictionary <ArmyType, int>(); for (int i = 0; i < (int)ArmyType.Length; i++) { ArmyType type = (ArmyType)i; ArmyMenuPopulator.Instance.ArmyLevel.Add(type, LogicController.Instance.GetArmyLevel(type)); } ArmyMenuPopulator.Instance.AvailableMercenaries = LogicController.Instance.AvailableMercenaries; Dictionary <ArmyType, int> armies = new Dictionary <ArmyType, int>(); foreach (KeyValuePair <ArmyType, List <ArmyIdentity> > army in LogicController.Instance.AvailableArmies) { armies.Add(army.Key, ArmyMenuPopulator.Instance.ArmyLevel[army.Key]); } List <MercenaryType> mercenaries = new List <MercenaryType>(); foreach (KeyValuePair <MercenaryType, List <MercenaryIdentity> > mercenary in LogicController.Instance.AvailableMercenaries) { mercenaries.Add(mercenary.Key); } List <PropsType> props = new List <PropsType>(); foreach (int propsNo in LogicController.Instance.AvailableBattleProps) { PropsLogicData data = LogicController.Instance.GetProps(propsNo); if (!props.Contains(data.PropsType)) { props.Add(data.PropsType); } } this.m_PreloadManager.Preload(armies, mercenaries, props); }
public void ConstructArmy(ArmyType armyType, int level, Vector3 position, bool isPlaySound) { if (isPlaySound) { AudioController.Play("PutdownSoldier"); } ArmyConfigData configData = ConfigInterface.Instance.ArmyConfigHelper.GetArmyData(armyType, level); GameObject armyPrefab = this.m_PreloadManager.GetArmyPrefab(armyType, level); this.ConstructCharacter(armyPrefab, position, (BuildingCategory)configData.LogicFavoriteType, configData.MaxHP, configData.ArmorCategory, configData.MoveVelocity, (TargetType)configData.Type, configData.AttackCD, configData.AttackValue, configData.AttackScope, configData.DamageScope, configData.AttackMiddleSpeed, configData.AttackCategory, (TargetType)configData.TargetType, configData.PushFactor, configData.PushAttenuateFactor); }
public Army(ArmyData data) : base(BattleManager.instance(), data.name) { m_type = (ArmyType)data.type; var bm = BattleManager.instance(); Goods gd; if (bm.m_dictionary.TryGetValue(data.league, out gd) == true && gd is League) { m_league = gd as League; } else { m_league = new League(data.league); } }
public bool hasUnits(ArmyType armyType) { if (armyType.Equals(ArmyType.Attack)) { if (unit1 > 0) return true; } else { if (unit4 > 0) return true; } //if (unit2 > 0) return true; //if (unit3 > 0) return true; //if (unit5 > 0) return true; //if (unit6 > 0) return true; return false; }
public void putIntoFormData(FormData formData, ArmyType armyType) { if (armyType.Equals(ArmyType.Attack)) { if (this.unit1 != 0) formData.addValue("unit_1", this.unit1.ToString()); if (this.unit2 != 0) formData.addValue("unit_2", "0"); if (this.unit3 != 0) formData.addValue("unit_3", "0"); if (this.unit4 != 0) formData.addValue("unit_4", "0"); if (this.unit5 != 0) formData.addValue("unit_5", "0"); if (this.unit6 != 0) formData.addValue("unit_6", "0"); } else { if (this.unit4 != 0) formData.addValue("unit_4", this.unit4.ToString()); if (this.unit1 != 0) formData.addValue("unit_1", "0"); if (this.unit2 != 0) formData.addValue("unit_2", "0"); if (this.unit3 != 0) formData.addValue("unit_3", "0"); if (this.unit5 != 0) formData.addValue("unit_5", "0"); if (this.unit6 != 0) formData.addValue("unit_6", "0"); } }
public void buyArmy(ArmyType armyType) { String urlAttack = "http://parafia.biz/units/buy/1/amount/"; String urlDefense = "http://parafia.biz/units/buy/4/amount/"; int maxBelivers = attributes.Beliver.Actual - 10; if (maxBelivers != 0) { int cashNeed = maxBelivers * 20; if (attributes.Cash.Actual < cashNeed) { int value = cashNeed - attributes.Cash.Actual; if (attributes.Safe.Actual < value) value = attributes.Safe.Actual; getFromSafe(value); } if (cashNeed > attributes.Cash.Actual) maxBelivers = attributes.Cash.Actual / 20; int timeout = 0; String content = String.Empty; do { try { switch (armyType) { case ArmyType.Attack: httpClient.SendHttpGetAndReturnResponseContent(urlAttack + maxBelivers); break; case ArmyType.Defense: httpClient.SendHttpGetAndReturnResponseContent(urlDefense + maxBelivers); break; } timeout = 0; } catch (WebException we) { worker.printLog("[ERROR] Wystąpił błąd. buyArmy!!!"); worker.printLog("[ERROR] Treść błędu: " + we.Message); worker.printLog("[ERROR] Ponawiam proces."); timeout++; } } while ((timeout != 0) && timeout < 5); } }
private Player getPlayer(string playerId, ArmyType team) { Player aux = listPlayer.Single(q => q.Id == playerId); aux.Army = team; return aux; }