new input
This commit is contained in:
@@ -169,7 +169,7 @@ namespace NBF
|
||||
PlayerID = 100 + index
|
||||
};
|
||||
|
||||
var add = Random.Range(0, 5f) + index * 0.5f;
|
||||
var add = 0;//Random.Range(0, 5f) + index * 0.5f;
|
||||
|
||||
player.position = new Vector3(261.546f + add, 3, 422.366f);
|
||||
player.rotation = quaternion.identity;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening;
|
||||
using NBC;
|
||||
using NBF;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
||||
using RootMotion.FinalIK;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -25,8 +23,6 @@ public partial class FPlayer : MonoBehaviour
|
||||
|
||||
private float interactionTargetWeight;
|
||||
|
||||
public bool isLeftHandVisable;
|
||||
|
||||
[HideInInspector] public float handPullUp;
|
||||
|
||||
public Fsm<FPlayer> Fsm { get; private set; }
|
||||
@@ -82,13 +78,13 @@ public partial class FPlayer : MonoBehaviour
|
||||
|
||||
if (data.PlayerID == GameModel.RoleID)
|
||||
{
|
||||
var mainSync = gameObject.AddComponent<FPlayerMainSync>();
|
||||
// var mainSync = gameObject.AddComponent<FPlayerMainSync>();
|
||||
BaseCamera.Main.transform.SetParent(CameraRoot);
|
||||
BaseCamera.Main.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
var otherSync = gameObject.AddComponent<FPlayerOtherSync>();
|
||||
// var otherSync = gameObject.AddComponent<FPlayerOtherSync>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
3
Assets/Scripts/Fishing/Player/PlayerCharacter.meta
Normal file
3
Assets/Scripts/Fishing/Player/PlayerCharacter.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26646598ef364c52809720f314858335
|
||||
timeCreated: 1747495726
|
||||
159
Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerCharacter.cs
Normal file
159
Assets/Scripts/Fishing/Player/PlayerCharacter/PlayerCharacter.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using ECM2;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerCharacter : Character
|
||||
{
|
||||
[Tooltip("The first person camera parent.")]
|
||||
public GameObject cameraParent;
|
||||
|
||||
private float _cameraPitch;
|
||||
private FPlayer _player;
|
||||
[HideInInspector] public int nextShowSlotIndex = -1;
|
||||
|
||||
|
||||
[Space(15.0f)] public bool invertLook = true;
|
||||
[Tooltip("Look sensitivity")] public Vector2 sensitivity = new Vector2(0.05f, 0.05f);
|
||||
|
||||
[Space(15.0f)] [Tooltip("How far in degrees can you move the camera down.")]
|
||||
public float minPitch = -80.0f;
|
||||
|
||||
[Tooltip("How far in degrees can you move the camera up.")]
|
||||
public float maxPitch = 80.0f;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
camera = BaseCamera.Main;
|
||||
|
||||
_player = GetComponent<FPlayer>();
|
||||
|
||||
transform.position = _player.Data.position;
|
||||
transform.rotation = _player.Data.rotation;
|
||||
|
||||
App.Inst.SetMouseCurrsor(false);
|
||||
|
||||
InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Move
|
||||
|
||||
Vector2 movementInput = InputManager.GetMovementInput();
|
||||
|
||||
Vector3 movementDirection = Vector3.zero;
|
||||
|
||||
movementDirection += Vector3.forward * movementInput.y;
|
||||
movementDirection += Vector3.right * movementInput.x;
|
||||
|
||||
movementDirection =
|
||||
movementDirection.relativeTo(cameraTransform, GetUpVector());
|
||||
|
||||
SetMovementDirection(movementDirection);
|
||||
|
||||
// Look
|
||||
|
||||
Vector2 lookInput = InputManager.GetLookInput() * sensitivity;
|
||||
|
||||
AddControlYawInput(lookInput.x);
|
||||
AddControlPitchInput(invertLook ? -lookInput.y : lookInput.y, minPitch, maxPitch);
|
||||
|
||||
|
||||
if (_player.CanChangeGear())
|
||||
{
|
||||
if (nextShowSlotIndex > 0)
|
||||
{
|
||||
Debug.LogError("切换钓组=========");
|
||||
var data = Fishing.Inst.Datasource;
|
||||
data.SetSelfTestGear(nextShowSlotIndex);
|
||||
nextShowSlotIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputManager.OnQuickIndexAction -= OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction -= OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction -= OnUseTelescopeAction;
|
||||
}
|
||||
|
||||
private void OnQuickIndexAction(int index)
|
||||
{
|
||||
nextShowSlotIndex = index;
|
||||
}
|
||||
|
||||
private void OnUseTorchAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseTelescopeAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
{
|
||||
_player.Data.openTelescope = !_player.Data.openTelescope;
|
||||
_player.ToggleTelescope();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add input (affecting Yaw).
|
||||
/// This is applied to the Character's rotation.
|
||||
/// </summary>
|
||||
public virtual void AddControlYawInput(float value)
|
||||
{
|
||||
if (value != 0.0f)
|
||||
AddYawInput(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add input (affecting Pitch).
|
||||
/// This is applied to the cameraParent's local rotation.
|
||||
/// </summary>
|
||||
public virtual void AddControlPitchInput(float value, float minPitch = -80.0f, float maxPitch = 80.0f)
|
||||
{
|
||||
if (value != 0.0f)
|
||||
_cameraPitch = MathLib.ClampAngle(_cameraPitch + value, minPitch, maxPitch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update cameraParent local rotation applying current _cameraPitch value.
|
||||
/// </summary>
|
||||
protected virtual void UpdateCameraParentRotation()
|
||||
{
|
||||
cameraParent.transform.localRotation = Quaternion.Euler(_cameraPitch, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If overriden, base method MUST be called.
|
||||
/// </summary>
|
||||
protected virtual void LateUpdate()
|
||||
{
|
||||
UpdateCameraParentRotation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If overriden, base method MUST be called.
|
||||
/// </summary>
|
||||
protected override void Reset()
|
||||
{
|
||||
// Call base method implementation
|
||||
|
||||
base.Reset();
|
||||
|
||||
// Disable character's rotation,
|
||||
// it is handled by the AddControlYawInput method
|
||||
|
||||
SetRotationMode(RotationMode.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcefd1090dc44a539b4fcd30f2adf503
|
||||
timeCreated: 1747495536
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9f9a5be72134763b20ce6c08ff84b0d
|
||||
timeCreated: 1744122878
|
||||
@@ -1,129 +0,0 @@
|
||||
using System;
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
using UnityStandardAssets.Characters.FirstPerson;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FPlayerMainSync : MonoBehaviour
|
||||
{
|
||||
public FirstPersonController firstPersonController;
|
||||
|
||||
[HideInInspector] public int nextShowSlotIndex = -1;
|
||||
|
||||
|
||||
private float walkingSpeed = 1f;
|
||||
|
||||
private float runningSpeed = 2f;
|
||||
|
||||
private FPlayer _player;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
firstPersonController = GetComponent<FirstPersonController>();
|
||||
walkingSpeed = firstPersonController.m_WalkSpeed;
|
||||
runningSpeed = firstPersonController.m_RunSpeed;
|
||||
_player = GetComponent<FPlayer>();
|
||||
|
||||
|
||||
transform.position = _player.Data.position;
|
||||
transform.rotation = _player.Data.rotation;
|
||||
|
||||
|
||||
Timer.Once(1f, this, EnableFirstPersonController);
|
||||
|
||||
App.Inst.SetMouseCurrsor(false);
|
||||
|
||||
InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputManager.OnQuickIndexAction -= OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction -= OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction -= OnUseTelescopeAction;
|
||||
}
|
||||
|
||||
private void EnableFirstPersonController()
|
||||
{
|
||||
firstPersonController.enabled = true;
|
||||
}
|
||||
|
||||
private void OnQuickIndexAction(int index)
|
||||
{
|
||||
nextShowSlotIndex = index;
|
||||
}
|
||||
|
||||
private void OnUseTorchAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseTelescopeAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
{
|
||||
_player.Data.openTelescope = !_player.Data.openTelescope;
|
||||
_player.ToggleTelescope();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var movementAxis = InputManager.GetMovementInput();
|
||||
if (movementAxis != Vector2.zero)
|
||||
{
|
||||
// Debug
|
||||
}
|
||||
|
||||
firstPersonController.horizontal = movementAxis.x;
|
||||
firstPersonController.vertical = movementAxis.y;
|
||||
|
||||
// firstPersonController.isJumping = InputManager.IsJumping;
|
||||
firstPersonController.isRuning = InputManager.IsRunning;
|
||||
|
||||
// firstPersonController.m_MouseLook.ControllerHandMode = GameManager.Instance._playerData
|
||||
// .Player[GameManager.Instance._playerData.currentPlayerProfileIndex].controllerSetup;
|
||||
|
||||
|
||||
if (firstPersonController.isWater)
|
||||
{
|
||||
firstPersonController.m_WalkSpeed = walkingSpeed - Mathf.Abs(transform.position.y - 1f);
|
||||
firstPersonController.m_RunSpeed = firstPersonController.m_WalkSpeed;
|
||||
firstPersonController.m_WalkSpeed = Mathf.Clamp(firstPersonController.m_WalkSpeed, 0.7f, 2f);
|
||||
firstPersonController.m_RunSpeed = Mathf.Clamp(firstPersonController.m_RunSpeed, 0.8f, 2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
firstPersonController.m_WalkSpeed = walkingSpeed;
|
||||
firstPersonController.m_RunSpeed = runningSpeed;
|
||||
}
|
||||
|
||||
|
||||
if (_player.CanChangeGear())
|
||||
{
|
||||
if (nextShowSlotIndex > 0)
|
||||
{
|
||||
Debug.LogError("切换钓组=========");
|
||||
var data = Fishing.Inst.Datasource;
|
||||
data.SetSelfTestGear(nextShowSlotIndex);
|
||||
nextShowSlotIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (_player.MainArm)
|
||||
{
|
||||
// _player.MainArm.Shoulder.SetCameraEulerAngleX(BaseCamera.Main.transform.localEulerAngles.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29e1feb22aa646bf9280b5ceab67cf3f
|
||||
timeCreated: 1743937049
|
||||
@@ -1,26 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityStandardAssets.Characters.FirstPerson;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FPlayerOtherSync : MonoBehaviour
|
||||
{
|
||||
public FirstPersonController firstPersonController;
|
||||
private float walkingSpeed = 1f;
|
||||
|
||||
private float runningSpeed = 2f;
|
||||
|
||||
private FPlayer _player;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
firstPersonController = GetComponent<FirstPersonController>();
|
||||
walkingSpeed = firstPersonController.m_WalkSpeed;
|
||||
runningSpeed = firstPersonController.m_RunSpeed;
|
||||
_player = GetComponent<FPlayer>();
|
||||
|
||||
transform.position = _player.Data.position;
|
||||
transform.rotation = _player.Data.rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa1161cd1ad944c38bbc33fdcc0ec321
|
||||
timeCreated: 1744122890
|
||||
Reference in New Issue
Block a user