示例#1
0
    public static float CalculateHitChance(IUnit attacker, IUnit defender)
    {
        //Accuracy is determined by combat skill and agility
        float accuracy = GameMath.CalculateSkillRatio(attacker.s_combat);

        accuracy += GameMath.CalculateAttributeRatio(attacker.a_agility.currValue);
        accuracy  = Mathf.Pow(accuracy, 3.75f);

        //Dodge chance is also determined by combat skill and agility
        float dodge = GameMath.CalculateSkillRatio(defender.s_combat);

        dodge += GameMath.CalculateAttributeRatio(defender.a_agility.currValue);
        dodge  = Mathf.Pow(dodge, 3.75f);

        //TODO: perks

        float hitChance = accuracy / (accuracy + dodge);

        //Debug.Log("Hit chance - " + hitChance);
        return(hitChance);
    }
示例#2
0
    /// <summary>
    /// Approximates squad performance depending on individual power and leader influence
    /// </summary>
    public void CalculateSquadPower()
    {
        float totalPower = 0.0f;
        float cohesion   = 0.0f;

        foreach (IUnit unit in members)
        {
            //Calculate individual combat skill -- Does not look at perks right now
            totalPower += GameMath.CalculateAttributeRatio(unit.a_strenght.currValue);
            totalPower += GameMath.CalculateSkillRatio(unit.s_combat + (leader.s_combat / 5));
            //totalPower += (SquadUtility.CalculateCombatFactor(unit));
            //Calculate cohesion
            float tempCohesion = 0.0f;
            foreach (IUnit rel in members)
            {
                if (rel.Equals(unit))
                {
                    continue;
                }
                else
                {
                    Relationship r;
                    if (unit.r_relationships.TryGetValue(rel, out r))
                    {
                        tempCohesion += r.GetAppreciation();
                    }
                }
            }
            tempCohesion /= members.Count;
            cohesion     += tempCohesion;
        }

        //Calculate the total
        //TODO - Cohesion does not work for now
        squadPower = totalPower * 1.0f /*cohesion*/ * GameMath.CalculateSkillRatio(leader.s_social) * CalculateSquadSizeAdjustment();
    }