156 lines
3.8 KiB
C#
156 lines
3.8 KiB
C#
using Beyond;
|
|
using Invector;
|
|
using Invector.vCharacterController;
|
|
using System.Collections;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace Beyond
|
|
{
|
|
[vClassHeader("Input Manager", iconName = "inputIcon")]
|
|
public class bThirdPersonInput : vThirdPersonInput
|
|
{
|
|
public bool forceWalking = false;
|
|
public float maxWalkSpeed = 0.5f;
|
|
|
|
[HideInInspector]
|
|
public bool lockSprintInput, lockCrouchInput, lockStrafeInput, lockJumpInput, lockRollInput;
|
|
|
|
[HideInInspector] public bHUDController bHud;
|
|
|
|
protected override void Start()
|
|
{
|
|
cc = GetComponent<bThirdPersonController>();
|
|
|
|
if (cc != null)
|
|
{
|
|
cc.Init();
|
|
}
|
|
|
|
StartCoroutine(CharacterInit());
|
|
|
|
ShowCursor(showCursorOnStart);
|
|
LockCursor(unlockCursorOnStart);
|
|
EnableOnAnimatorMove();
|
|
}
|
|
|
|
public Animator animator
|
|
{
|
|
get
|
|
{
|
|
if (cc == null)
|
|
{
|
|
cc = GetComponent<bThirdPersonController>();
|
|
}
|
|
|
|
if (cc.animator == null)
|
|
{
|
|
return GetComponent<Animator>();
|
|
}
|
|
|
|
return cc.animator;
|
|
}
|
|
}
|
|
|
|
public override void MoveInput()
|
|
{
|
|
if (!lockMoveInput)
|
|
{
|
|
// gets input
|
|
cc.input.x = horizontalInput.GetAxisRaw();
|
|
cc.input.z = verticallInput.GetAxisRaw();
|
|
if (forceWalking)
|
|
{
|
|
float m = cc.input.magnitude;
|
|
if (m > maxWalkSpeed)
|
|
{
|
|
cc.input = cc.input.normalized * maxWalkSpeed;
|
|
}
|
|
}
|
|
}
|
|
|
|
cc.ControlKeepDirection();
|
|
}
|
|
|
|
protected override void SprintInput()
|
|
{
|
|
if (!lockSprintInput)
|
|
{
|
|
base.SprintInput();
|
|
}
|
|
}
|
|
|
|
protected override void CrouchInput()
|
|
{
|
|
if (!lockCrouchInput)
|
|
{
|
|
base.CrouchInput();
|
|
}
|
|
}
|
|
|
|
protected override void StrafeInput()
|
|
{
|
|
if (!lockStrafeInput)
|
|
{
|
|
base.StrafeInput();
|
|
}
|
|
}
|
|
|
|
protected override void JumpInput()
|
|
{
|
|
if (!lockJumpInput)
|
|
{
|
|
base.JumpInput();
|
|
}
|
|
}
|
|
|
|
protected override void RollInput()
|
|
{
|
|
if (!lockRollInput)
|
|
{
|
|
base.RollInput();
|
|
}
|
|
}
|
|
|
|
public override void UpdateHUD()
|
|
{
|
|
if (bHud == null)
|
|
{
|
|
if (bHUDController.instance != null)
|
|
{
|
|
bHud = bHUDController.instance;
|
|
bHud.Init(cc);
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
bHud.UpdateHUD(cc);
|
|
}
|
|
|
|
public override void FindHUD()
|
|
{
|
|
if (bHud == null && bHUDController.instance != null)
|
|
{
|
|
bHud = bHUDController.instance;
|
|
bHud.Init(cc);
|
|
}
|
|
}
|
|
|
|
public override void SetLockBasicInput(bool value)
|
|
{
|
|
lockInput = value;
|
|
if (value)
|
|
{
|
|
cc.input = Vector2.zero;
|
|
cc.isSprinting = false;
|
|
cc.animator.SetFloat("InputHorizontal", 0, 0.25f, Time.deltaTime);
|
|
cc.animator.SetFloat("InputVertical", 0, 0.25f, Time.deltaTime);
|
|
cc.animator.SetFloat("InputMagnitude", 0, 0.25f, Time.deltaTime);
|
|
}
|
|
}
|
|
}
|
|
} |