Beispiel #1
0
    void ShotInput()
    {
        if (!shooterManager || shooterManager.rWeapon == null)
        {
            return;
        }
        if (isAiming && !shooterManager.shotting && aimConditions && !isReloading && !isAttacking)
        {
            if (shooterManager.rWeapon.automaticWeapon ? shotInput.GetButton() : shotInput.GetButtonDown())
            {
                shooterManager.Shoot(aimPosition);
            }

            else if (shotInput.GetButtonDown())
            {
                if (allowAttack == false)
                {
                    shooterManager.Shoot(aimPosition);
                    allowAttack = true;
                }
            }
            else
            {
                allowAttack = false;
            }
        }
    }
Beispiel #2
0
    }/// STRONG ATK INPUT

    protected virtual void BlockingInput()
    {
        if (cc.anime == null)
        {
            return;
        }

        isBlocking = blockInput.GetButton() && cc.currentStamina > 0;
    }/// BLOCK INPUT
 protected virtual void HandleShot(vShooterWeapon weapon, GenericInput weaponInput, bool secundaryShot = false)
 {
     if (weapon.chargeWeapon)
     {
         if (weapon.ammoCount > 0 && weapon.powerCharge < 1 && weaponInput.GetButton())
         {
             weapon.powerCharge += Time.deltaTime * weapon.chargeSpeed;
         }
         else if ((weapon.powerCharge >= 1 && weapon.autoShotOnFinishCharge) || weaponInput.GetButtonUp() || (!weaponInput.GetButton() && isAiming && weapon.powerCharge > 0))
         {
             if (shooterManager.hipfireShot)
             {
                 aimTimming = 3f;
             }
             shooterManager.Shoot(aimPosition, !isAiming, secundaryShot);
             weapon.powerCharge = 0;
         }
         animator.SetFloat("PowerCharger", weapon.powerCharge);
     }
     else if (weapon.automaticWeapon ? weaponInput.GetButton() : weaponInput.GetButtonDown())
     {
         if (shooterManager.hipfireShot)
         {
             aimTimming = 3f;
         }
         shooterManager.Shoot(aimPosition, !isAiming, secundaryShot);
     }
     else if (weaponInput.GetButtonDown())
     {
         if (allowAttack == false)
         {
             if (shooterManager.hipfireShot)
             {
                 aimTimming = 1f;
             }
             shooterManager.Shoot(aimPosition, !isAiming, secundaryShot);
             allowAttack = true;
         }
     }
     else
     {
         allowAttack = false;
     }
 }
Beispiel #4
0
 public virtual void HandleBuildRotation()
 {
     if (rotateLeft.GetButton())
     {
         currentBuild.angle -= Time.deltaTime * currentBuild.rotateSpeed;
     }
     else if (rotateRight.GetButton())
     {
         currentBuild.angle += Time.deltaTime * currentBuild.rotateSpeed;
     }
 }
Beispiel #5
0
        private void SwimUpOrDownInput()
        {
            if (tpInput.cc.customAction)
            {
                return;
            }
            var upConditions = (((tpInput.cc._capsuleCollider.bounds.center.y + heightOffset) - waterHeightLevel) < -.2f);

            if (!swimUpAndDown)
            {
                var newPos = new Vector3(transform.position.x, waterHeightLevel, transform.position.z);
                if (upConditions)
                {
                    tpInput.cc.transform.position = Vector3.Lerp(transform.position, newPos, 0.5f * Time.deltaTime);
                }
                return;
            }

            // extra rigibody up velocity
            if (swimUpInput.GetButton())
            {
                if (upConditions)
                {
                    var vel = tpInput.cc._rigidbody.velocity;
                    vel.y = swimUpSpeed;
                    tpInput.cc._rigidbody.velocity = vel;
                    tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 4);
                }
            }
            else if (swimDownInput.GetButton())
            {
                var vel = tpInput.cc._rigidbody.velocity;
                vel.y = -swimDownSpeed;
                tpInput.cc._rigidbody.velocity = vel;
                tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 3);
            }
            else
            {
                if (isUnderWater)
                {
                    tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 2);
                }
                else
                {
                    tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 1);
                }
            }
        }
