Ejemplo n.º 1
0
    public void AttemptShot(Athlete shooter)
    {
        Athlete defender = defense.roster[Random.Range(0, defense.roster.Count)];

        shooter.IncrementStat(StatType.ShotsAttempted);

        float shotRoll    = Random.value * shooter.GetAttribute(AttributeType.Shooting).value;
        float defenseRoll = Random.value * defender.GetAttribute(AttributeType.Defending).value;

        if (shotRoll > defenseRoll)
        {
            ShotSuccess(shooter);
        }
        else
        {
            ShotFailure(shooter, defender);
        }
    }
Ejemplo n.º 2
0
    public void AttemptPass(Athlete passer)
    {
        Athlete receiver = passer;
        Athlete defender = defense.roster[Random.Range(0, defense.roster.Count)];

        while (receiver == passer)
        {
            receiver = offense.roster[Random.Range(0, offense.roster.Count)];
        }

        passer.IncrementStat(StatType.PassesAttempted);

        float passRoll    = Random.value * passer.GetAttribute(AttributeType.Passing).value;
        float defenseRoll = Random.value * defender.GetAttribute(AttributeType.Defending).value;

        if (passRoll >= defenseRoll)
        {
            PassSuccess(passer, receiver);
        }
        else
        {
            PassFailure(passer, defender);
        }
    }