diff --git a/Assets/Scripts/CollisionManager.cs b/Assets/Scripts/CollisionManager.cs index f6db80a..56250e7 100644 --- a/Assets/Scripts/CollisionManager.cs +++ b/Assets/Scripts/CollisionManager.cs @@ -94,7 +94,7 @@ namespace Marro.PacManUdon if (!frozen && tile == pacManPosition) { - Debug.Log("Ghost hit PacMan!"); + //Debug.Log("Ghost hit PacMan!"); ghosts[ghostIndex].HitPacMan(); } @@ -128,7 +128,7 @@ namespace Marro.PacManUdon if (ghosts[i].HitPacMan()) // Only one collision may happen at a time { - Debug.Log("PacMan hit ghost!"); + //Debug.Log("PacMan hit ghost!"); return; } } diff --git a/Assets/Scripts/Ghost.cs b/Assets/Scripts/Ghost.cs index b19614c..deef668 100644 --- a/Assets/Scripts/Ghost.cs +++ b/Assets/Scripts/Ghost.cs @@ -602,12 +602,12 @@ namespace Marro.PacManUdon if (isScared) { - Debug.Log($"{gameObject} was cought!"); + //Debug.Log($"{gameObject} was cought!"); ghostManager.GhostCaught(this); return true; } - Debug.Log($"{gameObject} cought PacMan!"); + //Debug.Log($"{gameObject} cought PacMan!"); ghostManager.CapturedPacMan(); return true; } @@ -725,7 +725,6 @@ namespace Marro.PacManUdon if (ghostState == PacManGhostState.CaughtScore) { ReturnHome(); // Return home when unfreezing after being caught - collisionManager.PacManTryEatGhost(); // We may have skipped collisions while frozen } } diff --git a/Assets/Scripts/NetworkManager.cs b/Assets/Scripts/NetworkManager.cs index d8d314c..5ad5d10 100644 --- a/Assets/Scripts/NetworkManager.cs +++ b/Assets/Scripts/NetworkManager.cs @@ -327,7 +327,7 @@ namespace Marro.PacManUdon obj.networkManager = this; } - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Found {syncedUpdateSubscribers.Length} {nameof(SyncedObject)} in children of {root.name}."); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Found {syncedUpdateSubscribers.Length} {nameof(SyncedObject)} in children of {root.name}."); const int eventTypeCount = byte.MaxValue + 1; @@ -375,7 +375,7 @@ namespace Marro.PacManUdon RequestEvent(NetworkEventType.FullSync); } - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized"); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized"); } public void Update() @@ -567,7 +567,7 @@ namespace Marro.PacManUdon QueueEventInBuffer(data); - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event of type {eventType} with {data.Length} bytes, timestamp {timestamp} and id {eventId} for serialization."); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event of type {eventType} with {data.Length} bytes, timestamp {timestamp} and id {eventId} for serialization."); RequestSerializationForEvents(); @@ -647,7 +647,7 @@ namespace Marro.PacManUdon serializationRequested = false; - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serializing {eventsQueueIndex} event(s), eventTransmissionHistory is now {ArrayToString(eventTransmissionHistory)} with index {eventTransmissionHistoryIndex}"); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serializing {eventsQueueIndex} event(s), eventTransmissionHistory is now {ArrayToString(eventTransmissionHistory)} with index {eventTransmissionHistoryIndex}"); } public override void OnPostSerialization(SerializationResult result) => OnPostSerializationInternal(result.success, result.byteCount); @@ -666,7 +666,7 @@ namespace Marro.PacManUdon return; } - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serialized with {networkedData.Length} bytes.\nBytes sent:\n{ArrayToString(networkedData)}"); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serialized with {networkedData.Length} bytes.\nBytes sent:\n{ArrayToString(networkedData)}"); // Remove data from the buffer that no longer needs to be (re)transmitted DequeueEventsFromBuffer(eventTransmissionHistory[eventTransmissionHistoryIndex]); @@ -711,7 +711,7 @@ namespace Marro.PacManUdon return; // Nothing to store } - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{ArrayToString(networkedData)}"); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{ArrayToString(networkedData)}"); var length = networkedData.Length; int index = 0; @@ -798,7 +798,7 @@ namespace Marro.PacManUdon hasFullSyncReady = true; - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Queued full sync in buffer, should execute at {nextEventTime}."); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Queued full sync in buffer, should execute at {nextEventTime}."); } private void ApplyReceivedEvents() @@ -842,7 +842,7 @@ namespace Marro.PacManUdon var subscribers = GetEventSubscribers(eventType); - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) ApplyEvent with dt {SyncedDeltaTime}"); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) ApplyEvent with dt {SyncedDeltaTime}"); if (subscribers != null) { @@ -878,7 +878,7 @@ namespace Marro.PacManUdon Synced = true; } - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Performed incoming event of type {eventType}! Total {index} bytes."); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Performed incoming event of type {eventType}! Total {index} bytes."); retriesWithoutSuccess = 0; // We had success! @@ -970,7 +970,7 @@ namespace Marro.PacManUdon SyncedTime = SyncedTimeTicks * tickDelta; nextEventTime = timestamp; - Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to timestamp {timestamp}, internalTime is now {targetTicks}, SyncedTime is now {SyncedTime}, nextEventTime is now {nextEventTime}"); + //Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to timestamp {timestamp}, internalTime is now {targetTicks}, SyncedTime is now {SyncedTime}, nextEventTime is now {nextEventTime}"); } private void UpdateNextEventTime() diff --git a/Assets/Scripts/PacMan.cs b/Assets/Scripts/PacMan.cs index 71c8ed1..de5d381 100644 --- a/Assets/Scripts/PacMan.cs +++ b/Assets/Scripts/PacMan.cs @@ -216,7 +216,7 @@ namespace Marro.PacManUdon protected override void UpdateAnimator() { - Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}"); + //Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}"); if (!gameObject.activeInHierarchy) return; diff --git a/Assets/Scripts/PlayerInput.asset b/Assets/Scripts/PlayerInput.asset index 6fbd896..a727c3e 100644 --- a/Assets/Scripts/PlayerInput.asset +++ b/Assets/Scripts/PlayerInput.asset @@ -43,7 +43,7 @@ MonoBehaviour: Data: - Name: Entry: 12 - Data: 10 + Data: 11 - Name: Entry: 7 Data: @@ -217,31 +217,25 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: resultInput + Data: player - Name: $v Entry: 7 Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: resultInput + Data: player - Name: k__BackingField Entry: 7 Data: 13|System.RuntimeType, mscorlib - Name: Entry: 1 - Data: Marro.PacManUdon.Direction, Assembly-CSharp + Data: VRC.SDKBase.VRCPlayerApi, VRCSDKBase - Name: Entry: 8 Data: - Name: k__BackingField - Entry: 7 - Data: 14|System.RuntimeType, mscorlib - - Name: - Entry: 1 - Data: System.Int32, mscorlib - - Name: - Entry: 8 - Data: + Entry: 9 + Data: 13 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -256,7 +250,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 0 @@ -277,19 +271,25 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: inputHorizontal + Data: inputMethod - Name: $v Entry: 7 - Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: inputHorizontal + Data: inputMethod - Name: k__BackingField - Entry: 9 - Data: 13 + Entry: 6 + Data: - Name: k__BackingField - Entry: 9 - Data: 14 + Entry: 7 + Data: 16|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Int32, mscorlib + - Name: + Entry: 8 + Data: - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -325,19 +325,25 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: inputVertical + Data: resultInput - Name: $v Entry: 7 Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: inputVertical + Data: resultInput - Name: k__BackingField - Entry: 9 - Data: 13 + Entry: 7 + Data: 19|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: Marro.PacManUdon.Direction, Assembly-CSharp + - Name: + Entry: 8 + Data: - Name: k__BackingField Entry: 9 - Data: 14 + Data: 16 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -352,7 +358,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 0 @@ -373,25 +379,19 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: horizontalValue + Data: inputHorizontal - Name: $v Entry: 7 - Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: horizontalValue + Data: inputHorizontal - Name: k__BackingField - Entry: 7 - Data: 21|System.RuntimeType, mscorlib - - Name: - Entry: 1 - Data: System.Single, mscorlib - - Name: - Entry: 8 - Data: + Entry: 9 + Data: 19 - Name: k__BackingField Entry: 9 - Data: 21 + Data: 16 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -427,19 +427,19 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: verticalValue + Data: inputVertical - Name: $v Entry: 7 Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: verticalValue + Data: inputVertical - Name: k__BackingField Entry: 9 - Data: 21 + Data: 19 - Name: k__BackingField Entry: 9 - Data: 21 + Data: 16 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -475,19 +475,25 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: horizontalPriority + Data: horizontalValue - Name: $v Entry: 7 Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: horizontalPriority + Data: horizontalValue - Name: k__BackingField - Entry: 9 - Data: 7 + Entry: 7 + Data: 26|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Single, mscorlib + - Name: + Entry: 8 + Data: - Name: k__BackingField Entry: 9 - Data: 7 + Data: 26 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -502,7 +508,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 0 @@ -523,25 +529,19 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: player + Data: verticalValue - Name: $v Entry: 7 - Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: player + Data: verticalValue - Name: k__BackingField - Entry: 7 - Data: 28|System.RuntimeType, mscorlib - - Name: - Entry: 1 - Data: VRC.SDKBase.VRCPlayerApi, VRCSDKBase - - Name: - Entry: 8 - Data: + Entry: 9 + Data: 26 - Name: k__BackingField Entry: 9 - Data: 28 + Data: 26 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -572,6 +572,54 @@ MonoBehaviour: - Name: Entry: 8 Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: horizontalPriority + - Name: $v + Entry: 7 + Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: horizontalPriority + - Name: k__BackingField + Entry: 9 + Data: 7 + - Name: k__BackingField + Entry: 9 + Data: 7 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: diff --git a/Assets/Scripts/PlayerInput.cs b/Assets/Scripts/PlayerInput.cs index b851009..1c63d4c 100644 --- a/Assets/Scripts/PlayerInput.cs +++ b/Assets/Scripts/PlayerInput.cs @@ -5,17 +5,27 @@ using VRC.SDKBase; using VRC.Udon.Common; + enum InputMethod + { + KeyboardMouse, + Other, + } + public class PlayerInput : SyncedObject { public bool active; + private GameManager gameManager; - Direction resultInput; - Direction inputHorizontal; - Direction inputVertical; - float horizontalValue; - float verticalValue; - bool horizontalPriority; - VRCPlayerApi player; + + private VRCPlayerApi player; + private InputMethod inputMethod; + + private Direction resultInput; + private Direction inputHorizontal; + private Direction inputVertical; + private float horizontalValue; + private float verticalValue; + private bool horizontalPriority; public void Initialize(GameManager gameManager) { @@ -143,11 +153,29 @@ // Debug.Log("Vertical Input Event: " + value + " | Direction: " + direction + " | lastDirection : " + lastDirection); } + public override void OnInputMethodChanged(VRCInputMethod inputMethod) + { + switch (inputMethod) + { + case VRCInputMethod.Keyboard: + case VRCInputMethod.Mouse: + this.inputMethod = InputMethod.KeyboardMouse; + return; + default: + this.inputMethod = InputMethod.Other; + return; + } + } + private void SetPriority(bool horizontalPriority) { if (this.horizontalPriority != horizontalPriority) { - player.PlayHapticEventInHand(VRC_Pickup.PickupHand.Left, 0.1f, 0.15f, 75); + if (inputMethod != InputMethod.KeyboardMouse) + { + player.PlayHapticEventInHand(VRC_Pickup.PickupHand.Left, 0.1f, 0.15f, 75); + } + this.horizontalPriority = horizontalPriority; } } diff --git a/Assets/Test stuff/NetworkManagerTester.cs b/Assets/Test stuff/NetworkManagerTester.cs index 92081d7..5fb6cea 100644 --- a/Assets/Test stuff/NetworkManagerTester.cs +++ b/Assets/Test stuff/NetworkManagerTester.cs @@ -43,7 +43,7 @@ public class NetworkManagerTester : UdonSharpBehaviour var data = PerformSerialization(source); - Debug.Log($"{nameof(NetworkManagerTester)} Transferring {data.Length} bytes."); + //Debug.Log($"{nameof(NetworkManagerTester)} Transferring {data.Length} bytes."); foreach (var target in networkManagers) { @@ -91,7 +91,7 @@ public class NetworkManagerTester : UdonSharpBehaviour continue; } - Debug.Log($"{nameof(NetworkManagerTester)} Requested event with type {eventType}."); + //Debug.Log($"{nameof(NetworkManagerTester)} Requested event with type {eventType}."); target.RequestEventReceived(eventType); }