private ActionScore GetGeneralScore(List <Humanoid> targets, SkillCategory category = SkillCategory.Attack, float selfEffector = 1, float targetEffector = 1) { List <ActionScore> Targets = new List <ActionScore>(); // Calculate healing weight for all alive team members foreach (Humanoid h in targets) { if (h.IsDead) { continue; } ActionScore newTarget = new ActionScore(); newTarget.Target = h; // Get chance of hitting target float distanceFrom = Vector2.Distance(h.transform.position, ActiveHuman.transform.position); float distanceScore = GetDistanceScore(distanceFrom); // Get health score applying self effector if active player if (h.GetHashCode() == ActiveHuman.GetHashCode()) { float generalScore = GetHealthScore(h.CharData.health, h.MaxHealth, category, selfEffector, targetEffector); newTarget.Score = distanceScore * (generalScore / 50); //Debug.Log("General state score: " + newTarget.Score); } else { newTarget.Score = distanceScore * (GetHealthScore(h.CharData.health, h.MaxHealth, category, targetEffector) / 50); //Debug.Log("General state score: " + newTarget.Score); } // Cap Score if (newTarget.Score > 50) { newTarget.Score = 50; } Targets.Add(newTarget); } return(GetHighest(Targets)); }
private Humanoid Closest(List <Humanoid> team) { Humanoid closest = null; float minDistance = 10000; foreach (Humanoid h in team) { // Skip active player if (h.GetHashCode() == ActiveHuman.GetHashCode()) { continue; } float distance = Vector3.Distance(ActiveHuman.Position, h.Position); if (minDistance > distance) { closest = h; minDistance = distance; } } return(closest); }