コード例 #1
0
    public void PassSuccess(Athlete passer, Athlete receiver)
    {
        //Debug.Log("pass success");

        passer.IncrementStat(StatType.PassesCompleted);

        NewPlay(receiver);
    }
コード例 #2
0
    public void ShotFailure(Athlete shooter, Athlete defender)
    {
        //Debug.Log("shot failure");

        defender.IncrementStat(StatType.Saves);

        NewPossession(defense);
    }
コード例 #3
0
    public void PassFailure(Athlete passer, Athlete stealer)
    {
        //Debug.Log("pass failure");

        stealer.IncrementStat(StatType.Steals);

        NewPossession(defense);
    }
コード例 #4
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);
        }
    }
コード例 #5
0
    public void ShotSuccess(Athlete shooter)
    {
        //Debug.Log("shot success");

        shooter.IncrementStat(StatType.Goals);

        if (offense == homeTeam)
        {
            homeScore++;
        }
        else
        {
            awayScore++;
        }

        Debug.Log("GOAL! " + homeScore + " to " + awayScore);

        NewPossession(defense);
    }
コード例 #6
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);
        }
    }