private void DoLeftManaFactor(Strategy.Group group, out float factor, float weigh, float minVal, float maxVal) { int num; IList <Units> list; if (group == Strategy.Group.League) { num = this.helper.GetAliveLeagueHeroNum(this.team); list = this.helper.GetAliveLeagueHeros(this.team); } else { num = this.helper.GetAliveEnemyHeroNum(this.team); list = this.helper.GetAliveEnemyHeros(this.team); } if (num <= 0) { if (group == Strategy.Group.League) { factor = minVal; } else { factor = maxVal; } return; } float num2 = 0f; foreach (Units current in list) { num2 += current.mp; } float max = num2 * (1f / weigh) * (float)(1 / num); float num3 = UnityEngine.Random.Range(0f, max); if (group == Strategy.Group.League) { factor = num3; } else { factor = -num3; } if (factor > maxVal) { factor = maxVal; } else if (factor < minVal) { factor = minVal; } }
private void DoSkillCoolFactor(IList <Units> heros, out float factor, float weigh, float minVal, float maxVal, Strategy.Group group) { if (heros != null) { int num = 0; foreach (Units current in heros) { SkillManager unitComponent = current.GetUnitComponent <SkillManager>(); if (unitComponent == null) { Debug.LogError("DoSkillCoolFactor方法,获得的skillMgr为空。"); break; } List <string> unlockSkills = unitComponent.GetUnlockSkills(); if (unlockSkills == null) { Debug.LogError("DoSkillCoolFactor方法,获得的skills为空。"); break; } foreach (string current2 in unlockSkills) { Skill skillById = unitComponent.getSkillById(current2); if (skillById == null) { Debug.LogError("DoSkillCoolFactor方法,获得的skill为空。"); break; } if (skillById.IsInitiativeSkill && skillById.IsCDTimeOver) { num++; } } } factor = (float)num * weigh; if (factor > maxVal) { factor = maxVal; } else if (factor < minVal) { factor = minVal; } } else if (group == Strategy.Group.League) { factor = minVal; } else { factor = maxVal; } }
private void DoAverageHpFactor(IList <Units> heros, out float factor, float weigh, float minVal, float maxVal, Strategy.Group group) { if (heros != null) { float num = 0f; int count = heros.Count; foreach (Units current in heros) { num += current.hp / current.hp_max; } float max = num / (float)count * weigh; float num2 = UnityEngine.Random.Range(0f, max); if (group == Strategy.Group.League) { factor = num2; } else { factor = -num2; } if (factor > maxVal) { factor = maxVal; } else if (factor < minVal) { factor = minVal; } } else { factor = 0f; } }