Example #1
0
    public void Test_FighterSubclassesMustDeclareOwnReactToDodgeFunction()
    {
        FighterStatsClass stats = new FighterStatsClass();

        stats.ShowDodge();

        LogAssert.Expect(LogType.Error, "ShowDodge() must be implemented inside the sub-class!");
    }
Example #2
0
    public virtual bool AttackOpponent(FighterStatsClass opponent, bool CanBeDodged = true, bool ignoreTurnTime = false)
    {
        if (!CanAct() && !ignoreTurnTime)
        {
            Debug.LogWarning("Tried to attack an opponent when not allowed to do that!");
            return(false);
        }
        if (!ignoreTurnTime)
        {
            currentTurnTime = 0;
        }

        if (opponent == null)
        {
            Debug.LogWarning("Fighter tried to attack an opponent that's a nnullpointer. Can't attack non-existant opponents!");
        }
        else if (opponent.GetCurrentFighterState() == FighterState.dead)
        {
            Debug.LogWarning("Fighter tried to attack an opponent that already died. Can't attack dead opponents!");
        }
        else
        {
            if (CanBeDodged)
            {
                float dodgeRand = 1;
                dodgeRand = Random.value;
                if (dodgeRand >= opponent.GetDodgePropability())
                {
                    opponent.ReceiveDamage(GetCurrentAttackDamage());
                    return(true);
                }
                else
                {
                    opponent.ShowDodge();
                    return(false);
                }
            }
            else
            {
                opponent.ReceiveDamage(GetCurrentAttackDamage());
                return(true);
            }
        }
        return(false);
    }