private void Update()
 {
     UpdateAnimationSpeed();
     if (rpgCharacterMovementController.MaintainingGround())
     {
         //Revive.
         if (rpgCharacterInputController.inputDeath)
         {
             if (isDead)
             {
                 Revive();
             }
         }
         if (canAction)
         {
             Blocking();
             if (!isBlocking)
             {
                 Strafing();
                 RandomIdle();
                 Rolling();
                 //Hit.
                 if (rpgCharacterInputController.inputLightHit)
                 {
                     GetHit();
                 }
                 //Death.
                 if (rpgCharacterInputController.inputDeath)
                 {
                     if (!isDead)
                     {
                         Death();
                     }
                     else
                     {
                         Revive();
                     }
                 }
                 //Attacks.
                 if (rpgCharacterInputController.inputAttackL)
                 {
                     Attack(1);
                 }
                 if (rpgCharacterInputController.inputAttackR)
                 {
                     Attack(2);
                 }
                 if (rpgCharacterInputController.inputKickL)
                 {
                     AttackKick(1);
                 }
                 if (rpgCharacterInputController.inputKickR)
                 {
                     AttackKick(2);
                 }
                 if (rpgCharacterInputController.inputLightHit)
                 {
                     GetHit();
                 }
                 //Navmesh.
                 if (Input.GetMouseButtonDown(0))
                 {
                     if (rpgCharacterMovementController.useMeshNav)
                     {
                         RaycastHit hit;
                         if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
                         {
                             rpgCharacterMovementController.navMeshAgent.destination = hit.point;
                         }
                     }
                 }
             }
         }
     }
     //Injury toggle.
     if (Input.GetKeyDown(KeyCode.I))
     {
         if (injured == false)
         {
             injured = true;
             animator.SetBool("Injured", true);
         }
         else
         {
             injured = false;
             animator.SetBool("Injured", false);
         }
     }
     //Slow time toggle.
     if (Input.GetKeyDown(KeyCode.T))
     {
         if (Time.timeScale != 1)
         {
             Time.timeScale = 1;
         }
         else
         {
             Time.timeScale = 0.25f;
         }
     }
     //Pause toggle.
     if (Input.GetKeyDown(KeyCode.P))
     {
         if (Time.timeScale != 1)
         {
             Time.timeScale = 1;
         }
         else
         {
             Time.timeScale = 0f;
         }
     }
 }
示例#2
0
        private void Update()
        {
            if (rpgCharacterMovementControllerFREE.MaintainingGround())
            {
                //Revive.
                if (rpgCharacterInputControllerFREE.inputDeath)
                {
                    if (isDead)
                    {
                        Revive();
                    }
                }
                if (canAction)
                {
                    Blocking();
                    if (!isBlocking)
                    {
                        Targeting();
                        RandomIdle();
                        Rolling();
                        //Hit.
                        if (rpgCharacterInputControllerFREE.inputLightHit)
                        {
                            GetHit();
                        }
                        //Death.
                        if (rpgCharacterInputControllerFREE.inputDeath)
                        {
                            if (!isDead)
                            {
                                Death();
                            }
                            else
                            {
                                Revive();
                            }
                        }
                        //Attacks.
                        if (rpgCharacterInputControllerFREE.inputAttackL)
                        {
                            Attack(1);
                        }
                        if (rpgCharacterInputControllerFREE.inputAttackR)
                        {
                            Attack(2);
                        }
                        if (rpgCharacterInputControllerFREE.inputKickL)
                        {
                            AttackKick(1);
                        }
                        if (rpgCharacterInputControllerFREE.inputKickR)
                        {
                            AttackKick(2);
                        }
                        if (rpgCharacterInputControllerFREE.inputLightHit)
                        {
                            GetHit();
                        }
                        //Navmesh.
                        if (UnityEngine.InputSystem.Mouse.current.leftButton.wasPressedThisFrame)
                        {
                            if (rpgCharacterMovementControllerFREE.useMeshNav)
                            {
                                RaycastHit hit;
                                if (Physics.Raycast(Camera.main.ScreenPointToRay(rpgCharacterInputControllerFREE.inputMouseFacing), out hit, 100))
                                {
                                    rpgCharacterMovementControllerFREE.navMeshAgent.destination = hit.point;
                                }
                            }
                        }
                    }
                }
            }
            //Injury toggle.
            if (UnityEngine.InputSystem.Keyboard.current.iKey.wasPressedThisFrame)
            {
                if (injured == false)
                {
                    injured = true;
                    animator.SetBool("Injured", true);
                }
                else
                {
                    injured = false;
                    animator.SetBool("Injured", false);
                }
            }
            //Slow time toggle.
            if (UnityEngine.InputSystem.Keyboard.current.tKey.wasPressedThisFrame)
            {
                if (Time.timeScale != 1)
                {
                    Time.timeScale = 1;
                }
                else
                {
                    Time.timeScale = 0.25f;
                }
            }
            //Pause toggle.
            if (UnityEngine.InputSystem.Keyboard.current.pKey.wasPressedThisFrame)
            {
                if (Time.timeScale != 1)
                {
                    Time.timeScale = 1;
                }
                else
                {
                    Time.timeScale = 0f;
                }
            }

            //Update animation play speed if adjusted.
            animator.SetFloat("AnimationSpeed", animationSpeed);
        }
