From 1b50728e68c927bb9a0fced3d5f67b9667048118 Mon Sep 17 00:00:00 2001 From: "jiannan.guo@yingxiong.com" Date: Sat, 26 Jul 2025 00:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=91=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/RawResources/Model/Joystick.prefab | 4 +- .../client/Assets/Scenes/BattleEditor.unity | 6 +-- .../Logic/FrameCommand/Desc/MovePosDesc.cs | 34 ++++++++++++++++ .../FrameCommand/Desc/MovePosDesc.cs.meta | 3 ++ .../Logic/FrameCommand/LogicCommandSvc.cs | 1 + .../Logic/Service/LEntityCreatorSvc.cs | 2 +- .../Render/Component/Proxy/JoystickProxy.cs | 2 + .../Render/FrameCommand/RenderCommandSvc.cs | 1 + .../Render/System/Input/InputSystem.cs | 40 ++++++++++--------- .../AFramSync/Render/View/JoystickRender.cs | 9 ++++- .../Shared/FrameCommand/Data/MovePosCmd.cs | 36 +++++++++++++++++ .../FrameCommand/Data/MovePosCmd.cs.meta | 3 ++ .../Assets/Scripts/CoreGame/WorldPacks.meta | 3 -- 13 files changed, 115 insertions(+), 29 deletions(-) create mode 100644 client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs create mode 100644 client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs.meta create mode 100644 client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs create mode 100644 client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs.meta delete mode 100644 client/client/Assets/Scripts/CoreGame/WorldPacks.meta diff --git a/client/client/Assets/RawResources/Model/Joystick.prefab b/client/client/Assets/RawResources/Model/Joystick.prefab index a759e87a..b6e3ff41 100644 --- a/client/client/Assets/RawResources/Model/Joystick.prefab +++ b/client/client/Assets/RawResources/Model/Joystick.prefab @@ -158,7 +158,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -233,7 +233,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 diff --git a/client/client/Assets/Scenes/BattleEditor.unity b/client/client/Assets/Scenes/BattleEditor.unity index f61ea816..2cdf4284 100644 --- a/client/client/Assets/Scenes/BattleEditor.unity +++ b/client/client/Assets/Scenes/BattleEditor.unity @@ -806,8 +806,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: 0, y: 100} - m_SizeDelta: {x: -120, y: 100} + m_AnchoredPosition: {x: 0, y: 125.30005} + m_SizeDelta: {x: -120, y: 160} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &536237624 MonoBehaviour: @@ -2092,7 +2092,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 0} + m_SizeDelta: {x: 160, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1229089819 MonoBehaviour: diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs new file mode 100644 index 00000000..36dfd035 --- /dev/null +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs @@ -0,0 +1,34 @@ +using CoreGame.Shared; +using Entitas; +using Sog; + +namespace CoreGame.Logic +{ + public class MovePosDesc : ICommandLogicDesc + { + public void OnExecute(ref BaseCommand command, LogicContext context, in EntityHandle entityHandle) + { + var moveDirectionCommand = (MovePosCmd)command; + if (entityHandle == false) + { + LLog.LogInfo($"MoveDirectionDesc entityHandle is null {entityHandle}"); + return; + } + //TODO : GUO + Fixed64Vector2 dt = new Fixed64Vector2(moveDirectionCommand.x, moveDirectionCommand.y); + dt *= Fixed64.EN4; + var logicTransform = entityHandle.value.logicTransform; + var pos = logicTransform.position + dt; + var size = context.WorldExtendSize; + size -= Fixed64Vector2.one * Fixed64._0_50; + + // if (pos.x < -size.x || pos.x > size.x || pos.y < -size.y || pos.y > size.y) + // { + // + // } + pos = FixedMath.Clamp(pos, -size, size); + logicTransform.SetPosition(pos); + // entityHandle.value.ReplaceMoveDirection(moveDirectionCommand.Degree, moveDirectionCommand.nSeq); + } + } +} \ No newline at end of file diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs.meta b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs.meta new file mode 100644 index 00000000..912fec0a --- /dev/null +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 07a3da7eb5184569aaf0561f8efb6f67 +timeCreated: 1753458825 \ No newline at end of file diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/LogicCommandSvc.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/LogicCommandSvc.cs index e20de01c..800348e4 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/LogicCommandSvc.cs +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/LogicCommandSvc.cs @@ -15,6 +15,7 @@ namespace CoreGame.Logic s_LogicContext = context; s_LogicCommandDescs[(int)FrameCmdDef.MoveDir] = new MoveDirectionDesc(); s_LogicCommandDescs[(int)FrameCmdDef.ChangeShootDir] = new ChangeShootDirDesc(); + s_LogicCommandDescs[(int)FrameCmdDef.MovePoint] = new MovePosDesc(); } public static void UnInit() diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/Service/LEntityCreatorSvc.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/Service/LEntityCreatorSvc.cs index 685318d5..477ddfac 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/Service/LEntityCreatorSvc.cs +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Logic/Service/LEntityCreatorSvc.cs @@ -43,7 +43,7 @@ namespace CoreGame.Logic ce.AddLogicTransform(playerInfo.GetPos(), Fixed64Vector2.one, Fixed64Vector2.right); ce.AddNav(true); ce.AddProperty(); - ce.property.SetProperty(PropertyDef.SpeedFixedIncrease, 20, true); + ce.property.SetProperty(PropertyDef.SpeedFixedIncrease, 9999999, true); ce.AddBallBag(Fixed64._0_10, Fixed64Vector2.up); BallSvc.FillBall(ce); diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/JoystickProxy.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/JoystickProxy.cs index 3fb07743..09b9395d 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/JoystickProxy.cs +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/JoystickProxy.cs @@ -16,6 +16,8 @@ namespace CoreGame.Render public override void Sync2Proxy() { input = m_Render.input; + //todo : guo + m_Render.input = Vector2.zero; } diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/FrameCommand/RenderCommandSvc.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/FrameCommand/RenderCommandSvc.cs index 001a8980..3310de58 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/FrameCommand/RenderCommandSvc.cs +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/FrameCommand/RenderCommandSvc.cs @@ -22,6 +22,7 @@ namespace CoreGame.Render { s_CommandCreator[(int)FrameCmdDef.MoveDir] = MoveDirectionCmd.Creator; s_CommandCreator[(int)FrameCmdDef.ChangeShootDir] = ChangeShootDirCmd.Creator; + s_CommandCreator[(int)FrameCmdDef.MovePoint] = MovePosCmd.Creator; diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Input/InputSystem.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Input/InputSystem.cs index 4fce755f..98ae7cd4 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Input/InputSystem.cs +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Input/InputSystem.cs @@ -32,26 +32,30 @@ namespace CoreGame.Render.System if (combinePos.magnitude > 0.01) { - var atan2 = Math.Atan2(combinePos.y, combinePos.x); - var angle = atan2 * 180 / Math.PI; + var movePosCmd = RenderCommandSvc.CreateFrameCommand(); + movePosCmd.x = (int)(combinePos.x * 100); + movePosCmd.y = (int)(combinePos.y * 100); + movePosCmd.SendAndFree(localPlayerEntHandle); + // var atan2 = Math.Atan2(combinePos.y, combinePos.x); + // var angle = atan2 * 180 / Math.PI; - var moveDirectionCommand = RenderCommandSvc.CreateFrameCommand(); - moveDirectionCommand.Degree = (short)angle; - moveDirectionCommand.nSeq = m_InputSeq++; - moveDirectionCommand.SendAndFree(localPlayerEntHandle); - m_isMoving = true; - } - else - { - if (m_isMoving) - { - var moveDirectionCommand = RenderCommandSvc.CreateFrameCommand(); - moveDirectionCommand.Degree = int.MaxValue; - moveDirectionCommand.nSeq = m_InputSeq++; - moveDirectionCommand.SendAndFree(localPlayerEntHandle); - } - m_isMoving = false; + // var moveDirectionCommand = RenderCommandSvc.CreateFrameCommand(); + // moveDirectionCommand.Degree = (short)angle; + // moveDirectionCommand.nSeq = m_InputSeq++; + // moveDirectionCommand.SendAndFree(localPlayerEntHandle); + // m_isMoving = true; } + // else + // { + // if (m_isMoving) + // { + // var moveDirectionCommand = RenderCommandSvc.CreateFrameCommand(); + // moveDirectionCommand.Degree = int.MaxValue; + // moveDirectionCommand.nSeq = m_InputSeq++; + // moveDirectionCommand.SendAndFree(localPlayerEntHandle); + // } + // m_isMoving = false; + // } NetMsgGateway.Instance.GameTick(); diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/View/JoystickRender.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/View/JoystickRender.cs index 0abfc1f4..9e44d2ac 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/View/JoystickRender.cs +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/View/JoystickRender.cs @@ -19,6 +19,7 @@ namespace CoreGame.Render private RectTransform m_BaseRect; private Canvas m_Canvas; private Vector2 m_StartPos = Vector2.zero; + private Vector2 m_StartPosInWorld = Vector2.zero; private bool m_IsPointDown; private Camera m_UICamera; @@ -65,6 +66,7 @@ namespace CoreGame.Render m_IsForcePointerUp = false; background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position); m_StartPos = eventData.position; + m_StartPosInWorld = m_UICamera.ScreenToWorldPoint(eventData.position); // if (BattleModule.Instance.worldType == WorldType.Community) // { // if (m_JoystickCanvasCoroutine != null) @@ -108,9 +110,12 @@ namespace CoreGame.Render Vector2 position = background.anchoredPosition; Vector2 radius = background.sizeDelta / 2; + Vector2 worldPoint = m_UICamera.ScreenToWorldPoint(eventData.position); var posVector2 = ScreenPointToAnchoredPosition(eventData.position); - input = (posVector2 - position) / (radius * m_Canvas.scaleFactor); - HandleInput(input.magnitude, input.normalized); + // input = (posVector2 - position) / (radius * m_Canvas.scaleFactor); + input = eventData.delta; + m_StartPosInWorld = worldPoint; + // HandleInput(input.magnitude, input.normalized); handle.anchoredPosition = input * radius * handleRange; } diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs new file mode 100644 index 00000000..628b3a62 --- /dev/null +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs @@ -0,0 +1,36 @@ +using AOT; +using ProtoCSClass; + +namespace CoreGame.Shared +{ + [FrameCommandClass(FrameCmdDef.MovePoint)] + public class MovePosCmd : BaseCommand, ISptPool + { + public int x; + public int y; + + public static BaseCommand Creator(ref CSPlayerOpInfo msg) + { + MovePosCmd frameCmd = null; + SptPool.Malloc(ref frameCmd); + frameCmd.x = msg.MovePoint.X; + frameCmd.y = msg.MovePoint.Y; + return frameCmd; + } + protected override void ToProtocol2(ref CSPlayerOpInfo msg) + { + msg.MovePoint.X = x; + msg.MovePoint.Y = y; + } + + public void Reset() + { + + } + + public override string ToString() + { + return $"{base.ToString()}: x:{x}, y:{y}"; + } + } +} \ No newline at end of file diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs.meta b/client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs.meta new file mode 100644 index 00000000..b0bc4215 --- /dev/null +++ b/client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2d30ec0409634a83a4c4f04d2accc710 +timeCreated: 1753458572 \ No newline at end of file diff --git a/client/client/Assets/Scripts/CoreGame/WorldPacks.meta b/client/client/Assets/Scripts/CoreGame/WorldPacks.meta deleted file mode 100644 index 5b91659d..00000000 --- a/client/client/Assets/Scripts/CoreGame/WorldPacks.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 640393e0062d48ef9b4114d1703419cb -timeCreated: 1729759069 \ No newline at end of file