Browse Source

滑屏

master
jiannan.guo@yingxiong.com 1 month ago
parent
commit
1b50728e68
  1. 4
      client/client/Assets/RawResources/Model/Joystick.prefab
  2. 6
      client/client/Assets/Scenes/BattleEditor.unity
  3. 34
      client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs
  4. 3
      client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs.meta
  5. 1
      client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/LogicCommandSvc.cs
  6. 2
      client/client/Assets/Scripts/CoreGame/AFramSync/Logic/Service/LEntityCreatorSvc.cs
  7. 2
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/JoystickProxy.cs
  8. 1
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/FrameCommand/RenderCommandSvc.cs
  9. 42
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Input/InputSystem.cs
  10. 9
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/View/JoystickRender.cs
  11. 36
      client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs
  12. 3
      client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs.meta
  13. 3
      client/client/Assets/Scripts/CoreGame/WorldPacks.meta

4
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

6
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:

34
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<LogicEntity> 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);
}
}
}

3
client/client/Assets/Scripts/CoreGame/AFramSync/Logic/FrameCommand/Desc/MovePosDesc.cs.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 07a3da7eb5184569aaf0561f8efb6f67
timeCreated: 1753458825

1
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()

2
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);

2
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;
}

1
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;

42
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 moveDirectionCommand = RenderCommandSvc.CreateFrameCommand<MoveDirectionCmd>();
moveDirectionCommand.Degree = (short)angle;
moveDirectionCommand.nSeq = m_InputSeq++;
moveDirectionCommand.SendAndFree(localPlayerEntHandle);
m_isMoving = true;
}
else
{
if (m_isMoving)
{
var moveDirectionCommand = RenderCommandSvc.CreateFrameCommand<MoveDirectionCmd>();
moveDirectionCommand.Degree = int.MaxValue;
moveDirectionCommand.nSeq = m_InputSeq++;
moveDirectionCommand.SendAndFree(localPlayerEntHandle);
}
m_isMoving = false;
var movePosCmd = RenderCommandSvc.CreateFrameCommand<MovePosCmd>();
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<MoveDirectionCmd>();
// moveDirectionCommand.Degree = (short)angle;
// moveDirectionCommand.nSeq = m_InputSeq++;
// moveDirectionCommand.SendAndFree(localPlayerEntHandle);
// m_isMoving = true;
}
// else
// {
// if (m_isMoving)
// {
// var moveDirectionCommand = RenderCommandSvc.CreateFrameCommand<MoveDirectionCmd>();
// moveDirectionCommand.Degree = int.MaxValue;
// moveDirectionCommand.nSeq = m_InputSeq++;
// moveDirectionCommand.SendAndFree(localPlayerEntHandle);
// }
// m_isMoving = false;
// }
NetMsgGateway.Instance.GameTick();

9
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;
}

36
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<MovePosCmd>.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}";
}
}
}

3
client/client/Assets/Scripts/CoreGame/AFramSync/Shared/FrameCommand/Data/MovePosCmd.cs.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2d30ec0409634a83a4c4f04d2accc710
timeCreated: 1753458572

3
client/client/Assets/Scripts/CoreGame/WorldPacks.meta

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 640393e0062d48ef9b4114d1703419cb
timeCreated: 1729759069
Loading…
Cancel
Save