예제 #1
0
    void FixedUpdate()
    {
        //If it is this players turn
        if (active)
        {
            switch (state) //Switch states if active
            {
            case States.NavMesh:
                movement.NavMeshMovement();
                mouseWheelLocation      = 0;
                hud.stateIndicator.text = "Combat Movement";
                break;

            case States.WASD:
                movement.KeyboardMovement();
                hud.stateIndicator.text = "WASD Movement";
                break;

            case States.MeleeAttack:
                attack.MeleeAttackMode();
                mouseWheelLocation      = 1;
                hud.stateIndicator.text = "Melee Attack";
                movement.rb.velocity    = Vector3.zero;
                movement.anim.SetFloat("Speed", (movement.agent.velocity.magnitude / gameObject.transform.localScale.y));
                canAttack = true;
                break;

            case States.RangeAttack:
                attack.RangeAttackMode();
                mouseWheelLocation      = 2;
                hud.stateIndicator.text = "Mage Attack";
                movement.rb.velocity    = Vector3.zero;
                movement.anim.SetFloat("Speed", (movement.agent.velocity.magnitude / gameObject.transform.localScale.y));
                canAttack = true;
                break;

            case States.Shielding:
                //Changes the mouse wheel location and tells us which state we are in.
                mouseWheelLocation      = 3;
                hud.stateIndicator.text = "Shield";
                movement.rb.velocity    = Vector3.zero;
                movement.anim.SetFloat("Speed", (movement.agent.velocity.magnitude / gameObject.transform.localScale.y));

                //look at the mouse if active
                if (active)
                {
                    attack.LookAtMouse();
                }

                //Activates the visable shield if it isn't active
                if (!shieldActive)
                {
                    shield.SetActive(true);
                }
                break;
            }

            //Display the stats for the current state
            hud.DisplayStats();
            addedMana = false;
        }
        else
        {
            ResetPlayerCombat();
        }
    }