修复技能输入并更新战斗资源
This commit is contained in:
@@ -46,9 +46,9 @@ namespace XGame
|
||||
private const float JoystickPadding = 100.0f;
|
||||
private const float JoystickDeadZone = 0.18f;
|
||||
private const float JoystickAcquireRadiusMultiplier = 1.6f;
|
||||
private const float CameraMinDistance = 2.0f;
|
||||
private const float CameraMaxDistance = 8f;
|
||||
private const float CameraDefaultDistance = 4.5f;
|
||||
private const float CameraMinDistance = 4.0f;
|
||||
private const float CameraMaxDistance = 15f;
|
||||
private const float CameraDefaultDistance = 6.0f;
|
||||
private const float CameraMinPitch = 20f;
|
||||
private const float CameraMaxPitch = 75f;
|
||||
private const float CameraMouseOrbitSensitivity = 0.2f;
|
||||
@@ -102,6 +102,9 @@ namespace XGame
|
||||
private bool actionPadLoading;
|
||||
private bool actorBehaviorCatalogLoading;
|
||||
private bool actorBehaviorCatalogLoaded;
|
||||
private bool hasPendingActionButtonEvent;
|
||||
private ActionButtonEvent pendingActionButtonEvent;
|
||||
private Vector3 pendingActionButtonForward;
|
||||
private static int materialLogCount;
|
||||
|
||||
public void Initialize(Action<FrameworkOpcode, byte[]> sendFramework, int playerId, string playerName, int figure)
|
||||
@@ -453,6 +456,11 @@ namespace XGame
|
||||
|
||||
private Vector3 GetMoveDirection()
|
||||
{
|
||||
if (IsSelfBehaviorActive())
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
Camera cam = Camera.main;
|
||||
Vector3 forward = cam != null ? cam.transform.forward : Vector3.forward;
|
||||
Vector3 right = cam != null ? cam.transform.right : Vector3.right;
|
||||
@@ -466,6 +474,12 @@ namespace XGame
|
||||
Input.GetKey(KeyCode.D));
|
||||
}
|
||||
|
||||
private bool IsSelfBehaviorActive()
|
||||
{
|
||||
return actorBehaviorRuntime != null
|
||||
&& actorBehaviorRuntime.HasActiveBehavior(selfPlayerId);
|
||||
}
|
||||
|
||||
public static Vector3 MapMoveInputForTest(
|
||||
Vector2 joystickInput,
|
||||
Vector3 cameraForward,
|
||||
@@ -1008,6 +1022,7 @@ namespace XGame
|
||||
actorBehaviorRuntime.RegisterCatalog(catalog);
|
||||
actorBehaviorCatalogLoaded = true;
|
||||
UpdateActorBehaviorActors();
|
||||
ConsumePendingActionButtonEvent();
|
||||
}
|
||||
|
||||
private void RegisterActorBehavior(Avatar avatar)
|
||||
@@ -1164,19 +1179,52 @@ namespace XGame
|
||||
{
|
||||
if (LobbyActorBehaviorRuntime.IsSecondaryATrigger(evt))
|
||||
{
|
||||
QueuePendingActionButtonEvent(evt, GetSelfSkillForward());
|
||||
Debug.LogWarning("[LobbyWorldController] actor behavior catalog is not ready.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BehaviorStartResult result = actorBehaviorRuntime.HandleActionButton(evt, selfPlayerId, GetSelfSkillForward());
|
||||
HandleReadyActionButtonEvent(evt, GetSelfSkillForward());
|
||||
}
|
||||
|
||||
private void QueuePendingActionButtonEvent(ActionButtonEvent evt, Vector3 fallbackForward)
|
||||
{
|
||||
if (hasPendingActionButtonEvent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hasPendingActionButtonEvent = true;
|
||||
pendingActionButtonEvent = evt;
|
||||
pendingActionButtonForward = fallbackForward;
|
||||
}
|
||||
|
||||
private void ConsumePendingActionButtonEvent()
|
||||
{
|
||||
if (!hasPendingActionButtonEvent || !actorBehaviorCatalogLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActionButtonEvent evt = pendingActionButtonEvent;
|
||||
Vector3 fallbackForward = pendingActionButtonForward;
|
||||
hasPendingActionButtonEvent = false;
|
||||
pendingActionButtonEvent = default;
|
||||
pendingActionButtonForward = Vector3.zero;
|
||||
HandleReadyActionButtonEvent(evt, fallbackForward);
|
||||
}
|
||||
|
||||
private void HandleReadyActionButtonEvent(ActionButtonEvent evt, Vector3 fallbackForward)
|
||||
{
|
||||
BehaviorStartResult result = actorBehaviorRuntime.HandleActionButton(evt, selfPlayerId, fallbackForward);
|
||||
if (result.Success)
|
||||
{
|
||||
DrainActorBehaviorEvents();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.Error != "button ignored")
|
||||
if (result.Error != "button ignored" && result.Error != "actor already has active behavior")
|
||||
{
|
||||
Debug.LogWarning("[LobbyWorldController] start behavior failed: " + result.Error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user