示例#3
0
        private void OnGUI()
        {
            //If not dead.
            if (!rpgCharacterController.isDead)
            {
                //Actions.
                if (rpgCharacterController.canAction)
                {
                    //Character is on the ground.
                    if (rpgCharacterMovementController.MaintainingGround())
                    {
                        if (!navAgentToggle)
                        {
                            //Blocking.
                            blockGui = GUI.Toggle(new Rect(25, 215, 100, 30), blockGui, "Block");
                            if (blockGui)
                            {
                                if (!blockToggle)
                                {
                                    blockToggle = true;
                                    rpgCharacterController.canBlock   = false;
                                    rpgCharacterController.isBlocking = true;
                                    rpgCharacterController.animator.SetBool("Blocking", true);
                                    rpgCharacterMovementController.canMove = false;
                                    rpgCharacterController.animator.SetTrigger("BlockTrigger");
                                }
                            }
                            if (!blockGui)
                            {
                                if (blockToggle)
                                {
                                    rpgCharacterController.isBlocking = false;
                                    rpgCharacterController.animator.SetBool("Blocking", false);
                                    rpgCharacterMovementController.canMove = true;
                                    blockToggle = false;
                                    rpgCharacterController.canBlock = true;
                                }
                            }
                            //Blocking.
                            if (blockGui)
                            {
                                if (GUI.Button(new Rect(30, 240, 100, 30), "Get Hit"))
                                {
                                    rpgCharacterController.GetHit();
                                }
                                if (GUI.Button(new Rect(30, 270, 100, 30), "Block Break"))
                                {
                                    StartCoroutine(rpgCharacterController._BlockBreak());
                                }
                            }
                            //Not Blocking.
                            else if (!rpgCharacterController.isBlocking)
                            {
                                //Rolling.
                                if (GUI.Button(new Rect(25, 15, 100, 30), "Roll Forward"))
                                {
                                    StartCoroutine(rpgCharacterMovementController._Roll(1));
                                }
                                if (GUI.Button(new Rect(130, 15, 100, 30), "Roll Backward"))
                                {
                                    StartCoroutine(rpgCharacterMovementController._Roll(3));
                                }
                                if (GUI.Button(new Rect(25, 45, 100, 30), "Roll Left"))
                                {
                                    StartCoroutine(rpgCharacterMovementController._Roll(4));
                                }
                                if (GUI.Button(new Rect(130, 45, 100, 30), "Roll Right"))
                                {
                                    StartCoroutine(rpgCharacterMovementController._Roll(2));
                                }
                                //Dodging.
                                if (GUI.Button(new Rect(235, 15, 100, 30), "Dodge Left"))
                                {
                                    StartCoroutine(rpgCharacterController._Dodge(1));
                                }
                                if (GUI.Button(new Rect(235, 45, 100, 30), "Dodge Right"))
                                {
                                    StartCoroutine(rpgCharacterController._Dodge(2));
                                }
                                //ATTACK LEFT.
                                if (rpgCharacterWeaponController.leftWeapon != 0 && rpgCharacterWeaponController.leftWeapon != 7)
                                {
                                    if (GUI.Button(new Rect(25, 85, 100, 30), "Attack L"))
                                    {
                                        rpgCharacterController.Attack(1);
                                    }
                                }
                                //ATTACK RIGHT.
                                if (rpgCharacterController.animator.GetInteger("RightWeapon") != 0)
                                {
                                    if (GUI.Button(new Rect(130, 85, 100, 30), "Attack R"))
                                    {
                                        rpgCharacterController.Attack(2);
                                    }
                                }
                                //Kicking.
                                if (GUI.Button(new Rect(25, 115, 100, 30), "Left Kick"))
                                {
                                    rpgCharacterController.AttackKick(1);
                                }
                                if (GUI.Button(new Rect(130, 115, 100, 30), "Right Kick"))
                                {
                                    rpgCharacterController.AttackKick(2);
                                }
                                if (GUI.Button(new Rect(30, 240, 100, 30), "Get Hit"))
                                {
                                    rpgCharacterController.GetHit();
                                }
                                //Weapon Switching.
                                if (!rpgCharacterMovementController.isMoving)
                                {
                                    if (rpgCharacterController.weapon != Weapon.UNARMED)
                                    {
                                        if (GUI.Button(new Rect(1115, 310, 100, 30), "Unarmed"))
                                        {
                                            StartCoroutine(rpgCharacterWeaponController._SwitchWeapon(0));
                                            rpgCharacterController.canAction = true;
                                        }
                                    }
                                    if (rpgCharacterController.weapon != Weapon.TWOHANDSWORD)
                                    {
                                        if (GUI.Button(new Rect(1115, 340, 100, 30), "2 Hand Sword"))
                                        {
                                            StartCoroutine(rpgCharacterWeaponController._SwitchWeapon(1));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //Jump / Double Jump.
                    if ((rpgCharacterMovementController.canJump || rpgCharacterMovementController.canDoubleJump) && !blockGui && rpgCharacterController.canAction && !navAgentToggle)
                    {
                        if (rpgCharacterMovementController.MaintainingGround())
                        {
                            if (GUI.Button(new Rect(25, 175, 100, 30), "Jump"))
                            {
                                if (rpgCharacterMovementController.canJump)
                                {
                                    rpgCharacterMovementController.currentState      = RPGCharacterState.Jump;
                                    rpgCharacterMovementController.rpgCharacterState = RPGCharacterState.Jump;
                                }
                            }
                        }
                        if (rpgCharacterMovementController.canDoubleJump)
                        {
                            if (GUI.Button(new Rect(25, 175, 100, 30), "Jump Flip"))
                            {
                                rpgCharacterMovementController.currentState      = RPGCharacterState.DoubleJump;
                                rpgCharacterMovementController.rpgCharacterState = RPGCharacterState.DoubleJump;
                            }
                        }
                    }
                    //NavMesh
                    if (!blockGui && rpgCharacterMovementController.MaintainingGround())
                    {
                        if (rpgCharacterMovementController.navMeshAgent != null)
                        {
                            useNavAgent = GUI.Toggle(new Rect(500, 15, 100, 30), useNavAgent, "Use NavAgent");
                            if (useNavAgent)
                            {
                                navAgentToggle = true;
                                rpgCharacterMovementController.useMeshNav           = true;
                                rpgCharacterMovementController.navMeshAgent.enabled = true;
                                rpgCharacterController.rpgCharacterInputControllerFREE.allowedInput = false;
                                GUI.Label(new Rect(500, 45, 220, 50), "Click to move Character.");
                            }
                            else
                            {
                                navAgentToggle = false;
                                rpgCharacterMovementController.useMeshNav           = false;
                                rpgCharacterMovementController.navMeshAgent.enabled = false;
                                rpgCharacterController.rpgCharacterInputControllerFREE.allowedInput = true;
                            }
                        }
                        else
                        {
                            rpgCharacterMovementController.useMeshNav = false;
                            rpgCharacterController.rpgCharacterInputControllerFREE.allowedInput = true;
                        }
                    }
                }
                //Death Pickup Activate.
                if (!blockGui && !rpgCharacterController.isBlocking && rpgCharacterMovementController.MaintainingGround() && rpgCharacterController.canAction && !navAgentToggle)
                {
                    if (GUI.Button(new Rect(30, 270, 100, 30), "Death"))
                    {
                        rpgCharacterController.Death();
                    }
                }
            }

            //Revive.
            if (rpgCharacterController.isDead)
            {
                if (GUI.Button(new Rect(30, 270, 100, 30), "Revive"))
                {
                    rpgCharacterController.Revive();
                }
            }
        }