Ejemplo n.º 1
0
 private void Attack()
 {
     if (IsInRange(target) && attackCooldown <= 0)
     {
         attackCooldown = attackInterval;
         character.Bash();
         currentAction       = Action.Idle;
         currentAttackChoice = null;
     }
 }
Ejemplo n.º 2
0
        public void CheckInputs()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                menuEquipement.Open();
                return;
            }
            float forWalk       = 0;
            float sideWalk      = 0;
            bool  movementInput = false;

            if (UnityEngine.Input.GetKey(KeyCode.Z) && !UnityEngine.Input.GetKey(KeyCode.S))
            {
                forWalk       = 1;
                movementInput = true;
            }
            else if (UnityEngine.Input.GetKey(KeyCode.S))
            {
                forWalk       = -1;
                movementInput = true;
            }
            if (UnityEngine.Input.GetKey(KeyCode.Q) && !UnityEngine.Input.GetKey(KeyCode.D))
            {
                sideWalk      = -1;
                movementInput = true;
            }
            else if (UnityEngine.Input.GetKey(KeyCode.D))
            {
                sideWalk      = 1;
                movementInput = true;
            }
            if (movementInput)
            {
                Vector3 direction = playerCamera.transform.forward * forWalk + playerCamera.transform.right * sideWalk;
                direction.y = 0;
                if (UnityEngine.Input.GetKeyDown(KeyCode.Space))
                {
                    character.Dash(direction.normalized);
                }
                else if (UnityEngine.Input.GetMouseButtonDown(0))
                {
                    character.Attack(true);
                }
                else if (UnityEngine.Input.GetMouseButtonDown(1))
                {
                    character.Bash(true);
                }
                else if (lockTarget != null)
                {
                    direction.x = sideWalk;
                    direction.z = forWalk;
                    character.Strafe(playerCamera.transform.forward, direction.normalized);
                }
                else
                {
                    character.Move(direction.normalized);
                }
            }
            else
            {
                if (UnityEngine.Input.GetKeyDown(KeyCode.Space))
                {
                    character.Dash();
                }
                else if (UnityEngine.Input.GetMouseButtonDown(0))
                {
                    character.Attack(false);
                }
                else if (UnityEngine.Input.GetMouseButtonDown(1))
                {
                    character.Bash(false);
                }
                else if (lockTarget != null)
                {
                    Vector3 direction = playerCamera.transform.forward;
                    direction.y = 0;
                    character.Rotate(direction.normalized);
                }
                else
                {
                    character.NoMove();
                }
            }
            if (UnityEngine.Input.GetKeyDown(KeyCode.A))
            {
                Interact();
            }
            if (UnityEngine.Input.GetKeyDown(KeyCode.Alpha1))
            {
                character.UseSpell(0, lockTarget);
            }
            if (UnityEngine.Input.GetKeyDown(KeyCode.Alpha2))
            {
                character.UseSpell(1, lockTarget);
            }
            if (UnityEngine.Input.GetKeyDown(KeyCode.Alpha3))
            {
                character.UseSpell(2, lockTarget);
            }
            if (UnityEngine.Input.GetKeyDown(KeyCode.Alpha4))
            {
                character.UseSpell(3, lockTarget);
            }
            if (UnityEngine.Input.GetMouseButtonDown(2))
            {
                UpdateLockOn();
            }
        }