去掉复杂结构,一切从简
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -169,9 +169,9 @@ GameObject:
|
||||
- component: {fileID: 2216216690891386863}
|
||||
- component: {fileID: 3644333618879986678}
|
||||
- component: {fileID: 4477616030203838514}
|
||||
- component: {fileID: 2059248182290203691}
|
||||
- component: {fileID: 8101446342893690422}
|
||||
- component: {fileID: 2923025939212586282}
|
||||
- component: {fileID: 2431960384537678220}
|
||||
m_Layer: 14
|
||||
m_Name: Player
|
||||
m_TagString: Untagged
|
||||
@@ -247,6 +247,36 @@ CapsuleCollider:
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 1, z: 0}
|
||||
--- !u!114 &2059248182290203691
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8172838236951268422}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7c69e72330154a86b756d89e82d276e9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.Player
|
||||
EyeAngle: 0
|
||||
IsGrounded: 0
|
||||
Speed: 0
|
||||
RotationSpeed: 0
|
||||
MoveInput: {x: 0, y: 0}
|
||||
Run: 0
|
||||
Root: {fileID: 8695154010886802211}
|
||||
Eye: {fileID: 5745877877928638952}
|
||||
FppLook: {fileID: 2969532427624891124}
|
||||
IK: {fileID: 1593568502960682634}
|
||||
ModelAsset: {fileID: 0}
|
||||
Character: {fileID: 8101446342893690422}
|
||||
FirstPerson: {fileID: 2923025939212586282}
|
||||
MouseSensitivity: 0.1
|
||||
invertLook: 1
|
||||
minPitch: -75
|
||||
maxPitch: 60
|
||||
IsSelf: 0
|
||||
--- !u!114 &8101446342893690422
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -342,29 +372,6 @@ MonoBehaviour:
|
||||
_standingDownwardForceScale: 1
|
||||
_camera: {fileID: 0}
|
||||
cameraParent: {fileID: 6835675132305341997}
|
||||
--- !u!114 &2431960384537678220
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8172838236951268422}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a25908f34e4e4464a922b88337a5b733, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.PlayerUnityComponent
|
||||
Root: {fileID: 8695154010886802211}
|
||||
Eye: {fileID: 5745877877928638952}
|
||||
FppLook: {fileID: 2969532427624891124}
|
||||
IK: {fileID: 1593568502960682634}
|
||||
ModelAsset: {fileID: 0}
|
||||
Character: {fileID: 8101446342893690422}
|
||||
FirstPerson: {fileID: 2923025939212586282}
|
||||
MouseSensitivity: 0.1
|
||||
invertLook: 1
|
||||
minPitch: -75
|
||||
maxPitch: 60
|
||||
--- !u!1 &8378981416044742488
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace NBF
|
||||
[SerializeField] private CameraAsset _cameraAsset;
|
||||
private CameraShowMode _lastMode = CameraShowMode.None;
|
||||
|
||||
private PlayerUnityComponent FollowPlayer;
|
||||
private Player FollowPlayer;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -55,14 +55,14 @@ namespace NBF
|
||||
_cameraAsset.tppVCam.Priority = 0;
|
||||
}
|
||||
|
||||
public void SetFppLook(PlayerUnityComponent playerUnityComponent)
|
||||
public void SetFppLook(Player playerUnityComponent)
|
||||
{
|
||||
FollowPlayer = playerUnityComponent;
|
||||
_cameraAsset.fppVCam.LookAt = FollowPlayer.FppLook;
|
||||
Mode = CameraShowMode.FPP;
|
||||
}
|
||||
|
||||
public void SetFppFollow(PlayerUnityComponent playerUnityComponent)
|
||||
public void SetFppFollow(Player playerUnityComponent)
|
||||
{
|
||||
_cameraAsset.fppVCam.Follow = FollowPlayer.ModelAsset.NeckTransform;
|
||||
}
|
||||
|
||||
@@ -1,97 +1,97 @@
|
||||
using Enviro;
|
||||
using NBF;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest;
|
||||
|
||||
public class SceneSettings : MonoBehaviour
|
||||
{
|
||||
public static SceneSettings Instance;
|
||||
|
||||
public int sceneID;
|
||||
|
||||
public string sceneName = "";
|
||||
|
||||
public Transform WaterObject;
|
||||
|
||||
public Transform Node;
|
||||
|
||||
public Transform GearNode;
|
||||
|
||||
public WaterRenderer Water;
|
||||
|
||||
// public ObiUpdater obiFixedUpdater;
|
||||
|
||||
public LineRenderer LineRenderer;
|
||||
|
||||
|
||||
public int FPS;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
if (Node == null)
|
||||
{
|
||||
Node = transform;
|
||||
}
|
||||
|
||||
if (GearNode == null)
|
||||
{
|
||||
GearNode = Node;
|
||||
}
|
||||
|
||||
// obiFixedUpdater = FindFirstObjectByType<ObiLateFixedUpdater>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EnviroManager.instance.Time.Settings.simulate = true;
|
||||
// EnviroManager.instance.Time.SetTimeOfDay(0.5f * 24f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateFPS();
|
||||
UpdateTimeOfDay();
|
||||
}
|
||||
|
||||
|
||||
#region FPS
|
||||
|
||||
public float updateInterval = 0.2f; // 更新间隔(秒)
|
||||
|
||||
private float accum = 0;
|
||||
private int frames = 0;
|
||||
private float timeleft;
|
||||
|
||||
void UpdateFPS()
|
||||
{
|
||||
timeleft -= Time.deltaTime;
|
||||
accum += Time.timeScale / Time.deltaTime;
|
||||
frames++;
|
||||
|
||||
if (timeleft <= 0.0f)
|
||||
{
|
||||
FPS = (int)(accum / frames);
|
||||
|
||||
timeleft = updateInterval;
|
||||
accum = 0.0f;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 场景时间
|
||||
|
||||
private void UpdateTimeOfDay()
|
||||
{
|
||||
var p = GameTimer.GetGameDayProgress();
|
||||
p = 0.1f;
|
||||
// Debug.Log(p);
|
||||
EnviroManager.instance.Time.SetTimeOfDay(p * 24f);
|
||||
// if(AzureCoreSystem)
|
||||
// AzureCoreSystem.timeSystem.timeline = 24F * p;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
// using Enviro;
|
||||
// using NBF;
|
||||
// using UnityEngine;
|
||||
// using WaveHarmonic.Crest;
|
||||
//
|
||||
// public class SceneSettings : MonoBehaviour
|
||||
// {
|
||||
// public static SceneSettings Instance;
|
||||
//
|
||||
// public int sceneID;
|
||||
//
|
||||
// public string sceneName = "";
|
||||
//
|
||||
// public Transform WaterObject;
|
||||
//
|
||||
// public Transform Node;
|
||||
//
|
||||
// public Transform GearNode;
|
||||
//
|
||||
// public WaterRenderer Water;
|
||||
//
|
||||
// // public ObiUpdater obiFixedUpdater;
|
||||
//
|
||||
// public LineRenderer LineRenderer;
|
||||
//
|
||||
//
|
||||
// public int FPS;
|
||||
//
|
||||
// private void Awake()
|
||||
// {
|
||||
// Instance = this;
|
||||
// if (Node == null)
|
||||
// {
|
||||
// Node = transform;
|
||||
// }
|
||||
//
|
||||
// if (GearNode == null)
|
||||
// {
|
||||
// GearNode = Node;
|
||||
// }
|
||||
//
|
||||
// // obiFixedUpdater = FindFirstObjectByType<ObiLateFixedUpdater>();
|
||||
// }
|
||||
//
|
||||
// private void Start()
|
||||
// {
|
||||
// EnviroManager.instance.Time.Settings.simulate = true;
|
||||
// // EnviroManager.instance.Time.SetTimeOfDay(0.5f * 24f);
|
||||
// }
|
||||
//
|
||||
// private void Update()
|
||||
// {
|
||||
// UpdateFPS();
|
||||
// UpdateTimeOfDay();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// #region FPS
|
||||
//
|
||||
// public float updateInterval = 0.2f; // 更新间隔(秒)
|
||||
//
|
||||
// private float accum = 0;
|
||||
// private int frames = 0;
|
||||
// private float timeleft;
|
||||
//
|
||||
// void UpdateFPS()
|
||||
// {
|
||||
// timeleft -= Time.deltaTime;
|
||||
// accum += Time.timeScale / Time.deltaTime;
|
||||
// frames++;
|
||||
//
|
||||
// if (timeleft <= 0.0f)
|
||||
// {
|
||||
// FPS = (int)(accum / frames);
|
||||
//
|
||||
// timeleft = updateInterval;
|
||||
// accum = 0.0f;
|
||||
// frames = 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
//
|
||||
// #region 场景时间
|
||||
//
|
||||
// private void UpdateTimeOfDay()
|
||||
// {
|
||||
// var p = GameTimer.GetGameDayProgress();
|
||||
// p = 0.1f;
|
||||
// // Debug.Log(p);
|
||||
// EnviroManager.instance.Time.SetTimeOfDay(p * 24f);
|
||||
// // if(AzureCoreSystem)
|
||||
// // AzureCoreSystem.timeSystem.timeline = 24F * p;
|
||||
// }
|
||||
//
|
||||
// #endregion
|
||||
// }
|
||||
@@ -1,29 +1,29 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(Rope))]
|
||||
public class RopeFishLineEditor : Editor
|
||||
{
|
||||
private Rope _target;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_target = target as Rope;
|
||||
// lookAtPoint = serializedObject.FindProperty("lookAtPoint");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
|
||||
if (GUILayout.Button("打印总长度"))
|
||||
{
|
||||
_target.DebugLength();
|
||||
// Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()} smoot={_target.GetLengthSmoothVel()} relLen={_target.GetLengthByPoints()} PolylineLength={_target.GetPhysicsPolylineLength()}");
|
||||
}
|
||||
// serializedObject.Update();
|
||||
// EditorGUILayout.PropertyField(lookAtPoint);
|
||||
// serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
// using UnityEditor;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// [CustomEditor(typeof(Rope))]
|
||||
// public class RopeFishLineEditor : Editor
|
||||
// {
|
||||
// private Rope _target;
|
||||
//
|
||||
// void OnEnable()
|
||||
// {
|
||||
// _target = target as Rope;
|
||||
// // lookAtPoint = serializedObject.FindProperty("lookAtPoint");
|
||||
// }
|
||||
//
|
||||
// public override void OnInspectorGUI()
|
||||
// {
|
||||
// base.OnInspectorGUI();
|
||||
//
|
||||
//
|
||||
// if (GUILayout.Button("打印总长度"))
|
||||
// {
|
||||
// _target.DebugLength();
|
||||
// // Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()} smoot={_target.GetLengthSmoothVel()} relLen={_target.GetLengthByPoints()} PolylineLength={_target.GetPhysicsPolylineLength()}");
|
||||
// }
|
||||
// // serializedObject.Update();
|
||||
// // EditorGUILayout.PropertyField(lookAtPoint);
|
||||
// // serializedObject.ApplyModifiedProperties();
|
||||
// }
|
||||
// }
|
||||
3
Assets/Scripts/Fishing.meta
Normal file
3
Assets/Scripts/Fishing.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4778c7b6ca74bb2acdc894fc98a6c5d
|
||||
timeCreated: 1777437748
|
||||
65
Assets/Scripts/Fishing/Fishing.cs
Normal file
65
Assets/Scripts/Fishing/Fishing.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas;
|
||||
using NBF.Fishing2;
|
||||
using RootMotion.FinalIK;
|
||||
using Log = NBC.Log;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class Fishing
|
||||
{
|
||||
private static Fishing _instance;
|
||||
|
||||
public static Fishing Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
_instance ??= new Fishing();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Loading { get; private set; }
|
||||
|
||||
public async FTask<bool> Go(int mapId, string roomCode = "")
|
||||
{
|
||||
Loading = true;
|
||||
if (mapId == 0)
|
||||
{
|
||||
Log.Warning("账号没有进入过地图,进入新手引导地图");
|
||||
mapId = 99;
|
||||
}
|
||||
|
||||
var response = (G2C_EnterMapResponse)await Net.Call(new C2G_EnterMapRequest()
|
||||
{
|
||||
MapId = mapId,
|
||||
RoomCode = roomCode
|
||||
});
|
||||
Log.Info($"进入地图请求返回={response.ErrorCode}");
|
||||
if (response.ErrorCode != 0)
|
||||
{
|
||||
Notices.Error("enter room error");
|
||||
return false;
|
||||
}
|
||||
|
||||
LoadingPanel.Show();
|
||||
await ChangeMap(response.MapId, response.RoomCode, response.Units);
|
||||
LoadingPanel.Hide();
|
||||
Loading = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public async FTask ChangeMap(int mapId, string roomCode, List<MapUnitInfo> units)
|
||||
{
|
||||
var sceneName = "Map1";
|
||||
//加载场景==
|
||||
await SceneHelper.LoadScene(sceneName);
|
||||
Map.Instance.SetData(mapId, roomCode, units);
|
||||
Map.Instance.InstancePlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Fishing.cs.meta
Normal file
3
Assets/Scripts/Fishing/Fishing.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31a84e44641f4115a5531e1b7328630a
|
||||
timeCreated: 1777438436
|
||||
3
Assets/Scripts/Fishing/Helper.meta
Normal file
3
Assets/Scripts/Fishing/Helper.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a752ba9ae5b04fed93d81cf0764c5d00
|
||||
timeCreated: 1777437774
|
||||
@@ -4,7 +4,7 @@ using NBC.Asset;
|
||||
using NBF.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Fishing2
|
||||
namespace NBF
|
||||
{
|
||||
public static class PrefabsHelper
|
||||
{
|
||||
3
Assets/Scripts/Fishing/Item.meta
Normal file
3
Assets/Scripts/Fishing/Item.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be8d099db51445eea5a3eeb70849904a
|
||||
timeCreated: 1777449783
|
||||
9
Assets/Scripts/Fishing/Item/FHandItem.cs
Normal file
9
Assets/Scripts/Fishing/Item/FHandItem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class FHandItem : PlayerItem
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Item/FHandItem.cs.meta
Normal file
3
Assets/Scripts/Fishing/Item/FHandItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4bdd31c4ed448ecb00eca659d9d9db1
|
||||
timeCreated: 1777449812
|
||||
@@ -136,7 +136,7 @@ namespace NBF
|
||||
LinelenghtDiferent = GetLineDistance();
|
||||
|
||||
//非钓鱼状态
|
||||
if (Rod) Rod.PlayerItem.Tension = Mathf.Clamp(LinelenghtDiferent, 0f, 0.05f);
|
||||
if (Rod) Rod.Tension = Mathf.Clamp(LinelenghtDiferent, 0f, 0.05f);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
26
Assets/Scripts/Fishing/Item/PlayerItem.cs
Normal file
26
Assets/Scripts/Fishing/Item/PlayerItem.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class PlayerItem : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置id
|
||||
/// </summary>
|
||||
public int ConfigID;
|
||||
|
||||
public List<int> BindItems = new List<int>();
|
||||
|
||||
public Player Owner;
|
||||
|
||||
|
||||
public virtual void Init(Player player, int configId, List<int> bindItems)
|
||||
{
|
||||
Owner = player;
|
||||
ConfigID = configId;
|
||||
BindItems.Clear();
|
||||
BindItems.AddRange(bindItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Item/PlayerItem.cs.meta
Normal file
3
Assets/Scripts/Fishing/Item/PlayerItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef008d609b8049ac8416abb496cbec72
|
||||
timeCreated: 1777451467
|
||||
@@ -13,10 +13,6 @@ namespace NBF
|
||||
{
|
||||
public class FRod : FHandItem
|
||||
{
|
||||
public PlayerItem PlayerItem;
|
||||
|
||||
public override int ConfigId => PlayerItem?.ConfigID ?? 0;
|
||||
|
||||
public RodAsset Asset;
|
||||
|
||||
public FReel Reel;
|
||||
@@ -30,6 +26,84 @@ namespace NBF
|
||||
|
||||
public Transform GearRoot;
|
||||
|
||||
|
||||
#region Rod专属
|
||||
|
||||
private bool _stretchRope = true;
|
||||
|
||||
public bool StretchRope
|
||||
{
|
||||
get => _stretchRope;
|
||||
set
|
||||
{
|
||||
_stretchRope = value;
|
||||
// Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
|
||||
// {
|
||||
// Item = this
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
private float _lineLength = 4.2f;
|
||||
|
||||
/// <summary>
|
||||
/// 线长度
|
||||
/// </summary>
|
||||
public float LineLength
|
||||
{
|
||||
get => _lineLength;
|
||||
set
|
||||
{
|
||||
_lineLength = value;
|
||||
// Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
|
||||
// {
|
||||
// Item = this
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
private float _floatLength = 0.7f;
|
||||
|
||||
/// <summary>
|
||||
/// 浮漂线长度
|
||||
/// </summary>
|
||||
public float FloatLength
|
||||
{
|
||||
get => _floatLength;
|
||||
set
|
||||
{
|
||||
_floatLength = value;
|
||||
// Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
|
||||
// {
|
||||
// Item = this
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
private float _tension;
|
||||
|
||||
/// <summary>
|
||||
/// 拉力
|
||||
/// </summary>
|
||||
public float Tension
|
||||
{
|
||||
get => _tension;
|
||||
set
|
||||
{
|
||||
if (!Mathf.Approximately(_tension, value))
|
||||
{
|
||||
_tension = value;
|
||||
}
|
||||
|
||||
// Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
|
||||
// {
|
||||
// Item = this
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// public FWaterDisplacement LureHookWaterDisplacement;
|
||||
|
||||
[HideInInspector] public FFish currentFish;
|
||||
@@ -57,13 +131,13 @@ namespace NBF
|
||||
if (Line.LineType == LineType.Spinning)
|
||||
{
|
||||
//没有浮漂类型
|
||||
Line.SetLenght(PlayerItem.LineLength);
|
||||
Line.SetLenght(LineLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
//有浮漂
|
||||
Line.SetLenght(PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||
Line.SetLenght(PlayerItem.FloatLength, FLineLogicNodeType.End);
|
||||
Line.SetLenght(LineLength - FloatLength);
|
||||
Line.SetLenght(FloatLength, FLineLogicNodeType.End);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,33 +156,27 @@ namespace NBF
|
||||
yield return 1;
|
||||
}
|
||||
|
||||
public async FTask InitRod(PlayerItem playerItem)
|
||||
public async FTask InitRod()
|
||||
{
|
||||
PlayerItem = playerItem;
|
||||
|
||||
var playerView = playerItem.Owner.GetComponent<PlayerView>();
|
||||
|
||||
var playerViewUnity = playerView.Unity;
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
transform.localScale = Vector3.one;
|
||||
SceneSettings.Instance.GearNode.position = playerViewUnity.transform.position;
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
Map.Instance.GearsNode.position = transform.position;
|
||||
await FTask.WaitFrame(Game.Main); //等待1帧
|
||||
|
||||
var obj = new GameObject($"rod_{ConfigId}");
|
||||
obj.transform.SetParent(SceneSettings.Instance.GearNode);
|
||||
obj.transform.position = playerViewUnity.transform.position;
|
||||
obj.transform.rotation = playerViewUnity.transform.rotation;
|
||||
var obj = new GameObject($"rod_{ConfigID}");
|
||||
obj.transform.SetParent(Map.Instance.GearsNode);
|
||||
obj.transform.position = transform.position;
|
||||
obj.transform.rotation = transform.rotation;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
GearRoot = obj.transform;
|
||||
|
||||
var parent = GearRoot;
|
||||
|
||||
CreateFishingHandler();
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
await FTask.WaitFrame(Game.Main); //等待1帧
|
||||
// children.Sort();
|
||||
foreach (var childConfigId in playerItem.BindItems)
|
||||
foreach (var childConfigId in BindItems)
|
||||
{
|
||||
var itemType = childConfigId.GetItemType();
|
||||
var config = Game.Tables.TbItem.Get(childConfigId);
|
||||
@@ -154,7 +222,7 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
await FTask.WaitFrame(Game.Main); //等待1帧
|
||||
SetLineLength();
|
||||
if (Reel)
|
||||
{
|
||||
@@ -190,11 +258,11 @@ namespace NBF
|
||||
Weight.Init(this);
|
||||
}
|
||||
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
await FTask.WaitFrame(Game.Main); //等待1帧
|
||||
|
||||
transform.SetParent(playerViewUnity.ModelAsset.RodRoot);
|
||||
transform.SetParent(Owner.ModelAsset.RodRoot);
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.rotation = playerViewUnity.ModelAsset.RodRoot.rotation;
|
||||
transform.rotation = Owner.ModelAsset.RodRoot.rotation;
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +271,7 @@ namespace NBF
|
||||
if (Line == null)
|
||||
{
|
||||
Debug.LogError("创建钓组=====");
|
||||
var itemConfig = Game.Tables.TbItem.Get(ConfigId);
|
||||
var itemConfig = Game.Tables.TbItem.Get(ConfigID);
|
||||
var rodType = (ItemSubType)itemConfig.Type;
|
||||
if (rodType == ItemSubType.RodTele)
|
||||
{
|
||||
@@ -299,7 +367,7 @@ namespace NBF
|
||||
// }
|
||||
if (Line)
|
||||
{
|
||||
value = PlayerItem.Tension / maxRodStrength;
|
||||
value = Tension / maxRodStrength;
|
||||
}
|
||||
|
||||
return Mathf.Clamp01(value);
|
||||
@@ -308,51 +376,51 @@ namespace NBF
|
||||
|
||||
private void BendControl()
|
||||
{
|
||||
var _ccdik = Asset.CCDIK;
|
||||
|
||||
var state = PlayerItem.Owner.State;
|
||||
|
||||
|
||||
Vector3 vector = Line.EndNode.transform.position;
|
||||
|
||||
// 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
||||
float headingAlignment = Vector3.Angle(base.transform.forward,
|
||||
(Line.EndNode.transform.position - transform.position).normalized) / 180f;
|
||||
// 经过朝向调制后的有效张力
|
||||
var effectiveTension = Mathf.Clamp(CurrentTension01 * headingAlignment, 0f, 1f);
|
||||
|
||||
float multiple = 0;
|
||||
if (state == PlayerState.Fight)
|
||||
{
|
||||
multiple = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiple = 0.1f;
|
||||
}
|
||||
|
||||
float targetWeight = effectiveTension * multiple;
|
||||
if (targetWeight > 0)
|
||||
{
|
||||
// Debug.Log($"CurrentTension01={CurrentTension01} LinelenghtDiferent={Line.LinelenghtDiferent} Tension={PlayerItem.Tension} num2={effectiveTension} num3={headingAlignment} num6={multiple}");
|
||||
}
|
||||
|
||||
if (state == PlayerState.Prepare)
|
||||
{
|
||||
targetWeight = 0.002f;
|
||||
}
|
||||
|
||||
float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, targetWeight, Time.deltaTime * bendSmooth);
|
||||
previousWeights.RemoveAt(0);
|
||||
previousWeights.Add(item);
|
||||
float averageWeight = previousWeights.Average();
|
||||
if (currentFish)
|
||||
{
|
||||
averageWeight = Math.Min(averageWeight, 0.01f);
|
||||
}
|
||||
|
||||
_ccdik.solver.SetIKPosition(vector);
|
||||
_ccdik.solver.SetIKPositionWeight(averageWeight);
|
||||
// var _ccdik = Asset.CCDIK;
|
||||
//
|
||||
// var state = Owner.State;
|
||||
//
|
||||
//
|
||||
// Vector3 vector = Line.EndNode.transform.position;
|
||||
//
|
||||
// // 当前物体的朝向与指向 Lure 的方向之间的夹角,在 0(完全对齐)到 1(完全相反)之间的一个比例值
|
||||
// float headingAlignment = Vector3.Angle(base.transform.forward,
|
||||
// (Line.EndNode.transform.position - transform.position).normalized) / 180f;
|
||||
// // 经过朝向调制后的有效张力
|
||||
// var effectiveTension = Mathf.Clamp(CurrentTension01 * headingAlignment, 0f, 1f);
|
||||
//
|
||||
// float multiple = 0;
|
||||
// if (state == PlayerState.Fight)
|
||||
// {
|
||||
// multiple = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// multiple = 0.1f;
|
||||
// }
|
||||
//
|
||||
// float targetWeight = effectiveTension * multiple;
|
||||
// if (targetWeight > 0)
|
||||
// {
|
||||
// // Debug.Log($"CurrentTension01={CurrentTension01} LinelenghtDiferent={Line.LinelenghtDiferent} Tension={PlayerItem.Tension} num2={effectiveTension} num3={headingAlignment} num6={multiple}");
|
||||
// }
|
||||
//
|
||||
// if (state == PlayerState.Prepare)
|
||||
// {
|
||||
// targetWeight = 0.002f;
|
||||
// }
|
||||
//
|
||||
// float item = Mathf.MoveTowards(_ccdik.solver.IKPositionWeight, targetWeight, Time.deltaTime * bendSmooth);
|
||||
// previousWeights.RemoveAt(0);
|
||||
// previousWeights.Add(item);
|
||||
// float averageWeight = previousWeights.Average();
|
||||
// if (currentFish)
|
||||
// {
|
||||
// averageWeight = Math.Min(averageWeight, 0.01f);
|
||||
// }
|
||||
//
|
||||
// _ccdik.solver.SetIKPosition(vector);
|
||||
// _ccdik.solver.SetIKPositionWeight(averageWeight);
|
||||
}
|
||||
|
||||
#endregion
|
||||
3
Assets/Scripts/Fishing/Map.meta
Normal file
3
Assets/Scripts/Fishing/Map.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6dfe3235d0347008d10859d322eabd6
|
||||
timeCreated: 1777447863
|
||||
101
Assets/Scripts/Fishing/Map/Map.cs
Normal file
101
Assets/Scripts/Fishing/Map/Map.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System.Collections.Generic;
|
||||
using Enviro;
|
||||
using Fantasy;
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class Map : SingletonMono<Map>
|
||||
{
|
||||
[Header("节点信息")] public WaterRenderer Water;
|
||||
public Transform Node;
|
||||
public Transform GearsNode;
|
||||
[Header("角色参数")] public int MapId;
|
||||
public string RoomCode;
|
||||
|
||||
|
||||
public readonly List<MapUnitInfo> Units = new List<MapUnitInfo>();
|
||||
|
||||
|
||||
public readonly List<Player> Players = new List<Player>();
|
||||
|
||||
public void SetData(int mapId, string code, List<MapUnitInfo> units)
|
||||
{
|
||||
MapId = mapId;
|
||||
RoomCode = code;
|
||||
Units.AddRange(units);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EnviroManager.instance.Time.Settings.simulate = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateFPS();
|
||||
UpdateTimeOfDay();
|
||||
}
|
||||
|
||||
#region FPS
|
||||
|
||||
public int FPS;
|
||||
|
||||
public float updateInterval = 0.2f; // 更新间隔(秒)
|
||||
|
||||
private float accum = 0;
|
||||
private int frames = 0;
|
||||
private float timeleft;
|
||||
|
||||
void UpdateFPS()
|
||||
{
|
||||
timeleft -= Time.deltaTime;
|
||||
accum += Time.timeScale / Time.deltaTime;
|
||||
frames++;
|
||||
|
||||
if (timeleft <= 0.0f)
|
||||
{
|
||||
FPS = (int)(accum / frames);
|
||||
|
||||
timeleft = updateInterval;
|
||||
accum = 0.0f;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 场景时间
|
||||
|
||||
private void UpdateTimeOfDay()
|
||||
{
|
||||
var p = GameTimer.GetGameDayProgress();
|
||||
p = 0.3f;
|
||||
// Debug.Log(p);
|
||||
EnviroManager.instance.Time.SetTimeOfDay(p * 24f);
|
||||
// if(AzureCoreSystem)
|
||||
// AzureCoreSystem.timeSystem.timeline = 24F * p;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Player
|
||||
|
||||
public void InstancePlayers()
|
||||
{
|
||||
var playerObject = PrefabsHelper.CreatePlayer(Node);
|
||||
playerObject.transform.localPosition = new Vector3(484, 1, 422);
|
||||
var player = playerObject.GetComponent<Player>();
|
||||
Players.Add(player);
|
||||
player.IsSelf = true;
|
||||
if (player.IsSelf)
|
||||
{
|
||||
CameraManager.Instance.SetFppLook(player);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Map/Map.cs.meta
Normal file
3
Assets/Scripts/Fishing/Map/Map.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f820874d054495abd4d378473a14bcf
|
||||
timeCreated: 1777438296
|
||||
@@ -93,15 +93,15 @@ namespace NBF
|
||||
}
|
||||
|
||||
|
||||
public void OnUseItem(PlayerItemView item)
|
||||
{
|
||||
var itemType = item.Item.ConfigID.GetItemType();
|
||||
if (itemType == ItemType.Rod)
|
||||
{
|
||||
_isRodLayerEnabled = true;
|
||||
// _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
|
||||
}
|
||||
}
|
||||
// public void OnUseItem(PlayerItemView item)
|
||||
// {
|
||||
// var itemType = item.Item.ConfigID.GetItemType();
|
||||
// if (itemType == ItemType.Rod)
|
||||
// {
|
||||
// _isRodLayerEnabled = true;
|
||||
// // _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public void SetLayerWeight(string layer, float weight)
|
||||
@@ -153,14 +153,14 @@ namespace NBF
|
||||
public void OnRodThrowStart()
|
||||
{
|
||||
Debug.LogError("OnRodThrowStart");
|
||||
if (Player.State == PlayerState.Throw)
|
||||
{
|
||||
var playerStateView = Player.GetComponent<PlayerStateView>();
|
||||
if (playerStateView.CurrentStateView is PlayerStageViewThrow playerStateThrow)
|
||||
{
|
||||
playerStateThrow.OnRodThrowStart();
|
||||
}
|
||||
}
|
||||
// if (Player.State == PlayerState.Throw)
|
||||
// {
|
||||
// var playerStateView = Player.GetComponent<PlayerStateView>();
|
||||
// if (playerStateView.CurrentStateView is PlayerStageViewThrow playerStateThrow)
|
||||
// {
|
||||
// playerStateThrow.OnRodThrowStart();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -169,14 +169,14 @@ namespace NBF
|
||||
public void OnRodThrownEnd()
|
||||
{
|
||||
Debug.LogError("OnRodThrownEnd");
|
||||
if (Player.State == PlayerState.Throw)
|
||||
{
|
||||
var playerStateView = Player.GetComponent<PlayerStateView>();
|
||||
if (playerStateView.CurrentStateView is PlayerStageViewThrow playerStateThrow)
|
||||
{
|
||||
playerStateThrow.OnRodThrownEnd();
|
||||
}
|
||||
}
|
||||
// if (Player.State == PlayerState.Throw)
|
||||
// {
|
||||
// var playerStateView = Player.GetComponent<PlayerStateView>();
|
||||
// if (playerStateView.CurrentStateView is PlayerStageViewThrow playerStateThrow)
|
||||
// {
|
||||
// playerStateThrow.OnRodThrownEnd();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -15,10 +15,10 @@ namespace NBF
|
||||
if (Player == null) return;
|
||||
|
||||
|
||||
for (int i = 1; i < Player.TrajectoryPoints.Count; i++)
|
||||
{
|
||||
Debug.DrawLine(Player.TrajectoryPoints[i - 1], Player.TrajectoryPoints[i], Color.yellow);
|
||||
}
|
||||
// for (int i = 1; i < Player.TrajectoryPoints.Count; i++)
|
||||
// {
|
||||
// Debug.DrawLine(Player.TrajectoryPoints[i - 1], Player.TrajectoryPoints[i], Color.yellow);
|
||||
// }
|
||||
|
||||
// Debug.DrawRay(Player.TrajectoryPoints[Player.TrajectoryPoints.Count], Vector3.up * 0.3f, Color.cyan);
|
||||
}
|
||||
@@ -6,12 +6,14 @@ namespace NBF
|
||||
{
|
||||
public Player Player { get; private set; }
|
||||
|
||||
public PlayerUnityComponent UnityComponent { get; private set; }
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
UnityComponent = GetComponentInParent<PlayerUnityComponent>();
|
||||
Player = UnityComponent.Player;
|
||||
Player = GetComponent<Player>();
|
||||
if (Player == null)
|
||||
{
|
||||
Player = GetComponentInParent<Player>();
|
||||
}
|
||||
OnAwake();
|
||||
}
|
||||
|
||||
25
Assets/Scripts/Fishing/Mono/PlayerUnityComponent.cs
Normal file
25
Assets/Scripts/Fishing/Mono/PlayerUnityComponent.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// using ECM2;
|
||||
// using ECM2.Examples.FirstPerson;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace NBF
|
||||
// {
|
||||
// public class PlayerUnityComponent : MonoBehaviour
|
||||
// {
|
||||
// public Player Player { get; set; }
|
||||
// public Transform Root;
|
||||
// public Transform Eye;
|
||||
// public Transform FppLook;
|
||||
// public Transform IK;
|
||||
// public PlayerModelAsset ModelAsset;
|
||||
// public CharacterMovement Character;
|
||||
// public FirstPersonCharacter FirstPerson;
|
||||
//
|
||||
// [Header("视角相关")] public float MouseSensitivity = 0.1f;
|
||||
// [Space(15f)] public bool invertLook = true;
|
||||
//
|
||||
// public float minPitch = -60f;
|
||||
//
|
||||
// public float maxPitch = 60f;
|
||||
// }
|
||||
// }
|
||||
3
Assets/Scripts/Fishing/Player.meta
Normal file
3
Assets/Scripts/Fishing/Player.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e599a1ea5e4441f888ed9157dfbd0565
|
||||
timeCreated: 1777437826
|
||||
137
Assets/Scripts/Fishing/Player/Player.cs
Normal file
137
Assets/Scripts/Fishing/Player/Player.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ECM2;
|
||||
using ECM2.Examples.FirstPerson;
|
||||
using Fantasy.Async;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
[Header("角色参数")] public float EyeAngle;
|
||||
public bool IsGrounded;
|
||||
public float Speed;
|
||||
public float RotationSpeed;
|
||||
public Vector2 MoveInput;
|
||||
public bool Run;
|
||||
|
||||
[Header("角色节点")] public Transform Root;
|
||||
public Transform Eye;
|
||||
public Transform FppLook;
|
||||
public Transform IK;
|
||||
|
||||
[Header("角色控制")] public PlayerModelAsset ModelAsset;
|
||||
public CharacterMovement Character;
|
||||
public FirstPersonCharacter FirstPerson;
|
||||
|
||||
|
||||
[Header("视角相关")] public float MouseSensitivity = 0.1f;
|
||||
[Space(15f)] public bool invertLook = true;
|
||||
|
||||
public float minPitch = -60f;
|
||||
|
||||
public float maxPitch = 60f;
|
||||
|
||||
public bool IsLureRod => false;
|
||||
|
||||
public bool IsSelf;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CreatePlayerModel();
|
||||
if (IsSelf)
|
||||
{
|
||||
gameObject.AddComponent<PlayerInput>();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 手持物品
|
||||
|
||||
private FHandItem HandItem;
|
||||
private bool IsChangeItemIng;
|
||||
|
||||
public async FTask UseItem(int configId, List<int> bindItems)
|
||||
{
|
||||
if (IsChangeItemIng) return;
|
||||
IsChangeItemIng = true;
|
||||
|
||||
if (HandItem != null)
|
||||
{
|
||||
await UnUseItem();
|
||||
}
|
||||
|
||||
// ModelAsset.PlayerAnimator.OnUseItem(itemView);
|
||||
|
||||
// if (currItem == null)
|
||||
// {
|
||||
// //收起物品
|
||||
// await UnUseItem(prevItem);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 先收起旧的物品
|
||||
// await UnUseItemConfirm(prevItem);
|
||||
// var handItem = Player.HandItem;
|
||||
// //拿起新物品
|
||||
// var itemType = handItem.ConfigID.GetItemType();
|
||||
// if (itemType == ItemType.Rod)
|
||||
// {
|
||||
// var itemView = handItem.GetOrAddComponent<PlayerItemView>();
|
||||
// await itemView.InitShow(handItem);
|
||||
// Unity.ModelAsset.PlayerAnimator.OnUseItem(itemView);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// var stateView = Player.GetComponent<PlayerStateView>();
|
||||
// if (stateView != null && stateView.CurrentStateView is PlayerStageViewIdle playerStageViewIdle)
|
||||
// {
|
||||
// playerStageViewIdle.TakeLine();
|
||||
// }
|
||||
|
||||
IsChangeItemIng = false;
|
||||
}
|
||||
|
||||
public async FTask UnUseItem()
|
||||
{
|
||||
if (HandItem != null)
|
||||
{
|
||||
ModelAsset.PlayerAnimator.OnUnUseItem();
|
||||
await FTask.Wait(Game.Main, 100);
|
||||
}
|
||||
|
||||
Destroy(HandItem.gameObject);
|
||||
HandItem = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 模型创建
|
||||
|
||||
private void CreatePlayerModel()
|
||||
{
|
||||
var modelObject = PrefabsHelper.CreatePlayer(Root, "Human_Male");
|
||||
modelObject.transform.localPosition = Vector3.zero;
|
||||
ModelAsset = modelObject.GetComponent<PlayerModelAsset>();
|
||||
ModelAsset.SetPlayer(FppLook);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Player/Player.cs.meta
Normal file
3
Assets/Scripts/Fishing/Player/Player.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c69e72330154a86b756d89e82d276e9
|
||||
timeCreated: 1777437830
|
||||
205
Assets/Scripts/Fishing/Player/PlayerInput.cs
Normal file
205
Assets/Scripts/Fishing/Player/PlayerInput.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerInput : PlayerMonoBehaviour
|
||||
{
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
AddInputEvent();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateInput();
|
||||
UpdateMove();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
RemoveInputEvent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Input
|
||||
|
||||
private void UpdateInput()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Alpha0))
|
||||
{
|
||||
// SetLineLength(lineLength);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Plus) || Input.GetKeyDown(KeyCode.Equals))
|
||||
{
|
||||
// Player.HandItem.LineLength += 0.1f;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Minus))
|
||||
{
|
||||
// Player.HandItem.LineLength -= 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddInputEvent()
|
||||
{
|
||||
InputManager.OnPlayerPerformed += OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed += OnPlayerPerformed;
|
||||
|
||||
InputManager.OnPlayerValueCanceled += OnPlayerValueCanceled;
|
||||
InputManager.OnPlayerValuePerformed += OnPlayerValuePerformed;
|
||||
}
|
||||
|
||||
private void RemoveInputEvent()
|
||||
{
|
||||
InputManager.OnPlayerPerformed += OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed += OnPlayerPerformed;
|
||||
|
||||
InputManager.OnPlayerValueCanceled += OnPlayerValueCanceled;
|
||||
InputManager.OnPlayerValuePerformed += OnPlayerValuePerformed;
|
||||
}
|
||||
|
||||
private void OnPlayerPerformed(string action)
|
||||
{
|
||||
if (action == InputDef.Player.Run)
|
||||
{
|
||||
Player.Run = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerCanceled(string action)
|
||||
{
|
||||
if (action == InputDef.Player.Run)
|
||||
{
|
||||
Player.Run = false;
|
||||
}
|
||||
else if (action == InputDef.Player.ToBag)
|
||||
{
|
||||
//取消手持物品
|
||||
Log.Info($"取消手持物品");
|
||||
Player.UnUseItem().Coroutine();
|
||||
}
|
||||
else if (action.StartsWith(InputDef.Player.QuickStarts))
|
||||
{
|
||||
var index = int.Parse(action.Replace(InputDef.Player.QuickStarts, string.Empty));
|
||||
Log.Info($"快速使用===={index}");
|
||||
var item = RoleModel.Instance.GetSlotItem(index - 1);
|
||||
if (item != null)
|
||||
{
|
||||
List<ItemInfo> children = RoleModel.Instance.GetBindItems(item.Id);
|
||||
List<int> bindItems = children.Select(itemInfo => itemInfo.ConfigId).ToList();
|
||||
Player.UseItem(item.ConfigId, bindItems).Coroutine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerValueCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
var actionName = context.action.name;
|
||||
if (actionName == InputDef.Player.Move)
|
||||
{
|
||||
Player.MoveInput = Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerValuePerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
var actionName = context.action.name;
|
||||
if (actionName == InputDef.Player.Move)
|
||||
{
|
||||
var v2 = context.ReadValue<Vector2>();
|
||||
Player.MoveInput = v2;
|
||||
}
|
||||
else if (actionName == InputDef.Player.Look)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Move
|
||||
|
||||
private Quaternion _lastRotation;
|
||||
|
||||
private void UpdateMove()
|
||||
{
|
||||
UpdateGrounded();
|
||||
ProcessMoveStates();
|
||||
UpdateLookInput();
|
||||
}
|
||||
|
||||
private void ProcessMoveStates()
|
||||
{
|
||||
{
|
||||
var num2 = Player.Run ? 7 : 5;
|
||||
Vector3 vector2 = Player.FirstPerson.GetRightVector() * Player.MoveInput.x * num2;
|
||||
vector2 += Player.FirstPerson.GetForwardVector() * Player.MoveInput.y * num2;
|
||||
// if (checkWaterBound)
|
||||
// {
|
||||
// SetMovementDirectionWithRaycastCheck(vector2);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
Player.FirstPerson.SetMovementDirection(vector2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGrounded()
|
||||
{
|
||||
Player.IsGrounded = Player.FirstPerson.IsGrounded();
|
||||
Player.Speed = Player.FirstPerson.velocity.magnitude;
|
||||
|
||||
Quaternion rotation = Player.FirstPerson.transform.rotation;
|
||||
|
||||
// 计算当前帧与上一帧的旋转差异
|
||||
Quaternion rotationDelta = rotation * Quaternion.Inverse(_lastRotation);
|
||||
|
||||
// 将四元数转换为角度轴表示
|
||||
rotationDelta.ToAngleAxis(out float angle, out Vector3 axis);
|
||||
|
||||
// 确保角度在0-360范围内
|
||||
if (angle > 180f) angle -= 360f;
|
||||
|
||||
// 获取Y轴旋转分量(归一化处理)
|
||||
float yRotation = 0f;
|
||||
if (Mathf.Abs(angle) > 0.001f && Mathf.Abs(axis.y) > 0.1f)
|
||||
{
|
||||
// 计算Y轴方向的旋转角度(考虑旋转轴方向)
|
||||
yRotation = angle * Mathf.Sign(axis.y);
|
||||
}
|
||||
|
||||
float maxTurnSpeed = 180f; // 度/秒
|
||||
// 转换为角速度并归一化到[-1, 1]
|
||||
float angularSpeed = yRotation / Time.deltaTime;
|
||||
float turnValue = Mathf.Clamp(angularSpeed / maxTurnSpeed, -1f, 1f);
|
||||
|
||||
|
||||
Player.RotationSpeed = turnValue;
|
||||
|
||||
_lastRotation = rotation;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Look
|
||||
|
||||
private void UpdateLookInput()
|
||||
{
|
||||
Vector2 value = InputManager.GetLookInput();
|
||||
var u3d = Player;
|
||||
u3d.FirstPerson.AddControlYawInput(value.x * u3d.MouseSensitivity);
|
||||
u3d.FirstPerson.AddControlPitchInput((u3d.invertLook ? 0f - value.y : value.y) * u3d.MouseSensitivity,
|
||||
u3d.minPitch, u3d.maxPitch);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Player/PlayerInput.cs.meta
Normal file
3
Assets/Scripts/Fishing/Player/PlayerInput.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0ff16b93bf44060b69e6b052a4f3d63
|
||||
timeCreated: 1777449292
|
||||
8
Assets/Scripts/Fishing/Player/RemotePlayer.cs
Normal file
8
Assets/Scripts/Fishing/Player/RemotePlayer.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class RemotePlayer : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Player/RemotePlayer.cs.meta
Normal file
3
Assets/Scripts/Fishing/Player/RemotePlayer.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83d5c2102a7749f0acb36f871d75566e
|
||||
timeCreated: 1777438074
|
||||
@@ -1,25 +0,0 @@
|
||||
using ECM2;
|
||||
using ECM2.Examples.FirstPerson;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerUnityComponent : MonoBehaviour
|
||||
{
|
||||
public Player Player { get; set; }
|
||||
public Transform Root;
|
||||
public Transform Eye;
|
||||
public Transform FppLook;
|
||||
public Transform IK;
|
||||
public PlayerModelAsset ModelAsset;
|
||||
public CharacterMovement Character;
|
||||
public FirstPersonCharacter FirstPerson;
|
||||
|
||||
[Header("视角相关")] public float MouseSensitivity = 0.1f;
|
||||
[Space(15f)] public bool invertLook = true;
|
||||
|
||||
public float minPitch = -60f;
|
||||
|
||||
public float maxPitch = 60f;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class FHandItem : MonoBehaviour
|
||||
{
|
||||
public abstract int ConfigId { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5460b0f542fd45e38145b2a4fb12e329
|
||||
timeCreated: 1766583615
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NBF;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest;
|
||||
|
||||
@@ -84,9 +85,9 @@ public class CapsuleBuoyancyStable : MonoBehaviour
|
||||
|
||||
public void InitBobber()
|
||||
{
|
||||
if (_waterRenderer == null && SceneSettings.Instance)
|
||||
if (_waterRenderer == null && Map.Instance)
|
||||
{
|
||||
_waterRenderer = SceneSettings.Instance.Water;
|
||||
_waterRenderer = Map.Instance.Water;
|
||||
}
|
||||
_cap = GetComponentInChildren<CapsuleCollider>();
|
||||
_init = true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using NBF;
|
||||
using UnityEngine;
|
||||
|
||||
using WaveHarmonic.Crest;
|
||||
|
||||
@@ -225,8 +226,8 @@ public class BobberPresentationController : MonoBehaviour
|
||||
if (waterProviderBehaviour != null)
|
||||
_waterProvider = waterProviderBehaviour as IWaterSurfaceProvider;
|
||||
|
||||
if (waterRenderer == null && SceneSettings.Instance != null)
|
||||
waterRenderer = SceneSettings.Instance.Water;
|
||||
if (waterRenderer == null && Map.Instance != null)
|
||||
waterRenderer = Map.Instance.Water;
|
||||
|
||||
_pendingPosture = _posture;
|
||||
_pendingPostureTimer = 0f;
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace NBF
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (!SceneSettings.Instance) return;
|
||||
TextFPS.text = SceneSettings.Instance.FPS.ToString(CultureInfo.InvariantCulture);
|
||||
if (!Map.Instance) return;
|
||||
TextFPS.text = Map.Instance.FPS.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private void OnInteractiveObjectAction(InteractiveObject interactiveObject)
|
||||
|
||||
@@ -379,6 +379,9 @@ MonoBehaviour:
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0
|
||||
filter:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0
|
||||
downscale:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0
|
||||
|
||||
@@ -12,8 +12,8 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||
m_Name: Mobile_RPAsset
|
||||
m_EditorClassIdentifier:
|
||||
k_AssetVersion: 12
|
||||
k_AssetPreviousVersion: 12
|
||||
k_AssetVersion: 13
|
||||
k_AssetPreviousVersion: 13
|
||||
m_RendererType: 1
|
||||
m_RendererData: {fileID: 0}
|
||||
m_RendererDataList:
|
||||
@@ -53,6 +53,7 @@ MonoBehaviour:
|
||||
m_AdditionalLightsShadowResolutionTierHigh: 1024
|
||||
m_ReflectionProbeBlending: 1
|
||||
m_ReflectionProbeBoxProjection: 1
|
||||
m_ReflectionProbeAtlas: 1
|
||||
m_ShadowDistance: 50
|
||||
m_ShadowCascadeCount: 1
|
||||
m_Cascade2Split: 0.25
|
||||
@@ -78,11 +79,11 @@ MonoBehaviour:
|
||||
m_UseAdaptivePerformance: 1
|
||||
m_ColorGradingMode: 0
|
||||
m_ColorGradingLutSize: 32
|
||||
m_AllowPostProcessAlphaOutput: 0
|
||||
m_UseFastSRGBLinearConversion: 1
|
||||
m_SupportDataDrivenLensFlare: 1
|
||||
m_SupportScreenSpaceLensFlare: 1
|
||||
m_GPUResidentDrawerMode: 0
|
||||
m_UseLegacyLightmaps: 0
|
||||
m_SmallMeshScreenPercentage: 0
|
||||
m_GPUResidentDrawerEnableOcclusionCullingInCameras: 0
|
||||
m_ShadowType: 1
|
||||
@@ -109,6 +110,7 @@ MonoBehaviour:
|
||||
m_PrefilterDebugKeywords: 1
|
||||
m_PrefilterWriteRenderingLayers: 1
|
||||
m_PrefilterHDROutput: 1
|
||||
m_PrefilterAlphaOutput: 0
|
||||
m_PrefilterSSAODepthNormals: 1
|
||||
m_PrefilterSSAOSourceDepthLow: 1
|
||||
m_PrefilterSSAOSourceDepthMedium: 0
|
||||
@@ -126,8 +128,14 @@ MonoBehaviour:
|
||||
m_PrefilterSoftShadowsQualityHigh: 1
|
||||
m_PrefilterSoftShadows: 0
|
||||
m_PrefilterScreenCoord: 1
|
||||
m_PrefilterScreenSpaceIrradiance: 0
|
||||
m_PrefilterNativeRenderPass: 1
|
||||
m_PrefilterUseLegacyLightmaps: 0
|
||||
m_PrefilterBicubicLightmapSampling: 0
|
||||
m_PrefilterReflectionProbeRotation: 0
|
||||
m_PrefilterReflectionProbeBlending: 0
|
||||
m_PrefilterReflectionProbeBoxProjection: 0
|
||||
m_PrefilterReflectionProbeAtlas: 0
|
||||
m_ShaderVariantLogLevel: 0
|
||||
m_ShadowCascades: 0
|
||||
m_Textures:
|
||||
|
||||
@@ -233,6 +233,7 @@ QualitySettings:
|
||||
GameCoreXboxOne: 0
|
||||
Lumin: 0
|
||||
Nintendo Switch: 0
|
||||
Nintendo Switch 2: 0
|
||||
PS4: 0
|
||||
PS5: 0
|
||||
Server: 0
|
||||
|
||||
@@ -24,25 +24,25 @@ EditorUserSettings:
|
||||
value: 0005505f515750595e5f5f23412507441216497f2d7f24367e711c64b6b86c61
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-3:
|
||||
value: 5309035757065a0a54575f7216265c4444151d28792e72627d2f1935bbb8673a
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-4:
|
||||
value: 00050c5150005f5f54560f2640270d4410161c28282b72357e7c4835e4b63760
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-5:
|
||||
RecentlyUsedSceneGuid-4:
|
||||
value: 06090c5f54015f5a0f085b7b11765d444e4e1e287429773178704561b3b23561
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-6:
|
||||
RecentlyUsedSceneGuid-5:
|
||||
value: 0257035f51050d090f0f5d734521094414164e797e7a20667d7a4536e0e36461
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-7:
|
||||
RecentlyUsedSceneGuid-6:
|
||||
value: 07060c5454040c0a545b547240700a441216417e7f2e7268752c4966b4b0663d
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-7:
|
||||
value: 54070c5452075002590c0871127b5a4443161c2f797176312c2f1e6bb1b4353d
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-8:
|
||||
value: 5505015f5c515a085f5b092149760f441716407a787d7564287b1b36e7e1366e
|
||||
value: 5309035757065a0a54575f7216265c4444151d28792e72627d2f1935bbb8673a
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-9:
|
||||
value: 54070c5452075002590c0871127b5a4443161c2f797176312c2f1e6bb1b4353d
|
||||
value: 5505015f5c515a085f5b092149760f441716407a787d7564287b1b36e7e1366e
|
||||
flags: 0
|
||||
UnityEditor.ShaderGraph.Blackboard:
|
||||
value: 18135939215a0a5004000b0e15254b524c030a3f2964643d120d1230e9e93a3fd6e826abbd2e2d293c4ead313b08042de6030a0afa240c0d020be94c4ba75e435d8715fa32c70d15d11612dacc11fee5d3c5d1fe9ab1bf968e93e2ffcbc3e7e2f0b3ffe0e8b0be9afeffa9ffff8e85dd8390e2969e8899daa7
|
||||
|
||||
Reference in New Issue
Block a user