More sync
This commit is contained in:
@@ -458,7 +458,8 @@ Transform:
|
|||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children:
|
||||||
|
- {fileID: 1470248941}
|
||||||
m_Father: {fileID: 1886023632}
|
m_Father: {fileID: 1886023632}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &107806787
|
--- !u!1 &107806787
|
||||||
@@ -8438,6 +8439,37 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1465823362}
|
m_GameObject: {fileID: 1465823362}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &1470248940
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1470248941}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Check if ghost behaviour per level is correct
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1470248941
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1470248940}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 106401850}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1472000832 stripped
|
--- !u!1 &1472000832 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
m_CorrespondingSourceObject: {fileID: 6334235783093999612, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
m_CorrespondingSourceObject: {fileID: 6334235783093999612, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||||
|
|||||||
@@ -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,15 +31,17 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void SyncedUpdate()
|
public override void SyncedUpdate()
|
||||||
{
|
{
|
||||||
if (active && !frozen)
|
if (!active || frozen)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
activeCountdown -= networkManager.SyncedDeltaTime;
|
activeCountdown -= networkManager.SyncedDeltaTime;
|
||||||
if (activeCountdown <= 0)
|
if (activeCountdown <= 0)
|
||||||
{
|
{
|
||||||
SetActive(false);
|
SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Spawn()
|
public void Spawn()
|
||||||
{
|
{
|
||||||
@@ -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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacManFruitType FruitType
|
activeCountdown = data.ReadFloat(ref index);
|
||||||
{
|
frozen = data.ReadBool(ref index);
|
||||||
set
|
|
||||||
{
|
return true;
|
||||||
SetFruitType(value);
|
|
||||||
}
|
|
||||||
get => fruitType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Active
|
public bool Active => active;
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetActive(value);
|
|
||||||
}
|
|
||||||
get => active;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly DataDictionary fruitScoreValue = new DataDictionary()
|
private readonly DataDictionary fruitScoreValue = new DataDictionary()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -384,8 +384,11 @@ 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.FullSync)
|
if (eventType != NetworkEventType.FullSync)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Append(currentlyInTimeSequence, ref index);
|
data.Append(currentlyInTimeSequence, ref index);
|
||||||
|
|
||||||
if (currentlyInTimeSequence)
|
if (currentlyInTimeSequence)
|
||||||
@@ -394,6 +397,12 @@ namespace Marro.PacManUdon
|
|||||||
data.Append(timeSequenceSecondsPassed, ref index);
|
data.Append(timeSequenceSecondsPassed, ref index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.AppendAsByte(level, ref index);
|
||||||
|
data.Append(score, ref index);
|
||||||
|
data.AppendAsByte(extraLives, ref index);
|
||||||
|
|
||||||
|
bonusFruit.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
collisionManager.CollectSyncedData(data, ref index, eventType);
|
collisionManager.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
ghostManager.CollectSyncedData(data, ref index, eventType);
|
ghostManager.CollectSyncedData(data, ref index, eventType);
|
||||||
@@ -401,12 +410,6 @@ namespace Marro.PacManUdon
|
|||||||
pacMan.CollectSyncedData(data, ref index, eventType);
|
pacMan.CollectSyncedData(data, ref index, eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)gameState) };
|
|
||||||
//data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
|
|
||||||
//data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)currentTimeSequence) };
|
|
||||||
//data[offset++] = BitConverter.GetBytes(timeSequenceSecondsPassed);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.StartGameButtonPressed)
|
if (eventType == NetworkEventType.StartGameButtonPressed)
|
||||||
@@ -415,8 +418,11 @@ namespace Marro.PacManUdon
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventType == NetworkEventType.FullSync)
|
if (eventType != NetworkEventType.FullSync)
|
||||||
{
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var currentlyInTimeSequence = data.ReadBool(ref index);
|
var currentlyInTimeSequence = data.ReadBool(ref index);
|
||||||
if (currentlyInTimeSequence)
|
if (currentlyInTimeSequence)
|
||||||
{
|
{
|
||||||
@@ -429,20 +435,17 @@ namespace Marro.PacManUdon
|
|||||||
TimeSequenceTryEndCurrent();
|
TimeSequenceTryEndCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetLevel(data.ReadByte(ref index));
|
||||||
|
SetScore(data.ReadInt(ref index));
|
||||||
|
SetExtraLives(data.ReadByte(ref index));
|
||||||
|
|
||||||
|
bonusFruit.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
collisionManager.WriteSyncedData(data, ref index, eventType);
|
collisionManager.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
ghostManager.WriteSyncedData(data, ref index, eventType);
|
ghostManager.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
pacMan.WriteSyncedData(data, ref index, eventType);
|
pacMan.WriteSyncedData(data, ref index, eventType);
|
||||||
}
|
|
||||||
|
|
||||||
//SetGameState((PacManGameState)data[offset++]);
|
|
||||||
|
|
||||||
//var currentlyInTimeSequence = BitConverter.ToBoolean(data, offset++);
|
|
||||||
//var currentTimeSequence = (PacManTimeSequence)data[offset++];
|
|
||||||
//var timeSequenceSecondsPassed = BitConverter.ToSingle(data, offset);
|
|
||||||
//offset += 4;
|
|
||||||
//TimeSequenceSyncWithRemote(currentlyInTimeSequence, currentTimeSequence, timeSequenceSecondsPassed);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user