diff --git a/Assets/Scenes/StartUp.unity b/Assets/Scenes/StartUp.unity index 84f896e92..7aaab7e14 100644 --- a/Assets/Scenes/StartUp.unity +++ b/Assets/Scenes/StartUp.unity @@ -812,7 +812,7 @@ MonoBehaviour: videoPlayer: {fileID: 1810378423} startCanvas: {fileID: 386239068} playVideo: 0 - controllerType: 1 + controllerType: 0 --- !u!81 &2487858301405542861 AudioListener: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Common/Def/InputDef.cs b/Assets/Scripts/Common/Def/InputDef.cs index db041cf3f..1ea3fcf4e 100644 --- a/Assets/Scripts/Common/Def/InputDef.cs +++ b/Assets/Scripts/Common/Def/InputDef.cs @@ -48,6 +48,9 @@ namespace NBF public const string Run = "Run"; public const string Use1 = "Use1"; public const string Use2 = "Use2"; + + public const string Move = "Move"; + public const string Look = "Look"; } #region Load Icon diff --git a/Assets/Scripts/Fishing2/Camera/InputComponent.cs b/Assets/Scripts/Fishing2/Camera/InputComponent.cs index a6cebb9d3..71f9e6fc4 100644 --- a/Assets/Scripts/Fishing2/Camera/InputComponent.cs +++ b/Assets/Scripts/Fishing2/Camera/InputComponent.cs @@ -1,10 +1,17 @@ using System; using NBC.Entitas; using NBC.Entitas.Interface; +using UnityEngine; using UnityEngine.InputSystem; namespace NBF.Fishing2 { + public enum ControllerType + { + KeyboardMouse = 0, + GamePad = 1 + } + public class InputComponent : Entity { public PlayerInputControl PlayerInputControl { get; set; } @@ -29,6 +36,21 @@ namespace NBF.Fishing2 /// public event Action OnPlayerCanceled; + /// + /// 执行输入事件 + /// + public event Action OnPlayerValuePerformed; + + /// + /// 执行输入事件完毕 + /// + public event Action OnPlayerValueCanceled; + + /// + /// 触发交互游戏对象 + /// + public event Action OnInteractiveObjectAction; + /// /// 手柄输入 /// @@ -39,51 +61,9 @@ namespace NBF.Fishing2 /// public static bool IsUIStopInput; - public void OnUIButtonPerformed(InputAction.CallbackContext context) - { - OnUIPerformed?.Invoke(context.action.name); - } - public void OnUIButtonCanceled(InputAction.CallbackContext context) - { - OnUICanceled?.Invoke(context.action.name); - } + #region Event - public void OnPlayerButtonPerformed(InputAction.CallbackContext context) - { - if (IsUIStopInput) return; - var actionName = context.action.name; - // if (actionName == "Op1") - // { - // OnOp1Action?.Invoke(true); - // } - // else if (actionName == "Op2") - // { - // OnOp2Action?.Invoke(true); - // } - - OnPlayerPerformed?.Invoke(actionName); - } - - public void OnPlayerButtonCanceled(InputAction.CallbackContext context) - { - if (IsUIStopInput) return; - var actionName = context.action.name; - // if (actionName == "Op1") - // { - // OnOp1Action?.Invoke(false); - // } - // else if (actionName == "Op2") - // { - // OnOp2Action?.Invoke(false); - // } - // - OnPlayerCanceled?.Invoke(actionName); - } - } - - public static class InputComponentSystem - { public class InputComponentAwakeSystem : AwakeSystem { protected override void Awake(InputComponent self) @@ -114,6 +94,11 @@ namespace NBF.Fishing2 action.performed += self.OnPlayerButtonPerformed; action.canceled += self.OnPlayerButtonCanceled; } + else if (action.type == InputActionType.Value) + { + action.performed += self.OnInputPlayerValuePerformed; + action.canceled += self.OnInputPlayerValueCanceled; + } } } } @@ -147,10 +132,91 @@ namespace NBF.Fishing2 action.performed -= self.OnPlayerButtonPerformed; action.canceled -= self.OnPlayerButtonCanceled; } + else if (action.type == InputActionType.Value) + { + action.performed -= self.OnInputPlayerValuePerformed; + action.canceled -= self.OnInputPlayerValueCanceled; + } } } } } } + + + public void OnUIButtonPerformed(InputAction.CallbackContext context) + { + OnUIPerformed?.Invoke(context.action.name); + } + + private void OnUIButtonCanceled(InputAction.CallbackContext context) + { + OnUICanceled?.Invoke(context.action.name); + } + + private void OnPlayerButtonPerformed(InputAction.CallbackContext context) + { + if (IsUIStopInput) return; + var actionName = context.action.name; + // if (actionName == "Op1") + // { + // OnOp1Action?.Invoke(true); + // } + // else if (actionName == "Op2") + // { + // OnOp2Action?.Invoke(true); + // } + + OnPlayerPerformed?.Invoke(actionName); + } + + private void OnPlayerButtonCanceled(InputAction.CallbackContext context) + { + if (IsUIStopInput) return; + var actionName = context.action.name; + // if (actionName == "Op1") + // { + // OnOp1Action?.Invoke(false); + // } + // else if (actionName == "Op2") + // { + // OnOp2Action?.Invoke(false); + // } + // + OnPlayerCanceled?.Invoke(actionName); + } + + private void OnInputPlayerValuePerformed(InputAction.CallbackContext context) + { + if (IsUIStopInput) return; + OnPlayerValuePerformed?.Invoke(context); + } + + private void OnInputPlayerValueCanceled(InputAction.CallbackContext context) + { + if (IsUIStopInput) return; + OnPlayerValueCanceled?.Invoke(context); + } + + #endregion + + + public Vector2 GetMovementInput() + { + if (IsUIStopInput) return Vector2.zero; + return PlayerInputControl.Player.Move?.ReadValue() ?? Vector2.zero; + } + + public Vector2 GetLookInput() + { + if (IsUIStopInput) return Vector2.zero; + return PlayerInputControl.Player.Look?.ReadValue() ?? Vector2.zero; + } + + public void SendUIInput(string actionName) + { + OnUIPerformed?.Invoke(actionName); + OnUICanceled?.Invoke(actionName); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Helper/MapHelper.cs b/Assets/Scripts/Fishing2/Helper/MapHelper.cs index 0adb4735b..747110a59 100644 --- a/Assets/Scripts/Fishing2/Helper/MapHelper.cs +++ b/Assets/Scripts/Fishing2/Helper/MapHelper.cs @@ -13,21 +13,25 @@ namespace NBF.Fishing2 /// /// 开始进入地图 /// - public static async FTask EnterMap(int mapId, long roomId = 0) + public static async FTask EnterMap(int mapId, string roomCode = "") { try { var root = App.Main; + + var response = (Map2C_EnterMapResponse)await Net.Call(new C2Map_EnterMapRequest() { MapId = mapId, - RoomId = roomId + RoomId = roomCode }); Log.Info($"进入地图请求返回={response.ErrorCode}"); //如果有房间 - if (roomId > 0) + if (!string.IsNullOrEmpty(roomCode)) { //加入房间并请求获取房间数据 + await RoomHelper.EnterRoom(roomCode); + // mapId = roomMapId; } // 等待场景切换完成 diff --git a/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs b/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs index 2a8f2e3f6..a23f1f501 100644 --- a/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs +++ b/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs @@ -1,5 +1,7 @@ using System.Linq; using NBC; +using Unity.Mathematics; +using UnityEngine; namespace NBF.Fishing2 { @@ -10,7 +12,6 @@ namespace NBF.Fishing2 MapUnitInfo mapUnit = new MapUnitInfo(); mapUnit.Id = self.RoleId; mapUnit.RoleInfo = self.ToSimpleInfo(); - mapUnit.Location = new MapUnitPositionInfo(); mapUnit.Gears = self.Gears.First(); mapUnit.FishingInfo = new UnitFishingInfo(); return mapUnit; @@ -28,7 +29,55 @@ namespace NBF.Fishing2 return ret; } + + + #region Vector + public static Vector3Info ToVector3Info(this Vector3 self) + { + var ret = new Vector3Info(); + ret.x = self.x; + ret.y = self.y; + ret.z = self.z; + return ret; + } + + + public static QuaternionInfo ToQuaternionInfo(this Quaternion self) + { + var ret = new QuaternionInfo(); + ret.x = self.x; + ret.y = self.y; + ret.z = self.z; + ret.w = self.w; + return ret; + } + + public static Vector3 ToVector3(this Vector3Info self) + { + var ret = new Vector3 + { + x = self.x, + y = self.y, + z = self.z + }; + return ret; + } + + + public static Quaternion ToQuaternion(this QuaternionInfo self) + { + var ret = new Quaternion + { + x = self.x, + y = self.y, + z = self.z, + w = self.w + }; + return ret; + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Helper/RoomHelper.cs b/Assets/Scripts/Fishing2/Helper/RoomHelper.cs new file mode 100644 index 000000000..945475d56 --- /dev/null +++ b/Assets/Scripts/Fishing2/Helper/RoomHelper.cs @@ -0,0 +1,22 @@ +using NBC; + +namespace NBF.Fishing2 +{ + public class RoomHelper + { + public static async FTask EnterRoom(string roomCode) + { + var response = (G2C_EnterRoomResponse)await Net.Call(new C2G_EnterRoomRequest() + { + RoomCode = roomCode + }); + Log.Info($"进入房间返回 Code={response.RoomCode} 房间玩家数量={response.Units.Count}"); + // if (response.ErrorCode != 0) + // { + // return 0; + // } + + // return response.MapId; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Helper/RoomHelper.cs.meta b/Assets/Scripts/Fishing2/Helper/RoomHelper.cs.meta new file mode 100644 index 000000000..e1b294b5b --- /dev/null +++ b/Assets/Scripts/Fishing2/Helper/RoomHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0a565f17a34541a096ae34b8e67344d9 +timeCreated: 1757244384 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Helper/UnitHelper.cs b/Assets/Scripts/Fishing2/Helper/UnitHelper.cs index 00233ad4a..5f0210258 100644 --- a/Assets/Scripts/Fishing2/Helper/UnitHelper.cs +++ b/Assets/Scripts/Fishing2/Helper/UnitHelper.cs @@ -9,6 +9,16 @@ namespace NBF.Fishing2 { await FTask.CompletedTask; } - + + + public static bool IsSelf(this MapUnit self) + { + if (self.Id == Game.SelfId) + { + return true; + } + + return false; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Map/Handler.meta b/Assets/Scripts/Fishing2/Map/Handler.meta new file mode 100644 index 000000000..1e7150730 --- /dev/null +++ b/Assets/Scripts/Fishing2/Map/Handler.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9720afaa3bc94081b63a7c0571e4c86a +timeCreated: 1757251153 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Map/Map2C_ChangeMapHandler.cs b/Assets/Scripts/Fishing2/Map/Handler/Map2C_ChangeMapHandler.cs similarity index 100% rename from Assets/Scripts/Fishing2/Map/Map2C_ChangeMapHandler.cs rename to Assets/Scripts/Fishing2/Map/Handler/Map2C_ChangeMapHandler.cs diff --git a/Assets/Scripts/Fishing2/Map/Map2C_ChangeMapHandler.cs.meta b/Assets/Scripts/Fishing2/Map/Handler/Map2C_ChangeMapHandler.cs.meta similarity index 100% rename from Assets/Scripts/Fishing2/Map/Map2C_ChangeMapHandler.cs.meta rename to Assets/Scripts/Fishing2/Map/Handler/Map2C_ChangeMapHandler.cs.meta diff --git a/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleEnterMapNotifyHandler.cs b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleEnterMapNotifyHandler.cs new file mode 100644 index 000000000..8529d960b --- /dev/null +++ b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleEnterMapNotifyHandler.cs @@ -0,0 +1,14 @@ +using NBC; +using NBC.Network; +using NBC.Network.Interface; + +namespace Fishing2.Map +{ + public class Map2C_RoleEnterMapNotifyHandler : Message + { + protected override async FTask Run(Session session, Map2C_RoleEnterRoomNotify message) + { + Log.Info($"收到进入房间推送 id={message.Info.Id} "); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleEnterMapNotifyHandler.cs.meta b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleEnterMapNotifyHandler.cs.meta new file mode 100644 index 000000000..48650977c --- /dev/null +++ b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleEnterMapNotifyHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b0934eeab5b8445b824f1337f774379e +timeCreated: 1757251141 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleExitMapNotifyHandler.cs b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleExitMapNotifyHandler.cs new file mode 100644 index 000000000..71cffe6dc --- /dev/null +++ b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleExitMapNotifyHandler.cs @@ -0,0 +1,14 @@ +using NBC; +using NBC.Network; +using NBC.Network.Interface; + +namespace Fishing2.Map.Handler +{ + public class Map2C_RoleExitMapNotifyHandler : Message + { + protected override async FTask Run(Session session, Map2C_RoleExitRoomNotify message) + { + Log.Info($"收到离开房间推送 id={message.Id} "); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleExitMapNotifyHandler.cs.meta b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleExitMapNotifyHandler.cs.meta new file mode 100644 index 000000000..f33848f9c --- /dev/null +++ b/Assets/Scripts/Fishing2/Map/Handler/Map2C_RoleExitMapNotifyHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 18ae467167c44db1873fee88067d2f9a +timeCreated: 1757251193 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Map/Map.cs b/Assets/Scripts/Fishing2/Map/Map.cs index 87d59dd8d..0d9cd722b 100644 --- a/Assets/Scripts/Fishing2/Map/Map.cs +++ b/Assets/Scripts/Fishing2/Map/Map.cs @@ -36,7 +36,7 @@ namespace NBF.Fishing2 public void CreteMapUnit(MapUnitInfo unitInfo) { - var mapUnit = Entity.Create(Scene, unitInfo.RoleInfo.RoleId, true, true); + var mapUnit = Entity.Create(Scene, unitInfo.Id, true, true); mapUnit.SetUnitInfo(unitInfo); Add(mapUnit); } diff --git a/Assets/Scripts/Fishing2/Move/Map2C_LookNotifyHandler.cs b/Assets/Scripts/Fishing2/Move/Map2C_LookNotifyHandler.cs new file mode 100644 index 000000000..5d165c947 --- /dev/null +++ b/Assets/Scripts/Fishing2/Move/Map2C_LookNotifyHandler.cs @@ -0,0 +1,30 @@ +using NBC; +using NBC.Network; +using NBC.Network.Interface; + +namespace NBF.Fishing2 +{ + public class Map2C_LookNotifyHandler : Message + { + protected override async FTask Run(Session session, Map2C_LookeNotify message) + { + Log.Info($"收到朝向推送 id={message.Id} "); + var map = App.Main.GetComponent(); + var unit = map.Units[message.Id]; + if (unit.IsSelf()) + { + Log.Info("自己的旋转消息,不处理"); + } + else + { + var moveComponent = unit.GetComponent(); + if (moveComponent != null) + { + moveComponent.OnServerLook(message.Rotation.ToVector3(), message.Timestamp); + } + } + + await FTask.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Move/Map2C_LookNotifyHandler.cs.meta b/Assets/Scripts/Fishing2/Move/Map2C_LookNotifyHandler.cs.meta new file mode 100644 index 000000000..d81874f7e --- /dev/null +++ b/Assets/Scripts/Fishing2/Move/Map2C_LookNotifyHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f1f00b074c7f48248773361036d3bfcf +timeCreated: 1757238435 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Move/Map2C_MoveNotifyHandler.cs b/Assets/Scripts/Fishing2/Move/Map2C_MoveNotifyHandler.cs new file mode 100644 index 000000000..3329a1a90 --- /dev/null +++ b/Assets/Scripts/Fishing2/Move/Map2C_MoveNotifyHandler.cs @@ -0,0 +1,33 @@ +using NBC; +using NBC.Network; +using NBC.Network.Interface; + +namespace NBF.Fishing2 +{ + public class Map2C_MoveNotifyHandler : Message + { + protected override async FTask Run(Session session, Map2C_MoveNotify message) + { + Log.Info($"收到移动推送 id={message.Id} stop={message.IsStop}"); + // session.Scene + // session.Scene.GetComponent(message.Id), + var map = App.Main.GetComponent(); + var unit = map.Units[message.Id]; + var moveComponent = unit.GetComponent(); + if (moveComponent != null) + { + if (message.IsStop) + { + moveComponent.OnServerStopMove(message.Position.ToVector3(), message.Timestamp); + } + else + { + moveComponent.OnServerStartMove(message.Position.ToVector3(), + message.Direction.ToVector3(), 3, message.Timestamp); + } + } + + await FTask.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Move/Map2C_MoveNotifyHandler.cs.meta b/Assets/Scripts/Fishing2/Move/Map2C_MoveNotifyHandler.cs.meta new file mode 100644 index 000000000..9a9cfaa5c --- /dev/null +++ b/Assets/Scripts/Fishing2/Move/Map2C_MoveNotifyHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2306a332c3f842e78fd8d70c9ef1f8ed +timeCreated: 1757148423 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Move/MoveComponent.cs b/Assets/Scripts/Fishing2/Move/MoveComponent.cs index 0adb67143..a68a98ef6 100644 --- a/Assets/Scripts/Fishing2/Move/MoveComponent.cs +++ b/Assets/Scripts/Fishing2/Move/MoveComponent.cs @@ -1,339 +1,41 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using NBC; using NBC.Entitas; using NBC.Entitas.Interface; -using NBC.Helper; -using Unity.Mathematics; +using UnityEngine; +using UnityEngine.InputSystem; namespace NBF.Fishing2 { - public class MoveComponent : Entity + [System.Serializable] + public struct MoveState { - public float3 PreTarget - { - get { return this.Targets[this.N - 1]; } - } - - public float3 NextTarget - { - get { return this.Targets[this.N]; } - } - - // 开启移动协程的时间 - public long BeginTime; - - // 每个点的开始时间 - public long StartTime { get; set; } - - // 开启移动协程的Unit的位置 - public float3 StartPos; - - public float3 RealPos - { - get { return this.Targets[0]; } - } - - private long needTime; - - public long NeedTime - { - get { return this.needTime; } - set { this.needTime = value; } - } - - public long MoveTimer; - - public float Speed; // m/s - - public FTask tcs; - - public List Targets = new List(); - - public float3 FinalTarget - { - get { return this.Targets[^1]; } - } - - public int N; - public int TurnTime; - public bool IsTurnHorizontal; - - public quaternion From; - public quaternion To; + public Vector3 startPosition; // 开始移动时的位置 + public Vector3 moveDirection; // 移动方向(标准化向量) + public float moveSpeed; // 移动速度 + public bool isMoving; // 是否正在移动 + public double serverTimestamp; // 服务器时间戳 } - public static class MoveComponentSystem + public class MoveComponent : Entity { + public bool Run; + + public readonly Queue MoveStateQueue = new Queue(); + + #region System + public class MoveComponentDestroySystem : DestroySystem { protected override void Destroy(MoveComponent self) { + + self.Run = false; } } + + + #endregion - - public static bool IsArrived(this MoveComponent self) - { - return self.Targets.Count == 0; - } - - public static bool ChangeSpeed(this MoveComponent self, float speed) - { - if (self.IsArrived()) - { - return false; - } - - if (speed < 0.0001) - { - return false; - } - - MapUnit unit = self.GetParent(); - List path = new List(); - - self.MoveForward(false); - path.Add(unit.Position); // 第一个是Unit的pos - for (int i = self.N; i < self.Targets.Count; ++i) - { - path.Add(self.Targets[i]); - } - - self.MoveToAsync(path, speed).Coroutine(); - return true; - } - - // 该方法不需要用cancelToken的方式取消,因为即使不传入cancelToken,多次调用该方法也要取消之前的移动协程,上层可以stop取消 - public static async FTask MoveToAsync(this MoveComponent self, List target, float speed, - int turnTime = 100) - { - self.Stop(false); - foreach (float3 v in target) - { - self.Targets.Add(v); - } - - self.IsTurnHorizontal = true; - self.TurnTime = turnTime; - self.Speed = speed; - self.tcs = FTask.Create(true); - - self.Scene.EventComponent.Publish(new MoveStart() { Unit = self.GetParent() }); - - self.StartMove(); - - bool moveRet = await self.tcs; - - if (moveRet) - { - self.Scene.EventComponent.Publish(new MoveStop() { Unit = self.GetParent() }); - } - - return moveRet; - } - - // ret: 停止的时候,移动协程的返回值 - private static void MoveForward(this MoveComponent self, bool ret) - { - MapUnit unit = self.GetParent(); - - long timeNow = TimeHelper.Now; - long moveTime = timeNow - self.StartTime; - - while (true) - { - if (moveTime <= 0) - { - return; - } - - // 计算位置插值 - if (moveTime >= self.NeedTime) - { - unit.Position = self.NextTarget; - if (self.TurnTime > 0) - { - unit.Rotation = self.To; - } - } - else - { - // 计算位置插值 - float amount = moveTime * 1f / self.NeedTime; - if (amount > 0) - { - float3 newPos = math.lerp(self.StartPos, self.NextTarget, amount); - unit.Position = newPos; - } - - // 计算方向插值 - if (self.TurnTime > 0) - { - amount = moveTime * 1f / self.TurnTime; - if (amount > 1) - { - amount = 1f; - } - - quaternion q = math.slerp(self.From, self.To, amount); - unit.Rotation = q; - } - } - - moveTime -= self.NeedTime; - - // 表示这个点还没走完,等下一帧再来 - if (moveTime < 0) - { - return; - } - - // 到这里说明这个点已经走完 - - // 如果是最后一个点 - if (self.N >= self.Targets.Count - 1) - { - unit.Position = self.NextTarget; - unit.Rotation = self.To; - - self.MoveFinish(ret); - return; - } - - self.SetNextTarget(); - } - } - - private static void StartMove(this MoveComponent self) - { - self.BeginTime = TimeHelper.Now; - self.StartTime = self.BeginTime; - self.SetNextTarget(); - - // self.Scene.TimerComponent.Net.RepeatedTimer() - - self.MoveTimer = self.Scene.TimerComponent.Net.RepeatedTimer(1000 * 60, () => - { - try - { - self.MoveForward(true); - } - catch (Exception e) - { - Log.Error($"move timer error: {self.Id}\n{e}"); - } - }); - } - - private static void SetNextTarget(this MoveComponent self) - { - MapUnit unit = self.GetParent(); - - ++self.N; - - // 时间计算用服务端的位置, 但是移动要用客户端的位置来插值 - float3 v = self.GetFaceV(); - float distance = math.length(v); - - // 插值的起始点要以unit的真实位置来算 - self.StartPos = unit.Position; - - self.StartTime += self.NeedTime; - - self.NeedTime = (long)(distance / self.Speed * 1000); - - if (self.TurnTime > 0) - { - // 要用unit的位置 - float3 faceV = self.GetFaceV(); - if (math.lengthsq(faceV) < 0.0001f) - { - return; - } - - self.From = unit.Rotation; - - if (self.IsTurnHorizontal) - { - faceV.y = 0; - } - - if (Math.Abs(faceV.x) > 0.01 || Math.Abs(faceV.z) > 0.01) - { - self.To = quaternion.LookRotation(faceV, math.up()); - } - - return; - } - - if (self.TurnTime == 0) // turn time == 0 立即转向 - { - float3 faceV = self.GetFaceV(); - if (self.IsTurnHorizontal) - { - faceV.y = 0; - } - - if (Math.Abs(faceV.x) > 0.01 || Math.Abs(faceV.z) > 0.01) - { - self.To = quaternion.LookRotation(faceV, math.up()); - unit.Rotation = self.To; - } - } - } - - private static float3 GetFaceV(this MoveComponent self) - { - return self.NextTarget - self.PreTarget; - } - - public static bool FlashTo(this MoveComponent self, float3 target) - { - MapUnit unit = self.GetParent(); - unit.Position = target; - return true; - } - - // ret: 停止的时候,移动协程的返回值 - public static void Stop(this MoveComponent self, bool ret) - { - if (self.Targets.Count > 0) - { - self.MoveForward(ret); - } - - self.MoveFinish(ret); - if (!ret) - { - self.Scene.EventComponent.Publish( new MoveStop() { Unit = self.GetParent() }); - } - } - - private static void MoveFinish(this MoveComponent self, bool ret) - { - if (self.StartTime == 0) - { - return; - } - - self.StartTime = 0; - self.StartPos = float3.zero; - self.BeginTime = 0; - self.NeedTime = 0; - self.Targets.Clear(); - self.Speed = 0; - self.N = 0; - self.TurnTime = 0; - self.IsTurnHorizontal = false; - self.Scene.TimerComponent.Net.Remove(self.MoveTimer); - - if (self.tcs != null) - { - var tcs = self.tcs; - self.tcs = null; - tcs.SetResult(ret); - } - } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Move/MoveEvent.cs b/Assets/Scripts/Fishing2/Move/MoveEvent.cs index 402869eca..1927cfcc7 100644 --- a/Assets/Scripts/Fishing2/Move/MoveEvent.cs +++ b/Assets/Scripts/Fishing2/Move/MoveEvent.cs @@ -1,17 +1,14 @@ -namespace NBF.Fishing2 +using NBC; +using UnityEngine; + +namespace NBF.Fishing2 { - public struct MoveStart + public struct MoveChange { public MapUnit Unit; - } - - public struct MoveStop - { - public MapUnit Unit; - } - - public struct MoveTimer - { - + public Vector3 Position; + public Quaternion Rotation; + public Vector2Info Direction; + public bool IsStop; } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Role/Role.cs b/Assets/Scripts/Fishing2/Role/Role.cs index 636a27053..6227a4827 100644 --- a/Assets/Scripts/Fishing2/Role/Role.cs +++ b/Assets/Scripts/Fishing2/Role/Role.cs @@ -6,7 +6,7 @@ namespace NBF.Fishing2 { public class Role : Entity { - public long RoomId { get; set; } + public string RoomCode { get; set; } public RoleInfo Info { get; set; } @@ -14,7 +14,7 @@ namespace NBF.Fishing2 { protected override void Destroy(Role self) { - self.RoomId = 0; + self.RoomCode = string.Empty; self.Info = null; } } @@ -22,7 +22,7 @@ namespace NBF.Fishing2 public async FTask GetRoleInfo() { var response = (Game2C_GetRoleInfoResponse)await Net.Call(new C2Game_GetRoleInfoRequest()); - RoomId = response.RoomId; + RoomCode = response.RoomCode; Info = response.RoleInfo; } @@ -32,6 +32,12 @@ namespace NBF.Fishing2 mapUnit.Id = Id; mapUnit.RoleInfo = new RoleSimpleInfo() { + RoleId = Id, + NickName = Info.BaseInfo.NickName, + Head = Info.BaseInfo.Head, + Country = Info.BaseInfo.Country, + Level = Info.BaseInfo.Level, + Vip = Info.BaseInfo.Vip }; return mapUnit; diff --git a/Assets/Scripts/Fishing2/Unit/MapUnit.cs b/Assets/Scripts/Fishing2/Unit/MapUnit.cs index 9ac0473a8..b9cb5f07f 100644 --- a/Assets/Scripts/Fishing2/Unit/MapUnit.cs +++ b/Assets/Scripts/Fishing2/Unit/MapUnit.cs @@ -2,6 +2,7 @@ using NBC; using NBC.Entitas; using Unity.Mathematics; +using UnityEngine; namespace NBF.Fishing2 { @@ -12,34 +13,34 @@ namespace NBF.Fishing2 { public int ConfigId { get; set; } //配置表id - private float3 position; //坐标 + private Vector3 position; //坐标 - public float3 Position + public Vector3 Position { get => position; set { - float3 oldPos = position; + Vector3 oldPos = position; position = value; - Scene.EventComponent.Publish(new ChangePosition() { MapUnit = this, OldPos = oldPos }); + // Scene.EventComponent.Publish(new ChangePosition() { MapUnit = this, OldPos = oldPos }); } } - public float3 Forward + public Vector3 Forward { get => math.mul(Rotation, math.forward()); - set => Rotation = quaternion.LookRotation(value, math.up()); + set => Rotation = Quaternion.LookRotation(value, math.up()); } - private quaternion rotation; + private Quaternion rotation; - public quaternion Rotation + public Quaternion Rotation { get => rotation; set { rotation = value; - Scene.EventComponent.Publish(new ChangeRotation() { MapUnit = this }); + // Scene.EventComponent.Publish(new ChangeRotation() { MapUnit = this }); } } @@ -54,7 +55,7 @@ namespace NBF.Fishing2 public void SetUnitInfo(MapUnitInfo unitInfo) { - var moveComponent = GetOrAddComponent(); + GetOrAddComponent(); GetOrAddComponent(); var unitBasic = GetOrAddComponent(); unitBasic.UpdateInfo(unitInfo); diff --git a/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs new file mode 100644 index 000000000..6ce6bbe5e --- /dev/null +++ b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs @@ -0,0 +1,331 @@ +using System.Collections.Generic; +using NBC; +using NBC.Entitas; +using NBC.Entitas.Interface; +using NBC.Helper; +using UnityEngine; +using UnityEngine.InputSystem; + +namespace NBF.Fishing2 +{ + public class CharacterControllerComponent : Entity + { + public CharacterController characterController; + + public readonly Queue MoveStateQueue = new Queue(); + + public Transform transform => characterController.transform; + private MoveState currentMoveState; + + private Vector3 networkPosition; + // private Vector3 networkFacingDirection; + + // 插值平滑参数 + public float positionLerpSpeed = 10f; + public float rotationLerpSpeed = 10f; + + + [Tooltip("视角旋转敏感度")] public Vector2 sensitivity = new Vector2(0.015f, 0.015f); + public float minPitch = -40.0f; + public float maxPitch = 75.0f; + + #region System + + public class MoveComponentDestroySystem : DestroySystem + { + protected override void Destroy(CharacterControllerComponent self) + { + self.characterController = null; + var mapUnit = self.Parent as MapUnit; + if (mapUnit.IsSelf()) + { + var inputComponent = self.Scene.GetComponent(); + if (inputComponent != null) + { + inputComponent.OnPlayerPerformed -= self.OnPlayerCanceled; + inputComponent.OnPlayerPerformed -= self.OnPlayerPerformed; + + inputComponent.OnPlayerValueCanceled -= self.OnPlayerValueCanceled; + inputComponent.OnPlayerValuePerformed -= self.OnPlayerValuePerformed; + } + + } + } + } + + public class MoveComponentAwakeSystem : AwakeSystem + { + protected override void Awake(CharacterControllerComponent self) + { + var unitUnityComponent = self.Parent.GetComponent(); + self.characterController = unitUnityComponent.GameObject.GetComponent(); + self.lastSyncedFacing = self.characterController.transform.forward; + var mapUnit = self.Parent as MapUnit; + if (mapUnit.IsSelf()) + { + var inputComponent = self.Scene.GetComponent(); + inputComponent.OnPlayerPerformed += self.OnPlayerCanceled; + inputComponent.OnPlayerPerformed += self.OnPlayerPerformed; + + inputComponent.OnPlayerValueCanceled += self.OnPlayerValueCanceled; + inputComponent.OnPlayerValuePerformed += self.OnPlayerValuePerformed; + } + } + } + + public class MoveComponentUpdateSystem : UpdateSystem + { + protected override void Update(CharacterControllerComponent self) + { + self.ProcessMoveStates(); + self.CheckRotationSync(); + var mapUnit = self.Parent as MapUnit; + mapUnit.Position = self.characterController.transform.position; + mapUnit.Rotation = self.characterController.transform.rotation; + var f = mapUnit.Forward; + } + } + + #endregion + + + #region Input + + private void OnPlayerPerformed(string action) + { + if (action == InputDef.Player.Run) + { + // Run = true; + } + } + + private void OnPlayerCanceled(string action) + { + if (action == InputDef.Player.Run) + { + // Run = false; + } + } + + private void OnPlayerValueCanceled(InputAction.CallbackContext context) + { + var name = context.action.name; + if (name == InputDef.Player.Move) + { + var v2 = context.ReadValue(); + SendMoveMessage(v2, true); + } + } + + private void OnPlayerValuePerformed(InputAction.CallbackContext context) + { + var name = context.action.name; + if (name == InputDef.Player.Move) + { + var v2 = context.ReadValue(); + SendMoveMessage(v2, false); + } + else if (name == InputDef.Player.Look) + { + var v2 = context.ReadValue(); + UpdatePlayerRotation(v2); + } + } + + #endregion + + #region Message + + private void SendMoveMessage(Vector3 movementInput, bool isStop = false) + { + var mapUnit = Parent as MapUnit; + + Vector3 movementDirection = Vector3.zero; + + movementDirection += Vector3.forward * movementInput.y; + movementDirection += Vector3.right * movementInput.x; + + Net.Send(new C2Map_Move() + { + Direction = movementDirection.ToVector3Info(), + IsStop = isStop, + Timestamp = TimeHelper.Now, + Position = mapUnit.Position.ToVector3Info(), + Rotation = mapUnit.Forward.ToVector3Info(), + }); + } + + private void SendLookMessage() + { + Log.Info("发送朝向同步消息"); + Net.Send(new C2Map_Look() + { + Rotation = characterController.transform.forward.ToVector3Info(), + Timestamp = TimeHelper.Now + }); + } + + /// + /// 接收服务器移动开始通知 + /// + /// + /// + /// + /// + /// + public void OnServerStartMove(Vector3 startPosition, Vector3 moveDirection, float speed, double timestamp) + { + MoveState moveState = new MoveState + { + startPosition = startPosition, + moveDirection = moveDirection.normalized, + moveSpeed = speed, + isMoving = true, + serverTimestamp = timestamp + }; + + MoveStateQueue.Enqueue(moveState); + Log.Info($"MoveStateQueue Count={MoveStateQueue.Count}"); + } + + /// + /// 接收服务器移动停止通知 + /// + /// + /// + /// + public void OnServerStopMove(Vector3 finalPosition, double timestamp) + { + MoveState moveState = new MoveState + { + startPosition = finalPosition, + moveDirection = Vector3.zero, + moveSpeed = 0f, + isMoving = false, + serverTimestamp = timestamp + }; + + MoveStateQueue.Enqueue(moveState); + Log.Info($"MoveStateQueue Count={MoveStateQueue.Count}"); + } + + + public void OnServerLook(Vector3 rotation, double timestamp) + { + + } + + #endregion + + #region Move + + private void ProcessMoveStates() + { + // 只有在当前状态不是移动状态时,才处理下一个状态 + if (MoveStateQueue.Count > 0) + { + currentMoveState = MoveStateQueue.Dequeue(); + + if (currentMoveState.isMoving) + { + StartMovement(currentMoveState); + } + else + { + StopMovement(currentMoveState); + } + } + + // 如果正在移动,持续更新 + if (currentMoveState.isMoving) + { + UpdateMovement(); + + // 检查是否需要自动停止(可选) + // 例如基于时间或距离的条件 + } + } + + + private void StartMovement(MoveState moveState) + { + networkPosition = moveState.startPosition; + // networkFacingDirection = moveState.currentFacing; + + Debug.Log($"开始移动 - 位置: {moveState.startPosition}"); + } + + private void StopMovement(MoveState moveState) + { + networkPosition = moveState.startPosition; + // networkFacingDirection = moveState.currentFacing; + + Debug.Log($"停止移动 - 最终位置: {moveState.startPosition}"); + } + + private void UpdateMovement() + { + var movementDirection = + currentMoveState.moveDirection.relativeTo(BaseCamera.Main.transform, characterController.transform.up); + + Vector3 movement = movementDirection * currentMoveState.moveSpeed * Time.deltaTime; + networkPosition += movement; + characterController.Move(movement); + + // 如果移动方向不为零,可以自动更新朝向 + if (currentMoveState.moveDirection != Vector3.zero) + { + // networkFacingDirection = currentMoveState.moveDirection; + } + } + + #endregion + + #region Look + + public float rotationSyncInterval = 0.15f; + public float minRotationChange = 10f; + + private Vector3 _rotationInput = Vector3.zero; + private float _cameraPitch; + private float rotationSyncTimer; + private Vector3 lastSyncedFacing; + + private void UpdatePlayerRotation(Vector2 lookValue) + { + // Look + Vector2 lookInput = lookValue * sensitivity; + + if (lookInput.x != 0.0f) + { + _rotationInput.y += lookInput.x; + } + + // Player.CameraRoot.transform.localRotation = Quaternion.Euler(_cameraPitch, 0.0f, 0.0f); + if (_rotationInput != Vector3.zero) + { + characterController.transform.rotation *= Quaternion.Euler(_rotationInput); + _rotationInput = Vector3.zero; + } + } + + // 检查朝向同步 + private void CheckRotationSync() + { + rotationSyncTimer += Time.deltaTime; + if (rotationSyncTimer >= rotationSyncInterval) + { + float angleChange = Vector3.Angle(transform.forward, lastSyncedFacing); + + if (angleChange >= minRotationChange) + { + SendLookMessage(); + lastSyncedFacing = transform.forward; + rotationSyncTimer = 0f; + } + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs.meta b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs.meta new file mode 100644 index 000000000..a439abeef --- /dev/null +++ b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 36fb267f0f5149caa23ac1b6cf005067 +timeCreated: 1757164955 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Unit/Unity/UnitUnityComponent.cs b/Assets/Scripts/Fishing2/Unit/Unity/UnitUnityComponent.cs index 0b76af1a9..6e505bce8 100644 --- a/Assets/Scripts/Fishing2/Unit/Unity/UnitUnityComponent.cs +++ b/Assets/Scripts/Fishing2/Unit/Unity/UnitUnityComponent.cs @@ -22,6 +22,7 @@ namespace NBF.Fishing2 GameObject = gameObject; Transform = gameObject.transform; Animator = gameObject.GetComponent(); + Parent.AddComponent(); } diff --git a/Assets/Scripts/Global.cs b/Assets/Scripts/Game.cs similarity index 80% rename from Assets/Scripts/Global.cs rename to Assets/Scripts/Game.cs index 4f512184d..c6d8a7b5a 100644 --- a/Assets/Scripts/Global.cs +++ b/Assets/Scripts/Game.cs @@ -4,13 +4,13 @@ using UnityEngine; namespace NBF { - public class Global : MonoBehaviour + public class Game : MonoBehaviour { - public static Global Instance { get; private set; } + public static Game Instance { get; private set; } public static InputComponent Input; - + /// /// 主摄像机 /// @@ -21,10 +21,13 @@ namespace NBF /// public static CameraScriptObject CameraConfig { get; private set; } + public static long SelfId; private void Awake() { Instance = this; CameraConfig = Resources.Load(nameof(CameraConfig)); } + + } } \ No newline at end of file diff --git a/Assets/Scripts/Global.cs.meta b/Assets/Scripts/Game.cs.meta similarity index 100% rename from Assets/Scripts/Global.cs.meta rename to Assets/Scripts/Game.cs.meta diff --git a/Assets/Scripts/Generate/NetworkProtocol/MapMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/MapMessage.cs index be73a13ab..ac71c2698 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/MapMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/MapMessage.cs @@ -181,7 +181,7 @@ namespace NBC [ProtoMember(1)] public int MapId { get; set; } [ProtoMember(2)] - public long RoomId { get; set; } + public string RoomId { get; set; } } [ProtoContract] public partial class Map2C_EnterMapResponse : AMessage, ICustomRouteResponse, IProto diff --git a/Assets/Scripts/Generate/NetworkProtocol/MapProtoData.cs b/Assets/Scripts/Generate/NetworkProtocol/MapProtoData.cs index b2db96ad6..c7127ebf2 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/MapProtoData.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/MapProtoData.cs @@ -33,6 +33,26 @@ namespace NBC public float z { get; set; } } [ProtoContract] + public partial class Vector2Info : AMessage, IProto + { + public static Vector2Info Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + x = default; + y = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public float x { get; set; } + [ProtoMember(2)] + public float y { get; set; } + } + [ProtoContract] public partial class QuaternionInfo : AMessage, IProto { public static QuaternionInfo Create(Scene scene) @@ -115,7 +135,8 @@ namespace NBC { Id = default; RoleInfo = default; - Location = default; + Position = default; + Rotation = default; State = default; Gears = default; FishingInfo = default; @@ -129,34 +150,16 @@ namespace NBC [ProtoMember(2)] public RoleSimpleInfo RoleInfo { get; set; } [ProtoMember(3)] - public MapUnitPositionInfo Location { get; set; } + public Vector3Info Position { get; set; } [ProtoMember(4)] - public UnitStateInfo State { get; set; } + public Vector3Info Rotation { get; set; } [ProtoMember(5)] - public GearInfo Gears { get; set; } + public UnitStateInfo State { get; set; } [ProtoMember(6)] - public UnitFishingInfo FishingInfo { get; set; } + public GearInfo Gears { get; set; } [ProtoMember(7)] + public UnitFishingInfo FishingInfo { get; set; } + [ProtoMember(8)] public List KV = new List(); } - [ProtoContract] - public partial class MapUnitPositionInfo : AMessage, IProto - { - public static MapUnitPositionInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Position = default; - Rotation = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public Vector3Info Position { get; set; } - [ProtoMember(2)] - public QuaternionInfo Rotation { get; set; } - } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs index d893fbd31..c45707b56 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs @@ -151,7 +151,7 @@ namespace NBC { ErrorCode = default; RoleInfo = default; - RoomId = default; + RoomCode = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif @@ -160,7 +160,7 @@ namespace NBC [ProtoMember(1)] public RoleInfo RoleInfo { get; set; } [ProtoMember(2)] - public long RoomId { get; set; } + public string RoomCode { get; set; } [ProtoMember(3)] public uint ErrorCode { get; set; } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs index 99f79130d..ff1527bbd 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs @@ -18,45 +18,46 @@ namespace Fantasy public const uint G2C_RepeatLogin = 134227729; public const uint C2Game_GetRoleInfoRequest = 2281711379; public const uint Game2C_GetRoleInfoResponse = 2415929107; - public const uint C2Map_EnterRoomRequest = 2281711380; - public const uint Map2C_EnterRoomResponse = 2415929108; - public const uint C2Map_Move = 2147493650; - public const uint Map2C_RoleEnterMapNotify = 2147493651; - public const uint Map2C_RoleExitMapNotify = 2147493652; - public const uint Map2C_RoleStateNotify = 2147493653; - public const uint Map2C_RoleGearStateNotify = 2147493654; - public const uint Map2C_RoleGearChangeNotify = 2147493655; - public const uint C2S_GetConversationsRequest = 2281711381; - public const uint S2C_GetConversationsResponse = 2415929109; - public const uint C2S_SendMailRequest = 2281711382; - public const uint S2C_SendMailResponse = 2415929110; - public const uint C2S_DeleteMailRequest = 2281711383; - public const uint S2C_DeleteMailResponse = 2415929111; - public const uint S2C_HaveMail = 2147493656; - public const uint S2C_MailState = 2147493657; - public const uint C2S_CreateChannelRequest = 2281711384; - public const uint S2C_CreateChannelResponse = 2415929112; - public const uint C2S_JoinChannelRequest = 2281711385; - public const uint S2C_JoinChannelResponse = 2415929113; - public const uint C2S_SendMessageRequest = 2281711386; - public const uint S2C_SendMessageResponse = 2415929114; - public const uint S2C_Message = 2147493658; - public const uint C2S_CreateClubRequest = 2281711387; - public const uint S2C_CreateClubResponse = 2415929115; - public const uint C2S_GetClubInfoRequest = 2281711388; - public const uint S2C_GetClubInfoResponse = 2415929116; - public const uint C2S_GetMemberListRequest = 2281711389; - public const uint S2C_GetMemberListResponse = 2415929117; - public const uint C2S_GetClubListRequest = 2281711390; - public const uint S2C_GetClubListResponse = 2415929118; - public const uint C2S_JoinClubRequest = 2281711391; - public const uint S2C_JoinClubResponse = 2415929119; - public const uint C2S_LeaveClubRequest = 2281711392; - public const uint S2C_LeaveClubResponse = 2415929120; - public const uint C2S_DissolveClubRequest = 2281711393; - public const uint S2C_DissolveClubResponse = 2415929121; - public const uint C2S_DisposeJoinRequest = 2281711394; - public const uint S2C_DisposeJoinResponse = 2415929122; - public const uint S2C_ClubChange = 2147493659; + public const uint Map2C_RoleEnterRoomNotify = 2147493650; + public const uint Map2C_RoleExitRoomNotify = 2147493651; + public const uint Map2C_RoleStateNotify = 2147493652; + public const uint Map2C_RoleGearStateNotify = 2147493653; + public const uint Map2C_RoleGearChangeNotify = 2147493654; + public const uint C2Map_Move = 2147493655; + public const uint C2Map_Look = 2147493656; + public const uint Map2C_MoveNotify = 2147493657; + public const uint Map2C_LookeNotify = 2147493658; + public const uint C2S_GetConversationsRequest = 2281711380; + public const uint S2C_GetConversationsResponse = 2415929108; + public const uint C2S_SendMailRequest = 2281711381; + public const uint S2C_SendMailResponse = 2415929109; + public const uint C2S_DeleteMailRequest = 2281711382; + public const uint S2C_DeleteMailResponse = 2415929110; + public const uint S2C_HaveMail = 2147493659; + public const uint S2C_MailState = 2147493660; + public const uint C2S_CreateChannelRequest = 2281711383; + public const uint S2C_CreateChannelResponse = 2415929111; + public const uint C2S_JoinChannelRequest = 2281711384; + public const uint S2C_JoinChannelResponse = 2415929112; + public const uint C2S_SendMessageRequest = 2281711385; + public const uint S2C_SendMessageResponse = 2415929113; + public const uint S2C_Message = 2147493661; + public const uint C2S_CreateClubRequest = 2281711386; + public const uint S2C_CreateClubResponse = 2415929114; + public const uint C2S_GetClubInfoRequest = 2281711387; + public const uint S2C_GetClubInfoResponse = 2415929115; + public const uint C2S_GetMemberListRequest = 2281711388; + public const uint S2C_GetMemberListResponse = 2415929116; + public const uint C2S_GetClubListRequest = 2281711389; + public const uint S2C_GetClubListResponse = 2415929117; + public const uint C2S_JoinClubRequest = 2281711390; + public const uint S2C_JoinClubResponse = 2415929118; + public const uint C2S_LeaveClubRequest = 2281711391; + public const uint S2C_LeaveClubResponse = 2415929119; + public const uint C2S_DissolveClubRequest = 2281711392; + public const uint S2C_DissolveClubResponse = 2415929120; + public const uint C2S_DisposeJoinRequest = 2281711393; + public const uint S2C_DisposeJoinResponse = 2415929121; + public const uint S2C_ClubChange = 2147493662; } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs index c871955ac..0fddd28bd 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs @@ -9,96 +9,24 @@ using NBC.Serialize; namespace NBC { - [ProtoContract] - public partial class C2Map_EnterRoomRequest : AMessage, ICustomRouteRequest, IProto - { - public static C2Map_EnterRoomRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - MapId = default; - Password = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoIgnore] - public Map2C_EnterRoomResponse ResponseType { get; set; } - public uint OpCode() { return OuterOpcode.C2Map_EnterRoomRequest; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public int MapId { get; set; } - [ProtoMember(2)] - public string Password { get; set; } - } - [ProtoContract] - public partial class Map2C_EnterRoomResponse : AMessage, ICustomRouteResponse, IProto - { - public static Map2C_EnterRoomResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - ErrorCode = default; - MapId = default; - RoomId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_EnterRoomResponse; } - [ProtoMember(1)] - public int MapId { get; set; } - [ProtoMember(2)] - public long RoomId { get; set; } - [ProtoMember(3)] - public uint ErrorCode { get; set; } - } - [ProtoContract] - public partial class C2Map_Move : AMessage, ICustomRouteMessage, IProto - { - public static C2Map_Move Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Location = default; - IsStop = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.C2Map_Move; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public MapUnitPositionInfo Location { get; set; } - [ProtoMember(2)] - public bool IsStop { get; set; } - } /// /// 用户进入地图 /// [ProtoContract] - public partial class Map2C_RoleEnterMapNotify : AMessage, ICustomRouteMessage, IProto + public partial class Map2C_RoleEnterRoomNotify : AMessage, ICustomRouteMessage, IProto { - public static Map2C_RoleEnterMapNotify Create(Scene scene) + public static Map2C_RoleEnterRoomNotify Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { Info = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } - public uint OpCode() { return OuterOpcode.Map2C_RoleEnterMapNotify; } + public uint OpCode() { return OuterOpcode.Map2C_RoleEnterRoomNotify; } [ProtoIgnore] public int RouteType => Fantasy.RouteType.MapRoute; [ProtoMember(1)] @@ -108,20 +36,20 @@ namespace NBC /// 用户离开地图 /// [ProtoContract] - public partial class Map2C_RoleExitMapNotify : AMessage, ICustomRouteMessage, IProto + public partial class Map2C_RoleExitRoomNotify : AMessage, ICustomRouteMessage, IProto { - public static Map2C_RoleExitMapNotify Create(Scene scene) + public static Map2C_RoleExitRoomNotify Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { Id = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } - public uint OpCode() { return OuterOpcode.Map2C_RoleExitMapNotify; } + public uint OpCode() { return OuterOpcode.Map2C_RoleExitRoomNotify; } [ProtoIgnore] public int RouteType => Fantasy.RouteType.MapRoute; [ProtoMember(1)] @@ -205,11 +133,66 @@ namespace NBC [ProtoMember(2)] public GearInfo Gears { get; set; } } + [ProtoContract] + public partial class C2Map_Move : AMessage, ICustomRouteMessage, IProto + { + public static C2Map_Move Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Position = default; + Rotation = default; + Direction = default; + IsStop = default; + Timestamp = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.C2Map_Move; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public Vector3Info Position { get; set; } + [ProtoMember(2)] + public Vector3Info Rotation { get; set; } + [ProtoMember(3)] + public Vector3Info Direction { get; set; } + [ProtoMember(4)] + public bool IsStop { get; set; } + [ProtoMember(5)] + public long Timestamp { get; set; } + } + [ProtoContract] + public partial class C2Map_Look : AMessage, ICustomRouteMessage, IProto + { + public static C2Map_Look Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Rotation = default; + Timestamp = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.C2Map_Look; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public Vector3Info Rotation { get; set; } + [ProtoMember(2)] + public long Timestamp { get; set; } + } /// - /// 玩家位置变化 + /// 玩家移动推送 /// [ProtoContract] - public partial class Map2C_MoveNotify : AMessage, IProto + public partial class Map2C_MoveNotify : AMessage, ICustomRouteMessage, IProto { public static Map2C_MoveNotify Create(Scene scene) { @@ -218,14 +201,58 @@ namespace NBC public override void Dispose() { Id = default; - Location = default; + Position = default; + Rotation = default; + Direction = default; + IsStop = default; + Timestamp = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif } + public uint OpCode() { return OuterOpcode.Map2C_MoveNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; [ProtoMember(1)] public long Id { get; set; } [ProtoMember(2)] - public MapUnitPositionInfo Location { get; set; } + public Vector3Info Position { get; set; } + [ProtoMember(3)] + public Vector3Info Rotation { get; set; } + [ProtoMember(4)] + public Vector3Info Direction { get; set; } + [ProtoMember(5)] + public bool IsStop { get; set; } + [ProtoMember(6)] + public long Timestamp { get; set; } + } + /// + /// 玩家旋转推送 + /// + [ProtoContract] + public partial class Map2C_LookeNotify : AMessage, ICustomRouteMessage, IProto + { + public static Map2C_LookeNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + Rotation = default; + Timestamp = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_LookeNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public Vector3Info Rotation { get; set; } + [ProtoMember(3)] + public long Timestamp { get; set; } } } diff --git a/Assets/Scripts/Init.cs b/Assets/Scripts/Init.cs index 487a78502..3189a0937 100644 --- a/Assets/Scripts/Init.cs +++ b/Assets/Scripts/Init.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using FairyGUI; using NBC; +using NBF.Fishing2; using UnityEngine; using UnityEngine.Video; @@ -99,12 +101,12 @@ namespace NBF public void StartGame() { + Screen.SetResolution(1280, 720, FullScreenMode.Windowed); PermanentCommon.Init(); InputDef.LoadIcon(); // UI.Inst.OpenUI(); LoadData(); - CommonTopPanel.Show(); - LoginPanel.Show(); + OpenUI().Coroutine(); } private void LoadData() @@ -112,6 +114,13 @@ namespace NBF ConfigAssets.Init(); } + private async FTask OpenUI() + { + await Task.Delay(100); + CommonTopPanel.Show(); + LoginPanel.Show(); + } + #region New public ControllerType controllerType = ControllerType.GamePad; diff --git a/Assets/Scripts/Model/Common/Services/Input/InputCursorExtension.cs b/Assets/Scripts/Model/Common/Services/Input/InputCursorExtension.cs index 61096b6d7..2e6e46110 100644 --- a/Assets/Scripts/Model/Common/Services/Input/InputCursorExtension.cs +++ b/Assets/Scripts/Model/Common/Services/Input/InputCursorExtension.cs @@ -39,8 +39,8 @@ namespace NBF } } Log.Error($"showCursor={showCursor}"); - InputManager.IsUIStopInput = showCursor; - InputManager.SetMouseCursor(showCursor); + // Game.Input.IsUIStopInput = showCursor; + // Game.Input.SetMouseCursor(showCursor); } } } \ No newline at end of file diff --git a/Assets/Scripts/Model/Common/Services/Input/InputManager.cs b/Assets/Scripts/Model/Common/Services/Input/InputManager.cs deleted file mode 100644 index 5594df494..000000000 --- a/Assets/Scripts/Model/Common/Services/Input/InputManager.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NBC; -// using Rewired; -using UnityEngine; -using UnityEngine.InputSystem; - -namespace NBF -{ - public enum ControllerType - { - KeyboardMouse = 0, - GamePad = 1 - } - - public class InputManager : MonoService - { - public static bool IsOp1; - public static bool IsOp2; - - public static event Action OnOp1Action; - public static event Action OnOp2Action; - - /// - /// 执行输入事件 - /// - public static event Action OnUIPerformed; - - /// - /// 执行输入事件完毕 - /// - public static event Action OnUICanceled; - - /// - /// 执行输入事件 - /// - public static event Action OnPlayerPerformed; - - /// - /// 执行输入事件完毕 - /// - public static event Action OnPlayerCanceled; - - /// - /// 触发交互游戏对象 - /// - public static event Action OnInteractiveObjectAction; - - public static PlayerInputControl PlayerInputControl { get; private set; } - - /// - /// 手柄输入 - /// - public static bool IsControllerInput; - - /// - /// ui阻止游戏输入 - /// - public static bool IsUIStopInput; - - public static ControllerType ControllerType = ControllerType.KeyboardMouse; - - protected override void OnAwake() - { - InputCursorExtension.InputInit(); - DontDestroyOnLoad(gameObject); - PlayerInputControl = new PlayerInputControl(); - PlayerInputControl.Enable(); - } - - private void Start() - { - AddEvent(); - } - - private void OnDestroy() - { - RemoveEvent(); - InputCursorExtension.Dispose(); - } - - - public static void SetMouseCursor(bool val) - { - if (val) - { - if (ControllerType == ControllerType.KeyboardMouse) - { - Cursor.visible = true; - } - - Cursor.lockState = CursorLockMode.None; - } - else if (ControllerType == ControllerType.KeyboardMouse) - { - Cursor.visible = false; - } - - Cursor.visible = val; - if (!val) - { - Cursor.lockState = CursorLockMode.Confined; - } - } - - public static Vector2 GetMovementInput() - { - if (IsUIStopInput) return Vector2.zero; - return PlayerInputControl.Player.Move?.ReadValue() ?? Vector2.zero; - } - - public static Vector2 GetLookInput() - { - if (IsUIStopInput) return Vector2.zero; - return PlayerInputControl.Player.Look?.ReadValue() ?? Vector2.zero; - } - - - private void AddEvent() - { - foreach (var actionMap in PlayerInputControl.asset.actionMaps) - { - actionMap.Enable(); - if (actionMap.name == "UI") - { - foreach (var action in actionMap.actions) - { - if (action.type == InputActionType.Button) - { - action.performed += OnUIButtonPerformed; - action.canceled += OnUIButtonCanceled; - } - } - } - else if (actionMap.name == "Player") - { - foreach (var action in actionMap.actions) - { - if (action.type == InputActionType.Button) - { - action.performed += OnPlayerButtonPerformed; - action.canceled += OnPlayerButtonCanceled; - } - } - } - } - } - - private void RemoveEvent() - { - OnUIPerformed = null; - OnUICanceled = null; - OnPlayerPerformed = null; - OnPlayerCanceled = null; - } - - private void OnUIButtonPerformed(InputAction.CallbackContext context) - { - OnUIPerformed?.Invoke(context.action.name); - } - - private void OnUIButtonCanceled(InputAction.CallbackContext context) - { - OnUICanceled?.Invoke(context.action.name); - } - - private void OnPlayerButtonPerformed(InputAction.CallbackContext context) - { - if (IsUIStopInput) return; - var actionName = context.action.name; - if (actionName == "Op1") - { - OnOp1Action?.Invoke(true); - } - else if (actionName == "Op2") - { - OnOp2Action?.Invoke(true); - } - - OnPlayerPerformed?.Invoke(actionName); - } - - private void OnPlayerButtonCanceled(InputAction.CallbackContext context) - { - if (IsUIStopInput) return; - var actionName = context.action.name; - if (actionName == "Op1") - { - OnOp1Action?.Invoke(false); - } - else if (actionName == "Op2") - { - OnOp2Action?.Invoke(false); - } - - OnPlayerCanceled?.Invoke(actionName); - } - - - public void OnInteractiveObject(InteractiveObject interactiveObject) - { - Debug.LogError($"OnInteractiveObject {interactiveObject != null}"); - OnInteractiveObjectAction?.Invoke(interactiveObject); - } - - public void SendUIInput(string actionName) - { - OnUIPerformed?.Invoke(actionName); - OnUICanceled?.Invoke(actionName); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Model/Common/Services/Input/InputManager.cs.meta b/Assets/Scripts/Model/Common/Services/Input/InputManager.cs.meta deleted file mode 100644 index 4e25f2794..000000000 --- a/Assets/Scripts/Model/Common/Services/Input/InputManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: fecc50928be248b896f6ee0a17e7b76d -timeCreated: 1746892722 \ No newline at end of file diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputAddBobSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputAddBobSetting.cs index ed23b32a2..0e5609a3d 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputAddBobSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputAddBobSetting.cs @@ -8,7 +8,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.AddBob; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.AddBob; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputChatSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputChatSetting.cs index df4827926..27a3feea9 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputChatSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputChatSetting.cs @@ -9,7 +9,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.Chat; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.Chat; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputHelpSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputHelpSetting.cs index 7b87ef87a..6b4f4427e 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputHelpSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputHelpSetting.cs @@ -8,7 +8,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.Help; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.Help; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputSubBobSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputSubBobSetting.cs index c5a5c167c..e74bd6873 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputSubBobSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputSubBobSetting.cs @@ -8,7 +8,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.SubBob; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.SubBob; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputToBagSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputToBagSetting.cs index e04b3acbe..8ee07d40f 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputToBagSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputToBagSetting.cs @@ -8,7 +8,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.ToBag; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.ToBag; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTelescopeSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTelescopeSetting.cs index 6f62b10ef..eae34339d 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTelescopeSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTelescopeSetting.cs @@ -8,7 +8,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.UseTelescope; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.UseTelescope; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTorchSetting.cs b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTorchSetting.cs index 73141495f..d2b505f1e 100644 --- a/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTorchSetting.cs +++ b/Assets/Scripts/Model/Common/Services/Settings/Options/Input/InputUseTorchSetting.cs @@ -8,7 +8,7 @@ namespace NBF.Setting public override string Group => SettingsDef.Group.Keyboard; public override string Tab => SettingsDef.Tab.Keyboard; - public override InputAction InputAction => InputManager.PlayerInputControl.Player.UseTorch; + public override InputAction InputAction => Game.Input.PlayerInputControl.Player.UseTorch; protected override void OnApply() { diff --git a/Assets/Scripts/Model/Login/LoginHelper.cs b/Assets/Scripts/Model/Login/LoginHelper.cs index a08929c5f..f2df5fcae 100644 --- a/Assets/Scripts/Model/Login/LoginHelper.cs +++ b/Assets/Scripts/Model/Login/LoginHelper.cs @@ -62,7 +62,7 @@ namespace NBF Log.Debug($"登录到Gate服务器成功!ErrorCode:{loginResponse.ErrorCode}"); await role.GetRoleInfo(); Log.Debug( - $"获取角色信息成功!roleId={role.Id} Room={role.RoomId} RoleInfo={JsonConvert.SerializeObject(role.Info)}"); + $"获取角色信息成功!roleId={role.Id} Room={role.RoomCode} RoleInfo={JsonConvert.SerializeObject(role.Info)}"); var mapId = role.Info.MapId; if (mapId == 0) { @@ -70,7 +70,8 @@ namespace NBF mapId = 99; } - await MapHelper.EnterMap(mapId, role.RoomId); + Game.SelfId = loginResponse.RoleId; + await MapHelper.EnterMap(mapId, role.RoomCode); } } } \ No newline at end of file diff --git a/Assets/Scripts/OnSceneCreate_Init.cs b/Assets/Scripts/OnSceneCreate_Init.cs index e2561bc54..5da37df6b 100644 --- a/Assets/Scripts/OnSceneCreate_Init.cs +++ b/Assets/Scripts/OnSceneCreate_Init.cs @@ -17,7 +17,7 @@ namespace NBF.Fishing2 var input = scene.AddComponent(); scene.AddComponent(); - Global.Input = input; + Game.Input = input; } await FTask.CompletedTask; diff --git a/Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs b/Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs index 637e5d314..3265f10b4 100644 --- a/Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs +++ b/Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs @@ -49,7 +49,8 @@ namespace NBF { // if (!SRDebug.Instance.IsDebugPanelVisible && !SRDebug.Instance.IsDebugPanelVisible) { - var lookInput = InputManager.GetLookInput(); + // var lookInput = InputManager.GetLookInput(); + var lookInput = Vector2.zero; float num = Mathf.Clamp(lookInput.y * YSensitivity * 5f * Time.deltaTime, -10f, 10f); float num2 = diff --git a/Assets/Scripts/UI/Bag/BagPanel.cs b/Assets/Scripts/UI/Bag/BagPanel.cs index 3737ab235..e3885af4f 100644 --- a/Assets/Scripts/UI/Bag/BagPanel.cs +++ b/Assets/Scripts/UI/Bag/BagPanel.cs @@ -15,7 +15,7 @@ namespace NBF protected override void OnShow() { - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; UseBottomMenu(); } @@ -49,7 +49,7 @@ namespace NBF protected override void OnHide() { - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; } protected override void OnDestroy() diff --git a/Assets/Scripts/UI/Common/ClassifyList.cs b/Assets/Scripts/UI/Common/ClassifyList.cs index 71489110d..3605a081c 100644 --- a/Assets/Scripts/UI/Common/ClassifyList.cs +++ b/Assets/Scripts/UI/Common/ClassifyList.cs @@ -18,12 +18,12 @@ namespace NBF private void OnInited() { - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; } public override void Dispose() { - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; base.Dispose(); } diff --git a/Assets/Scripts/UI/Common/Menu/BottomMenu.cs b/Assets/Scripts/UI/Common/Menu/BottomMenu.cs index 848ee8bae..470760002 100644 --- a/Assets/Scripts/UI/Common/Menu/BottomMenu.cs +++ b/Assets/Scripts/UI/Common/Menu/BottomMenu.cs @@ -21,7 +21,7 @@ namespace NBF { var item = context.data as BtnTitleInputControl; if (item == null) return; - InputManager.Instance.SendUIInput(item.ActionName); + Game.Input.SendUIInput(item.ActionName); Debug.Log("模拟点击==="); } diff --git a/Assets/Scripts/UI/Common/Menu/CommonMenu.cs b/Assets/Scripts/UI/Common/Menu/CommonMenu.cs index 7a409a937..f6dc3eb6d 100644 --- a/Assets/Scripts/UI/Common/Menu/CommonMenu.cs +++ b/Assets/Scripts/UI/Common/Menu/CommonMenu.cs @@ -18,12 +18,12 @@ namespace NBF BtnPrev.onClick.Add(OnClickBtnPrev); BtnNext.onClick.Add(OnClickBtnNext); - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; } public override void Dispose() { - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; base.Dispose(); } diff --git a/Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs b/Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs index f946d4dc5..de3b87f90 100644 --- a/Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs +++ b/Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs @@ -18,12 +18,12 @@ namespace NBF BtnPrev.onClick.Add(OnClickBtnPrev); BtnNext.onClick.Add(OnClickBtnNext); - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; } public override void Dispose() { - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; base.Dispose(); } diff --git a/Assets/Scripts/UI/Common/Panel/CommonTopPanel.cs b/Assets/Scripts/UI/Common/Panel/CommonTopPanel.cs index fef134f7a..88c59745a 100644 --- a/Assets/Scripts/UI/Common/Panel/CommonTopPanel.cs +++ b/Assets/Scripts/UI/Common/Panel/CommonTopPanel.cs @@ -15,7 +15,7 @@ namespace NBF protected override void OnShow() { - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; } private void OnUICanceled(string action) @@ -37,7 +37,7 @@ namespace NBF protected override void OnHide() { - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; } protected override void OnDestroy() diff --git a/Assets/Scripts/UI/Common/Panel/MessageBox.cs b/Assets/Scripts/UI/Common/Panel/MessageBox.cs index cc3979c55..a7715f094 100644 --- a/Assets/Scripts/UI/Common/Panel/MessageBox.cs +++ b/Assets/Scripts/UI/Common/Panel/MessageBox.cs @@ -51,7 +51,7 @@ namespace NBF HideAnim = this.HideCenterScaleBig; IsModal = true; IsDontBack = true; - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; } protected override void OnShow() @@ -80,7 +80,7 @@ namespace NBF protected override void OnDestroy() { base.OnDestroy(); - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; } diff --git a/Assets/Scripts/UI/Fishing/FishingPanel.cs b/Assets/Scripts/UI/Fishing/FishingPanel.cs index fbfa7504c..3fda2151b 100644 --- a/Assets/Scripts/UI/Fishing/FishingPanel.cs +++ b/Assets/Scripts/UI/Fishing/FishingPanel.cs @@ -16,9 +16,9 @@ namespace NBF protected override void OnShow() { - InputManager.OnUICanceled += OnUICanceled; - InputManager.OnInteractiveObjectAction += OnInteractiveObjectAction; - InputManager.OnPlayerCanceled += OnPlayerCanceled; + Game.Input.OnUICanceled += OnUICanceled; + Game.Input.OnInteractiveObjectAction += OnInteractiveObjectAction; + Game.Input.OnPlayerCanceled += OnPlayerCanceled; // InputManager.OnUseAction += OnUseAction; // InputManager.OnUse2Action += OnUse2Action; } @@ -70,9 +70,9 @@ namespace NBF protected override void OnHide() { base.OnHide(); - InputManager.OnUICanceled -= OnUICanceled; - InputManager.OnInteractiveObjectAction -= OnInteractiveObjectAction; - InputManager.OnUICanceled -= OnPlayerCanceled; + Game.Input.OnUICanceled -= OnUICanceled; + Game.Input.OnInteractiveObjectAction -= OnInteractiveObjectAction; + Game.Input.OnUICanceled -= OnPlayerCanceled; } } } \ No newline at end of file diff --git a/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs b/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs index 8139b8dda..32ea5d352 100644 --- a/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs +++ b/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs @@ -29,7 +29,7 @@ namespace NBF protected override void OnShow() { - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; UseBottomMenu(); @@ -40,7 +40,7 @@ namespace NBF protected override void OnHide() { - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; } private void OnUICanceled(string action) diff --git a/Assets/Scripts/UI/Login/LoginPanel.cs b/Assets/Scripts/UI/Login/LoginPanel.cs index b6556e4b6..91982d2fb 100644 --- a/Assets/Scripts/UI/Login/LoginPanel.cs +++ b/Assets/Scripts/UI/Login/LoginPanel.cs @@ -5,6 +5,7 @@ using UnityEngine; using NBC; using NBC.Entitas; using NBF.Fishing2; +using UnityEngine.InputSystem; using UIPanel = NBC.UIPanel; namespace NBF @@ -14,6 +15,54 @@ namespace NBF protected override void OnInit() { this.AutoAddClick(OnClick); + + Game.Input.OnPlayerPerformed += OnPlayerCanceled; + Game.Input.OnPlayerPerformed += OnPlayerPerformed; + + Game.Input.OnPlayerValueCanceled += OnPlayerValueCanceled; + Game.Input.OnPlayerValuePerformed += OnPlayerValuePerformed; + } + + private bool _isRun; + + private void OnPlayerPerformed(string action) + { + if (action == "Run") + { + _isRun = true; + } + + Log.Info($"OnPlayerPerformed action = {action}"); + } + + private void OnPlayerCanceled(string action) + { + if (action == "Run") + { + _isRun = false; + } + + Log.Info($"OnPlayerCanceled action = {action}"); + } + + private void OnPlayerValueCanceled(InputAction.CallbackContext context) + { + var name = context.action.name; + if (name == "Move") + { + var v2 = context.ReadValue(); + Log.Info($"OnPlayerValueCanceled name={name} v2={v2}"); + } + } + + private void OnPlayerValuePerformed(InputAction.CallbackContext context) + { + var name = context.action.name; + if (name == "Move") + { + var v2 = context.ReadValue(); + Log.Info($"OnPlayerValuePerformed name={name} v2={v2}"); + } } private void OnClick(GComponent btn) diff --git a/Assets/Scripts/UI/Settings/SettingPanel.cs b/Assets/Scripts/UI/Settings/SettingPanel.cs index 9f205be5f..9162140b9 100644 --- a/Assets/Scripts/UI/Settings/SettingPanel.cs +++ b/Assets/Scripts/UI/Settings/SettingPanel.cs @@ -43,7 +43,7 @@ namespace NBF protected override void OnShow() { Settings.Instance.LoadAllSettings(); - InputManager.OnUICanceled += OnUICanceled; + Game.Input.OnUICanceled += OnUICanceled; Menu.SetTabs(tabList); UseBottomMenu(); } @@ -271,7 +271,7 @@ namespace NBF protected override void OnHide() { base.OnHide(); - InputManager.OnUICanceled -= OnUICanceled; + Game.Input.OnUICanceled -= OnUICanceled; } protected override void OnDestroy() diff --git a/Assets/Settings/PC_RPAsset.asset b/Assets/Settings/PC_RPAsset.asset index c0087c542..d7b5b1f35 100644 --- a/Assets/Settings/PC_RPAsset.asset +++ b/Assets/Settings/PC_RPAsset.asset @@ -53,6 +53,7 @@ MonoBehaviour: m_AdditionalLightsShadowResolutionTierHigh: 1024 m_ReflectionProbeBlending: 1 m_ReflectionProbeBoxProjection: 1 + m_ReflectionProbeAtlas: 1 m_ShadowDistance: 150 m_ShadowCascadeCount: 4 m_Cascade2Split: 0.25 @@ -129,6 +130,10 @@ MonoBehaviour: m_PrefilterScreenCoord: 1 m_PrefilterNativeRenderPass: 1 m_PrefilterUseLegacyLightmaps: 0 + m_PrefilterBicubicLightmapSampling: 1 + m_PrefilterReflectionProbeBlending: 0 + m_PrefilterReflectionProbeBoxProjection: 0 + m_PrefilterReflectionProbeAtlas: 0 m_ShaderVariantLogLevel: 0 m_ShadowCascades: 0 m_Textures: diff --git a/Assets/Settings/UniversalRenderPipelineGlobalSettings.asset b/Assets/Settings/UniversalRenderPipelineGlobalSettings.asset index cf209f46d..8eaa86023 100644 --- a/Assets/Settings/UniversalRenderPipelineGlobalSettings.asset +++ b/Assets/Settings/UniversalRenderPipelineGlobalSettings.asset @@ -63,7 +63,21 @@ MonoBehaviour: - rid: 6565977368940511236 - rid: 6565977368940511237 m_RuntimeSettings: - m_List: [] + m_List: + - rid: 6852985685364965378 + - rid: 6852985685364965379 + - rid: 6852985685364965380 + - rid: 6852985685364965381 + - rid: 6852985685364965384 + - rid: 6852985685364965385 + - rid: 6852985685364965392 + - rid: 6852985685364965394 + - rid: 8712630790384254976 + - rid: 7166519162571063296 + - rid: 7166519162571063298 + - rid: 7166519162571063301 + - rid: 6565977368940511236 + - rid: 6565977368940511237 m_AssetVersion: 8 m_ObsoleteDefaultVolumeProfile: {fileID: 0} m_RenderingLayerNames: diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset index 868c4bb69..3e1be0a2c 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset @@ -281,7 +281,7 @@ Texture2D: serializedVersion: 2 Hash: 00000000000000000000000000000000 m_IsAlphaChannelOptional: 0 - serializedVersion: 3 + serializedVersion: 4 m_Width: 1 m_Height: 1 m_CompleteImageSize: 1 diff --git a/Fishing2.sln.DotSettings.user b/Fishing2.sln.DotSettings.user index b4418cfba..2da2ef4ad 100644 --- a/Fishing2.sln.DotSettings.user +++ b/Fishing2.sln.DotSettings.user @@ -5,6 +5,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 488bf8eaf..2b69d85f0 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -106,7 +106,7 @@ PlayerSettings: xboxEnableFitness: 0 visibleInBackground: 1 allowFullscreenSwitch: 1 - fullscreenMode: 1 + fullscreenMode: 3 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 @@ -142,7 +142,8 @@ PlayerSettings: visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 bundleVersion: 0.1.0 - preloadedAssets: [] + preloadedAssets: + - {fileID: -944628639613478452, guid: 8a314d59348c97b4e96e6eb9b09285a6, type: 3} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -520,7 +521,10 @@ PlayerSettings: m_Height: 720 m_Kind: 1 m_SubKind: - m_BuildTargetBatching: [] + m_BuildTargetBatching: + - m_BuildTarget: Standalone + m_StaticBatching: 1 + m_DynamicBatching: 0 m_BuildTargetShaderSettings: [] m_BuildTargetGraphicsJobs: [] m_BuildTargetGraphicsJobMode: []