Beispiel #1
0
    //public PlayerAgent(LayerMask enemyHitLayerMask, LayerMask floorHitLayerMask)
    //{
    //    this.enemyHitLayerMask = enemyHitLayerMask;
    //    this.floorHitLayerMask = floorHitLayerMask;
    //}


    #region Updates

    private void controllerUpdate()
    {
        verticleSpeed   = Mathf.Lerp(verticleSpeed, Input.GetAxis("Vertical"), 1);
        horizontalSpeed = Mathf.Lerp(horizontalSpeed, Input.GetAxis("Horizontal"), 1f);

        // Setting Character Aiming.
        if (Input.GetMouseButton(1) && !m_movingAgent.isEquipingWeapon())
        {
            m_movingAgent.aimWeapon();
        }
        else
        {
            m_movingAgent.stopAiming();
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            m_movingAgent.togglepSecondaryWeapon();
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            m_movingAgent.togglePrimaryWeapon();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            m_movingAgent.toggleHide();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            m_movingAgent.dodgeAttack(getDirectionRelativeToCamera(new Vector3(verticleSpeed, 0, -horizontalSpeed)));
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            speedModifyVale = Mathf.Lerp(speedModifyVale, 2, 0.1f);
            m_movingAgent.moveCharacter(getDirectionRelativeToCamera(new Vector3(verticleSpeed * speedModifyVale, 0, -horizontalSpeed * speedModifyVale)));
        }
        else
        {
            speedModifyVale = Mathf.Lerp(speedModifyVale, 1f, 0.1f);
            m_movingAgent.moveCharacter(getDirectionRelativeToCamera((new Vector3(verticleSpeed, 0, -horizontalSpeed)).normalized * speedModifyVale));
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            m_movingAgent.reloadWeapon();
        }


        UpdateShooting();

        UpdateTargetPoint();
    }