public virtual void Update()
 {
     targetCameraPos        = camera.localPosition;
     targetCameraQuatRot    = cameraLook.GetCameraTargetRot();
     targetCameraEulerRot   = targetCameraQuatRot.eulerAngles;
     targetCameraEulerRot.y = 0;
     if (UInput.GetButton(INC.RIGHT_TILT))
     {
         targetCameraPos.x      = Mathf.SmoothStep(targetCameraPos.x, outputRange, outputSpeed * Time.deltaTime);
         targetCameraEulerRot.z = -angle;
         targetCameraQuatRot    = Quaternion.Euler(targetCameraEulerRot);
         isTilt = true;
     }
     else if (UInput.GetButton(INC.LEFT_TILT))
     {
         targetCameraPos.x      = Mathf.SmoothStep(targetCameraPos.x, -outputRange, outputSpeed * Time.deltaTime);
         targetCameraEulerRot.z = angle;
         targetCameraQuatRot    = Quaternion.Euler(targetCameraEulerRot);
         isTilt = true;
     }
     else if (!UInput.GetButton(INC.RIGHT_TILT) && !UInput.GetButton(INC.LEFT_TILT))
     {
         targetCameraPos.x      = Mathf.SmoothStep(targetCameraPos.x, originalOutput, outputSpeed * Time.deltaTime);
         targetCameraEulerRot.z = -originalAngle;
         targetCameraQuatRot    = Quaternion.Euler(targetCameraEulerRot);
         isTilt = false;
     }
     camera.localPosition = targetCameraPos;
     cameraLook.SetCameraTargetRot(Quaternion.Slerp(cameraLook.GetCameraTargetRot(), targetCameraQuatRot, rotateSpeed * Time.deltaTime));
 }
 public WeaponActionState GetActiveState()
 {
     if (UInput.GetButton(INC.SIGHT))
     {
         return(WeaponActionState.Sight);
     }
     else if (!characterController.isGrounded)
     {
         return(WeaponActionState.InAir);
     }
     else if (controller.GetCrouchSystem().IsCrouch())
     {
         return(WeaponActionState.Crouch);
     }
     else if (animator.GetInteger(SPEED_HASH) == 3)
     {
         return(WeaponActionState.Sprint);
     }
     else if (animator.GetInteger(SPEED_HASH) == 2)
     {
         return(WeaponActionState.Run);
     }
     else if (animator.GetInteger(SPEED_HASH) == 1)
     {
         return(WeaponActionState.Walk);
     }
     else
     {
         return(WeaponActionState.Idle);
     }
 }
