Compare commits
23 Commits
74e6493108
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 42f9e2ee9d | |||
| 8255eb8b99 | |||
| 2f18464e71 | |||
| ad605bcab3 | |||
| 3be8d2f6a6 | |||
| 875d0ad5f0 | |||
| 378d6bc7a7 | |||
| 540cfe16ab | |||
| b688b4739b | |||
| 1252933ca4 | |||
| d6b870de79 | |||
| 8a6f1b482b | |||
| 18499ab576 | |||
| a32df1bd09 | |||
| d739c9d7b5 | |||
| 4ba203b1de | |||
| 7f87a9779b | |||
| 99556b81b1 | |||
| ca116ac77f | |||
| e431dab042 | |||
| cb975c24b2 | |||
| a4733b33b8 | |||
| 95bbbcc5e2 |
+30
-88
@@ -4023,7 +4023,7 @@ MonoBehaviour:
|
|||||||
pacMan: {fileID: 7714172614521704433}
|
pacMan: {fileID: 7714172614521704433}
|
||||||
ghostManager: {fileID: 86024623784576607}
|
ghostManager: {fileID: 86024623784576607}
|
||||||
bonusFruit: {fileID: 9157969083631739240}
|
bonusFruit: {fileID: 9157969083631739240}
|
||||||
pelletManager: {fileID: 5525660384197170489}
|
collisionManager: {fileID: 5525660384197170489}
|
||||||
statusDisplay: {fileID: 2491098304099187056}
|
statusDisplay: {fileID: 2491098304099187056}
|
||||||
attractScreen: {fileID: 775310085919228412}
|
attractScreen: {fileID: 775310085919228412}
|
||||||
intermissionScreen: {fileID: 5421513610437161912}
|
intermissionScreen: {fileID: 5421513610437161912}
|
||||||
@@ -7208,8 +7208,8 @@ Transform:
|
|||||||
m_GameObject: {fileID: 3147892916020834424}
|
m_GameObject: {fileID: 3147892916020834424}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -21.5, y: -0.5, z: 0}
|
m_LocalPosition: {x: -16.5, y: -0.5, z: 0}
|
||||||
m_LocalScale: {x: 3, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 3555002988650332767}
|
m_Father: {fileID: 3555002988650332767}
|
||||||
@@ -9785,7 +9785,7 @@ MonoBehaviour:
|
|||||||
_udonSharpBackingUdonBehaviour: {fileID: 1180286844452673728}
|
_udonSharpBackingUdonBehaviour: {fileID: 1180286844452673728}
|
||||||
networkManager: {fileID: 0}
|
networkManager: {fileID: 0}
|
||||||
root: {fileID: 6505452106475299050}
|
root: {fileID: 6505452106475299050}
|
||||||
delay: 50
|
delay: 1
|
||||||
maxEventSendTries: 3
|
maxEventSendTries: 3
|
||||||
pingDelay: 15
|
pingDelay: 15
|
||||||
tickDelta: 0.016666668
|
tickDelta: 0.016666668
|
||||||
@@ -10013,8 +10013,8 @@ Transform:
|
|||||||
m_GameObject: {fileID: 4219034801460140058}
|
m_GameObject: {fileID: 4219034801460140058}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 21.5, y: -0.5, z: -0}
|
m_LocalPosition: {x: 16.5, y: -0.5, z: 0}
|
||||||
m_LocalScale: {x: 3, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 3555002988650332767}
|
m_Father: {fileID: 3555002988650332767}
|
||||||
@@ -13286,8 +13286,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 6046534300734189827}
|
m_GameObject: {fileID: 6046534300734189827}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0.707061, y: -0, z: -0, w: 0.70715266}
|
||||||
m_LocalPosition: {x: 0, y: 6.63, z: -17.23}
|
m_LocalPosition: {x: 0.91, y: 6.63, z: -17.23}
|
||||||
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
@@ -13298,7 +13298,7 @@ Transform:
|
|||||||
- {fileID: 7739671690796916192}
|
- {fileID: 7739671690796916192}
|
||||||
- {fileID: 8246186970405181641}
|
- {fileID: 8246186970405181641}
|
||||||
m_Father: {fileID: 4412758497759775873}
|
m_Father: {fileID: 4412758497759775873}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
|
||||||
--- !u!1 &6154585327471317047
|
--- !u!1 &6154585327471317047
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -17723,7 +17723,7 @@ MonoBehaviour:
|
|||||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
m_IntArgument: 0
|
m_IntArgument: 0
|
||||||
m_FloatArgument: 0
|
m_FloatArgument: 0
|
||||||
m_StringArgument: Intermission3
|
m_StringArgument: JumpToTimeSequenceIntermission3
|
||||||
m_BoolArgument: 0
|
m_BoolArgument: 0
|
||||||
m_CallState: 2
|
m_CallState: 2
|
||||||
--- !u!1 &8473082740403796940
|
--- !u!1 &8473082740403796940
|
||||||
@@ -18064,7 +18064,6 @@ Transform:
|
|||||||
- {fileID: 4974322025078650459}
|
- {fileID: 4974322025078650459}
|
||||||
- {fileID: 8663222629720968739}
|
- {fileID: 8663222629720968739}
|
||||||
- {fileID: 5905242471040052083}
|
- {fileID: 5905242471040052083}
|
||||||
- {fileID: 7572300588514824209}
|
|
||||||
- {fileID: 1307805930192074193}
|
- {fileID: 1307805930192074193}
|
||||||
- {fileID: 8119785692059435336}
|
- {fileID: 8119785692059435336}
|
||||||
- {fileID: 862107006485386518}
|
- {fileID: 862107006485386518}
|
||||||
@@ -21302,7 +21301,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 2100000, guid: 27754be47f0109d4ebd0238a3abcab08, type: 2}
|
objectReference: {fileID: 2100000, guid: 27754be47f0109d4ebd0238a3abcab08, type: 2}
|
||||||
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_Enabled
|
propertyPath: m_Enabled
|
||||||
@@ -21342,7 +21341,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 0
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6697301723706685617, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 6697301723706685617, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
@@ -35338,7 +35337,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 2100000, guid: d77dfda7d2b90ea4983b8659e2c6c0e9, type: 2}
|
objectReference: {fileID: 2100000, guid: d77dfda7d2b90ea4983b8659e2c6c0e9, type: 2}
|
||||||
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: _syncMethod
|
propertyPath: _syncMethod
|
||||||
@@ -35374,7 +35373,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 0
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6697301723706685617, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 6697301723706685617, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
@@ -38846,7 +38845,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 2100000, guid: 60dca779cada8784ab66dba8be5a3187, type: 2}
|
objectReference: {fileID: 2100000, guid: 60dca779cada8784ab66dba8be5a3187, type: 2}
|
||||||
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: _syncMethod
|
propertyPath: _syncMethod
|
||||||
@@ -38882,7 +38881,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 0
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6697301723706685617, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 6697301723706685617, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
@@ -44975,6 +44974,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Pellet
|
value: Pellet
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7512162431685415002, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||||
|
propertyPath: pelletRenderer
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 6717290563504616900}
|
||||||
- target: {fileID: 7512162431685415002, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
- target: {fileID: 7512162431685415002, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||||
propertyPath: serializationData.Prefab
|
propertyPath: serializationData.Prefab
|
||||||
value:
|
value:
|
||||||
@@ -44993,6 +44996,11 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||||
m_PrefabInstance: {fileID: 5788101997426616030}
|
m_PrefabInstance: {fileID: 5788101997426616030}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!212 &6717290563504616900 stripped
|
||||||
|
SpriteRenderer:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 967117457436250906, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 5788101997426616030}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &5818701876316508941
|
--- !u!1001 &5818701876316508941
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -56274,7 +56282,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 1872706630021487550, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 2436955608773050784, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: _syncMethod
|
propertyPath: _syncMethod
|
||||||
@@ -56292,6 +56300,10 @@ PrefabInstance:
|
|||||||
propertyPath: serializationData.Prefab
|
propertyPath: serializationData.Prefab
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 4749455077414662322, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
objectReference: {fileID: 4749455077414662322, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
|
- target: {fileID: 5838653651634851978, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7954158839068841090, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
- target: {fileID: 7954158839068841090, guid: 5cb7233bb90971d45b4f876816f8ca1e, type: 3}
|
||||||
propertyPath: gameStateManager
|
propertyPath: gameStateManager
|
||||||
value:
|
value:
|
||||||
@@ -58768,76 +58780,6 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||||
m_PrefabInstance: {fileID: 8822547946008480523}
|
m_PrefabInstance: {fileID: 8822547946008480523}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &8886851716888325062
|
|
||||||
PrefabInstance:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Modification:
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransformParent: {fileID: 3712504672009017146}
|
|
||||||
m_Modifications:
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: 23.5
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.y
|
|
||||||
value: 22.500011
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: -0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: -0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: -0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4099390335584803315, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: m_Name
|
|
||||||
value: Pellet (132)
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 7512162431685415002, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: serializationData.Prefab
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 7512162431685415002, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
- target: {fileID: 9117212235706742114, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
propertyPath: _syncMethod
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_RemovedGameObjects: []
|
|
||||||
m_AddedGameObjects: []
|
|
||||||
m_AddedComponents: []
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
--- !u!4 &7572300588514824209 stripped
|
|
||||||
Transform:
|
|
||||||
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 8886851716888325062}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
--- !u!1001 &8933059863330629529
|
--- !u!1001 &8933059863330629529
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
+351
-311
File diff suppressed because it is too large
Load Diff
@@ -8,15 +8,16 @@ namespace Marro.PacManUdon
|
|||||||
[RequireComponent(typeof(Renderer))]
|
[RequireComponent(typeof(Renderer))]
|
||||||
public class BonusFruit : SyncedObject
|
public class BonusFruit : SyncedObject
|
||||||
{
|
{
|
||||||
PacManFruitType fruitType;
|
private PacManFruitType fruitType;
|
||||||
|
|
||||||
Animator animator;
|
private Animator animator;
|
||||||
new Renderer renderer;
|
private new Renderer renderer;
|
||||||
ScoreBonusDisplay scoreBonusDisplay;
|
private ScoreBonusDisplay scoreBonusDisplay;
|
||||||
|
|
||||||
[UdonSynced] bool active;
|
private bool active;
|
||||||
private int value;
|
|
||||||
private float activeCountdown;
|
private float activeCountdown;
|
||||||
|
|
||||||
|
private int value;
|
||||||
private bool frozen;
|
private bool frozen;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
@@ -30,13 +31,15 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void SyncedUpdate()
|
public override void SyncedUpdate()
|
||||||
{
|
{
|
||||||
if (active && !frozen)
|
if (!active || frozen)
|
||||||
{
|
{
|
||||||
activeCountdown -= networkManager.SyncedDeltaTime;
|
return;
|
||||||
if (activeCountdown <= 0)
|
}
|
||||||
{
|
|
||||||
SetActive(false);
|
activeCountdown -= networkManager.SyncedDeltaTime;
|
||||||
}
|
if (activeCountdown <= 0)
|
||||||
|
{
|
||||||
|
SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +65,6 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public void SetFruitType(PacManFruitType fruitType)
|
public void SetFruitType(PacManFruitType fruitType)
|
||||||
{
|
{
|
||||||
this.fruitType = fruitType;
|
|
||||||
value = (int)fruitScoreValue[PacManConstants.FruitTypeToValue(fruitType)];
|
value = (int)fruitScoreValue[PacManConstants.FruitTypeToValue(fruitType)];
|
||||||
animator.SetFloat("FruitType", PacManConstants.FruitTypeToValue(fruitType));
|
animator.SetFloat("FruitType", PacManConstants.FruitTypeToValue(fruitType));
|
||||||
}
|
}
|
||||||
@@ -80,31 +82,33 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
|
data.Append(active, ref index);
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.Append(activeCountdown, ref index);
|
||||||
|
data.Append(frozen, ref index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
|
SetActive(data.ReadBool(ref index));
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeCountdown = data.ReadFloat(ref index);
|
||||||
|
frozen = data.ReadBool(ref index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacManFruitType FruitType
|
public bool Active => active;
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetFruitType(value);
|
|
||||||
}
|
|
||||||
get => fruitType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Active
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetActive(value);
|
|
||||||
}
|
|
||||||
get => active;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly DataDictionary fruitScoreValue = new DataDictionary()
|
private readonly DataDictionary fruitScoreValue = new DataDictionary()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 16
|
Data: 18
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data:
|
Data:
|
||||||
@@ -109,25 +109,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: <PelletCollectedCount>k__BackingField
|
Data: gameManager
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: <PelletCollectedCount>k__BackingField
|
Data: gameManager
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 7|System.RuntimeType, mscorlib
|
Data: 7|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Int32, mscorlib
|
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 7
|
Data: 4
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -163,19 +163,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: gameManager
|
Data: bonusFruit
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: gameManager
|
Data: bonusFruit
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 10|System.RuntimeType, mscorlib
|
Data: 10|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
|
Data: Marro.PacManUdon.BonusFruit, Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -217,25 +217,31 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: bonusFruit
|
Data: pellets
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: bonusFruit
|
Data: pellets
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 13|System.RuntimeType, mscorlib
|
Data: 13|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: Marro.PacManUdon.BonusFruit, Assembly-CSharp
|
Data: Marro.PacManUdon.Pellet[], Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 4
|
Data: 14|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: UnityEngine.Component[], UnityEngine.CoreModule
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -250,7 +256,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -271,31 +277,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pellets
|
Data: powerPellets
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pellets
|
Data: powerPellets
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
|
||||||
Data: 16|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: Marro.PacManUdon.Pellet[], Assembly-CSharp
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 17|System.RuntimeType, mscorlib
|
Data: 17|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: UnityEngine.Component[], UnityEngine.CoreModule
|
Data: UnityEngine.Animator[], UnityEngine.AnimationModule
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 17
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -331,25 +331,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPellets
|
Data: ghosts
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPellets
|
Data: ghosts
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 20|System.RuntimeType, mscorlib
|
Data: 20|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: UnityEngine.Animator[], UnityEngine.AnimationModule
|
Data: Marro.PacManUdon.Ghost[], Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 20
|
Data: 14
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -385,25 +385,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: ghosts
|
Data: collisionMap
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: ghosts
|
Data: collisionMap
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 23|System.RuntimeType, mscorlib
|
Data: 23|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: Marro.PacManUdon.Ghost[], Assembly-CSharp
|
Data: System.Byte[], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 17
|
Data: 23
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -439,19 +439,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkEnabled
|
Data: pelletIndices
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkEnabled
|
Data: pelletIndices
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 26|System.RuntimeType, mscorlib
|
Data: 26|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Boolean, mscorlib
|
Data: System.Int32[], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -493,19 +493,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkToggleInterval
|
Data: powerPelletBlinkEnabled
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkToggleInterval
|
Data: powerPelletBlinkEnabled
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 29|System.RuntimeType, mscorlib
|
Data: 29|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Single, mscorlib
|
Data: System.Boolean, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -547,19 +547,73 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkProgress
|
Data: powerPelletBlinkToggleInterval
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: powerPelletBlinkToggleInterval
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 32|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Single, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 32
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 33|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: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: powerPelletBlinkProgress
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkProgress
|
Data: powerPelletBlinkProgress
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 29
|
Data: 32
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 29
|
Data: 32
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -574,7 +628,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -598,70 +652,16 @@ MonoBehaviour:
|
|||||||
Data: powerPelletBlinkCurrentlyVisible
|
Data: powerPelletBlinkCurrentlyVisible
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 33|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: powerPelletBlinkCurrentlyVisible
|
Data: powerPelletBlinkCurrentlyVisible
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 26
|
Data: 29
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 26
|
Data: 29
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: false
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 34|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: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: syncedPelletsCollected
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: syncedPelletsCollected
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 36|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.Byte[], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 9
|
|
||||||
Data: 36
|
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -697,19 +697,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: collisionMap
|
Data: pelletMap
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: collisionMap
|
Data: pelletMap
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 36
|
Data: 23
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 36
|
Data: 23
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -745,19 +745,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pelletMap
|
Data: syncedPelletsCollected
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pelletMap
|
Data: syncedPelletsCollected
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 36
|
Data: 23
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 36
|
Data: 23
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -793,19 +793,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: ghostPositions
|
Data: pelletCollectedCount
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: ghostPositions
|
Data: pelletCollectedCount
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 43|System.RuntimeType, mscorlib
|
Data: 43|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Int32[], mscorlib
|
Data: System.Byte, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -847,19 +847,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pacManPosition
|
Data: ghostPositions
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pacManPosition
|
Data: ghostPositions
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 7
|
Data: 26
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 7
|
Data: 26
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -890,6 +890,108 @@ MonoBehaviour:
|
|||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: pacManPosition
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 47|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: pacManPosition
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 48|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Int32, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 48
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 49|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: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: frozen
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 50|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: frozen
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 29
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 29
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 51|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:
|
- Name:
|
||||||
Entry: 13
|
Entry: 13
|
||||||
Data:
|
Data:
|
||||||
|
|||||||
@@ -13,31 +13,33 @@ namespace Marro.PacManUdon
|
|||||||
public class CollisionManager : SyncedObject
|
public class CollisionManager : SyncedObject
|
||||||
{
|
{
|
||||||
public int PelletCount => pellets.Length;
|
public int PelletCount => pellets.Length;
|
||||||
public int PelletCollectedCount { get; private set; }
|
|
||||||
|
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
private BonusFruit bonusFruit;
|
private BonusFruit bonusFruit;
|
||||||
|
private Pellet[] pellets;
|
||||||
|
private Animator[] powerPellets;
|
||||||
|
private Ghost[] ghosts;
|
||||||
|
|
||||||
Pellet[] pellets;
|
private byte[] collisionMap;
|
||||||
Animator[] powerPellets;
|
private int[] pelletIndices;
|
||||||
Ghost[] ghosts;
|
|
||||||
|
|
||||||
bool powerPelletBlinkEnabled;
|
private const int mazeWidth = 32;
|
||||||
float powerPelletBlinkToggleInterval;
|
private const int mazeHeight = 32;
|
||||||
float powerPelletBlinkProgress;
|
|
||||||
bool powerPelletBlinkCurrentlyVisible;
|
|
||||||
|
|
||||||
byte[] syncedPelletsCollected;
|
private bool powerPelletBlinkEnabled;
|
||||||
|
private float powerPelletBlinkToggleInterval;
|
||||||
|
private float powerPelletBlinkProgress;
|
||||||
|
private bool powerPelletBlinkCurrentlyVisible;
|
||||||
|
|
||||||
byte[] collisionMap;
|
private byte[] pelletMap;
|
||||||
byte[] pelletMap;
|
private byte[] syncedPelletsCollected;
|
||||||
|
private byte pelletCollectedCount;
|
||||||
const int mazeWidth = 32;
|
|
||||||
const int mazeHeight = 32;
|
|
||||||
|
|
||||||
private int[] ghostPositions = new int[4];
|
private int[] ghostPositions = new int[4];
|
||||||
private int pacManPosition;
|
private int pacManPosition;
|
||||||
|
|
||||||
|
private bool frozen;
|
||||||
|
|
||||||
public void Initialize(GameManager gameManager, BonusFruit bonusFruit, Ghost[] ghosts)
|
public void Initialize(GameManager gameManager, BonusFruit bonusFruit, Ghost[] ghosts)
|
||||||
{
|
{
|
||||||
this.gameManager = gameManager;
|
this.gameManager = gameManager;
|
||||||
@@ -49,13 +51,28 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
powerPellets = GetComponentsInChildren<Animator>(true);
|
powerPellets = GetComponentsInChildren<Animator>(true);
|
||||||
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
|
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
|
||||||
SetPowerPelletsBlink(false);
|
|
||||||
|
|
||||||
collisionMap = PacManConstants.GetMazeCollisionInfo();
|
collisionMap = PacManConstants.GetMazeCollisionInfo();
|
||||||
|
pelletIndices = PacManConstants.GetMazePelletIndices();
|
||||||
|
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
SetPowerPelletsBlink(false);
|
||||||
|
|
||||||
RestoreAllPellets();
|
RestoreAllPellets();
|
||||||
|
}
|
||||||
|
|
||||||
SubscribeToEvent(NetworkEventType.SyncPellets);
|
internal void SetFrozen(bool frozen)
|
||||||
|
{
|
||||||
|
this.frozen = frozen;
|
||||||
|
|
||||||
|
if (!frozen)
|
||||||
|
{
|
||||||
|
SetPowerPelletsBlink(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Collision
|
#region Collision
|
||||||
@@ -74,9 +91,9 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
ghostPositions[ghostIndex] = tile;
|
ghostPositions[ghostIndex] = tile;
|
||||||
|
|
||||||
if (tile == pacManPosition)
|
if (!frozen && tile == pacManPosition)
|
||||||
{
|
{
|
||||||
Debug.Log("Ghost hit PacMan!");
|
//Debug.Log("Ghost hit PacMan!");
|
||||||
ghosts[ghostIndex].HitPacMan();
|
ghosts[ghostIndex].HitPacMan();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,20 +107,28 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
pacManPosition = tilemapIndex;
|
pacManPosition = tilemapIndex;
|
||||||
|
|
||||||
TryEatGhost(tilemapIndex);
|
if (!frozen)
|
||||||
|
{
|
||||||
|
PacManTryEatGhost();
|
||||||
|
}
|
||||||
|
|
||||||
TryCollectFruit(tile, position);
|
TryCollectFruit(tile, position);
|
||||||
return TryCollectPellet(tile, tilemapIndex);
|
return TryCollectPellet(tile, tilemapIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryEatGhost(int tilemapIndex)
|
internal void PacManTryEatGhost()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ghosts.Length; i++)
|
for (int i = 0; i < ghosts.Length; i++)
|
||||||
{
|
{
|
||||||
if (ghostPositions[i] == tilemapIndex)
|
if (ghostPositions[i] != pacManPosition)
|
||||||
{
|
{
|
||||||
Debug.Log("PacMan hit ghost!");
|
continue;
|
||||||
ghosts[i].HitPacMan();
|
}
|
||||||
|
|
||||||
|
if (ghosts[i].HitPacMan()) // Only one collision may happen at a time
|
||||||
|
{
|
||||||
|
//Debug.Log("PacMan hit ghost!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,11 +187,11 @@ namespace Marro.PacManUdon
|
|||||||
var index = pellet.transform.GetSiblingIndex();
|
var index = pellet.transform.GetSiblingIndex();
|
||||||
syncedPelletsCollected[index / 8] |= (byte)(1 << index % 8);
|
syncedPelletsCollected[index / 8] |= (byte)(1 << index % 8);
|
||||||
|
|
||||||
PelletCollectedCount++;
|
pelletCollectedCount++;
|
||||||
|
|
||||||
var pelletType = pellet.isPowerPellet ? EatResult.PowerPellet : EatResult.Pellet;
|
var pelletType = pellet.isPowerPellet ? EatResult.PowerPellet : EatResult.Pellet;
|
||||||
|
|
||||||
gameManager.GotPellet(pellet, pellet.isPowerPellet, PelletCollectedCount, PelletCount - PelletCollectedCount);
|
gameManager.GotPellet(pellet, pellet.isPowerPellet, pelletCollectedCount, PelletCount - pelletCollectedCount);
|
||||||
|
|
||||||
return pelletType;
|
return pelletType;
|
||||||
}
|
}
|
||||||
@@ -179,7 +204,7 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
|
|
||||||
syncedPelletsCollected = new byte[pellets.Length/8 + 1];
|
syncedPelletsCollected = new byte[pellets.Length/8 + 1];
|
||||||
PelletCollectedCount = 0;
|
pelletCollectedCount = 0;
|
||||||
|
|
||||||
pelletMap = PacManConstants.GetMazePelletMap();
|
pelletMap = PacManConstants.GetMazePelletMap();
|
||||||
|
|
||||||
@@ -188,10 +213,11 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
private void SetPelletsCollectedFromSync()
|
private void SetPelletsCollectedFromSync()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < pellets.Length; i++)
|
for (byte i = 0; i < pellets.Length; i++)
|
||||||
{
|
{
|
||||||
var active = (syncedPelletsCollected[i/8] & (byte)(1 << i%8)) == 0;
|
var active = (syncedPelletsCollected[i/8] & (byte)(1 << i%8)) == 0;
|
||||||
pellets[i].gameObject.SetActive(active);
|
pellets[i].gameObject.SetActive(active);
|
||||||
|
pelletMap[pelletIndices[i]] = active ? i : (byte)PacManConsumableType.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -241,26 +267,20 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.SyncPellets)
|
data.Append(pelletCollectedCount, ref index);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.Append((byte)PelletCollectedCount, ref index);
|
|
||||||
data.Append(syncedPelletsCollected, ref index);
|
data.Append(syncedPelletsCollected, ref index);
|
||||||
|
|
||||||
|
data.Append(frozen, ref index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.SyncPellets)
|
pelletCollectedCount = data.ReadByte(ref index);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PelletCollectedCount = data.ReadByte(ref index);
|
|
||||||
Array.Copy(data, index, syncedPelletsCollected, 0, syncedPelletsCollected.Length);
|
Array.Copy(data, index, syncedPelletsCollected, 0, syncedPelletsCollected.Length);
|
||||||
index += syncedPelletsCollected.Length;
|
index += syncedPelletsCollected.Length;
|
||||||
SetPelletsCollectedFromSync();
|
SetPelletsCollectedFromSync();
|
||||||
|
|
||||||
|
frozen = data.ReadBool(ref index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-33
@@ -354,8 +354,8 @@ MonoBehaviour:
|
|||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 3
|
Entry: 6
|
||||||
Data: 1
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -367,13 +367,7 @@ MonoBehaviour:
|
|||||||
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 1
|
Data: 0
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data: 22|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 13
|
Entry: 13
|
||||||
Data:
|
Data:
|
||||||
@@ -391,19 +385,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: value
|
Data: activeCountdown
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: value
|
Data: activeCountdown
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 8
|
Data: 23|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Single, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 8
|
Data: 23
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -439,25 +439,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: activeCountdown
|
Data: value
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: activeCountdown
|
Data: value
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 9
|
||||||
Data: 26|System.RuntimeType, mscorlib
|
Data: 8
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.Single, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 26
|
Data: 8
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -472,7 +466,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -496,7 +490,7 @@ MonoBehaviour:
|
|||||||
Data: frozen
|
Data: frozen
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: frozen
|
Data: frozen
|
||||||
@@ -520,7 +514,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -544,13 +538,13 @@ MonoBehaviour:
|
|||||||
Data: fruitScoreValue
|
Data: fruitScoreValue
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: fruitScoreValue
|
Data: fruitScoreValue
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 31|System.RuntimeType, mscorlib
|
Data: 30|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
|
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
|
||||||
@@ -559,7 +553,7 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 31
|
Data: 30
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -574,7 +568,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
|
|||||||
+331
-386
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,6 @@ namespace Marro.PacManUdon
|
|||||||
[SerializeField] private GameObject intermissionScreen;
|
[SerializeField] private GameObject intermissionScreen;
|
||||||
[SerializeField] private GameObject pressStartButtonScreen;
|
[SerializeField] private GameObject pressStartButtonScreen;
|
||||||
[SerializeField] private PlayerInput playerInput;
|
[SerializeField] private PlayerInput playerInput;
|
||||||
[SerializeField] private Animator demo;
|
|
||||||
[SerializeField] private SoundManager soundManager;
|
[SerializeField] private SoundManager soundManager;
|
||||||
[SerializeField] private NetworkManager networkManagerSetup;
|
[SerializeField] private NetworkManager networkManagerSetup;
|
||||||
|
|
||||||
@@ -68,7 +67,7 @@ namespace Marro.PacManUdon
|
|||||||
intermission2Pole.Initialize(this, ghostManager.Ghosts[0]);
|
intermission2Pole.Initialize(this, ghostManager.Ghosts[0]);
|
||||||
|
|
||||||
SubscribeToEvent(NetworkEventType.StartGameButtonPressed);
|
SubscribeToEvent(NetworkEventType.StartGameButtonPressed);
|
||||||
SubscribeToEvent(NetworkEventType.TimeSequenceSync);
|
SubscribeToEvent(NetworkEventType.FullSync);
|
||||||
|
|
||||||
HideEverything();
|
HideEverything();
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ namespace Marro.PacManUdon
|
|||||||
Debug.Log($"{gameObject} Start Game Button was pressed!");
|
Debug.Log($"{gameObject} Start Game Button was pressed!");
|
||||||
if (networkManager.IsOwner)
|
if (networkManager.IsOwner)
|
||||||
{
|
{
|
||||||
networkManager.SendEventNow(NetworkEventType.StartGameButtonPressed);
|
networkManager.SendEventSoon(NetworkEventType.StartGameButtonPressed, false);
|
||||||
}
|
}
|
||||||
StartTimeSequence(PacManTimeSequence.StartNewGame);
|
StartTimeSequence(PacManTimeSequence.StartNewGame);
|
||||||
}
|
}
|
||||||
@@ -132,28 +131,18 @@ namespace Marro.PacManUdon
|
|||||||
SetLevel(1);
|
SetLevel(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeLevel()
|
|
||||||
{
|
|
||||||
//Debug.Log($"{gameObject} New level started!");
|
|
||||||
|
|
||||||
collisionManager.RestoreAllPellets();
|
|
||||||
|
|
||||||
ghostManager.NewLevel();
|
|
||||||
|
|
||||||
mazeSpriteAnimator.SetBool("Blinking", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RestartLevel(bool afterLifeLost = false)
|
private void RestartLevel(bool afterLifeLost = false)
|
||||||
{
|
{
|
||||||
//Debug.Log($"{gameObject} (Re)started level!");
|
//Debug.Log($"{gameObject} (Re)started level!");
|
||||||
|
|
||||||
// SetInGameComponentVisibility(true);
|
mazeSpriteAnimator.SetBool("Blinking", false);
|
||||||
|
|
||||||
ghostManager.RestartLevel(afterLifeLost);
|
ghostManager.RestartLevel(afterLifeLost);
|
||||||
pacMan.Reset();
|
pacMan.Reset();
|
||||||
bonusFruit.Despawn();
|
bonusFruit.Despawn();
|
||||||
soundManager.Reset();
|
soundManager.Reset();
|
||||||
collisionManager.SetPowerPelletsBlink(false);
|
collisionManager.Reset();
|
||||||
|
statusDisplay.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrepareForCutscene()
|
private void PrepareForCutscene()
|
||||||
@@ -229,7 +218,6 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
AddScore(scoreBonus);
|
AddScore(scoreBonus);
|
||||||
StartTimeSequence(PacManTimeSequence.GhostCaught);
|
StartTimeSequence(PacManTimeSequence.GhostCaught);
|
||||||
pacMan.HideUntilUnfrozen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PacManCaught()
|
public void PacManCaught()
|
||||||
@@ -275,7 +263,6 @@ namespace Marro.PacManUdon
|
|||||||
statusDisplay.SetLevelDisplayVisible(false);
|
statusDisplay.SetLevelDisplayVisible(false);
|
||||||
statusDisplay.SetPlayer1TextVisible(false);
|
statusDisplay.SetPlayer1TextVisible(false);
|
||||||
statusDisplay.SetReadyTextVisible(false);
|
statusDisplay.SetReadyTextVisible(false);
|
||||||
demo.gameObject.SetActive(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPelletsActive(bool active)
|
void SetPelletsActive(bool active)
|
||||||
@@ -385,36 +372,66 @@ namespace Marro.PacManUdon
|
|||||||
soundManager.PlayExtraLifeSound();
|
soundManager.PlayExtraLifeSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetupInGameState()
|
||||||
|
{
|
||||||
|
gameState = PacManGameState.InGame;
|
||||||
|
|
||||||
|
attractScreen.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
SetPelletsActive(true);
|
||||||
|
SetMazeVisible(true);
|
||||||
|
SetGhostsActive(true);
|
||||||
|
SetPacManActive(true);
|
||||||
|
|
||||||
|
statusDisplay.SetExtraLivesDisplayVisible(true);
|
||||||
|
statusDisplay.SetLevelDisplayVisible(true);
|
||||||
|
statusDisplay.SetLabel1UPTextBlinking(true);
|
||||||
|
|
||||||
|
soundManager.SuppressSound(false);
|
||||||
|
soundManager.StartGhostSound();
|
||||||
|
|
||||||
|
SetFrozen(false);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFrozen(bool frozen, bool ghostIgnoreIfCaught = false, bool ghostKeepAnimating = false)
|
public void SetFrozen(bool frozen, bool ghostIgnoreIfCaught = false, bool ghostKeepAnimating = false)
|
||||||
{
|
{
|
||||||
// Debug.Log($"{gameObject} Set Frozen: {frozen}");
|
// Debug.Log($"{gameObject} Set Frozen: {frozen}");
|
||||||
pacMan.SetFrozen(frozen);
|
pacMan.SetFrozen(frozen);
|
||||||
bonusFruit.SetFrozen(frozen);
|
bonusFruit.SetFrozen(frozen);
|
||||||
ghostManager.SetFrozen(frozen, ignoreIfCaught: ghostIgnoreIfCaught);
|
ghostManager.SetFrozen(frozen, ignoreIfCaught: ghostIgnoreIfCaught);
|
||||||
|
collisionManager.SetFrozen(frozen);
|
||||||
if (!frozen)
|
|
||||||
{
|
|
||||||
collisionManager.SetPowerPelletsBlink(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType == NetworkEventType.TimeSequenceSync)
|
if (eventType != NetworkEventType.FullSync)
|
||||||
{
|
{
|
||||||
data.Append(currentlyInTimeSequence, ref index);
|
return;
|
||||||
|
|
||||||
if (currentlyInTimeSequence)
|
|
||||||
{
|
|
||||||
data.AppendAsByte((int)currentTimeSequence, ref index);
|
|
||||||
data.Append(timeSequenceSecondsPassed, ref index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)gameState) };
|
data.Append(gameState == PacManGameState.InGame, ref index);
|
||||||
//data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
|
|
||||||
//data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)currentTimeSequence) };
|
data.AppendAsByte(level, ref index);
|
||||||
//data[offset++] = BitConverter.GetBytes(timeSequenceSecondsPassed);
|
data.Append(score, ref index);
|
||||||
|
data.AppendAsByte(extraLives, ref index);
|
||||||
|
|
||||||
|
data.Append(currentlyInTimeSequence, ref index);
|
||||||
|
|
||||||
|
if (currentlyInTimeSequence)
|
||||||
|
{
|
||||||
|
data.AppendAsByte((int)currentTimeSequence, ref index);
|
||||||
|
data.Append(timeSequenceSecondsPassed, ref index);
|
||||||
|
}
|
||||||
|
|
||||||
|
bonusFruit.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
collisionManager.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
ghostManager.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
pacMan.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
soundManager.CollectSyncedData(data, ref index, eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
@@ -422,30 +439,48 @@ namespace Marro.PacManUdon
|
|||||||
if (eventType == NetworkEventType.StartGameButtonPressed)
|
if (eventType == NetworkEventType.StartGameButtonPressed)
|
||||||
{
|
{
|
||||||
StartGameButtonPressed();
|
StartGameButtonPressed();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventType == NetworkEventType.TimeSequenceSync)
|
if (eventType != NetworkEventType.FullSync)
|
||||||
{
|
{
|
||||||
var currentlyInTimeSequence = data.ReadBool(ref index);
|
return true;
|
||||||
if (currentlyInTimeSequence)
|
|
||||||
{
|
|
||||||
var currentTimeSequence = (PacManTimeSequence)data.ReadByte(ref index);
|
|
||||||
var timeSequenceSecondsPassed = data.ReadFloat(ref index);
|
|
||||||
TimeSequenceSyncWithRemote(currentTimeSequence, timeSequenceSecondsPassed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TimeSequenceTryEndCurrent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetGameState((PacManGameState)data[offset++]);
|
// If we're currently in-game, we'll need to make sure the state is setup correctly
|
||||||
|
var remoteCurrentlyInGame = data.ReadBool(ref index);
|
||||||
|
if (remoteCurrentlyInGame)
|
||||||
|
{
|
||||||
|
currentlyInTimeSequence = false; // Kill the current time sequence, otherwise it might interfere
|
||||||
|
// No need to run it to completion since we're overriding all state
|
||||||
|
SetupInGameState();
|
||||||
|
}
|
||||||
|
|
||||||
//var currentlyInTimeSequence = BitConverter.ToBoolean(data, offset++);
|
SetLevel(data.ReadByte(ref index));
|
||||||
//var currentTimeSequence = (PacManTimeSequence)data[offset++];
|
SetScore(data.ReadInt(ref index));
|
||||||
//var timeSequenceSecondsPassed = BitConverter.ToSingle(data, offset);
|
SetExtraLives(data.ReadByte(ref index));
|
||||||
//offset += 4;
|
|
||||||
//TimeSequenceSyncWithRemote(currentlyInTimeSequence, currentTimeSequence, timeSequenceSecondsPassed);
|
// Sync up with the remote's time sequence
|
||||||
|
var remoteCurrentlyInTimeSequence = data.ReadBool(ref index);
|
||||||
|
if (remoteCurrentlyInTimeSequence)
|
||||||
|
{
|
||||||
|
var currentTimeSequence = (PacManTimeSequence)data.ReadByte(ref index);
|
||||||
|
var timeSequenceSecondsPassed = data.ReadFloat(ref index);
|
||||||
|
TimeSequenceSyncWithRemote(currentTimeSequence, timeSequenceSecondsPassed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note that we don't have any logic for if the remote is not in-game and not in a time sequence.
|
||||||
|
// Such a state should be impossible.
|
||||||
|
|
||||||
|
bonusFruit.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
collisionManager.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
ghostManager.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
pacMan.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
soundManager.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+446
-410
File diff suppressed because it is too large
Load Diff
+72
-52
@@ -15,6 +15,15 @@ namespace Marro.PacManUdon
|
|||||||
Special,
|
Special,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PacManGhostAnimatorState
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
Caught,
|
||||||
|
Scared,
|
||||||
|
ScaredWhite,
|
||||||
|
Special
|
||||||
|
}
|
||||||
|
|
||||||
public enum PacManGhostState
|
public enum PacManGhostState
|
||||||
{
|
{
|
||||||
Normal,
|
Normal,
|
||||||
@@ -50,9 +59,7 @@ namespace Marro.PacManUdon
|
|||||||
private Ghost blinky;
|
private Ghost blinky;
|
||||||
private ScoreBonusDisplay scoreBonusDisplay;
|
private ScoreBonusDisplay scoreBonusDisplay;
|
||||||
|
|
||||||
private Vector3 startPosition;
|
private Vector2 startPosition;
|
||||||
private Quaternion startRotation;
|
|
||||||
|
|
||||||
private Vector2 homePosition;
|
private Vector2 homePosition;
|
||||||
private Vector2 idlePosition1;
|
private Vector2 idlePosition1;
|
||||||
private Vector2 idlePosition2;
|
private Vector2 idlePosition2;
|
||||||
@@ -70,6 +77,7 @@ namespace Marro.PacManUdon
|
|||||||
// State
|
// State
|
||||||
private PacManGhostState ghostState;
|
private PacManGhostState ghostState;
|
||||||
private bool isScared;
|
private bool isScared;
|
||||||
|
private bool whiteScared;
|
||||||
private bool scattering;
|
private bool scattering;
|
||||||
private PacManGhostFrozenState frozenState;
|
private PacManGhostFrozenState frozenState;
|
||||||
|
|
||||||
@@ -110,21 +118,18 @@ namespace Marro.PacManUdon
|
|||||||
scoreBonusDisplay = transform.Find("ScoreBonusDisplay").gameObject.GetComponent<ScoreBonusDisplay>();
|
scoreBonusDisplay = transform.Find("ScoreBonusDisplay").gameObject.GetComponent<ScoreBonusDisplay>();
|
||||||
scoreBonusDisplay.Initialize();
|
scoreBonusDisplay.Initialize();
|
||||||
startPosition = startTransform.localPosition;
|
startPosition = startTransform.localPosition;
|
||||||
startRotation = startTransform.localRotation;
|
|
||||||
|
|
||||||
frozenState = PacManGhostFrozenState.Frozen;
|
frozenState = PacManGhostFrozenState.Frozen;
|
||||||
|
|
||||||
Index = index;
|
Index = index;
|
||||||
|
|
||||||
SubscribeToEvent(NetworkEventType.GhostUpdate);
|
|
||||||
|
|
||||||
targetIndicator.transform.parent = transform.parent;
|
targetIndicator.transform.parent = transform.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
// Debug.Log($"{gameObject} Reset!");
|
// Debug.Log($"{gameObject} Reset!");
|
||||||
transform.SetLocalPositionAndRotation(startPosition, startRotation);
|
SetPosition(startPosition);
|
||||||
|
|
||||||
offGrid = true;
|
offGrid = true;
|
||||||
isScared = false;
|
isScared = false;
|
||||||
@@ -393,25 +398,26 @@ namespace Marro.PacManUdon
|
|||||||
default:
|
default:
|
||||||
return gridPosition;
|
return gridPosition;
|
||||||
case PacManGhostType.Blinky: // Chase PacMan directly
|
case PacManGhostType.Blinky: // Chase PacMan directly
|
||||||
return PositionToGrid(pacMan.transform.localPosition);
|
return PositionToGrid(pacMan.GetPosition());
|
||||||
case PacManGhostType.Pinky: // Try to get ahead of PacMan
|
case PacManGhostType.Pinky: // Try to get ahead of PacMan
|
||||||
return GetTargetAheadOfPacMan(4);
|
return GetTargetAheadOfPacMan(4);
|
||||||
case PacManGhostType.Inky: // Try to attack from the opposite side of Blinky
|
case PacManGhostType.Inky: // Try to attack from the opposite side of Blinky
|
||||||
var blinkyPosition = PositionToGrid(blinky.transform.localPosition);
|
var blinkyPosition = PositionToGrid(blinky.GetPosition());
|
||||||
return ((GetTargetAheadOfPacMan(2) - blinkyPosition) * 2) + blinkyPosition;
|
return ((GetTargetAheadOfPacMan(2) - blinkyPosition) * 2) + blinkyPosition;
|
||||||
case PacManGhostType.Clyde: // Chase PacMan, but retreat to corner if PacMan gets to close
|
case PacManGhostType.Clyde: // Chase PacMan, but retreat to corner if PacMan gets to close
|
||||||
if (Vector2.Distance(gridPosition, PositionToGrid(pacMan.transform.localPosition)) < 8)
|
var pacManPosition = PositionToGrid(pacMan.GetPosition());
|
||||||
|
if (Vector2.Distance(gridPosition, pacManPosition) < 8)
|
||||||
{
|
{
|
||||||
return cornerPosition;
|
return cornerPosition;
|
||||||
}
|
}
|
||||||
return PositionToGrid(pacMan.transform.localPosition);
|
return pacManPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 GetTargetAheadOfPacMan(int tilesInFront)
|
private Vector2 GetTargetAheadOfPacMan(int tilesInFront)
|
||||||
{
|
{
|
||||||
var direction = pacMan.GetTargetDirection();
|
var direction = pacMan.GetTargetDirection();
|
||||||
var result = PositionToGrid(pacMan.transform.localPosition) + directionVectors[(int)direction] * tilesInFront;
|
var result = PositionToGrid(pacMan.GetPosition()) + directionVectors[(int)direction] * tilesInFront;
|
||||||
|
|
||||||
if (direction == Direction.Up) // Reproducing a bug in the original game
|
if (direction == Direction.Up) // Reproducing a bug in the original game
|
||||||
{
|
{
|
||||||
@@ -544,21 +550,20 @@ namespace Marro.PacManUdon
|
|||||||
SetAnimatorDirection((int)targetDirection);
|
SetAnimatorDirection((int)targetDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isScared) // Don't update ghost type while scared as this interrupts the white/blue blinking
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PacManGhostType ghostType = this.ghostType;
|
PacManGhostType ghostType = this.ghostType;
|
||||||
|
|
||||||
if (specialLook)
|
if (isScared)
|
||||||
{
|
{
|
||||||
ghostType = PacManGhostType.Special;
|
ghostType = whiteScared ? PacManGhostType.ScaredWhite : PacManGhostType.Scared;
|
||||||
}
|
}
|
||||||
else if (ghostState == PacManGhostState.Returning || ghostState == PacManGhostState.Entering)
|
else if (ghostState == PacManGhostState.Returning || ghostState == PacManGhostState.Entering)
|
||||||
{
|
{
|
||||||
ghostType = PacManGhostType.Caught;
|
ghostType = PacManGhostType.Caught;
|
||||||
}
|
}
|
||||||
|
else if (specialLook)
|
||||||
|
{
|
||||||
|
ghostType = PacManGhostType.Special;
|
||||||
|
}
|
||||||
|
|
||||||
SetAnimatorGhostType((int)ghostType);
|
SetAnimatorGhostType((int)ghostType);
|
||||||
}
|
}
|
||||||
@@ -595,18 +600,23 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void HitPacMan()
|
internal bool HitPacMan()
|
||||||
{
|
{
|
||||||
|
if (ghostState != PacManGhostState.Normal)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isScared)
|
if (isScared)
|
||||||
{
|
{
|
||||||
Debug.Log($"{gameObject} was cought!");
|
//Debug.Log($"{gameObject} was cought!");
|
||||||
ghostManager.GhostCaughtQueue(this);
|
ghostManager.GhostCaught(this);
|
||||||
}
|
return true;
|
||||||
else if (ghostState == PacManGhostState.Normal)
|
|
||||||
{
|
|
||||||
Debug.Log($"{gameObject} cought PacMan!");
|
|
||||||
ghostManager.CapturedPacMan();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Debug.Log($"{gameObject} cought PacMan!");
|
||||||
|
ghostManager.CapturedPacMan();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Caught(int scoreBonus)
|
public void Caught(int scoreBonus)
|
||||||
@@ -670,13 +680,8 @@ namespace Marro.PacManUdon
|
|||||||
private void SetScared(bool scared)
|
private void SetScared(bool scared)
|
||||||
{
|
{
|
||||||
isScared = scared;
|
isScared = scared;
|
||||||
UpdateAnimator();
|
SetWhite(false);
|
||||||
UpdateSpeed();
|
UpdateSpeed();
|
||||||
|
|
||||||
if (isScared)
|
|
||||||
{
|
|
||||||
SetWhite(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScattering(bool scattering, bool reverseDirection = true)
|
public void SetScattering(bool scattering, bool reverseDirection = true)
|
||||||
@@ -697,25 +702,32 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public void SetFrozen(bool frozen, bool ignoreIfCaught = false, bool keepAnimating = false)
|
public void SetFrozen(bool frozen, bool ignoreIfCaught = false, bool keepAnimating = false)
|
||||||
{
|
{
|
||||||
|
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
|
||||||
|
|
||||||
if (frozen && !ignoreIfCaught)
|
if (frozen && !ignoreIfCaught)
|
||||||
{
|
{
|
||||||
frozenState = PacManGhostFrozenState.Frozen;
|
frozenState = PacManGhostFrozenState.Frozen;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (frozen && ignoreIfCaught)
|
|
||||||
|
if (frozen && ignoreIfCaught)
|
||||||
{
|
{
|
||||||
frozenState = PacManGhostFrozenState.FrozenIfNotCaught;
|
frozenState = PacManGhostFrozenState.FrozenIfNotCaught;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
var oldFrozenState = frozenState;
|
|
||||||
frozenState = PacManGhostFrozenState.NotFrozen;
|
|
||||||
|
|
||||||
if (oldFrozenState == PacManGhostFrozenState.FrozenIfNotCaught) // Catch animator up after not updating during FrozenIfNotCaught
|
var oldFrozenState = frozenState;
|
||||||
{
|
frozenState = PacManGhostFrozenState.NotFrozen;
|
||||||
UpdateAnimator();
|
|
||||||
}
|
if (oldFrozenState == PacManGhostFrozenState.FrozenIfNotCaught) // Catch animator up after not updating during FrozenIfNotCaught
|
||||||
|
{
|
||||||
|
UpdateAnimator();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ghostState == PacManGhostState.CaughtScore)
|
||||||
|
{
|
||||||
|
ReturnHome(); // Return home when unfreezing after being caught
|
||||||
}
|
}
|
||||||
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHousePelletCounterActive(bool active)
|
public void SetHousePelletCounterActive(bool active)
|
||||||
@@ -730,10 +742,8 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public void SetWhite(bool white)
|
public void SetWhite(bool white)
|
||||||
{
|
{
|
||||||
if (!isScared || !gameObject.activeInHierarchy)
|
whiteScared = white;
|
||||||
return;
|
UpdateAnimator();
|
||||||
|
|
||||||
SetAnimatorGhostType(white ? (int)PacManGhostType.ScaredWhite : (int)PacManGhostType.Scared);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetElroy(int elroyLevel)
|
public void SetElroy(int elroyLevel)
|
||||||
@@ -798,7 +808,7 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.GhostUpdate)
|
if (eventType != NetworkEventType.FullSync)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -812,8 +822,8 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
data.AppendAsByte((int)ghostState, ref index);
|
data.AppendAsByte((int)ghostState, ref index);
|
||||||
data.Append(isScared, ref index);
|
data.Append(isScared, ref index);
|
||||||
|
data.Append(whiteScared, ref index);
|
||||||
data.Append(scattering, ref index);
|
data.Append(scattering, ref index);
|
||||||
data.AppendAsByte((int)frozenState, ref index);
|
|
||||||
|
|
||||||
data.Append(offGrid, ref index);
|
data.Append(offGrid, ref index);
|
||||||
data.AppendAsByte(housePelletCounter, ref index);
|
data.AppendAsByte(housePelletCounter, ref index);
|
||||||
@@ -821,11 +831,13 @@ namespace Marro.PacManUdon
|
|||||||
data.AppendAsByte(housePelletCounterLimit, ref index);
|
data.AppendAsByte(housePelletCounterLimit, ref index);
|
||||||
|
|
||||||
base.CollectSyncedData(data, ref index, eventType);
|
base.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
data.AppendAsByte((int)frozenState, ref index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.GhostUpdate)
|
if (eventType != NetworkEventType.FullSync)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -839,15 +851,23 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
ghostState = (PacManGhostState)data.ReadByte(ref index);
|
ghostState = (PacManGhostState)data.ReadByte(ref index);
|
||||||
isScared = data.ReadBool(ref index);
|
isScared = data.ReadBool(ref index);
|
||||||
|
whiteScared = data.ReadBool(ref index);
|
||||||
scattering = data.ReadBool(ref index);
|
scattering = data.ReadBool(ref index);
|
||||||
frozenState = (PacManGhostFrozenState)data.ReadByte(ref index);
|
|
||||||
|
|
||||||
offGrid = data.ReadBool(ref index);
|
offGrid = data.ReadBool(ref index);
|
||||||
housePelletCounter = data.ReadByte(ref index);
|
housePelletCounter = data.ReadByte(ref index);
|
||||||
housePelletCounterActive = data.ReadBool(ref index);
|
housePelletCounterActive = data.ReadBool(ref index);
|
||||||
housePelletCounterLimit = data.ReadByte(ref index);
|
housePelletCounterLimit = data.ReadByte(ref index);
|
||||||
|
|
||||||
return base.WriteSyncedData(data, ref index, eventType);
|
UpdateSpeed();
|
||||||
|
|
||||||
|
frozenState = PacManGhostFrozenState.NotFrozen; // Ensure UpdateAnimator runs fully
|
||||||
|
|
||||||
|
var success = base.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
frozenState = (PacManGhostFrozenState)data.ReadByte(ref index);
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 33
|
Data: 32
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data:
|
Data:
|
||||||
@@ -1081,64 +1081,10 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: ghostScaredQueue
|
Data: blinkingActivated
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: ghostScaredQueue
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 55|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: VRC.SDK3.Data.DataList, VRCSDK3
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 9
|
|
||||||
Data: 55
|
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: false
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 56|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: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: blinkingActivated
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: blinkingActivated
|
Data: blinkingActivated
|
||||||
@@ -1162,7 +1108,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 55|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1186,7 +1132,7 @@ MonoBehaviour:
|
|||||||
Data: blinkCountdown
|
Data: blinkCountdown
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 59|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 56|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: blinkCountdown
|
Data: blinkCountdown
|
||||||
@@ -1210,7 +1156,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 57|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1234,7 +1180,7 @@ MonoBehaviour:
|
|||||||
Data: blinkCurrentlyWhite
|
Data: blinkCurrentlyWhite
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 61|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: blinkCurrentlyWhite
|
Data: blinkCurrentlyWhite
|
||||||
@@ -1258,7 +1204,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 62|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 59|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1282,7 +1228,7 @@ MonoBehaviour:
|
|||||||
Data: scatterCounter
|
Data: scatterCounter
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 63|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 60|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: scatterCounter
|
Data: scatterCounter
|
||||||
@@ -1306,7 +1252,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 64|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 61|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1330,7 +1276,7 @@ MonoBehaviour:
|
|||||||
Data: scatterPatternIndex
|
Data: scatterPatternIndex
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 65|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 62|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: scatterPatternIndex
|
Data: scatterPatternIndex
|
||||||
@@ -1354,7 +1300,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 66|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 63|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1378,7 +1324,7 @@ MonoBehaviour:
|
|||||||
Data: elroyLevel
|
Data: elroyLevel
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 67|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 64|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: elroyLevel
|
Data: elroyLevel
|
||||||
@@ -1402,7 +1348,7 @@ MonoBehaviour:
|
|||||||
Data: true
|
Data: true
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 68|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 65|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1426,7 +1372,7 @@ MonoBehaviour:
|
|||||||
Data: sharedPelletCounterActive
|
Data: sharedPelletCounterActive
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 69|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 66|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: sharedPelletCounterActive
|
Data: sharedPelletCounterActive
|
||||||
@@ -1450,7 +1396,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 70|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 67|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1474,7 +1420,7 @@ MonoBehaviour:
|
|||||||
Data: sharedPelletCounter
|
Data: sharedPelletCounter
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 71|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 68|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: sharedPelletCounter
|
Data: sharedPelletCounter
|
||||||
@@ -1496,6 +1442,60 @@ MonoBehaviour:
|
|||||||
- Name: <IsSerialized>k__BackingField
|
- Name: <IsSerialized>k__BackingField
|
||||||
Entry: 5
|
Entry: 5
|
||||||
Data: false
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 69|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: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: sharedPelletCounterReleaseValues
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 70|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: sharedPelletCounterReleaseValues
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 71|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Int32[], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 71
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 72|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 72|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
@@ -1519,64 +1519,10 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: sharedPelletCounterReleaseValues
|
Data: pelletTimeout
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 73|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 73|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: sharedPelletCounterReleaseValues
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 74|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.Int32[], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 9
|
|
||||||
Data: 74
|
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: false
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 75|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: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: pelletTimeout
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 76|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: pelletTimeout
|
Data: pelletTimeout
|
||||||
@@ -1600,7 +1546,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 77|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 74|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1624,7 +1570,7 @@ MonoBehaviour:
|
|||||||
Data: frozen
|
Data: frozen
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 78|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 75|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: frozen
|
Data: frozen
|
||||||
@@ -1648,7 +1594,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 79|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 76|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1672,7 +1618,7 @@ MonoBehaviour:
|
|||||||
Data: kinematic
|
Data: kinematic
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 80|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 77|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: kinematic
|
Data: kinematic
|
||||||
@@ -1696,7 +1642,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 81|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 78|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ namespace Marro.PacManUdon
|
|||||||
private float powerPelletCountdown;
|
private float powerPelletCountdown;
|
||||||
private int powerPelletMultiplier;
|
private int powerPelletMultiplier;
|
||||||
|
|
||||||
private DataList ghostScaredQueue;
|
|
||||||
|
|
||||||
// Blink logic
|
// Blink logic
|
||||||
private const float blinkCycleRate = 0.233333333f;
|
private const float blinkCycleRate = 0.233333333f;
|
||||||
private bool blinkingActivated;
|
private bool blinkingActivated;
|
||||||
@@ -74,13 +72,10 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
ghosts[ghostIndex].Initialize(collisionManager, pacMan, blinky, startTransform, homePosition, idlePosition1, idlePosition2, cornerPosition, ghostIndex);
|
ghosts[ghostIndex].Initialize(collisionManager, pacMan, blinky, startTransform, homePosition, idlePosition1, idlePosition2, cornerPosition, ghostIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscribeToEvent(NetworkEventType.GhostUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestartLevel(bool afterLifeLost = false)
|
public void RestartLevel(bool afterLifeLost = false)
|
||||||
{
|
{
|
||||||
ghostScaredQueue = new DataList();
|
|
||||||
powerPelletActive = false;
|
powerPelletActive = false;
|
||||||
scatterCounter = 0;
|
scatterCounter = 0;
|
||||||
scatterPatternIndex = 0;
|
scatterPatternIndex = 0;
|
||||||
@@ -100,10 +95,7 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetScattering(true, reverseDirection: false);
|
SetScattering(true, reverseDirection: false);
|
||||||
}
|
|
||||||
|
|
||||||
public void NewLevel()
|
|
||||||
{
|
|
||||||
SetSharedPelletCounterActive(false);
|
SetSharedPelletCounterActive(false);
|
||||||
UpdateElroyLevel(collisionManager.PelletCount);
|
UpdateElroyLevel(collisionManager.PelletCount);
|
||||||
foreach (Ghost ghost in ghosts)
|
foreach (Ghost ghost in ghosts)
|
||||||
@@ -186,7 +178,7 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GhostCaughtQueue(Ghost ghost)
|
public void GhostCaught(Ghost ghost)
|
||||||
{
|
{
|
||||||
if (gameController.GameState == PacManGameState.AttractMode)
|
if (gameController.GameState == PacManGameState.AttractMode)
|
||||||
{
|
{
|
||||||
@@ -194,34 +186,6 @@ namespace Marro.PacManUdon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
|
|
||||||
//networkManager.SendEventSoon(NetworkEventType.TimeSequenceSync);
|
|
||||||
//networkManager.SendEventSoon(NetworkEventType.GhostUpdate);
|
|
||||||
|
|
||||||
ghostScaredQueue.Add(ghost);
|
|
||||||
GhostCaughtExecute(ghost);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GhostCaughtContinue()
|
|
||||||
{
|
|
||||||
// Debug.Log($"{gameObject} GhostCaughtContinue with ghost queue length {ghostScaredQueue.Count}");
|
|
||||||
if (!ghostScaredQueue.TryGetValue(0, out DataToken currentGhost))
|
|
||||||
{
|
|
||||||
Debug.LogError("Called GhostCaughtContinue without a ghost in the queue!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
((Ghost)currentGhost.Reference).ReturnHome();
|
|
||||||
ghostScaredQueue.RemoveAt(0);
|
|
||||||
|
|
||||||
if (ghostScaredQueue.TryGetValue(0, out DataToken nextGhost))
|
|
||||||
{
|
|
||||||
GhostCaughtExecute((Ghost)nextGhost.Reference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GhostCaughtExecute(Ghost ghost)
|
|
||||||
{
|
|
||||||
int scoreBonus = 200 * (int)Math.Pow(2, powerPelletMultiplier);
|
int scoreBonus = 200 * (int)Math.Pow(2, powerPelletMultiplier);
|
||||||
powerPelletMultiplier += 1;
|
powerPelletMultiplier += 1;
|
||||||
ghost.Caught(scoreBonus);
|
ghost.Caught(scoreBonus);
|
||||||
@@ -325,7 +289,7 @@ namespace Marro.PacManUdon
|
|||||||
for (int i = 0; i < ghosts.Length; i++)
|
for (int i = 0; i < ghosts.Length; i++)
|
||||||
{
|
{
|
||||||
ghosts[i].SetHousePelletCounterLimit(privatePelletCounterReleaseValues[i]);
|
ghosts[i].SetHousePelletCounterLimit(privatePelletCounterReleaseValues[i]);
|
||||||
RestartLevel(); // Reset needed to properly apply level
|
ghosts[i].UpdateSpeed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,11 +451,6 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.GhostUpdate)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Power Pellet logic
|
// Power Pellet logic
|
||||||
data.Append(powerPelletActive, ref index);
|
data.Append(powerPelletActive, ref index);
|
||||||
data.Append(powerPelletCountdown, ref index);
|
data.Append(powerPelletCountdown, ref index);
|
||||||
@@ -519,28 +478,14 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
data.AppendAsByte(gameController.Level, ref index);
|
data.AppendAsByte(gameController.Level, ref index);
|
||||||
|
|
||||||
var ghostScaredQueueArray = new byte[ghosts.Length];
|
foreach (var ghost in ghosts)
|
||||||
for (int i = 0; i < ghostScaredQueueArray.Length; i++)
|
|
||||||
{
|
{
|
||||||
var add = ghostScaredQueue.TryGetValue(i, out var ghost);
|
ghost.CollectSyncedData(data, ref index, eventType);
|
||||||
if (!add)
|
|
||||||
{
|
|
||||||
ghostScaredQueueArray[i] = byte.MaxValue; // Add a terminator
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ghostScaredQueueArray[i] = (byte)((Ghost)ghost.Reference).Index;
|
|
||||||
}
|
}
|
||||||
//Debug.Log($"{gameObject} Sent a ghostScareQueue of length {ghostScaredQueue.Count}");
|
|
||||||
data.Append(ghostScaredQueueArray, ref index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.GhostUpdate)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Power Pellet logic
|
// Power Pellet logic
|
||||||
powerPelletActive = data.ReadBool(ref index);
|
powerPelletActive = data.ReadBool(ref index);
|
||||||
powerPelletCountdown = data.ReadFloat(ref index);
|
powerPelletCountdown = data.ReadFloat(ref index);
|
||||||
@@ -569,18 +514,10 @@ namespace Marro.PacManUdon
|
|||||||
var level = data.ReadByte(ref index);
|
var level = data.ReadByte(ref index);
|
||||||
SetLevelConstants(level);
|
SetLevelConstants(level);
|
||||||
|
|
||||||
ghostScaredQueue.Clear();
|
foreach (var ghost in ghosts)
|
||||||
for (int i = 0; i < ghosts.Length; i++)
|
|
||||||
{
|
{
|
||||||
var ghostIndex = data[index + i];
|
ghost.WriteSyncedData(data, ref index, eventType);
|
||||||
if (ghostIndex > ghosts.Length) // Reached terminator
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ghostScaredQueue.Add(ghosts[ghostIndex]);
|
|
||||||
}
|
}
|
||||||
index += ghosts.Length;
|
|
||||||
//Debug.Log($"{gameObject} Read back a ghostScareQueue of length {ghostScaredQueue.Count}");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public abstract class GridMover : SyncedObject
|
public abstract class GridMover : SyncedObject
|
||||||
{
|
{
|
||||||
|
protected Vector2 position;
|
||||||
protected Direction direction;
|
protected Direction direction;
|
||||||
protected Direction targetDirection;
|
protected Direction targetDirection;
|
||||||
|
|
||||||
// Cannot be static, much to my annoyance
|
// Cannot be static
|
||||||
public readonly Vector2[] directionVectors =
|
public readonly Vector2[] directionVectors =
|
||||||
{
|
{
|
||||||
Vector2.zero, // 0
|
Vector2.zero, // 0
|
||||||
@@ -43,11 +44,13 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public virtual Vector2 GetPosition()
|
public virtual Vector2 GetPosition()
|
||||||
{
|
{
|
||||||
return (Vector2)transform.localPosition;
|
//return (Vector2)transform.localPosition;
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetPosition(Vector2 position)
|
public virtual void SetPosition(Vector2 position)
|
||||||
{
|
{
|
||||||
|
this.position = position;
|
||||||
transform.localPosition = new Vector3(position.x, position.y, transform.localPosition.z);
|
transform.localPosition = new Vector3(position.x, position.y, transform.localPosition.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,15 +143,5 @@ namespace Marro.PacManUdon
|
|||||||
{
|
{
|
||||||
return (Vector2)transform.localPosition;
|
return (Vector2)transform.localPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+647
-447
File diff suppressed because it is too large
Load Diff
+213
-128
@@ -13,13 +13,9 @@ namespace Marro.PacManUdon
|
|||||||
{
|
{
|
||||||
public enum NetworkEventType
|
public enum NetworkEventType
|
||||||
{
|
{
|
||||||
FullSyncForced = 0,
|
|
||||||
FullSync = 1,
|
FullSync = 1,
|
||||||
PacManTurn = 2,
|
InputChange = 2,
|
||||||
StartGameButtonPressed = 3,
|
StartGameButtonPressed = 3,
|
||||||
SyncPellets = 4,
|
|
||||||
GhostUpdate = 5,
|
|
||||||
TimeSequenceSync = 6,
|
|
||||||
Pause = 7,
|
Pause = 7,
|
||||||
Resume = 8,
|
Resume = 8,
|
||||||
Step = 9,
|
Step = 9,
|
||||||
@@ -56,19 +52,23 @@ namespace Marro.PacManUdon
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delay in ticks at which the receiving side replays events.
|
/// The delay in ticks at which the receiving side replays events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeField] private int delay = 50;
|
[SerializeField] private int delay = 1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum amount of times a message is sent.
|
/// The maximum amount of times a message is sent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeField] private int maxEventSendTries = 3;
|
[SerializeField] private int maxEventSendTries = 3;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How long to wait since last message to send next ping.
|
/// How long to wait since last message to send next message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeField] private int pingDelay = 15;
|
[SerializeField] private int sendingPingDelay = 15;
|
||||||
|
/// <summary>
|
||||||
|
/// How long to wait since last attempt to request sync.
|
||||||
|
/// </summary>
|
||||||
|
[SerializeField] private int syncingPingDelay = 300;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time delta at which updates occur.
|
/// The time delta at which updates occur.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeField] private float tickDelta = 0.0166666667f;
|
[SerializeField] private float tickDelta = 0.0165f;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
@@ -101,6 +101,15 @@ namespace Marro.PacManUdon
|
|||||||
/// The total length of the header of an event, in bytes.
|
/// The total length of the header of an event, in bytes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const ushort HeaderLength = 8;
|
private const ushort HeaderLength = 8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of a GUID as used in the Reset event, in bytes.
|
||||||
|
/// </summary>
|
||||||
|
private const ushort GuidSize = 16;
|
||||||
|
/// <summary>
|
||||||
|
/// The total size of the Reset event.
|
||||||
|
/// </summary>
|
||||||
|
private const ushort ResetEventSize = HeaderTimestampIndex + GuidSize;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private attributes
|
#region Private attributes
|
||||||
@@ -154,6 +163,11 @@ namespace Marro.PacManUdon
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int retriesWithoutSuccess;
|
private int retriesWithoutSuccess;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The data of the last aknowledged Reset event.
|
||||||
|
/// </summary>
|
||||||
|
private byte[] lastResetEventData;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For receiver: True if there's a full sync in the queue and we are not synced, otherwise false.
|
/// For receiver: True if there's a full sync in the queue and we are not synced, otherwise false.
|
||||||
/// For transmitter: True if there's a full sync in the queue which has not yet been transmitted, otherwise false.
|
/// For transmitter: True if there's a full sync in the queue which has not yet been transmitted, otherwise false.
|
||||||
@@ -165,13 +179,21 @@ namespace Marro.PacManUdon
|
|||||||
private bool serializationRequested;
|
private bool serializationRequested;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events to send at the end of SyncedUpdate cycle
|
/// Events to send at the end of SyncedUpdate cycle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private NetworkEventType[] eventsToSend;
|
private NetworkEventType[] eventsToSendEarly;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Index for <see cref="eventsToSend"/>
|
/// Index for <see cref="eventsToSendEarly"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int eventsToSendIndex;
|
private int eventsToSendEarlyIndex;
|
||||||
|
/// <summary>
|
||||||
|
/// Events to send at the end of SyncedUpdate cycle, delayed by a tick.
|
||||||
|
/// </summary>
|
||||||
|
private NetworkEventType[] eventsToSendLate;
|
||||||
|
/// <summary>
|
||||||
|
/// Index for <see cref="eventsToSendLate"/>.
|
||||||
|
/// </summary>
|
||||||
|
private int eventsToSendLateIndex;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queue of events to be transmitted or processed.
|
/// Queue of events to be transmitted or processed.
|
||||||
@@ -195,7 +217,7 @@ namespace Marro.PacManUdon
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int eventTransmissionHistoryIndex;
|
private int eventTransmissionHistoryIndex;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time of last event transmission, in ticks.
|
/// Time of last event transmission sent, requested or received, in ticks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int lastEventTransmissionTime;
|
private int lastEventTransmissionTime;
|
||||||
|
|
||||||
@@ -205,7 +227,6 @@ namespace Marro.PacManUdon
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private byte lastEventId;
|
private byte lastEventId;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data which is currently available on the network.
|
/// Data which is currently available on the network.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -290,26 +311,17 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
#region General
|
#region General
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the <see cref="NetworkManager"/>. Call <see cref="Reset"/> afterwards to activate networking.
|
/// Initializes the <see cref="NetworkManager"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
if (initialized)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Tried to call {nameof(Initialize)} when already initialized!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!BitConverter.IsLittleEndian)
|
if (!BitConverter.IsLittleEndian)
|
||||||
{
|
{
|
||||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root == null)
|
root = transform.parent.gameObject;
|
||||||
{
|
|
||||||
root = transform.parent.gameObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeSubscribers();
|
InitializeSubscribers();
|
||||||
|
|
||||||
@@ -327,12 +339,14 @@ namespace Marro.PacManUdon
|
|||||||
obj.networkManager = this;
|
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;
|
const int eventTypeCount = byte.MaxValue + 1;
|
||||||
|
|
||||||
networkEventSubscribers = new SyncedObject[eventTypeCount][];
|
networkEventSubscribers = new SyncedObject[eventTypeCount][];
|
||||||
networkEventSubscribersIndices = new int[eventTypeCount];
|
networkEventSubscribersIndices = new int[eventTypeCount];
|
||||||
|
|
||||||
|
lastResetEventData = new byte[ResetEventSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
@@ -354,9 +368,7 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
ClearBuffer();
|
ClearBuffer();
|
||||||
|
|
||||||
Synced = IsOwner; // Owner is always synced
|
|
||||||
retriesWithoutSuccess = 0;
|
retriesWithoutSuccess = 0;
|
||||||
hasFullSyncReady = false;
|
|
||||||
|
|
||||||
targetTicks = 0;
|
targetTicks = 0;
|
||||||
startTime = Time.fixedTime;
|
startTime = Time.fixedTime;
|
||||||
@@ -366,16 +378,17 @@ namespace Marro.PacManUdon
|
|||||||
Ready = true;
|
Ready = true;
|
||||||
|
|
||||||
// Sync up
|
// Sync up
|
||||||
if (IsOwner)
|
if (!IsOwner)
|
||||||
{
|
{
|
||||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
SetSynced(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RequestEvent(NetworkEventType.FullSync);
|
Synced = true; // Owner is always synced
|
||||||
|
SendReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized");
|
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@@ -404,14 +417,18 @@ namespace Marro.PacManUdon
|
|||||||
{
|
{
|
||||||
if (Ready)
|
if (Ready)
|
||||||
{
|
{
|
||||||
if (IsOwner)
|
if (isOwner)
|
||||||
{
|
{
|
||||||
ProcessEventsToSend(); // Prepare events from last cycle
|
ProcessEventsToSend(); // Prepare events from last cycle
|
||||||
ProgressPingTime(); // See if we need to send a ping
|
ProgressSendingPingTime(); // See if we need to send a ping
|
||||||
|
}
|
||||||
|
else if (Synced || hasFullSyncReady)
|
||||||
|
{
|
||||||
|
ApplyReceivedEvents(); // See if there's events after last update that need to be replayed
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ApplyReceivedEvents(); // See if there's events after last update that need to be replayed
|
ProgressSyncingPingTime(); // See if we should request syncing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,15 +469,13 @@ namespace Marro.PacManUdon
|
|||||||
ClearBuffer();
|
ClearBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Synced = false;
|
|
||||||
|
|
||||||
if (!IsOwner)
|
if (!IsOwner)
|
||||||
{
|
{
|
||||||
RequestEvent(NetworkEventType.FullSync);
|
SetSynced(false);
|
||||||
}
|
}
|
||||||
else
|
else if (clearBuffer)
|
||||||
{
|
{
|
||||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
SendReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +507,7 @@ namespace Marro.PacManUdon
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sender
|
#region Sender
|
||||||
public void SendEventSoon(NetworkEventType eventType)
|
public void SendEventSoon(NetworkEventType eventType, bool early = false)
|
||||||
{
|
{
|
||||||
if (!Ready)
|
if (!Ready)
|
||||||
{
|
{
|
||||||
@@ -501,31 +516,57 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
if (!IsOwner)
|
if (!IsOwner)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEventSoon)} while not the owner!");
|
//Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEventSoon)} while not the owner!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventsQueueIndex > eventsToSend.Length)
|
if (early)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(eventsToSend)} overflow!");
|
if (eventsToSendEarlyIndex >= eventsToSendEarly.Length)
|
||||||
HandleError(false);
|
{
|
||||||
return;
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(eventsToSendEarly)} overflow!");
|
||||||
|
HandleError(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventsToSendEarly[eventsToSendEarlyIndex++] = eventType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (eventsToSendLateIndex >= eventsToSendLate.Length)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(eventsToSendLate)} overflow!");
|
||||||
|
HandleError(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventsToSendLate[eventsToSendLateIndex++] = eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
eventsToSend[eventsToSendIndex++] = eventType;
|
if (eventType == NetworkEventType.FullSync)
|
||||||
|
{
|
||||||
|
hasFullSyncReady = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessEventsToSend()
|
private void ProcessEventsToSend()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < eventsToSendIndex; i++)
|
for (int i = 0; i < eventsToSendEarlyIndex; i++)
|
||||||
{
|
{
|
||||||
SendEventNow(eventsToSend[0]);
|
SendEventNow(eventsToSendEarly[i], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
eventsToSendIndex = 0;
|
eventsToSendEarlyIndex = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < eventsToSendLateIndex; i++)
|
||||||
|
{
|
||||||
|
SendEventNow(eventsToSendLate[i], false);
|
||||||
|
}
|
||||||
|
|
||||||
|
eventsToSendLateIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendEventNow(NetworkEventType eventType)
|
public void SendEventNow(NetworkEventType eventType, bool early)
|
||||||
{
|
{
|
||||||
if (!Ready)
|
if (!Ready)
|
||||||
{
|
{
|
||||||
@@ -540,6 +581,11 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
var timestamp = SyncedTimeTicks;
|
var timestamp = SyncedTimeTicks;
|
||||||
|
|
||||||
|
if (early)
|
||||||
|
{
|
||||||
|
timestamp--;
|
||||||
|
}
|
||||||
|
|
||||||
var eventId = GetNextEventId(lastEventId);
|
var eventId = GetNextEventId(lastEventId);
|
||||||
|
|
||||||
InitializeEvent(eventType, timestamp, eventId, out byte[] data, out var index);
|
InitializeEvent(eventType, timestamp, eventId, out byte[] data, out var index);
|
||||||
@@ -558,11 +604,6 @@ namespace Marro.PacManUdon
|
|||||||
var eventSizeBytes = BitConverter.GetBytes((ushort)index);
|
var eventSizeBytes = BitConverter.GetBytes((ushort)index);
|
||||||
Array.Copy(eventSizeBytes, 0, data, HeaderEventSizeIndex, eventSizeBytes.Length);
|
Array.Copy(eventSizeBytes, 0, data, HeaderEventSizeIndex, eventSizeBytes.Length);
|
||||||
|
|
||||||
if (IsFullSync(eventType))
|
|
||||||
{
|
|
||||||
hasFullSyncReady = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = GetArrayPart(data, 0, index);
|
data = GetArrayPart(data, 0, index);
|
||||||
|
|
||||||
QueueEventInBuffer(data);
|
QueueEventInBuffer(data);
|
||||||
@@ -588,6 +629,19 @@ namespace Marro.PacManUdon
|
|||||||
index = HeaderLength;
|
index = HeaderLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SendReset()
|
||||||
|
{
|
||||||
|
var data = new byte[ResetEventSize];
|
||||||
|
|
||||||
|
var guid = Guid.NewGuid().ToByteArray();
|
||||||
|
Array.Copy(guid, 0, data, HeaderTimestampIndex, GuidSize);
|
||||||
|
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Sent Reset event!");
|
||||||
|
|
||||||
|
QueueEventInBuffer(data);
|
||||||
|
RequestSerializationForEvents();
|
||||||
|
}
|
||||||
|
|
||||||
private void RequestSerializationForEvents()
|
private void RequestSerializationForEvents()
|
||||||
{
|
{
|
||||||
RequestSerialization();
|
RequestSerialization();
|
||||||
@@ -606,29 +660,32 @@ namespace Marro.PacManUdon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFullSync(eventType) && hasFullSyncReady)
|
if (eventType == NetworkEventType.FullSync && hasFullSyncReady)
|
||||||
{
|
{
|
||||||
|
//Debug.Log($"Rejected event request because already have full sync ready");
|
||||||
return; // Don't send another full sync if we're already preparing to send one
|
return; // Don't send another full sync if we're already preparing to send one
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventType == NetworkEventType.FullSyncForced)
|
|
||||||
{
|
|
||||||
SendEventSoon(NetworkEventType.FullSync); // Remote is not allowed to request a forced full sync
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SendEventSoon(eventType);
|
SendEventSoon(eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProgressPingTime()
|
private void ProgressSendingPingTime()
|
||||||
{
|
{
|
||||||
if (eventsQueueIndex > 0 && !serializationRequested
|
if (eventsQueueIndex > 0 && !serializationRequested
|
||||||
&& targetTicks - lastEventTransmissionTime >= pingDelay)
|
&& targetTicks - lastEventTransmissionTime >= sendingPingDelay)
|
||||||
{
|
{
|
||||||
RequestSerializationForEvents();
|
RequestSerializationForEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProgressSyncingPingTime()
|
||||||
|
{
|
||||||
|
if (targetTicks - lastEventTransmissionTime >= syncingPingDelay)
|
||||||
|
{
|
||||||
|
RequestEvent(NetworkEventType.FullSync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnPreSerialization()
|
public override void OnPreSerialization()
|
||||||
{
|
{
|
||||||
if (!Ready || !IsOwner || !serializationRequested || eventsQueue == null || eventsQueueIndex == 0)
|
if (!Ready || !IsOwner || !serializationRequested || eventsQueue == null || eventsQueueIndex == 0)
|
||||||
@@ -647,7 +704,7 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
serializationRequested = false;
|
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);
|
public override void OnPostSerialization(SerializationResult result) => OnPostSerializationInternal(result.success, result.byteCount);
|
||||||
@@ -655,6 +712,9 @@ namespace Marro.PacManUdon
|
|||||||
// Version of OnPostSerialization which does not require instantiating SerializationResult, so that it can be called for debugging purposes.
|
// Version of OnPostSerialization which does not require instantiating SerializationResult, so that it can be called for debugging purposes.
|
||||||
public void OnPostSerializationInternal(bool success, int byteCount)
|
public void OnPostSerializationInternal(bool success, int byteCount)
|
||||||
{
|
{
|
||||||
|
// If there was a full sync in the queue, it should now have been transmitted at least once
|
||||||
|
hasFullSyncReady = false;
|
||||||
|
|
||||||
if (!Ready || !IsOwner || networkedData.Length == 0)
|
if (!Ready || !IsOwner || networkedData.Length == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -666,7 +726,7 @@ namespace Marro.PacManUdon
|
|||||||
return;
|
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
|
// Remove data from the buffer that no longer needs to be (re)transmitted
|
||||||
DequeueEventsFromBuffer(eventTransmissionHistory[eventTransmissionHistoryIndex]);
|
DequeueEventsFromBuffer(eventTransmissionHistory[eventTransmissionHistoryIndex]);
|
||||||
@@ -675,9 +735,6 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
networkedData = new byte[0];
|
networkedData = new byte[0];
|
||||||
|
|
||||||
// If there was a full sync in the queue, it has now been transmitted at least once
|
|
||||||
hasFullSyncReady = false;
|
|
||||||
|
|
||||||
lastEventTransmissionTime = targetTicks;
|
lastEventTransmissionTime = targetTicks;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -697,6 +754,7 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
|
|
||||||
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
|
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
|
||||||
|
lastEventTransmissionTime = SyncedTimeTicks;
|
||||||
|
|
||||||
if (tester != null)
|
if (tester != null)
|
||||||
{
|
{
|
||||||
@@ -718,7 +776,7 @@ namespace Marro.PacManUdon
|
|||||||
int eventSize = 0; // Store event size here so we can increment the index no matter how we increment the loop
|
int eventSize = 0; // Store event size here so we can increment the index no matter how we increment the loop
|
||||||
while ((index += eventSize) < length)
|
while ((index += eventSize) < length)
|
||||||
{
|
{
|
||||||
if (length - index < HeaderLength)
|
if (length - index < HeaderLength) // Check package is at least as long as the minimum length possible. Reset package is also larger than HeaderLength.
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(StoreIncomingData)}: Remaining data in networkedData is not long enough to form a complete event! remaining: {length - index}.");
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(StoreIncomingData)}: Remaining data in networkedData is not long enough to form a complete event! remaining: {length - index}.");
|
||||||
HandleError(false);
|
HandleError(false);
|
||||||
@@ -726,6 +784,12 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
|
|
||||||
eventSize = GetEventSizeFromHeader(networkedData, index);
|
eventSize = GetEventSizeFromHeader(networkedData, index);
|
||||||
|
bool isReset = eventSize == 0;
|
||||||
|
|
||||||
|
if (isReset)
|
||||||
|
{
|
||||||
|
eventSize = ResetEventSize;
|
||||||
|
}
|
||||||
|
|
||||||
if (length - index < eventSize)
|
if (length - index < eventSize)
|
||||||
{
|
{
|
||||||
@@ -743,11 +807,16 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
var @event = GetArrayPart(networkedData, index, eventSize);
|
var @event = GetArrayPart(networkedData, index, eventSize);
|
||||||
|
|
||||||
|
if (isReset && TryApplyReset(@event))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var timestamp = GetTimestampFromHeader(@event);
|
var timestamp = GetTimestampFromHeader(@event);
|
||||||
var eventId = GetEventIdFromHeader(@event);
|
var eventId = GetEventIdFromHeader(@event);
|
||||||
var eventType = GetEventTypeFromHeader(@event);
|
var eventType = GetEventTypeFromHeader(@event);
|
||||||
|
|
||||||
if (eventType != NetworkEventType.FullSyncForced && (Synced || hasFullSyncReady))
|
if (Synced || hasFullSyncReady)
|
||||||
{
|
{
|
||||||
// Check if event id is sequential
|
// Check if event id is sequential
|
||||||
if (eventId != GetNextEventId(lastEventId))
|
if (eventId != GetNextEventId(lastEventId))
|
||||||
@@ -765,25 +834,29 @@ namespace Marro.PacManUdon
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueEventInBuffer(@event);
|
if (!QueueEventInBuffer(@event))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventsQueueIndex == 1) // If this is the next upcoming event, update the next event time
|
||||||
|
{
|
||||||
|
UpdateNextEventTime();
|
||||||
|
}
|
||||||
|
|
||||||
//Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)} Queued event with id {eventId}");
|
//Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)} Queued event with id {eventId}");
|
||||||
}
|
}
|
||||||
|
else if (eventType == NetworkEventType.FullSync) // If we're not yet synced, we only care about full sync events.
|
||||||
|
{
|
||||||
|
QueueFullSyncForReplay(@event); // Immediately process full sync
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If we're not yet synced, we only care about full sync events.
|
continue; // Event is currently not relevant
|
||||||
if (IsFullSync(eventType))
|
|
||||||
{
|
|
||||||
QueueFullSyncForReplay(@event); // Immediately process full sync
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastEventId = eventId;
|
lastEventId = eventId;
|
||||||
}
|
lastEventTransmissionTime = SyncedTimeTicks;
|
||||||
|
|
||||||
if (Synced)
|
|
||||||
{
|
|
||||||
UpdateNextEventTime();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -798,7 +871,47 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
hasFullSyncReady = true;
|
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, current time is {SyncedTimeTicks}, should execute at {nextEventTime}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryApplyReset(byte[] @event)
|
||||||
|
{
|
||||||
|
// Compare the guid to the one in the previous reset event
|
||||||
|
if (IsDuplicateResetEvent(@event))
|
||||||
|
{
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Rejected Reset event as it was a duplicate.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Applied Reset event!");
|
||||||
|
|
||||||
|
lastResetEventData = @event;
|
||||||
|
Reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsDuplicateResetEvent(byte[] @event)
|
||||||
|
{
|
||||||
|
for (int i = HeaderTimestampIndex; i < ResetEventSize; i++)
|
||||||
|
{
|
||||||
|
if (@event[i] != lastResetEventData[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetSynced(bool synced)
|
||||||
|
{
|
||||||
|
Synced = synced;
|
||||||
|
|
||||||
|
if (!Synced)
|
||||||
|
{
|
||||||
|
Synced = false;
|
||||||
|
RequestEvent(NetworkEventType.FullSync);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyReceivedEvents()
|
private void ApplyReceivedEvents()
|
||||||
@@ -824,11 +937,11 @@ namespace Marro.PacManUdon
|
|||||||
var timestamp = GetTimestampFromHeader(@event);
|
var timestamp = GetTimestampFromHeader(@event);
|
||||||
var eventType = GetEventTypeFromHeader(@event);
|
var eventType = GetEventTypeFromHeader(@event);
|
||||||
|
|
||||||
var isFullSync = IsFullSync(eventType);
|
if (!Synced)
|
||||||
|
|
||||||
if (!Synced || eventType == NetworkEventType.FullSyncForced)
|
|
||||||
{
|
{
|
||||||
SyncToTimestamp(timestamp);
|
SyncToTimestamp(timestamp);
|
||||||
|
hasFullSyncReady = false;
|
||||||
|
SetSynced(true);
|
||||||
}
|
}
|
||||||
else if (timestamp < SyncedTimeTicks)
|
else if (timestamp < SyncedTimeTicks)
|
||||||
{
|
{
|
||||||
@@ -842,15 +955,10 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
var subscribers = GetEventSubscribers(eventType);
|
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)
|
if (subscribers != null)
|
||||||
{
|
{
|
||||||
foreach (var obj in subscribers)
|
|
||||||
{
|
|
||||||
obj.SyncedUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var obj in subscribers)
|
foreach (var obj in subscribers)
|
||||||
{
|
{
|
||||||
var success = obj.WriteSyncedData(@event, ref index, eventType);
|
var success = obj.WriteSyncedData(@event, ref index, eventType);
|
||||||
@@ -872,12 +980,6 @@ namespace Marro.PacManUdon
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Synced && isFullSync)
|
|
||||||
{
|
|
||||||
hasFullSyncReady = false;
|
|
||||||
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!
|
retriesWithoutSuccess = 0; // We had success!
|
||||||
@@ -903,12 +1005,16 @@ namespace Marro.PacManUdon
|
|||||||
eventsQueueIndex = 0;
|
eventsQueueIndex = 0;
|
||||||
lastEventId = 0;
|
lastEventId = 0;
|
||||||
hasFullSyncReady = false;
|
hasFullSyncReady = false;
|
||||||
|
lastEventTransmissionTime = SyncedTimeTicks;
|
||||||
|
|
||||||
eventTransmissionHistory = new int[maxEventSendTries];
|
eventTransmissionHistory = new int[maxEventSendTries];
|
||||||
eventTransmissionHistoryIndex = 0;
|
eventTransmissionHistoryIndex = 0;
|
||||||
eventsQueueIndexAtLastTransmission = 0;
|
eventsQueueIndexAtLastTransmission = 0;
|
||||||
eventsToSend = new NetworkEventType[BufferMaxTotalEvents];
|
|
||||||
eventsToSendIndex = 0;
|
eventsToSendEarly = new NetworkEventType[BufferMaxTotalEvents];
|
||||||
|
eventsToSendEarlyIndex = 0;
|
||||||
|
eventsToSendLate = new NetworkEventType[BufferMaxTotalEvents];
|
||||||
|
eventsToSendLateIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DequeueEventsFromBuffer(int eventCount)
|
private void DequeueEventsFromBuffer(int eventCount)
|
||||||
@@ -970,7 +1076,7 @@ namespace Marro.PacManUdon
|
|||||||
SyncedTime = SyncedTimeTicks * tickDelta;
|
SyncedTime = SyncedTimeTicks * tickDelta;
|
||||||
nextEventTime = timestamp;
|
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()
|
private void UpdateNextEventTime()
|
||||||
@@ -991,7 +1097,7 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
if (nextEventTime < SyncedTimeTicks)
|
if (nextEventTime < SyncedTimeTicks)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event timestamp is earlier than our current synced time by {SyncedTime - nextEventTime} seconds! nextEventTime: {nextEventTime} SyncedTime: {SyncedTime}, internalTime: {targetTicks}");
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event timestamp is earlier than our current synced time by {SyncedTimeTicks - nextEventTime}! nextEventTime: {nextEventTime} SyncedTime: {SyncedTimeTicks}, targetTicks: {targetTicks}");
|
||||||
HandleError(true);
|
HandleError(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1013,9 +1119,6 @@ namespace Marro.PacManUdon
|
|||||||
return currentEventId;
|
return currentEventId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsFullSync(NetworkEventType eventType)
|
|
||||||
=> eventType == NetworkEventType.FullSync || eventType == NetworkEventType.FullSyncForced;
|
|
||||||
|
|
||||||
private static ushort GetEventSizeFromHeader(byte[] @event, int eventIndex = 0)
|
private static ushort GetEventSizeFromHeader(byte[] @event, int eventIndex = 0)
|
||||||
=> BitConverter.ToUInt16(@event, eventIndex + HeaderEventSizeIndex);
|
=> BitConverter.ToUInt16(@event, eventIndex + HeaderEventSizeIndex);
|
||||||
|
|
||||||
@@ -1042,7 +1145,8 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
if (newOwnerIsLocalPlayer)
|
if (newOwnerIsLocalPlayer)
|
||||||
{
|
{
|
||||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
ClearBuffer();
|
||||||
|
SendReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -1103,11 +1207,6 @@ namespace Marro.PacManUdon
|
|||||||
Array.Copy(data, start, result, 0, length);
|
Array.Copy(data, start, result, 0, length);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float RoundDown(float value, float precision)
|
|
||||||
{
|
|
||||||
return (float)(Math.Floor(value / precision) * precision);
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SyncedData
|
#region SyncedData
|
||||||
@@ -1180,6 +1279,7 @@ namespace Marro.PacManUdon
|
|||||||
[SerializeField] private Animator DebugImageToIndicateReady;
|
[SerializeField] private Animator DebugImageToIndicateReady;
|
||||||
|
|
||||||
private NetworkManagerTester tester;
|
private NetworkManagerTester tester;
|
||||||
|
|
||||||
public void SetNetworkManagerTester(NetworkManagerTester tester)
|
public void SetNetworkManagerTester(NetworkManagerTester tester)
|
||||||
{
|
{
|
||||||
this.tester = tester;
|
this.tester = tester;
|
||||||
@@ -1200,21 +1300,6 @@ namespace Marro.PacManUdon
|
|||||||
SendEventSoon(NetworkEventType.FullSync);
|
SendEventSoon(NetworkEventType.FullSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoPelletSync()
|
|
||||||
{
|
|
||||||
SendEventSoon(NetworkEventType.SyncPellets);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoGhostSync()
|
|
||||||
{
|
|
||||||
SendEventSoon(NetworkEventType.GhostUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoTimeSequenceSync()
|
|
||||||
{
|
|
||||||
SendEventSoon(NetworkEventType.TimeSequenceSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Pause()
|
public void Pause()
|
||||||
{
|
{
|
||||||
paused = true;
|
paused = true;
|
||||||
|
|||||||
+316
-418
File diff suppressed because it is too large
Load Diff
+98
-104
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using UnityEngine;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
@@ -12,64 +11,65 @@ namespace Marro.PacManUdon
|
|||||||
Dead,
|
Dead,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PacManState
|
||||||
|
{
|
||||||
|
Idle,
|
||||||
|
Normal,
|
||||||
|
PowerPellet,
|
||||||
|
Dead,
|
||||||
|
Big,
|
||||||
|
}
|
||||||
|
|
||||||
[RequireComponent(typeof(Animator))]
|
[RequireComponent(typeof(Animator))]
|
||||||
[RequireComponent(typeof(Renderer))]
|
[RequireComponent(typeof(Renderer))]
|
||||||
public class PacMan : GridMover
|
public class PacMan : GridMover
|
||||||
{
|
{
|
||||||
private GameManager gameManager;
|
|
||||||
private PlayerInput input;
|
private PlayerInput input;
|
||||||
private CollisionManager collisionManager;
|
private CollisionManager collisionManager;
|
||||||
|
private Animator animator;
|
||||||
|
private new Renderer renderer;
|
||||||
|
|
||||||
|
private Vector2 startPosition;
|
||||||
private float defaultSpeed;
|
private float defaultSpeed;
|
||||||
private float powerPelletSpeed;
|
private float powerPelletSpeed;
|
||||||
|
|
||||||
|
private PacManState state;
|
||||||
|
|
||||||
private float speed;
|
private float speed;
|
||||||
private Vector3 startPosition;
|
private float freezeSeconds;
|
||||||
private Quaternion startRotation;
|
private bool frozen;
|
||||||
private Animator animator;
|
|
||||||
new Renderer renderer;
|
|
||||||
private bool hideUntilUnfrozen;
|
|
||||||
private bool dead;
|
|
||||||
private bool kinematic;
|
private bool kinematic;
|
||||||
|
|
||||||
private bool followingPredefinedPath;
|
private bool followingPredefinedPath;
|
||||||
private Direction[] predefinedPath;
|
private Direction[] predefinedPath;
|
||||||
private int predefinedPathIndex;
|
private int predefinedPathIndex;
|
||||||
|
|
||||||
private float freezeSeconds;
|
|
||||||
private bool frozen;
|
|
||||||
|
|
||||||
#region Animator constants
|
|
||||||
private readonly int animatorKeyState = Animator.StringToHash("State");
|
private readonly int animatorKeyState = Animator.StringToHash("State");
|
||||||
private readonly int animatorKeyDirection = Animator.StringToHash("Direction");
|
private readonly int animatorKeyDirection = Animator.StringToHash("Direction");
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
public void Initialize(PlayerInput input, Transform startTransform, GameManager gameManager, CollisionManager collisionManager)
|
public void Initialize(PlayerInput input, Transform startTransform, GameManager gameManager, CollisionManager collisionManager)
|
||||||
{
|
{
|
||||||
this.gameManager = gameManager;
|
|
||||||
this.collisionManager = collisionManager;
|
this.collisionManager = collisionManager;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
renderer = GetComponent<Renderer>();
|
renderer = GetComponent<Renderer>();
|
||||||
frozen = false;
|
frozen = false;
|
||||||
hideUntilUnfrozen = false;
|
|
||||||
startPosition = startTransform.localPosition;
|
startPosition = startTransform.localPosition;
|
||||||
startRotation = startTransform.localRotation;
|
|
||||||
|
|
||||||
SubscribeToEvent(NetworkEventType.PacManTurn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
transform.SetLocalPositionAndRotation(startPosition, startRotation);
|
SetPosition(startPosition);
|
||||||
direction = Direction.Left;
|
direction = Direction.Left;
|
||||||
targetDirection = Direction.Left;
|
targetDirection = Direction.Left;
|
||||||
speed = defaultSpeed;
|
|
||||||
kinematic = false;
|
kinematic = false;
|
||||||
followingPredefinedPath = false;
|
followingPredefinedPath = false;
|
||||||
|
|
||||||
SetDead(false);
|
state = PacManState.Idle;
|
||||||
|
|
||||||
SetAnimatorState((int)PacManAnimatorState.Idle);
|
UpdateSpeed();
|
||||||
|
UpdateAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SyncedUpdate()
|
public override void SyncedUpdate()
|
||||||
@@ -81,30 +81,7 @@ namespace Marro.PacManUdon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hideUntilUnfrozen)
|
float speed = GetNextSpeed();
|
||||||
{
|
|
||||||
hideUntilUnfrozen = false;
|
|
||||||
SetVisibility(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
float speed = this.speed;
|
|
||||||
if (freezeSeconds > 0)
|
|
||||||
{
|
|
||||||
float freezePart = freezeSeconds / networkManager.SyncedDeltaTime;
|
|
||||||
if (freezePart >= 1)
|
|
||||||
{
|
|
||||||
freezeSeconds -= networkManager.SyncedDeltaTime;
|
|
||||||
animator.speed = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
speed *= 1 - freezePart;
|
|
||||||
animator.speed = 1 - freezePart;
|
|
||||||
freezeSeconds = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
animator.speed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 position = GetPosition();
|
Vector2 position = GetPosition();
|
||||||
Vector2 nextPosition = GetNextPosition(position, directionVectors[(int)direction], speed, networkManager.SyncedDeltaTime); // The position pacman will move to, assuming it doens't get changed
|
Vector2 nextPosition = GetNextPosition(position, directionVectors[(int)direction], speed, networkManager.SyncedDeltaTime); // The position pacman will move to, assuming it doens't get changed
|
||||||
@@ -129,6 +106,33 @@ namespace Marro.PacManUdon
|
|||||||
SetPosition(nextPosition);
|
SetPosition(nextPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float GetNextSpeed()
|
||||||
|
{
|
||||||
|
float speed = this.speed;
|
||||||
|
if (freezeSeconds > 0)
|
||||||
|
{
|
||||||
|
float freezePart = freezeSeconds / networkManager.SyncedDeltaTime;
|
||||||
|
if (freezePart >= 1)
|
||||||
|
{
|
||||||
|
freezeSeconds -= networkManager.SyncedDeltaTime;
|
||||||
|
animator.speed = 0;
|
||||||
|
speed = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
speed *= 1 - freezePart;
|
||||||
|
animator.speed = 1 - freezePart;
|
||||||
|
freezeSeconds = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
animator.speed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
|
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
|
||||||
{
|
{
|
||||||
if (CrossesTileCenter(position, nextPosition, Direction.Left) // If pacman is moving horizontally, check if he may cross the center of a tile in that axis
|
if (CrossesTileCenter(position, nextPosition, Direction.Left) // If pacman is moving horizontally, check if he may cross the center of a tile in that axis
|
||||||
@@ -163,11 +167,6 @@ namespace Marro.PacManUdon
|
|||||||
SetDirection((Direction)((int)inputDirection | (int)directionToCenter));
|
SetDirection((Direction)((int)inputDirection | (int)directionToCenter));
|
||||||
}
|
}
|
||||||
SetTargetDirection(inputDirection); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering
|
SetTargetDirection(inputDirection); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering
|
||||||
|
|
||||||
if (!followingPredefinedPath)
|
|
||||||
{
|
|
||||||
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nextPosition;
|
return nextPosition;
|
||||||
@@ -217,32 +216,33 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
if (eatResult == EatResult.Pellet)
|
if (eatResult == EatResult.Pellet)
|
||||||
{
|
{
|
||||||
freezeSeconds = 0.0166666666666667f;
|
freezeSeconds = 0.0165f;
|
||||||
}
|
}
|
||||||
else if (eatResult == EatResult.PowerPellet)
|
else if (eatResult == EatResult.PowerPellet)
|
||||||
{
|
{
|
||||||
freezeSeconds = freezeSeconds = 0.05f;
|
freezeSeconds = 0.0495f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAnimator()
|
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)
|
if (!gameObject.activeInHierarchy)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dead)
|
switch (state)
|
||||||
{
|
{
|
||||||
SetAnimatorState((int)PacManAnimatorState.Dead);
|
case PacManState.Dead:
|
||||||
animator.speed = 1;
|
SetAnimatorState((int)PacManAnimatorState.Dead);
|
||||||
return;
|
animator.speed = 1;
|
||||||
}
|
return;
|
||||||
|
case PacManState.Idle:
|
||||||
animator.speed = frozen ? 0 : 1;
|
SetAnimatorState((int)PacManAnimatorState.Idle);
|
||||||
|
return;
|
||||||
if (frozen)
|
case PacManState.Big:
|
||||||
{
|
SetAnimatorState((int)PacManAnimatorState.Big);
|
||||||
return;
|
animator.speed = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction.Equals(Direction.Zero))
|
if (direction.Equals(Direction.Zero))
|
||||||
@@ -252,8 +252,12 @@ namespace Marro.PacManUdon
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetAnimatorState((int)PacManAnimatorState.Moving);
|
SetAnimatorState((int)PacManAnimatorState.Moving);
|
||||||
SetAnimatorDirection((int)targetDirection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
animator.speed = frozen ? 0 : 1;
|
||||||
|
|
||||||
|
SetAnimatorDirection((int)targetDirection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetAnimatorDirection(int value) =>
|
private void SetAnimatorDirection(int value) =>
|
||||||
@@ -262,22 +266,22 @@ namespace Marro.PacManUdon
|
|||||||
private void SetAnimatorState(int value) =>
|
private void SetAnimatorState(int value) =>
|
||||||
animator.SetFloat(animatorKeyState, value);
|
animator.SetFloat(animatorKeyState, value);
|
||||||
|
|
||||||
public void SetDead(bool dead)
|
public void Die()
|
||||||
{
|
{
|
||||||
this.dead = dead;
|
state = PacManState.Dead;
|
||||||
UpdateAnimator();
|
UpdateAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFrozen(bool frozen)
|
public void SetFrozen(bool frozen)
|
||||||
{
|
{
|
||||||
this.frozen = frozen;
|
this.frozen = frozen;
|
||||||
UpdateAnimator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HideUntilUnfrozen()
|
if (!frozen && state == PacManState.Idle)
|
||||||
{
|
{
|
||||||
hideUntilUnfrozen = true;
|
state = PacManState.Normal;
|
||||||
SetVisibility(false);
|
}
|
||||||
|
|
||||||
|
UpdateAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLevel(int level)
|
public void SetLevel(int level)
|
||||||
@@ -285,11 +289,18 @@ namespace Marro.PacManUdon
|
|||||||
// Debug.Log($"{gameObject} SetLevel {level}");
|
// Debug.Log($"{gameObject} SetLevel {level}");
|
||||||
defaultSpeed = PacManConstants.GetPacManDefaultSpeedForLevel(level);
|
defaultSpeed = PacManConstants.GetPacManDefaultSpeedForLevel(level);
|
||||||
powerPelletSpeed = PacManConstants.GetPacManPowerPelletSpeedForLevel(level);
|
powerPelletSpeed = PacManConstants.GetPacManPowerPelletSpeedForLevel(level);
|
||||||
|
UpdateSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPowerPellet(bool powerPellet)
|
public void SetPowerPellet(bool powerPellet)
|
||||||
{
|
{
|
||||||
if (powerPellet)
|
state = powerPellet ? PacManState.PowerPellet : PacManState.Normal;
|
||||||
|
UpdateSpeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSpeed()
|
||||||
|
{
|
||||||
|
if (state == PacManState.PowerPellet)
|
||||||
{
|
{
|
||||||
speed = powerPelletSpeed;
|
speed = powerPelletSpeed;
|
||||||
}
|
}
|
||||||
@@ -323,48 +334,31 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public void BecomeBig()
|
public void BecomeBig()
|
||||||
{
|
{
|
||||||
SetAnimatorState((int)PacManAnimatorState.Big);
|
state = PacManState.Big;
|
||||||
|
UpdateAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVisibility(bool visible)
|
public void SetVisibility(bool visible)
|
||||||
{
|
{
|
||||||
renderer.enabled = visible;
|
renderer.enabled = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.PacManTurn)
|
data.AppendAsByte((int)state, ref index);
|
||||||
{
|
data.Append(freezeSeconds, ref index);
|
||||||
return;
|
data.Append(frozen, ref index);
|
||||||
}
|
|
||||||
|
|
||||||
if (kinematic || frozen || !enabled)
|
|
||||||
{
|
|
||||||
index += 1;
|
|
||||||
PadSyncedData(ref index);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.AppendAsByte((int)targetDirection, ref index);
|
|
||||||
|
|
||||||
base.CollectSyncedData(data, ref index, eventType);
|
base.CollectSyncedData(data, ref index, eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType != NetworkEventType.PacManTurn)
|
state = (PacManState)data.ReadByte(ref index);
|
||||||
{
|
freezeSeconds = data.ReadFloat(ref index);
|
||||||
return true;
|
frozen = data.ReadBool(ref index);
|
||||||
}
|
|
||||||
|
|
||||||
if (kinematic || frozen || !enabled)
|
UpdateSpeed();
|
||||||
{
|
|
||||||
index += 1;
|
|
||||||
PadSyncedData(ref index);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetTargetDirection((Direction)data.ReadByte(ref index));
|
|
||||||
|
|
||||||
return base.WriteSyncedData(data, ref index, eventType);
|
return base.WriteSyncedData(data, ref index, eventType);
|
||||||
}
|
}
|
||||||
|
|||||||
+216
-102
@@ -43,31 +43,37 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 8
|
Data: 10
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: active
|
Data: networkManager
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: active
|
Data: networkManager
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 3|System.RuntimeType, mscorlib
|
Data: 3|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Boolean, mscorlib
|
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 3
|
Data: 4|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: VRC.Udon.UdonBehaviour, VRC.Udon
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -82,7 +88,7 @@ MonoBehaviour:
|
|||||||
Data: true
|
Data: true
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -103,31 +109,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: gameManager
|
Data: active
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: gameManager
|
Data: active
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
|
||||||
Data: 6|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 7|System.RuntimeType, mscorlib
|
Data: 7|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: VRC.Udon.UdonBehaviour, VRC.Udon
|
Data: System.Boolean, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 7
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -139,7 +139,7 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: <IsSerialized>k__BackingField
|
- Name: <IsSerialized>k__BackingField
|
||||||
Entry: 5
|
Entry: 5
|
||||||
Data: false
|
Data: true
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
@@ -163,31 +163,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: inputHorizontal
|
Data: gameManager
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: inputHorizontal
|
Data: gameManager
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 10|System.RuntimeType, mscorlib
|
Data: 10|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: Marro.PacManUdon.Direction, Assembly-CSharp
|
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 7
|
Entry: 9
|
||||||
Data: 11|System.RuntimeType, mscorlib
|
Data: 4
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.Int32, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -202,7 +196,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -223,19 +217,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: inputVertical
|
Data: player
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: inputVertical
|
Data: player
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 10
|
Data: 13|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: VRC.SDKBase.VRCPlayerApi, VRCSDKBase
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 11
|
Data: 13
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -271,25 +271,31 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: horizontalValue
|
Data: inputMethod
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: horizontalValue
|
Data: inputMethod
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 16|System.RuntimeType, mscorlib
|
Data: 16|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Single, mscorlib
|
Data: Marro.PacManUdon.InputMethod, Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 16
|
Data: 17|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Int32, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -304,7 +310,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -325,67 +331,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: verticalValue
|
Data: resultInput
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: verticalValue
|
Data: resultInput
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 16
|
Data: 20|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: Marro.PacManUdon.Direction, Assembly-CSharp
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 16
|
Data: 17
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: false
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 19|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: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: horizontalPriority
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: horizontalPriority
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 9
|
|
||||||
Data: 3
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 9
|
|
||||||
Data: 3
|
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -421,19 +385,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: player
|
Data: analogInput
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: player
|
Data: analogInput
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 23|System.RuntimeType, mscorlib
|
Data: 23|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: VRC.SDKBase.VRCPlayerApi, VRCSDKBase
|
Data: UnityEngine.Vector2, UnityEngine.CoreModule
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -470,6 +434,156 @@ MonoBehaviour:
|
|||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: dirty
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: dirty
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 7
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 7
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 26|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: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: lastUsedHand
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: lastUsedHand
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 28|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: VRC.Udon.Common.HandType, VRC.Udon.Common
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 28
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 29|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: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: horizontalPriority
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: horizontalPriority
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 7
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 7
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>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:
|
- Name:
|
||||||
Entry: 13
|
Entry: 13
|
||||||
Data:
|
Data:
|
||||||
|
|||||||
+190
-65
@@ -1,29 +1,80 @@
|
|||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using UdonSharp;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VRC.SDKBase;
|
using VRC.SDKBase;
|
||||||
using VRC.Udon.Common;
|
using VRC.Udon.Common;
|
||||||
|
|
||||||
public class PlayerInput : UdonSharpBehaviour
|
enum InputMethod
|
||||||
|
{
|
||||||
|
KeyboardMouse,
|
||||||
|
Other,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PlayerInput : SyncedObject
|
||||||
{
|
{
|
||||||
public bool active;
|
public bool active;
|
||||||
|
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
Direction inputHorizontal;
|
|
||||||
Direction inputVertical;
|
private VRCPlayerApi player;
|
||||||
float horizontalValue;
|
private InputMethod inputMethod;
|
||||||
float verticalValue;
|
|
||||||
bool horizontalPriority;
|
private Direction resultInput;
|
||||||
VRCPlayerApi player;
|
private Vector2 analogInput;
|
||||||
|
private bool dirty;
|
||||||
|
private HandType lastUsedHand;
|
||||||
|
private bool horizontalPriority;
|
||||||
|
|
||||||
public void Initialize(GameManager gameManager)
|
public void Initialize(GameManager gameManager)
|
||||||
{
|
{
|
||||||
this.gameManager = gameManager;
|
this.gameManager = gameManager;
|
||||||
inputHorizontal = Direction.Zero;
|
|
||||||
inputVertical = Direction.Zero;
|
|
||||||
horizontalPriority = false;
|
|
||||||
player = Networking.LocalPlayer;
|
player = Networking.LocalPlayer;
|
||||||
|
inputMethod = InputMethod.KeyboardMouse;
|
||||||
|
|
||||||
|
resultInput = Direction.Zero;
|
||||||
|
analogInput = Vector2.zero;
|
||||||
|
dirty = false;
|
||||||
|
horizontalPriority = false;
|
||||||
|
|
||||||
|
SubscribeToEvent(NetworkEventType.InputChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.R))
|
||||||
|
{
|
||||||
|
gameManager.ResetButtonPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(KeyCode.G))
|
||||||
|
{
|
||||||
|
gameManager.networkManager.DoFullSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(KeyCode.C))
|
||||||
|
{
|
||||||
|
gameManager.JumpToTimeSequenceBoardClear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.T))
|
||||||
|
{
|
||||||
|
gameManager.ResetButtonPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SyncedUpdate()
|
||||||
|
{
|
||||||
|
if (dirty) // Update now to ensure input feedback is performed timely
|
||||||
|
{
|
||||||
|
UpdateResultInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
public void Activate()
|
||||||
@@ -67,30 +118,10 @@
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
horizontalValue = Math.Abs(value);
|
|
||||||
if (value < -0.5)
|
|
||||||
{
|
|
||||||
inputHorizontal = Direction.Left;
|
|
||||||
if (horizontalValue >= verticalValue)
|
|
||||||
{
|
|
||||||
SetPriority(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (value > 0.5)
|
|
||||||
{
|
|
||||||
inputHorizontal = Direction.Right;
|
|
||||||
if (horizontalValue >= verticalValue)
|
|
||||||
{
|
|
||||||
SetPriority(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inputHorizontal = Direction.Zero;
|
|
||||||
SetPriority(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug.Log("Horizontal Input Event: " + value + " | Direction: " + direction + " | lastDirection: " + lastDirection + " | Left: " + left + " | Right: " + right);
|
analogInput.x = value;
|
||||||
|
lastUsedHand = args.handType;
|
||||||
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void InputMoveVertical(float value, UdonInputEventArgs args)
|
public override void InputMoveVertical(float value, UdonInputEventArgs args)
|
||||||
@@ -99,51 +130,145 @@
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
verticalValue = Math.Abs(value);
|
|
||||||
if (value > 0.5)
|
|
||||||
{
|
|
||||||
inputVertical = Direction.Up;
|
|
||||||
if (verticalValue >= horizontalValue)
|
|
||||||
{
|
|
||||||
SetPriority(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (value < -0.5)
|
|
||||||
{
|
|
||||||
inputVertical = Direction.Down;
|
|
||||||
if (verticalValue >= horizontalValue)
|
|
||||||
{
|
|
||||||
SetPriority(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inputVertical = Direction.Zero;
|
|
||||||
SetPriority(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug.Log("Vertical Input Event: " + value + " | Direction: " + direction + " | lastDirection : " + lastDirection);
|
analogInput.y = value;
|
||||||
|
lastUsedHand = args.handType;
|
||||||
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPriority(bool horizontalPriority)
|
public override void OnInputMethodChanged(VRCInputMethod inputMethod)
|
||||||
{
|
{
|
||||||
if (this.horizontalPriority != horizontalPriority)
|
switch (inputMethod)
|
||||||
{
|
{
|
||||||
player.PlayHapticEventInHand(VRC_Pickup.PickupHand.Left, 0.1f, 0.15f, 75);
|
case VRCInputMethod.Keyboard:
|
||||||
this.horizontalPriority = horizontalPriority;
|
case VRCInputMethod.Mouse:
|
||||||
|
this.inputMethod = InputMethod.KeyboardMouse;
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
this.inputMethod = InputMethod.Other;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateResultInput()
|
||||||
|
{
|
||||||
|
dirty = false;
|
||||||
|
var newResult = GetResultInput(analogInput);
|
||||||
|
|
||||||
|
if (newResult == resultInput)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Debug.Log($"Switched to input direction {newResult} from analogInput {analogInput} with HorizontalPriority {horizontalPriority}");
|
||||||
|
|
||||||
|
resultInput = newResult;
|
||||||
|
networkManager.SendEventSoon(NetworkEventType.InputChange, true);
|
||||||
|
PlayHaptics();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayHaptics()
|
||||||
|
{
|
||||||
|
if (inputMethod == InputMethod.KeyboardMouse)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VRC_Pickup.PickupHand hand;
|
||||||
|
switch (lastUsedHand)
|
||||||
|
{
|
||||||
|
case HandType.LEFT:
|
||||||
|
hand = VRC_Pickup.PickupHand.Left;
|
||||||
|
break;
|
||||||
|
case HandType.RIGHT:
|
||||||
|
hand = VRC_Pickup.PickupHand.Right;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.PlayHapticEventInHand(hand, 0.1f, 0.15f, 75);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Direction GetResultInput(Vector2 analogInput)
|
||||||
|
{
|
||||||
|
if (analogInput.magnitude < 0.8)
|
||||||
|
{
|
||||||
|
return Direction.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
var normalized = analogInput.normalized;
|
||||||
|
|
||||||
|
//Debug.Log($"Checking analogInput {analogInput} with HorizontalPriority {horizontalPriority}, normalized {normalized}");
|
||||||
|
|
||||||
|
const float directionDivider = 0.72f;
|
||||||
|
if (normalized.x > directionDivider)
|
||||||
|
{
|
||||||
|
horizontalPriority = false;
|
||||||
|
return Direction.Right;
|
||||||
|
}
|
||||||
|
else if (normalized.x < -directionDivider)
|
||||||
|
{
|
||||||
|
horizontalPriority = false;
|
||||||
|
return Direction.Left;
|
||||||
|
}
|
||||||
|
else if (normalized.y > directionDivider)
|
||||||
|
{
|
||||||
|
horizontalPriority = true;
|
||||||
|
return Direction.Up;
|
||||||
|
}
|
||||||
|
else if (normalized.y < -directionDivider)
|
||||||
|
{
|
||||||
|
horizontalPriority = true;
|
||||||
|
return Direction.Down;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (horizontalPriority)
|
||||||
|
{
|
||||||
|
if (normalized.x > 0)
|
||||||
|
{
|
||||||
|
return Direction.Right;
|
||||||
|
}
|
||||||
|
return Direction.Left;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.y > 0)
|
||||||
|
{
|
||||||
|
return Direction.Up;
|
||||||
|
}
|
||||||
|
return Direction.Down;
|
||||||
|
}
|
||||||
|
|
||||||
public Direction GetDirection()
|
public Direction GetDirection()
|
||||||
{
|
{
|
||||||
if (horizontalPriority)
|
if (dirty) // Update now to reduce input delay
|
||||||
{
|
{
|
||||||
return inputHorizontal;
|
UpdateResultInput();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return resultInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
|
{
|
||||||
|
if (eventType != NetworkEventType.InputChange)
|
||||||
{
|
{
|
||||||
return inputVertical;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ByteUtils.AppendAsByte(data, (int)resultInput, ref index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
|
{
|
||||||
|
if (eventType != NetworkEventType.InputChange)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultInput = (Direction)ByteUtils.ReadByte(data, ref index);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
|
||||||
m_Name: PowerPellet
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
serializedUdonProgramAsset: {fileID: 11400000, guid: bc9582994932aa648bc02c914215e7cc, type: 2}
|
|
||||||
udonAssembly:
|
|
||||||
assemblyError:
|
|
||||||
sourceCsScript: {fileID: 11500000, guid: 55d0efe8af4dba540a508287baca6656, type: 3}
|
|
||||||
scriptVersion: 2
|
|
||||||
compiledVersion: 2
|
|
||||||
behaviourSyncMode: 0
|
|
||||||
hasInteractEvent: 0
|
|
||||||
scriptID: 7835090324168685075
|
|
||||||
serializationData:
|
|
||||||
SerializedFormat: 2
|
|
||||||
SerializedBytes:
|
|
||||||
ReferencedUnityObjects: []
|
|
||||||
SerializedBytesString:
|
|
||||||
Prefab: {fileID: 0}
|
|
||||||
PrefabModificationsReferencedUnityObjects: []
|
|
||||||
PrefabModifications: []
|
|
||||||
SerializationNodes:
|
|
||||||
- Name: fieldDefinitions
|
|
||||||
Entry: 7
|
|
||||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
|
|
||||||
UdonSharp.Editor]], mscorlib
|
|
||||||
- Name: comparer
|
|
||||||
Entry: 7
|
|
||||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
|
||||||
mscorlib]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 0
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 896816ace5640c644bd057ab48c3b9a1
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace Marro.PacManUdon
|
|
||||||
{
|
|
||||||
using UdonSharp;
|
|
||||||
|
|
||||||
public class PowerPellet : UdonSharpBehaviour
|
|
||||||
{
|
|
||||||
// Oh how I wish I could just have this method extend pellet and do things the normal way...
|
|
||||||
// But alas, with 'typeof', 'is' and overriding base fields all broken/not available I don't see a good way of differentiating between a type or its derivatives...
|
|
||||||
// The only reason I even want to use this class is so I can do GetComponentsInChildren<PowerPellet> instead of gathering all Pellets and then sorting through them.
|
|
||||||
// But since power pellets are the only pellets with animators, I'll probably just use GetComponentsInChildren<Animator> instead without further checking, since the animator is what I need to manipulate anyway.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 55d0efe8af4dba540a508287baca6656
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -14,7 +14,6 @@ namespace Marro.PacManUdon
|
|||||||
SetGameState(PacManGameState.AttractModeDemo);
|
SetGameState(PacManGameState.AttractModeDemo);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
InitializeLevel();
|
|
||||||
SetMazeVisible(true);
|
SetMazeVisible(true);
|
||||||
SetLevel(1);
|
SetLevel(1);
|
||||||
break;
|
break;
|
||||||
@@ -323,7 +322,6 @@ namespace Marro.PacManUdon
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
SetPelletsActive(true);
|
SetPelletsActive(true);
|
||||||
collisionManager.RestoreAllPellets();
|
|
||||||
statusDisplay.SetGameOverTextVisible(true);
|
statusDisplay.SetGameOverTextVisible(true);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ namespace Marro.PacManUdon
|
|||||||
pacMan.SetPosition(attractScreenElements[16].transform.localPosition);
|
pacMan.SetPosition(attractScreenElements[16].transform.localPosition);
|
||||||
pacMan.SetDirection(Direction.Left);
|
pacMan.SetDirection(Direction.Left);
|
||||||
|
|
||||||
ghostManager.RestartLevel();
|
|
||||||
ghostManager.SetLevel(2);
|
ghostManager.SetLevel(2);
|
||||||
ghostManager.SetKinematic(true);
|
ghostManager.SetKinematic(true);
|
||||||
ghostManager.SetActive(true);
|
ghostManager.SetActive(true);
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ namespace Marro.PacManUdon
|
|||||||
{
|
{
|
||||||
// Unfreeze and reveal pacman
|
// Unfreeze and reveal pacman
|
||||||
SetPacManActive(true);
|
SetPacManActive(true);
|
||||||
SetFrozen(false);
|
SetFrozen(false); // This also makes the caught ghost return home
|
||||||
ghostManager.GhostCaughtContinue();
|
|
||||||
soundManager.SetGhostRetreat(true);
|
soundManager.SetGhostRetreat(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Marro.PacManUdon
|
|||||||
case 1:
|
case 1:
|
||||||
// Hide ghosts, start pacman death animation
|
// Hide ghosts, start pacman death animation
|
||||||
SetGhostsActive(false);
|
SetGhostsActive(false);
|
||||||
pacMan.SetDead(true);
|
pacMan.Die();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// Start playing death sound
|
// Start playing death sound
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ namespace Marro.PacManUdon
|
|||||||
SetFrozen(false);
|
SetFrozen(false);
|
||||||
soundManager.SuppressSound(false);
|
soundManager.SuppressSound(false);
|
||||||
soundManager.StartGhostSound();
|
soundManager.StartGhostSound();
|
||||||
soundManager.UpdatePelletCount(collisionManager.PelletCount - collisionManager.PelletCollectedCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ namespace Marro.PacManUdon
|
|||||||
gameState = PacManGameState.InGame;
|
gameState = PacManGameState.InGame;
|
||||||
|
|
||||||
InitializeNewGame();
|
InitializeNewGame();
|
||||||
InitializeLevel();
|
|
||||||
PrepareForCutscene();
|
PrepareForCutscene();
|
||||||
|
|
||||||
soundManager.SuppressSound(false);
|
soundManager.SuppressSound(false);
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ namespace Marro.PacManUdon
|
|||||||
PrepareForCutscene();
|
PrepareForCutscene();
|
||||||
|
|
||||||
// Reset, show maze and score display
|
// Reset, show maze and score display
|
||||||
InitializeLevel();
|
|
||||||
SetMazeVisible(true);
|
SetMazeVisible(true);
|
||||||
statusDisplay.SetScoreDisplayVisible(true);
|
statusDisplay.SetScoreDisplayVisible(true);
|
||||||
|
statusDisplay.SetLabel1UPTextBlinking(true);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Increment level, show ready, show pellets, show lives indicators
|
// Increment level, show ready, show pellets, show lives indicators
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ namespace Marro.PacManUdon
|
|||||||
public partial class GameManager
|
public partial class GameManager
|
||||||
{
|
{
|
||||||
// A note about the quality of the code here:
|
// A note about the quality of the code here:
|
||||||
// I intended to write this using proper classes, right until I realized Udon does not support instantiating classes.
|
// I intended to write this using separate classes per time sequence, until I realized Udon does not support instantiating classes.
|
||||||
// While I'm not a big fan of the partial class solution that I ended up doing (static classes would still be neater, or perhaps separate UdonSharpBehaviour instances),
|
// While I'm not a big fan of using partial classes for this, I'm not redoing this unless there's a major Udon update before I wrap up this project.
|
||||||
// I'm not redoing this unless I get instantiatable classes before I wrap up this project.
|
|
||||||
bool currentlyInTimeSequence;
|
bool currentlyInTimeSequence;
|
||||||
bool waitingForTimeSequenceFinalize;
|
bool waitingForTimeSequenceFinalize;
|
||||||
bool jumpingToTimeSequence;
|
bool jumpingToTimeSequence;
|
||||||
@@ -44,7 +43,6 @@ namespace Marro.PacManUdon
|
|||||||
jumpingToTimeSequence = true;
|
jumpingToTimeSequence = true;
|
||||||
TimeSequenceProgressToTime(100000f);
|
TimeSequenceProgressToTime(100000f);
|
||||||
|
|
||||||
|
|
||||||
if (waitingForTimeSequenceFinalize)
|
if (waitingForTimeSequenceFinalize)
|
||||||
{
|
{
|
||||||
TimeSequenceExecuteFinalize(currentTimeSequence);
|
TimeSequenceExecuteFinalize(currentTimeSequence);
|
||||||
@@ -97,29 +95,29 @@ namespace Marro.PacManUdon
|
|||||||
private void TimeSequenceFinish(PacManTimeSequence timeSequence)
|
private void TimeSequenceFinish(PacManTimeSequence timeSequence)
|
||||||
{
|
{
|
||||||
TimeSequenceExecuteFinalize(timeSequence);
|
TimeSequenceExecuteFinalize(timeSequence);
|
||||||
networkManager.SendEventSoon(NetworkEventType.TimeSequenceSync);
|
|
||||||
if (!jumpingToTimeSequence)
|
if (!jumpingToTimeSequence)
|
||||||
{
|
{
|
||||||
TimeSequenceExecuteFinished(timeSequence);
|
TimeSequenceExecuteFinished(timeSequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TimeSequenceSyncWithRemote(PacManTimeSequence currentTimeSequence, float timeSequenceSecondsPassed)
|
private void TimeSequenceSyncWithRemote(PacManTimeSequence remoteCurrentTimeSequence, float timeSequenceSecondsPassedRemote)
|
||||||
{
|
{
|
||||||
// If the remote is in a time sequence but we're not, or we're in a different time sequence, or if we're behind,
|
// If our current time sequence state is incompatible with the remote time sequence, kill it
|
||||||
// jump to the remote's time sequence.
|
if (currentlyInTimeSequence && remoteCurrentTimeSequence != currentTimeSequence
|
||||||
if (!currentlyInTimeSequence
|
|| timeSequenceSecondsPassedRemote < timeSequenceSecondsPassed)
|
||||||
|| currentTimeSequence != this.currentTimeSequence
|
|
||||||
|| timeSequenceSecondsPassed < this.timeSequenceSecondsPassed)
|
|
||||||
{
|
{
|
||||||
StartTimeSequence(currentTimeSequence);
|
currentlyInTimeSequence = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're (now) in a time sequence, jump our progress to match the one on the remote
|
// If we're not/no longer in a time sequence, start the remote's time sequence
|
||||||
if (currentlyInTimeSequence)
|
if (!currentlyInTimeSequence)
|
||||||
{
|
{
|
||||||
TimeSequenceProgressToTime(timeSequenceSecondsPassed);
|
StartTimeSequence(remoteCurrentTimeSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jump our progress to match the one on the remote
|
||||||
|
TimeSequenceProgressToTime(timeSequenceSecondsPassedRemote);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
|||||||
@@ -1147,19 +1147,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _nextDotSound
|
Data: alternatePelletSound
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 65|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 65|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _nextDotSound
|
Data: alternatePelletSound
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 7
|
||||||
Data: 17
|
Data: 66|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Boolean, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 17
|
Data: 66
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -1174,7 +1180,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 66|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 67|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -1195,25 +1201,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _ghostRetreating
|
Data: ghostRetreating
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 67|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 68|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _ghostRetreating
|
Data: ghostRetreating
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 9
|
||||||
Data: 68|System.RuntimeType, mscorlib
|
Data: 66
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.Boolean, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -1249,19 +1249,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _ghostBlue
|
Data: ghostBlue
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 70|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 70|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _ghostBlue
|
Data: ghostBlue
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -1297,13 +1297,13 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _ghostSoundLevel
|
Data: ghostSoundLevel
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 72|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 72|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _ghostSoundLevel
|
Data: ghostSoundLevel
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 73|System.RuntimeType, mscorlib
|
Data: 73|System.RuntimeType, mscorlib
|
||||||
@@ -1351,19 +1351,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _currentlyPlayingSiren
|
Data: currentlyPlayingSiren
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 75|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 75|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _currentlyPlayingSiren
|
Data: currentlyPlayingSiren
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -1399,19 +1399,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _suppress
|
Data: suppress
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 77|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 77|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: _suppress
|
Data: suppress
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 68
|
Data: 66
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Marro.PacManUdon;
|
using Marro.PacManUdon;
|
||||||
using UdonSharp;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VRC.SDKBase;
|
|
||||||
using VRC.Udon;
|
|
||||||
|
|
||||||
public class SoundManager : SyncedObject
|
public class SoundManager : SyncedObject
|
||||||
{
|
{
|
||||||
@@ -30,13 +28,13 @@ public class SoundManager : SyncedObject
|
|||||||
[SerializeField] private AudioClip siren3;
|
[SerializeField] private AudioClip siren3;
|
||||||
[SerializeField] private AudioClip siren4;
|
[SerializeField] private AudioClip siren4;
|
||||||
|
|
||||||
private AudioClip _nextDotSound;
|
private bool alternatePelletSound;
|
||||||
private bool _ghostRetreating;
|
private bool ghostRetreating;
|
||||||
private bool _ghostBlue;
|
private bool ghostBlue;
|
||||||
private int _ghostSoundLevel;
|
private int ghostSoundLevel;
|
||||||
private bool _currentlyPlayingSiren;
|
private bool currentlyPlayingSiren;
|
||||||
|
|
||||||
private bool _suppress;
|
private bool suppress;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
@@ -47,19 +45,19 @@ public class SoundManager : SyncedObject
|
|||||||
{
|
{
|
||||||
StopAllSound();
|
StopAllSound();
|
||||||
|
|
||||||
_nextDotSound = pacDot2;
|
alternatePelletSound = false;
|
||||||
|
|
||||||
_ghostRetreating = false;
|
ghostRetreating = false;
|
||||||
_ghostBlue = false;
|
ghostBlue = false;
|
||||||
_ghostSoundLevel = 0;
|
ghostSoundLevel = 0;
|
||||||
_currentlyPlayingSiren = false;
|
currentlyPlayingSiren = false;
|
||||||
|
|
||||||
_suppress = true;
|
suppress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SuppressSound(bool suppress)
|
public void SuppressSound(bool suppress)
|
||||||
{
|
{
|
||||||
_suppress = suppress;
|
this.suppress = suppress;
|
||||||
|
|
||||||
if (suppress)
|
if (suppress)
|
||||||
{
|
{
|
||||||
@@ -79,8 +77,8 @@ public class SoundManager : SyncedObject
|
|||||||
|
|
||||||
public void PlayPelletSound()
|
public void PlayPelletSound()
|
||||||
{
|
{
|
||||||
PlaySound(audioSourcePacMan, _nextDotSound);
|
PlaySound(audioSourcePacMan, alternatePelletSound ? pacDot2 : pacDot1);
|
||||||
_nextDotSound = _nextDotSound == pacDot1 ? pacDot2 : pacDot1;
|
alternatePelletSound = !alternatePelletSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayDeathSound()
|
public void PlayDeathSound()
|
||||||
@@ -115,13 +113,13 @@ public class SoundManager : SyncedObject
|
|||||||
|
|
||||||
public void SetGhostBlue(bool isBlue)
|
public void SetGhostBlue(bool isBlue)
|
||||||
{
|
{
|
||||||
_ghostBlue = isBlue;
|
ghostBlue = isBlue;
|
||||||
UpdateGhostSound();
|
UpdateGhostSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetGhostRetreat(bool isRetreating)
|
public void SetGhostRetreat(bool isRetreating)
|
||||||
{
|
{
|
||||||
_ghostRetreating = isRetreating;
|
ghostRetreating = isRetreating;
|
||||||
UpdateGhostSound();
|
UpdateGhostSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,19 +152,19 @@ public class SoundManager : SyncedObject
|
|||||||
|
|
||||||
// Debug.Log($"UpdatePelletCount: {pelletCount}, level: {level}");
|
// Debug.Log($"UpdatePelletCount: {pelletCount}, level: {level}");
|
||||||
|
|
||||||
if (_ghostSoundLevel >= level)
|
if (ghostSoundLevel >= level)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ghostSoundLevel = level;
|
ghostSoundLevel = level;
|
||||||
UpdateGhostSound();
|
UpdateGhostSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlaySound(AudioSource audioSource, AudioClip audioClip, bool loop = false)
|
private void PlaySound(AudioSource audioSource, AudioClip audioClip, bool loop = false)
|
||||||
{
|
{
|
||||||
// Debug.Log($"PlaySound, audioSource: {audioSource}, audioClip: {audioClip}, loop: {loop}, suppress: {_suppress}");
|
// Debug.Log($"PlaySound, audioSource: {audioSource}, audioClip: {audioClip}, loop: {loop}, suppress: {_suppress}");
|
||||||
if (_suppress)
|
if (suppress)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,7 +182,7 @@ public class SoundManager : SyncedObject
|
|||||||
|
|
||||||
private void SwitchSound(AudioSource audioSource, AudioClip audioClip, bool loop)
|
private void SwitchSound(AudioSource audioSource, AudioClip audioClip, bool loop)
|
||||||
{
|
{
|
||||||
if (_suppress)
|
if (suppress)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -210,22 +208,22 @@ public class SoundManager : SyncedObject
|
|||||||
|
|
||||||
private void UpdateGhostSound()
|
private void UpdateGhostSound()
|
||||||
{
|
{
|
||||||
if (_ghostRetreating)
|
if (ghostRetreating)
|
||||||
{
|
{
|
||||||
PlaySound(audioSourceGhosts, pacGhostRetreat, true);
|
PlaySound(audioSourceGhosts, pacGhostRetreat, true);
|
||||||
_currentlyPlayingSiren = false;
|
currentlyPlayingSiren = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ghostBlue)
|
if (ghostBlue)
|
||||||
{
|
{
|
||||||
PlaySound(audioSourceGhosts, pacGhostBlue, true);
|
PlaySound(audioSourceGhosts, pacGhostBlue, true);
|
||||||
_currentlyPlayingSiren = false;
|
currentlyPlayingSiren = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentGhostLevelSound = GetSoundForGhostLevel(_ghostSoundLevel);
|
var currentGhostLevelSound = GetSoundForGhostLevel(ghostSoundLevel);
|
||||||
if (_currentlyPlayingSiren)
|
if (currentlyPlayingSiren)
|
||||||
{
|
{
|
||||||
SwitchSound(audioSourceGhosts, currentGhostLevelSound, true);
|
SwitchSound(audioSourceGhosts, currentGhostLevelSound, true);
|
||||||
}
|
}
|
||||||
@@ -234,7 +232,7 @@ public class SoundManager : SyncedObject
|
|||||||
PlaySound(audioSourceGhosts, currentGhostLevelSound, true);
|
PlaySound(audioSourceGhosts, currentGhostLevelSound, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentlyPlayingSiren = true;
|
currentlyPlayingSiren = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AudioClip GetSoundForGhostLevel(int ghostLevel)
|
private AudioClip GetSoundForGhostLevel(int ghostLevel)
|
||||||
@@ -256,11 +254,23 @@ public class SoundManager : SyncedObject
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
|
data.Append(alternatePelletSound, ref index);
|
||||||
|
data.Append(ghostRetreating, ref index);
|
||||||
|
data.Append(ghostBlue, ref index);
|
||||||
|
data.AppendAsByte(ghostSoundLevel, ref index);
|
||||||
|
data.Append(currentlyPlayingSiren, ref index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
|
alternatePelletSound = data.ReadBool(ref index);
|
||||||
|
ghostRetreating = data.ReadBool(ref index);
|
||||||
|
ghostBlue = data.ReadBool(ref index);
|
||||||
|
ghostSoundLevel = data.ReadByte(ref index);
|
||||||
|
currentlyPlayingSiren = data.ReadBool(ref index);
|
||||||
|
|
||||||
|
UpdateGhostSound();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,15 +166,5 @@ namespace Marro.PacManUdon
|
|||||||
levelDisplayDigitAnimators[i].SetFloat("FruitType", PacManConstants.FruitTypeToValue(PacManConstants.GetFruitTypeForLevel(level - i)));
|
levelDisplayDigitAnimators[i].SetFloat("FruitType", PacManConstants.FruitTypeToValue(PacManConstants.GetFruitTypeForLevel(level - i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Collections;
|
using UdonSharp;
|
||||||
using UdonSharp;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
|
||||||
m_Name: Teleporter
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 1589eb7cce8925e4da3272208dfa87f4, type: 2}
|
|
||||||
udonAssembly:
|
|
||||||
assemblyError:
|
|
||||||
sourceCsScript: {fileID: 11500000, guid: aae1c5d18ae01b3488b54c72e6f1edf6, type: 3}
|
|
||||||
scriptVersion: 2
|
|
||||||
compiledVersion: 2
|
|
||||||
behaviourSyncMode: 0
|
|
||||||
hasInteractEvent: 0
|
|
||||||
scriptID: -7788394196284941649
|
|
||||||
serializationData:
|
|
||||||
SerializedFormat: 2
|
|
||||||
SerializedBytes:
|
|
||||||
ReferencedUnityObjects: []
|
|
||||||
SerializedBytesString:
|
|
||||||
Prefab: {fileID: 0}
|
|
||||||
PrefabModificationsReferencedUnityObjects: []
|
|
||||||
PrefabModifications: []
|
|
||||||
SerializationNodes:
|
|
||||||
- Name: fieldDefinitions
|
|
||||||
Entry: 7
|
|
||||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
|
|
||||||
UdonSharp.Editor]], mscorlib
|
|
||||||
- Name: comparer
|
|
||||||
Entry: 7
|
|
||||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
|
||||||
mscorlib]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 2
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: direction
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: direction
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 3|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: Marro.PacManUdon.Direction, Assembly-CSharp
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 4|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.Int32, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: true
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 1
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: target
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: target
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 8|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: UnityEngine.Transform, UnityEngine.CoreModule
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 9
|
|
||||||
Data: 8
|
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: true
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 1
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c6e306d768eba5b469eea599abcf4800
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
namespace Marro.PacManUdon
|
|
||||||
{
|
|
||||||
using UdonSharp;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class Teleporter : UdonSharpBehaviour
|
|
||||||
{
|
|
||||||
[SerializeField] private Direction direction = Direction.Zero;
|
|
||||||
[SerializeField] private Transform target;
|
|
||||||
|
|
||||||
void OnTriggerEnter(Collider other)
|
|
||||||
{
|
|
||||||
GridMover gridMover = other.gameObject.GetComponent<GridMover>();
|
|
||||||
|
|
||||||
if (gridMover == null || gridMover.GetDirection() != direction)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gridMover.SetPosition(gridMover.GetPosition() + (Vector2)(target.localPosition - transform.localPosition));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: aae1c5d18ae01b3488b54c72e6f1edf6
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
namespace Marro.PacManUdon
|
|
||||||
{
|
|
||||||
using UdonSharp;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class Test : UdonSharpBehaviour
|
|
||||||
{
|
|
||||||
[SerializeField] Pellet pellet;
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
Debug.Log(pellet.enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0227a738d77ab0849bdc9047b5b27c78
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
|
||||||
m_Name: Test1
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 6457f9f1332ac0742bdff23291631f30, type: 2}
|
|
||||||
udonAssembly:
|
|
||||||
assemblyError:
|
|
||||||
sourceCsScript: {fileID: 11500000, guid: 0227a738d77ab0849bdc9047b5b27c78, type: 3}
|
|
||||||
scriptVersion: 2
|
|
||||||
compiledVersion: 2
|
|
||||||
behaviourSyncMode: 0
|
|
||||||
hasInteractEvent: 0
|
|
||||||
scriptID: -4571266787425106669
|
|
||||||
serializationData:
|
|
||||||
SerializedFormat: 2
|
|
||||||
SerializedBytes:
|
|
||||||
ReferencedUnityObjects: []
|
|
||||||
SerializedBytesString:
|
|
||||||
Prefab: {fileID: 0}
|
|
||||||
PrefabModificationsReferencedUnityObjects: []
|
|
||||||
PrefabModifications: []
|
|
||||||
SerializationNodes:
|
|
||||||
- Name: fieldDefinitions
|
|
||||||
Entry: 7
|
|
||||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
|
|
||||||
UdonSharp.Editor]], mscorlib
|
|
||||||
- Name: comparer
|
|
||||||
Entry: 7
|
|
||||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
|
||||||
mscorlib]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 1
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 1
|
|
||||||
Data: pellet
|
|
||||||
- Name: $v
|
|
||||||
Entry: 7
|
|
||||||
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
|
||||||
- Name: <Name>k__BackingField
|
|
||||||
Entry: 1
|
|
||||||
Data: pellet
|
|
||||||
- Name: <UserType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 3|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: Marro.PacManUdon.Pellet, Assembly-CSharp
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: 4|System.RuntimeType, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: VRC.Udon.UdonBehaviour, VRC.Udon
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SyncMode>k__BackingField
|
|
||||||
Entry: 7
|
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 6
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <IsSerialized>k__BackingField
|
|
||||||
Entry: 5
|
|
||||||
Data: true
|
|
||||||
- Name: _fieldAttributes
|
|
||||||
Entry: 7
|
|
||||||
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 1
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 184e93443ec1bb24fa4e1db8b51405da
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
// // Silly me for wanting to make the code neat, forgot this was Udon :)
|
|
||||||
|
|
||||||
// using System.Collections;
|
|
||||||
// using System.Collections.Generic;
|
|
||||||
// using UdonSharp;
|
|
||||||
// using UnityEngine;
|
|
||||||
|
|
||||||
// public abstract class TimeSequence : UdonSharpBehaviour
|
|
||||||
// {
|
|
||||||
// [UdonSynced] float secondsPassed;
|
|
||||||
// int sequenceProgress;
|
|
||||||
// float[] sequenceTimeSeconds;
|
|
||||||
|
|
||||||
// protected TimeSequence(float[] sequenceTimeSeconds)
|
|
||||||
// {
|
|
||||||
// sequenceProgress = 0;
|
|
||||||
// secondsPassed = 0;
|
|
||||||
// this.sequenceTimeSeconds = sequenceTimeSeconds;
|
|
||||||
// ProgressSequenceToTime(secondsPassed);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void ProgressInTime(float deltaSeconds)
|
|
||||||
// {
|
|
||||||
// ProgressSequenceToTime(secondsPassed + deltaSeconds);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void ProgressSequenceToTime(float seconds)
|
|
||||||
// {
|
|
||||||
// secondsPassed = seconds;
|
|
||||||
// while (secondsPassed >= sequenceTimeSeconds[sequenceProgress])
|
|
||||||
// {
|
|
||||||
// sequenceProgress += 1;
|
|
||||||
// SequenceStep(sequenceProgress);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected abstract void SequenceStep(int sequneceProgress);
|
|
||||||
|
|
||||||
// public static float[] DeltaToAbsolute(float[] delta)
|
|
||||||
// {
|
|
||||||
// if (delta.Length < 1)
|
|
||||||
// {
|
|
||||||
// return new float[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// float[] absolute = new float[delta.Length];
|
|
||||||
// absolute[0] = delta[0];
|
|
||||||
// for (int i = 1; i < delta.Length; i++)
|
|
||||||
// {
|
|
||||||
// absolute[i] = delta[i] + absolute[i-1];
|
|
||||||
// }
|
|
||||||
// return absolute;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public int SequenceProgress
|
|
||||||
// {
|
|
||||||
// get => sequenceProgress;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public float SecondsPassed
|
|
||||||
// {
|
|
||||||
// get => secondsPassed;
|
|
||||||
// set => ProgressSequenceToTime(value);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 789dbd838d9dd5645852b3bda8c5a161
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -12,6 +12,7 @@ public class NetworkManagerSyncTester : UdonSharpBehaviour
|
|||||||
[SerializeField] GridMover[] gridMovers1;
|
[SerializeField] GridMover[] gridMovers1;
|
||||||
[SerializeField] NetworkManager networkManager2;
|
[SerializeField] NetworkManager networkManager2;
|
||||||
[SerializeField] GridMover[] gridMovers2;
|
[SerializeField] GridMover[] gridMovers2;
|
||||||
|
|
||||||
[SerializeField] Animator debugImageToIndicateSynced;
|
[SerializeField] Animator debugImageToIndicateSynced;
|
||||||
|
|
||||||
private int[] captureTimes = new int[1000];
|
private int[] captureTimes = new int[1000];
|
||||||
@@ -46,11 +47,11 @@ public class NetworkManagerSyncTester : UdonSharpBehaviour
|
|||||||
DiscardCapture();
|
DiscardCapture();
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"ownerTime: {ownerTime}, remoteTime: {remoteTime}, ownerIndex: {ownerIndex} ({captureTimes[ownerIndex]}), remoteIndex: {remoteIndex} ({captureTimes[remoteIndex]})");
|
//Debug.Log($"ownerTime: {ownerTime}, remoteTime: {remoteTime}, ownerIndex: {ownerIndex} ({captureTimes[ownerIndex]}), remoteIndex: {remoteIndex} ({captureTimes[remoteIndex]})");
|
||||||
|
|
||||||
if (captureTimes[remoteIndex] == remoteTime)
|
if (captureTimes[remoteIndex] == remoteTime)
|
||||||
{
|
{
|
||||||
bool equal = IsEqual(remoteIndex);
|
bool equal = IsEqual(remoteIndex, remoteTime);
|
||||||
SetIndicator(equal);
|
SetIndicator(equal);
|
||||||
|
|
||||||
DiscardCapture();
|
DiscardCapture();
|
||||||
@@ -63,11 +64,15 @@ public class NetworkManagerSyncTester : UdonSharpBehaviour
|
|||||||
IncrementIndex(ref remoteIndex);
|
IncrementIndex(ref remoteIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsEqual(int index)
|
private bool IsEqual(int index, int time)
|
||||||
{
|
{
|
||||||
var equal = true;
|
var equal = true;
|
||||||
|
|
||||||
var positions1 = positionCaptures[index];
|
var positions1 = positionCaptures[index];
|
||||||
|
if (positions1 == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var positions2 = GetPositions(gridMovers2);
|
var positions2 = GetPositions(gridMovers2);
|
||||||
for (int i = 0; i < positions1.Length; i++)
|
for (int i = 0; i < positions1.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -79,7 +84,7 @@ public class NetworkManagerSyncTester : UdonSharpBehaviour
|
|||||||
|
|
||||||
if (gridMover1Position != gridMover2Position)
|
if (gridMover1Position != gridMover2Position)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"{nameof(NetworkManagerSyncTester)} Desync found:\n{gridMover1.name} {gridMover1Position} != {gridMover2.name} {gridMover2Position}");
|
Debug.LogWarning($"{nameof(NetworkManagerSyncTester)} Desync found at {time} in {gridMover1.name}:\n {gridMover1Position} (local) != {gridMover2Position} (remote)");
|
||||||
//networkManager1.Pause();
|
//networkManager1.Pause();
|
||||||
//networkManager2.Pause();
|
//networkManager2.Pause();
|
||||||
equal = false;
|
equal = false;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
|||||||
public class NetworkManagerTester : UdonSharpBehaviour
|
public class NetworkManagerTester : UdonSharpBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private NetworkManager[] networkManagers;
|
[SerializeField] private NetworkManager[] networkManagers;
|
||||||
[SerializeField] private float interval = 0.1f;
|
[SerializeField] private float interval = 0.01f;
|
||||||
[SerializeField] private int ownerIndex = 0;
|
[SerializeField] private int ownerIndex = 0;
|
||||||
|
|
||||||
private float countdown = 0;
|
private float countdown = 0;
|
||||||
@@ -43,7 +43,7 @@ public class NetworkManagerTester : UdonSharpBehaviour
|
|||||||
|
|
||||||
var data = PerformSerialization(source);
|
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)
|
foreach (var target in networkManagers)
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ public class NetworkManagerTester : UdonSharpBehaviour
|
|||||||
{
|
{
|
||||||
networkManager.OnPreSerialization();
|
networkManager.OnPreSerialization();
|
||||||
var data = networkManager.NetworkedData;
|
var data = networkManager.NetworkedData;
|
||||||
networkManager.OnPostSerializationInternal(true, data.Length) ;
|
networkManager.OnPostSerializationInternal(true, data.Length);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class NetworkManagerTester : UdonSharpBehaviour
|
|||||||
{
|
{
|
||||||
foreach (var target in networkManagers)
|
foreach (var target in networkManagers)
|
||||||
{
|
{
|
||||||
if (!target.IsOwner || !target.SerializationRequested)
|
if (!target.IsOwner)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,8 +130,7 @@ public class TestBall : SyncedObject
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType == NetworkEventType.FullSync
|
if (eventType == NetworkEventType.FullSync)
|
||||||
|| eventType == NetworkEventType.FullSyncForced)
|
|
||||||
{
|
{
|
||||||
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
|
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
|
||||||
data.Append(amountUp, ref index);
|
data.Append(amountUp, ref index);
|
||||||
@@ -141,8 +140,7 @@ public class TestBall : SyncedObject
|
|||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (eventType == NetworkEventType.FullSync
|
if (eventType == NetworkEventType.FullSync)
|
||||||
|| eventType == NetworkEventType.FullSyncForced)
|
|
||||||
{
|
{
|
||||||
amountUp = data.ReadFloat(ref index);
|
amountUp = data.ReadFloat(ref index);
|
||||||
SetProgress(data.ReadFloat(ref index));
|
SetProgress(data.ReadFloat(ref index));
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class TestBallManager : UdonSharpBehaviour
|
|||||||
testBall.UpButtonPressed();
|
testBall.UpButtonPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
|
networkManager.SendEventSoon(NetworkEventType.InputChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SyncButtonPressed()
|
public void SyncButtonPressed()
|
||||||
|
|||||||
Reference in New Issue
Block a user