示例#1
0
 public void Blocking()
 {
     if (canBlock)
     {
         if (!isBlocking)
         {
             if (rpgCharacterInputController.HasBlockInput())
             {
                 isBlocking = true;
                 animator.SetBool("Blocking", true);
                 rpgCharacterMovementController.canMove = false;
                 animator.SetTrigger("BlockTrigger");
             }
         }
         else
         {
             if (!rpgCharacterInputController.HasBlockInput())
             {
                 isBlocking = false;
                 animator.SetBool("Blocking", false);
                 rpgCharacterMovementController.canMove = true;
             }
         }
     }
 }
示例#2
0
 private void Swim_SuperUpdate()
 {
     //Swim movement.
     currentVelocity = Vector3.MoveTowards(currentVelocity, rpgCharacterInputController.moveInput * swimSpeed, waterFriction * superCharacterController.deltaTime);
     //Apply friction to slow character to a halt on vertical axis.
     currentVelocity = Vector3.MoveTowards(currentVelocity, new Vector3(currentVelocity.x, 0, currentVelocity.z), (waterFriction * 5) * superCharacterController.deltaTime);
     if (rpgCharacterInputController.inputJump && (!rpgCharacterInputController.inputTarget || !rpgCharacterInputController.HasBlockInput()))
     {
         SwimDescent();
     }
     else if (rpgCharacterInputController.inputJump)
     {
         SwimAscend();
     }
 }
示例#3
0
 private void Update()
 {
     UpdateAnimationSpeed();
     if (rpgCharacterMovementController.rpgCharacterState != RPGCharacterState.Swim && rpgCharacterMovementController.MaintainingGround())
     {
         //Revive.
         if (rpgCharacterInputController.inputDeath)
         {
             if (isDead)
             {
                 Revive();
             }
         }
         if (canAction)
         {
             Blocking();
             if (!isBlocking)
             {
                 Strafing();
                 RandomIdle();
                 DirectionalAiming();
                 Aiming();
                 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.inputLightHit)
                 {
                     GetHit();
                 }
                 if (rpgCharacterInputController.inputCastL)
                 {
                     AttackKick(1);
                 }
                 if (rpgCharacterInputController.inputCastL)
                 {
                     StartCoroutine(_BlockBreak());
                 }
                 if (rpgCharacterInputController.inputCastR)
                 {
                     AttackKick(2);
                 }
                 if (rpgCharacterInputController.inputCastR)
                 {
                     StartCoroutine(_BlockBreak());
                 }
                 //Switch weapons.
                 if (rpgCharacterWeaponController != null)
                 {
                     if (rpgCharacterWeaponController.isSwitchingFinished)
                     {
                         if (rpgCharacterInputController.inputSwitchUpDown < -0.1f)
                         {
                             rpgCharacterWeaponController.SwitchWeaponTwoHand(0);
                         }
                         else if (rpgCharacterInputController.inputSwitchUpDown > 0.1f)
                         {
                             rpgCharacterWeaponController.SwitchWeaponTwoHand(1);
                         }
                         if (rpgCharacterInputController.inputSwitchLeftRight < -0.1f)
                         {
                             rpgCharacterWeaponController.SwitchWeaponLeftRight(0);
                         }
                         else if (rpgCharacterInputController.inputSwitchLeftRight > 0.1f)
                         {
                             rpgCharacterWeaponController.SwitchWeaponLeftRight(1);
                         }
                         //Shield.
                         if (rpgCharacterInputController.inputShield)
                         {
                             StartCoroutine(rpgCharacterWeaponController._SwitchWeapon(7));
                         }
                         if (rpgCharacterInputController.inputRelax)
                         {
                             StartCoroutine(rpgCharacterWeaponController._SwitchWeapon(-1));
                         }
                     }
                 }
                 //Reset Switching.
                 if (rpgCharacterInputController.inputSwitchLeftRight == 0 && rpgCharacterInputController.inputSwitchUpDown == 0)
                 {
                     if (rpgCharacterWeaponController != null)
                     {
                         rpgCharacterWeaponController.isSwitchingFinished = true;
                     }
                 }
                 //Shooting / 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;
                         }
                     }
                     else if ((weapon == Weapon.TWOHANDBOW || weapon == Weapon.TWOHANDCROSSBOW || weapon == Weapon.RIFLE) && isAiming)
                     {
                         animator.SetInteger("Action", 1);
                         if (weapon == Weapon.RIFLE && hipShooting == true)
                         {
                             animator.SetInteger("Action", 2);
                         }
                         animator.SetTrigger("AttackTrigger");
                     }
                 }
                 //Reload.
                 if (Input.GetMouseButtonDown(2))
                 {
                     animator.SetTrigger("ReloadTrigger");
                 }
                 //Climbing ladder.
                 if (rpgCharacterMovementController.rpgCharacterState == RPGCharacterState.ClimbLadder && !isClimbing)
                 {
                     if (rpgCharacterInputController.inputVertical > 0.1f)
                     {
                         animator.SetInteger("Action", 1);
                         animator.SetTrigger("ClimbLadderTrigger");
                     }
                     else if (rpgCharacterInputController.inputVertical < -0.1f)
                     {
                         animator.SetInteger("Action", 2);
                         animator.SetTrigger("ClimbLadderTrigger");
                     }
                 }
                 if (rpgCharacterMovementController.rpgCharacterState == RPGCharacterState.ClimbLadder && isClimbing)
                 {
                     if (rpgCharacterInputController.inputVertical == 0)
                     {
                         isClimbing = false;
                     }
                 }
             }
         }
     }
     //Injury toggle.
     if (Input.GetKeyDown(KeyCode.I))
     {
         if (injured == false)
         {
             injured = true;
             animator.SetBool("Injured", true);
         }
         else
         {
             injured = false;
             animator.SetBool("Injured", false);
         }
     }
     //Head look toggle.
     if (Input.GetKeyDown(KeyCode.L))
     {
         if (headLook == false)
         {
             headLook   = true;
             isHeadlook = true;
         }
         else
         {
             headLook   = false;
             isHeadlook = false;
         }
     }
     //Slow time toggle.
     if (Input.GetKeyDown(KeyCode.T))
     {
         if (Time.timeScale != 1)
         {
             Time.timeScale = 1;
         }
         else
         {
             Time.timeScale = 0.005f;
         }
     }
     //Pause toggle.
     if (Input.GetKeyDown(KeyCode.P))
     {
         if (Time.timeScale != 1)
         {
             Time.timeScale = 1;
         }
         else
         {
             Time.timeScale = 0f;
         }
     }
     //Swim up/down toggle.
     if (rpgCharacterMovementController.rpgCharacterState == RPGCharacterState.Swim && (!rpgCharacterInputController.inputTarget || !rpgCharacterInputController.HasBlockInput()))
     {
         animator.SetBool("Strafing", true);
     }
     else
     {
         animator.SetBool("Strafing", false);
     }
 }