Beispiel #6
0
    void AimInput()
    {
        if (cc.locomotionType == vThirdPersonMotor.LocomotionType.OnlyFree)
        {
            Debug.LogWarning("Shooter behaviour needs to be OnlyStrafe or Free with Strafe. \n Please change the Locomotion Type.");
            return;
        }

        if (!shooterManager || shooterManager.rWeapon == null)
        {
            if (controlAimCanvas)
            {
                controlAimCanvas.SetActiveAim(false);
                controlAimCanvas.SetActiveScopeCamera(false);
            }
            isAiming = false;
            return;
        }

        isAiming = !isReloading && (aimInput.GetButton() || (shooterManager.alwaysAiming)) && !cc.actions && !cc.customAction || (cc.actions && cc.isJumping);

        if (cc.locomotionType == vThirdPersonMotor.LocomotionType.FreeWithStrafe)
        {
            if (isAiming && !cc.isStrafing)
            {
                cc.Strafe();
            }
            else if (!isAiming && cc.isStrafing)
            {
                cc.Strafe();
            }
        }

        if (controlAimCanvas)
        {
            if (isAiming && !controlAimCanvas.isAimActive)
            {
                controlAimCanvas.SetActiveAim(true);
            }
            if (!isAiming && controlAimCanvas.isAimActive)
            {
                controlAimCanvas.SetActiveAim(false);
            }
        }

        shooterManager.rWeapon.SetActiveAim(isAiming && aimConditions);
        shooterManager.rWeapon.SetActiveScope(isAiming && isUsingScopeView);
    }
    protected virtual void ShotInput()
    {
        if (!shooterManager || shooterManager.rWeapon == null)
        {
            return;
        }

        if ((isAiming && !shooterManager.hipfireShot || shooterManager.hipfireShot) && !shooterManager.isShooting && aimConditions && !isReloading && !isAttacking)
        {
            if (shooterManager.rWeapon.automaticWeapon ? shotInput.GetButton() : shotInput.GetButtonDown())
            {
                if (shooterManager.hipfireShot)
                {
                    aimTimming = 3f;
                }
                shooterManager.Shoot(aimPosition, !isAiming);
            }
            else if (shotInput.GetButtonDown())
            {
                if (allowAttack == false)
                {
                    if (shooterManager.hipfireShot)
                    {
                        aimTimming = 1f;
                    }
                    shooterManager.Shoot(aimPosition, !isAiming);
                    allowAttack = true;
                }
            }
            else
            {
                allowAttack = false;
            }
        }
        shooterManager.UpdateShotTime();
    }
        void UseLadder()
        {
            if (!isUsingLadder)
            {
                return;
            }

            // update the base layer to know what animations are being played
            tpInput.cc.AnimatorLayerControl();
            tpInput.cc.ActionsControl();
            // update camera movement
            tpInput.CameraInput();

            // go up or down
            speed = verticallInput.GetAxis();
            tpInput.cc.animator.SetFloat(vAnimatorParameters.InputVertical, speed, 0.1f, Time.deltaTime);
            if (speed >= 0.05f || speed <= -0.05f)
            {
                tpInput.cc.animator.speed = Mathf.Lerp(tpInput.cc.animator.speed, currentClimbSpeed, 2f * Time.deltaTime);
            }
            else
            {
                tpInput.cc.animator.speed = Mathf.Lerp(tpInput.cc.animator.speed, 1f, 2f * Time.deltaTime);
            }

            // increase speed by input and consume stamina
            if (fastClimbInput.GetButton() && tpInput.cc.currentStamina > 0)
            {
                currentClimbSpeed = fastClimbSpeed;
                StaminaConsumption();
            }
            else
            {
                currentClimbSpeed = climbSpeed;
            }

            // enter ladder behaviour
            if (tpInput.cc.baseLayerInfo.IsName("EnterLadderTop") || tpInput.cc.baseLayerInfo.IsName("EnterLadderBottom") && !tpInput.cc.animator.IsInTransition(0))
            {
                tpInput.cc.DisableGravityAndCollision();              // disable gravity & turn collision trigger
                // disable ingame hud
                if (ladderActionTemp != null)
                {
                    ladderActionTemp.OnPlayerExit.Invoke();
                }

                if (ladderActionTemp.useTriggerRotation)
                {
                    if (debugMode)
                    {
                        Debug.Log("Rotating to target...");
                    }
                    EvaluateToRotation(ladderActionTemp.enterRotationCurve, ladderActionTemp.matchTarget.transform.rotation, tpInput.cc.baseLayerInfo.normalizedTime);
                }

                if (ladderActionTemp.matchTarget != null)
                {
                    if (transform.parent != ladderActionTemp.targetCharacterParent)
                    {
                        transform.parent = ladderActionTemp.targetCharacterParent;
                    }

                    if (debugMode)
                    {
                        Debug.Log("Match Target to enter...");
                    }

                    EvaluateToPosition(ladderActionTemp.enterPositionXZCurve, ladderActionTemp.enterPositionYCurve, ladderActionTemp.matchTarget.position, tpInput.cc.baseLayerInfo.normalizedTime);
                }
            }

            // exit ladder behaviour
            isExitingLadder = tpInput.cc.baseLayerInfo.IsName("ExitLadderTop") || tpInput.cc.baseLayerInfo.IsName("ExitLadderBottom") || tpInput.cc.baseLayerInfo.IsName("QuickExitLadder");

            if (isExitingLadder)
            {
                tpInput.cc.animator.speed = 1;

                if (ladderActionTemp.exitMatchTarget != null && !tpInput.cc.baseLayerInfo.IsName("QuickExitLadder"))
                {
                    if (debugMode)
                    {
                        Debug.Log("Match Target to exit...");
                    }

                    EvaluateToPosition(ladderActionTemp.exitPositionXZCurve, ladderActionTemp.exitPositionYCurve, ladderActionTemp.exitMatchTarget.position, tpInput.cc.baseLayerInfo.normalizedTime);
                }
                var newRot = new Vector3(0, tpInput.animator.rootRotation.eulerAngles.y, 0);
                EvaluateToRotation(ladderActionTemp.exitRotationCurve, Quaternion.Euler(newRot), tpInput.cc.baseLayerInfo.normalizedTime);

                if (tpInput.cc.baseLayerInfo.normalizedTime >= 0.8f)
                {
                    // after playing the animation we reset some values
                    ResetPlayerSettings();
                }
            }
        }
        protected virtual void AimInput()
        {
            if (!shooterManager)
            {
                isAiming = false;
                if (controlAimCanvas)
                {
                    controlAimCanvas.SetActiveAim(false);
                    controlAimCanvas.SetActiveScopeCamera(false);
                }
                if (cc.isStrafing)
                {
                    cc.Strafe();
                }
                return;
            }
            var weapon = shooterManager.rWeapon ? shooterManager.rWeapon : shooterManager.lWeapon;

            if (cc.locomotionType == vThirdPersonMotor.LocomotionType.OnlyFree)
            {
                Debug.LogWarning("Shooter behaviour needs to be OnlyStrafe or Free with Strafe. \n Please change the Locomotion Type.");
                return;
            }

            if (shooterManager.hipfireShot)
            {
                if (aimTimming > 0)
                {
                    aimTimming -= Time.deltaTime;
                }
            }

            if (!shooterManager || !weapon)
            {
                if (controlAimCanvas)
                {
                    controlAimCanvas.SetActiveAim(false);
                    controlAimCanvas.SetActiveScopeCamera(false);
                }
                isAiming = false;
                if (cc.isStrafing)
                {
                    cc.Strafe();
                }
                return;
            }

            if (!cc.isRolling)
            {
                isAiming = !isReloading && (aimInput.GetButton() || (shooterManager.alwaysAiming)) && !cc.ragdolled && !cc.actions && !cc.customAction || (cc.actions && cc.isJumping);
            }

            if (headTrack)
            {
                headTrack.awaysFollowCamera = isAiming;
            }

            if (cc.locomotionType == vThirdPersonMotor.LocomotionType.FreeWithStrafe)
            {
                if ((isAiming || aimTimming > 0) && !cc.isStrafing)
                {
                    cc.Strafe();
                }
                else if ((!isAiming && aimTimming <= 0) && cc.isStrafing)
                {
                    cc.Strafe();
                }
            }

            if (controlAimCanvas)
            {
                if ((isAiming || aimTimming > 0) && !controlAimCanvas.isAimActive)
                {
                    controlAimCanvas.SetActiveAim(true);
                }
                if ((!isAiming && aimTimming <= 0) && controlAimCanvas.isAimActive)
                {
                    controlAimCanvas.SetActiveAim(false);
                }
            }
            if (shooterManager.rWeapon)
            {
                shooterManager.rWeapon.SetActiveAim(isAiming && aimConditions);
                shooterManager.rWeapon.SetActiveScope(isAiming && isUsingScopeView);
            }
            else if (shooterManager.lWeapon)
            {
                shooterManager.lWeapon.SetActiveAim(isAiming && aimConditions);
                shooterManager.lWeapon.SetActiveScope(isAiming && isUsingScopeView);
            }
        }
