Exemplo n.º 1
0
    private void HandleInput()
    {
        if (Input.GetAxisRaw("Sprint") > 0)
        {
            if (stamina > 0)
            {
                moveState         = playerMoveState.sprinting;
                staminaRegenTimer = Time.time + staminaRegenDelay;
            }
            else
            {
                moveState = playerMoveState.walking;
            }
        }
        else
        {
            moveState = playerMoveState.walking;
        }

        float x = Input.GetAxisRaw("Horizontal");
        float y = Input.GetAxisRaw("Vertical");

        moveDir = new Vector2(x, y).normalized;

        if (moveDir.magnitude != 0)
        {
            BufferInput(moveDir.x, moveDir.y);
        }
    }
Exemplo n.º 2
0
    public virtual void SetPossessionAs(GameObject newCreature)
    {
        if (_currentPossession)
        {
            //Kill _currentPossession;
            Destroy(_currentPossession);
        }

        _currentPossession = newCreature;
        if (_cc)
        {
            _cc.target = newCreature.transform;
        }

        _aim = newCreature.GetComponent <AIManager>();
        if (_aim)
        {
            _aim.isControllingCreature = false;
            _aim.MyAgent.enabled       = false;
            if (_aim.crownSpawnLocation && CrownPrefab)
            {
                Instantiate(CrownPrefab, _aim.crownSpawnLocation);
            }
        }
        _sm = newCreature.GetComponent <StatesManager>();
        if (_sm)
        {
            _sm.DoTransition(moveState);
            playerMoveState pms = moveState as playerMoveState;
            if (pms && _aim)
            {
                pms.speed = _aim.MyAgent.speed * 2;
            }
        }
    }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     moveSpeed = walkSpeed;
     moveState = playerMoveState.walking;
 }