Пример #3
0
        protected virtual void OnGUI()
        {
            if (hideWhileSight)
            {
                showCrosshair = !UInput.GetButton(INC.SIGHT);
            }

            if (showCrosshair && verticalTexture && horizontalTexture)
            {
                GUI.color = crosshairColor;
                switch (preset)
                {
                case Preset.Default:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - width) / 2, (Screen.height - spread) / 2 - height, width, height), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - width) / 2, (Screen.height + spread) / 2, width, height), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - spread) / 2 - height, (Screen.height - width) / 2, height, width), verticalTexture);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - width) / 2, height, width), verticalTexture);
                    break;

                case Preset.Shotgun:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - height) / 2, (Screen.height - spread) / 2 - width, height, width), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - height) / 2, (Screen.height + spread) / 2, height, width), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - spread) / 2 - width, (Screen.height - height) / 2, width, height), verticalTexture);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - height) / 2, width, height), verticalTexture);
                    break;

                case Preset.Triangle:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - 2) / 2, (Screen.height - spread) / 2 - 14, width, height), horizontalTexture);
                    GUIUtility.RotateAroundPivot(45, center);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - 2) / 2, height, width), horizontalTexture);
                    GUIUtility.RotateAroundPivot(0, center);
                    GUI.DrawTexture(new Rect((Screen.width - 2) / 2, (Screen.height + spread) / 2, width, height), horizontalTexture);
                    break;
                }
                GUI.color = Color.white;
            }

            if (hitEffectIsActive && hitEffectTexture)
            {
                if (!UMathf.Approximately(hitEffectColor.a, 0, 0.001f))
                {
                    hitEffectColor.a = Mathf.SmoothStep(hitEffectColor.a, 0, hitEffectHideSpeed * Time.deltaTime);
                }
                GUI.color = hitEffectColor;
                GUIUtility.RotateAroundPivot(hitEffecntAngle, center);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectWidth) / 2, (Screen.height - hitEffectSpread) / 2 - hitEffectHeight, hitEffectWidth, hitEffectHeight), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectWidth) / 2, (Screen.height + hitEffectSpread) / 2, hitEffectWidth, hitEffectHeight), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectSpread) / 2 - hitEffectHeight, (Screen.height - hitEffectWidth) / 2, hitEffectHeight, hitEffectWidth), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width + hitEffectSpread) / 2, (Screen.height - hitEffectWidth) / 2, hitEffectHeight, hitEffectWidth), hitEffectTexture);
            }
        }
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (controller == null)
            {
                return;
            }

            if (controller.IsSprinting())
            {
                animator.SetInteger(SPEED_HASH, 3);
            }
            else if (controller.IsRunning())
            {
                animator.SetInteger(SPEED_HASH, 2);
            }
            else if (controller.IsWalking())
            {
                animator.SetInteger(SPEED_HASH, 1);
            }
            else if (!UInput.GetButton(INC.ATTACK) && !UInput.GetButton(INC.JUMP))
            {
                animator.SetInteger(SPEED_HASH, 0);
            }

            if (UInput.GetButtonDown(INC.SIGHT))
            {
                animator.SetBool(SIGHT_HASH, true);
            }
            else if (UInput.GetButtonUp(INC.SIGHT))
            {
                animator.SetBool(SIGHT_HASH, false);
            }

            if (useRotationSway)
            {
                RotationSwayProcessing(transform);
            }

            if (useJumpSway)
            {
                JumpSwayProcessing(transform);
            }
        }
Пример #5
0
        /// <summary>
        /// Shooting system processing.
        /// </summary>
        protected virtual IEnumerator ShootingProcessing()
        {
            WaitForSeconds    updateDelay = new WaitForSeconds(delay);
            WaitForEndOfFrame endOfFrame  = new WaitForEndOfFrame();

            while (true)
            {
                if (!weaponReloading.BulletsIsEmpty() && !weaponReloading.IsReloading())
                {
                    if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) || fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK))
                    {
                        DoShoot();
                        yield return(updateDelay);
                    }
                    else if (fireMode == Mode.Queue && UInput.GetButtonDown(INC.ATTACK))
                    {
                        for (int i = 0; i < queueCount; i++)
                        {
                            DoShoot();
                            weaponAnimator.SetAttack(1);
                            yield return(endOfFrame);

                            weaponAnimator.SetAttack(-1);
                            yield return(updateDelay);
                        }
                    }
                }
                else if (UInput.GetButtonDown(INC.ATTACK))
                {
                    AudioClip sound = soundProperties.GetRandomEmptySound();
                    if (sound != null)
                    {
                        audioSource.PlayOneShot(sound);
                    }
                    weaponAnimator.SetAttack(0);
                    yield return(endOfFrame);

                    weaponAnimator.SetAttack(-1);
                }
                yield return(null);
            }
        }
Пример #6
0
        private void AnimatorStateProcessing()
        {
            if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) && !weaponReloading.BulletsIsEmpty())
            {
                weaponAnimator.SetAttack(1);
            }
            else if (fireMode == Mode.Free && !UInput.GetButton(INC.ATTACK))
            {
                weaponAnimator.SetAttack(-1);
            }

            if (fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK) && !weaponReloading.BulletsIsEmpty())
            {
                weaponAnimator.SetAttack(1);
            }
            else if (fireMode == Mode.Single && !UInput.GetButtonDown(INC.ATTACK))
            {
                weaponAnimator.SetAttack(-1);
            }
        }