Beispiel #10
0
        protected virtual void UsingLadder()
        {
            if (!isUsingLadder)
            {
                return;
            }

            // update the base layer to know what animations are being played
            tpInput.cc.AnimatorLayerControl();
            tpInput.cc.ActionsControl();
            // update camera movement
            tpInput.CameraInput();

            // go up or down
            speed = verticallInput.GetAxis();
            tpInput.cc.animator.SetFloat(vAnimatorParameters.InputVertical, speed, 0.1f, Time.deltaTime);
            if (speed >= 0.05f || speed <= -0.05f)
            {
                tpInput.cc.animator.speed = Mathf.Lerp(tpInput.cc.animator.speed, currentClimbSpeed, 2f * Time.deltaTime);
            }
            else
            {
                tpInput.cc.animator.speed = Mathf.Lerp(tpInput.cc.animator.speed, 1f, 2f * Time.deltaTime);
            }

            // increase speed by input and consume stamina
            if (fastClimbInput.GetButton() && tpInput.cc.currentStamina > 0)
            {
                currentClimbSpeed = fastClimbSpeed;
                StaminaConsumption();
            }
            else
            {
                currentClimbSpeed = climbSpeed;
            }

            // enter ladder behaviour
            var _inEnterLadderAnimation = tpInput.cc.baseLayerInfo.IsName("EnterLadderTop") || tpInput.cc.baseLayerInfo.IsName("EnterLadderBottom") && !tpInput.cc.animator.IsInTransition(0);

            if (_inEnterLadderAnimation)
            {
                this.inEnterLadderAnimation = true;

                tpInput.cc.DisableGravityAndCollision();              // disable gravity & turn collision trigger
                // disable ingame hud
                if (currentLadderAction != null)
                {
                    currentLadderAction.OnPlayerExit.Invoke();
                }

                if (currentLadderAction.useTriggerRotation)
                {
                    if (debugMode)
                    {
                        Debug.Log("Rotating to target..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
                    }
                    EvaluateToRotation(currentLadderAction.enterRotationCurve, currentLadderAction.matchTarget.transform.rotation, tpInput.cc.baseLayerInfo.normalizedTime);
                }

                if (currentLadderAction.matchTarget != null)
                {
                    if (transform.parent != currentLadderAction.targetCharacterParent)
                    {
                        transform.parent = currentLadderAction.targetCharacterParent;
                    }

                    if (debugMode)
                    {
                        Debug.Log("Match Target to Enter..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
                    }

                    EvaluateToPosition(currentLadderAction.enterPositionXZCurve, currentLadderAction.enterPositionYCurve, currentLadderAction.matchTarget.position, tpInput.cc.baseLayerInfo.normalizedTime);
                }
            }

            if (!_inEnterLadderAnimation && inEnterLadderAnimation)
            {
                enterLadderStarted     = false;
                inEnterLadderAnimation = false;
            }
            TriggerExitLadder();
        }