Exemplo n.º 1
0
    public override State Next()
    {
        State res;

        if (_stateMachine.animal.foundFood)
        {
            res = new StateEating(_stateMachine);
        }
        else if (Vector3.Distance(_stateMachine.animal.transform.position, _game.transform.position) < 4)
        {
            res = new StateNearPlayer(_stateMachine);
        }
        else if (_stateMachine.animal.isHungry())
        {
            res = this;
        }
        else if (_stateMachine.animal.isSad())
        {
            res = new StateSad(_stateMachine);
        }
        else
        {
            res = new StateWalking(_stateMachine);
        }
        return(res);
    }
Exemplo n.º 2
0
    public override State Next()
    {
        State res = this;

        if (_stateMachine.animal.isHungry())
        {
            res = new StateHungry(_stateMachine);
        }
        else if (_stateMachine.animal.isSad())
        {
            res = new StateSad(_stateMachine);
        }
        else if (Vector3.Distance(_stateMachine.animal.transform.position, _game.transform.position) < 5)
        {
            res = new StateNearPlayer(_stateMachine);
        }
        else if (Random.Range(0, 600) == 1)
        {
            res = new StateSleeping(_stateMachine);
        }
        else if (Random.Range(0, 600) == 5)
        {
            res = new StateDrinking(_stateMachine);
        }

        return(res);
    }
Exemplo n.º 3
0
    public override State Next()
    {
        State res;

        if (Vector3.Distance(_stateMachine.animal.transform.position, _game.transform.position) < 5)
        {
            res = new StateNearPlayer(_stateMachine);
        }
        else if (_stateMachine.animal.isHungry())
        {
            _stateMachine.animal.SetNormalSpeed();
            res = new StateHungry(_stateMachine);
        }
        else if (_stateMachine.animal.isSad())
        {
            res = this;
        }
        else
        {
            _stateMachine.animal.SetNormalSpeed();
            res = new StateWalking(_stateMachine);
        }
        return(res);
    }