- Location board orientation corrected to properly match Unity axes.

- Markers are no longer thrown when dropped while walking.
- Markers stay much more stable and are far less prone to falling over.
- Rounds 2 and 3 properly sync to other clients.
This commit is contained in:
Jamie Greunbaum
2025-06-26 17:09:42 -04:00
parent 4fad27ce19
commit 05cf67b1e2
57 changed files with 6220 additions and 4425 deletions
@@ -1,12 +1,9 @@
using System.Runtime.InteropServices.WindowsRuntime;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDK3.StringLoading;
using VRC.SDK3.UdonNetworkCalling;
using VRC.SDKBase;
using VRC.Udon;
using VRC.Udon.Common.Interfaces;
@@ -222,23 +222,17 @@ public class GameManagerRound2 : GameManagerBase
public void PlayTheLoot()
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
NetworkEventTarget.All,
"PlaySFX", SFXEventType.TheLoot);
_AudioManager.PlaySFX(SFXEventType.TheLoot);
}
public void PlayTheWarrant()
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
NetworkEventTarget.All,
"PlaySFX", SFXEventType.TheWarrant);
_AudioManager.PlaySFX(SFXEventType.TheWarrant);
}
public void PlayTheCrookTheme()
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
NetworkEventTarget.All,
"PlayCrookTheme", _CaseManager.GetCrook());
_AudioManager.PlayCrookTheme(_CaseManager.GetCrook());
}
@@ -445,8 +445,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -458,7 +458,13 @@ MonoBehaviour:
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 31|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
@@ -479,13 +485,13 @@ MonoBehaviour:
Data: _ContinentData
- Name: $v
Entry: 7
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 32|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ContinentData
- Name: <UserType>k__BackingField
Entry: 7
Data: 32|System.RuntimeType, mscorlib
Data: 33|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
@@ -494,7 +500,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
Data: 33
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -509,7 +515,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 34|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -533,7 +539,7 @@ MonoBehaviour:
Data: _StageIndex
- Name: $v
Entry: 7
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _StageIndex
@@ -547,8 +553,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -557,10 +563,16 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 37|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
@@ -581,13 +593,13 @@ MonoBehaviour:
Data: _GameStatus
- Name: $v
Entry: 7
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _GameStatus
- Name: <UserType>k__BackingField
Entry: 7
Data: 37|System.RuntimeType, mscorlib
Data: 39|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: GameStatus, Assembly-CSharp
@@ -601,56 +613,8 @@ MonoBehaviour:
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: 38|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: _Timer
- Name: $v
Entry: 7
Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Timer
- 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:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -662,7 +626,67 @@ MonoBehaviour:
Data: 40|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 41|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- 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: _Timer
- Name: $v
Entry: 7
Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Timer
- 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: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 43|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 44|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
@@ -683,7 +707,7 @@ MonoBehaviour:
Data: _SuccessCounter
- Name: $v
Entry: 7
Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _SuccessCounter
@@ -697,8 +721,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -707,10 +731,16 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 42|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 46|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 47|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
@@ -731,7 +761,7 @@ MonoBehaviour:
Data: _FailureCounter
- Name: $v
Entry: 7
Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FailureCounter
@@ -745,8 +775,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -755,10 +785,16 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 44|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 49|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 50|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
@@ -3,6 +3,7 @@ using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDK3.UdonNetworkCalling;
using VRC.Udon.Common.Interfaces;
public enum ContinentMap
@@ -35,17 +36,17 @@ public class GameManagerRound3 : GameManagerBase
[SerializeField] private AudioManager _AudioManager;
private ContinentMap _ActiveMap = ContinentMap.Africa;
[UdonSynced] private ContinentMap _ActiveMap = ContinentMap.Africa;
private DataDictionary _ContinentData;
private int _StageIndex = 0;
[UdonSynced] private int _StageIndex = 0;
private GameStatus _GameStatus = GameStatus.Pregame;
private int _Timer = TIMER_LENGTH;
[UdonSynced] private GameStatus _GameStatus = GameStatus.Pregame;
[UdonSynced] private int _Timer = TIMER_LENGTH;
private const float LENGTH_OF_ONE_SECOND = 1.04444444444444444f;
private const int TIMER_LENGTH = 45;
private int _SuccessCounter = 0;
private int _FailureCounter = 0;
[UdonSynced] private int _SuccessCounter = 0;
[UdonSynced] private int _FailureCounter = 0;
private const int MAX_FAILURE_COUNT = 2;
private const int MAX_SUCCESS_COUNT = 8;
@@ -73,7 +74,10 @@ public class GameManagerRound3 : GameManagerBase
}
}
GetCurrentMap().RandomiseCountries();
FloorMap CurrentMap = GetCurrentMap();
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)CurrentMap,
NetworkEventTarget.Owner,
"RandomiseCountries");
}
else
{
@@ -98,18 +102,24 @@ public class GameManagerRound3 : GameManagerBase
{
UpdateInterface();
GetCurrentMarker().EnablePickup(true);
FloorMapMarker Marker = GetCurrentMarker();
Marker.EnablePickup(true);
Marker.LocationFindingEnabled = true;
StartTimer();
}
private void StartTimer()
{
_AudioManager.PlayMusicLoop(MusicEventType.CarmenChaseMusic);
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
NetworkEventTarget.All,
"PlayMusicLoop", MusicEventType.CarmenChaseMusic);
_GameStatus = GameStatus.Begin;
_Timer = TIMER_LENGTH;
SendCustomEventDelayedSeconds(nameof(TickTimer), LENGTH_OF_ONE_SECOND);
RequestSerialization();
}
public void TickTimer()
@@ -117,29 +127,39 @@ public class GameManagerRound3 : GameManagerBase
_Timer--;
if (_Timer < 0)
{
GameHasBeenLost();
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this,
NetworkEventTarget.Owner,
nameof(GameHasBeenLost), false);
return;
}
SendCustomEventDelayedSeconds(nameof(TickTimer), LENGTH_OF_ONE_SECOND);
RequestSerialization();
}
public void CorrectResponse()
{
PlayCorrectSound();
GetCurrentMarker().EnablePickup(false);
FloorMapMarker Marker = GetCurrentMarker();
Marker.EnablePickup(false);
Marker.LocationFindingEnabled = false;
_FailureCounter = 0;
_SuccessCounter++;
if (_SuccessCounter >= MAX_SUCCESS_COUNT)
{
GameHasBeenWon();
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this,
NetworkEventTarget.Owner,
nameof(GameHasBeenWon));
}
else
{
SetUpNextCountry();
}
RequestSerialization();
}
public void IncorrectResponse()
@@ -148,7 +168,9 @@ public class GameManagerRound3 : GameManagerBase
if (_FailureCounter >= MAX_FAILURE_COUNT)
{
_FailureCounter = 0;
GetCurrentMarker().EnablePickup(false);
FloorMapMarker Marker = GetCurrentMarker();
Marker.EnablePickup(false);
Marker.LocationFindingEnabled = false;
SetUpNextCountry();
}
@@ -183,13 +205,17 @@ public class GameManagerRound3 : GameManagerBase
if (NextCountry < 0)
{
// If we ran out of countries, lose the game here.
GameHasBeenLost(true);
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this,
NetworkEventTarget.Owner,
nameof(GameHasBeenLost), true);
return;
}
_Markers[NextCountry].EnablePickup(true);
_Markers[NextCountry].LocationFindingEnabled = true;
UpdateInterface();
}
[NetworkCallable]
public void GameHasBeenWon()
{
if ((int)_GameStatus <= (int)GameStatus.Begin)
@@ -200,11 +226,14 @@ public class GameManagerRound3 : GameManagerBase
(HostCardBetweenRoundsInterface)GetHostCardInterface(RoundSegmentType.BetweenSegments);
GameWinInterface.HeaderUI.text = "The player has won the game. " + _Timer + " seconds to spare.";
_AudioManager.PlayMusicLoop(MusicEventType.CarmenSandiegoWindDown);
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
NetworkEventTarget.All,
"PlayMusicLoop", MusicEventType.CarmenSandiegoWindDown);
}
}
public void GameHasBeenLost(bool RanOutOfMarkers = false)
[NetworkCallable]
public void GameHasBeenLost(bool RanOutOfMarkers)
{
if ((int)_GameStatus != (int)GameStatus.Win)
{
@@ -219,7 +248,9 @@ public class GameManagerRound3 : GameManagerBase
(HostCardBetweenRoundsInterface)GetHostCardInterface(RoundSegmentType.BetweenSegments);
GameLossInterface.HeaderUI.text = "The player has lost. " + _SuccessCounter + " countries in " + TIMER_LENGTH + " seconds.";
_AudioManager.StopMusic();
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
NetworkEventTarget.All,
"StopMusic");
}
}
@@ -229,6 +260,8 @@ public class GameManagerRound3 : GameManagerBase
{
_GameStatus = NewStatus;
}
RequestSerialization();
}
+137 -65
View File
@@ -19,7 +19,7 @@ MonoBehaviour:
sourceCsScript: {fileID: 11500000, guid: 949eb8690c7931145836b58adb7eafcf, type: 3}
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 1
behaviourSyncMode: 4
hasInteractEvent: 0
scriptID: 5372152653533207248
serializationData:
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 4
Data: 5
- Name:
Entry: 7
Data:
@@ -110,19 +110,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _ChosenCountries
Data: _CurrentCountry
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChosenCountries
Data: _CurrentCountry
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.String[], mscorlib
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
@@ -133,8 +133,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -144,6 +144,132 @@ MonoBehaviour:
- Name: _fieldAttributes
Entry: 7
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 9|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- 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: _RandomisedCountriesAndCities
- Name: $v
Entry: 7
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _RandomisedCountriesAndCities
- Name: <UserType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 13|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 14|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- 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: _ChosenCountries
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChosenCountries
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.String[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
- 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: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -167,16 +293,16 @@ MonoBehaviour:
Data: _ChosenCities
- Name: $v
Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChosenCities
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 16
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 16
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -191,61 +317,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 10|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: _CurrentCountry
- Name: $v
Entry: 7
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentCountry
- Name: <UserType>k__BackingField
Entry: 7
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 12
- 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: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
+78 -14
View File
@@ -1,21 +1,19 @@
using System;
using System.Linq;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class FloorMap : UdonSharpBehaviour
{
public FloorMapCountry[] Countries;
[UdonSynced] private int _CurrentCountry = 0;
[UdonSynced, FieldChangeCallback(nameof(RandomisedCountriesAndCities))] private int[] _RandomisedCountriesAndCities;
private string[] _ChosenCountries = new string[MAX_SELECTED_COUNTRIES];
private string[] _ChosenCities = new string[MAX_SELECTED_COUNTRIES];
private int _CurrentCountry = 0;
private const int MAX_SELECTED_COUNTRIES = 13;
@@ -26,21 +24,61 @@ public class FloorMap : UdonSharpBehaviour
UnityEngine.Random.InitState(Networking.GetServerTimeInMilliseconds());
FloorMapCountry[] SelectedCountries = new FloorMapCountry[MAX_SELECTED_COUNTRIES];
int[] NewRandomCountries = new int[MAX_SELECTED_COUNTRIES];
int[] NewRandomCities = new int[MAX_SELECTED_COUNTRIES];
// Fill the countries array with values too big to be considered valid.
int NumberOfCountries = Countries.Length;
for (int i = 0; i < MAX_SELECTED_COUNTRIES; i++)
{
NewRandomCountries[i] = NumberOfCountries;
}
for (int i = 0; i < MAX_SELECTED_COUNTRIES; i++)
{
int NewPulledIndex = UnityEngine.Random.Range(0, Countries.Length);
while (Countries[NewPulledIndex].gameObject.activeSelf)
int NewPulledIndex = NumberOfCountries;
while (CountryIsAlreadyInArray(NewRandomCountries, NewPulledIndex))
{
NewPulledIndex = UnityEngine.Random.Range(0, Countries.Length);
NewPulledIndex = UnityEngine.Random.Range(0, NumberOfCountries);
}
NewRandomCountries[i] = NewPulledIndex;
NewRandomCities[i] = UnityEngine.Random.Range(0, Countries[NewPulledIndex].Locations.Length);
}
FloorMapCountry Country = Countries[NewPulledIndex];
// We're syncing the countries and cities as one array to keep
// things simple to sync all at once.
// Array format is all countries first, then all cities.
int[] NewRandomCountriesAndCities = new int[MAX_SELECTED_COUNTRIES * 2];
NewRandomCountries.CopyTo(NewRandomCountriesAndCities, 0);
NewRandomCities.CopyTo(NewRandomCountriesAndCities, MAX_SELECTED_COUNTRIES);
RandomisedCountriesAndCities = NewRandomCountriesAndCities;
RequestSerialization();
}
private bool CountryIsAlreadyInArray(int[] Countries, int IndexToCheck)
{
for (int i = 0; i < MAX_SELECTED_COUNTRIES; i++)
{
if (Countries[i] == IndexToCheck)
{
return true;
}
}
return false;
}
private void AssignRandomCountriesAndCities()
{
DisableAllLocations();
_CurrentCountry = 0;
for (int i = 0; i < MAX_SELECTED_COUNTRIES; i++)
{
FloorMapCountry Country = Countries[RandomisedCountriesAndCities[i]];
Country.gameObject.SetActive(true);
SelectedCountries[i] = Countries[NewPulledIndex];
FloorMapLocation Location = Country.Locations[UnityEngine.Random.Range(0, Country.Locations.Length)];
FloorMapLocation Location = Country.Locations[RandomisedCountriesAndCities[MAX_SELECTED_COUNTRIES + i]];
Location.gameObject.SetActive(true);
_ChosenCountries[i] = Location.Country;
@@ -53,9 +91,10 @@ public class FloorMap : UdonSharpBehaviour
_CurrentCountry++;
if (_CurrentCountry >= MAX_SELECTED_COUNTRIES)
{
Debug.LogError("We ran out of countries. Just end the game here.");
// We ran out of countries. Just end the game here.
return -1;
}
return _CurrentCountry;
}
@@ -74,4 +113,29 @@ public class FloorMap : UdonSharpBehaviour
{
return _ChosenCities[_CurrentCountry];
}
private void DisableAllLocations()
{
for (int i = 0; i < Countries.Length; i++)
{
FloorMapCountry Country = Countries[i];
for (int j = 0; j < Country.Locations.Length; j++)
{
Country.Locations[j].gameObject.SetActive(false);
}
Country.gameObject.SetActive(false);
}
}
public int[] RandomisedCountriesAndCities
{
set
{
_RandomisedCountriesAndCities = value;
AssignRandomCountriesAndCities();
}
get => _RandomisedCountriesAndCities;
}
}
+44 -38
View File
@@ -86,7 +86,7 @@ MonoBehaviour:
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 3
Data: 2
- Name:
Entry: 7
Data: 5|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
@@ -95,13 +95,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 7
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 7|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 6|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -125,7 +119,7 @@ MonoBehaviour:
Data: _IsGrabbed
- Name: $v
Entry: 7
Data: 8|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _IsGrabbed
@@ -149,19 +143,19 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 10|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 9|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 11|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 10|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -185,13 +179,13 @@ MonoBehaviour:
Data: _GameManager
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _GameManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: GameManagerRound3, Assembly-CSharp
@@ -200,7 +194,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 14|System.RuntimeType, mscorlib
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
@@ -221,13 +215,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 16|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 15|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -251,13 +245,13 @@ MonoBehaviour:
Data: _LitLampMaterial
- Name: $v
Entry: 7
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _LitLampMaterial
- Name: <UserType>k__BackingField
Entry: 7
Data: 18|System.RuntimeType, mscorlib
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Material, UnityEngine.CoreModule
@@ -266,7 +260,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 18
Data: 17
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -281,13 +275,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 20|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 19|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -311,13 +305,13 @@ MonoBehaviour:
Data: _CollidingLocations
- Name: $v
Entry: 7
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollidingLocations
- Name: <UserType>k__BackingField
Entry: 7
Data: 22|System.RuntimeType, mscorlib
Data: 21|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataList, VRCSDK3
@@ -326,7 +320,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 22
Data: 21
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -341,7 +335,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -365,13 +359,13 @@ MonoBehaviour:
Data: _CollisionCheckCounter
- Name: $v
Entry: 7
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollisionCheckCounter
- Name: <UserType>k__BackingField
Entry: 7
Data: 25|System.RuntimeType, mscorlib
Data: 24|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
@@ -380,13 +374,13 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 25
Data: 24
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -395,10 +389,16 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 26|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
@@ -425,16 +425,16 @@ MonoBehaviour:
Data: _NoCollisionCounter
- Name: <UserType>k__BackingField
Entry: 9
Data: 25
Data: 24
- Name: <SystemType>k__BackingField
Entry: 9
Data: 25
Data: 24
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -446,7 +446,13 @@ MonoBehaviour:
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Data: 1
- Name:
Entry: 7
Data: 29|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
+22 -15
View File
@@ -3,13 +3,15 @@ using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDK3.Data;
using VRC.SDK3.UdonNetworkCalling;
using VRC.SDKBase;
using VRC.Udon.Common.Interfaces;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class FloorMapMarker : UdonSharpBehaviour
{
[UdonSynced, SerializeField, FieldChangeCallback(nameof(LocationFindingEnabled))] public bool _LocationFindingEnabled = false;
[UdonSynced, FieldChangeCallback(nameof(LocationFindingEnabled))] public bool _LocationFindingEnabled = false;
[UdonSynced, FieldChangeCallback(nameof(IsGrabbed))] private bool _IsGrabbed = false;
[SerializeField] private GameManagerRound3 _GameManager;
@@ -17,8 +19,8 @@ public class FloorMapMarker : UdonSharpBehaviour
[SerializeField] private Material _LitLampMaterial;
private DataList _CollidingLocations = new DataList();
private int _CollisionCheckCounter = 0;
private int _NoCollisionCounter = 0;
[UdonSynced] private int _CollisionCheckCounter = 0;
[UdonSynced] private int _NoCollisionCounter = 0;
private const int MAX_REPEAT_COLLISION_CHECKS = 3;
private const int MAX_TIME_WITH_NO_COLLISIONS = 8;
@@ -56,7 +58,6 @@ public class FloorMapMarker : UdonSharpBehaviour
Body.constraints = RigidbodyConstraints.None;
}
LocationFindingEnabled = true;
IsGrabbed = true;
_NoCollisionCounter = 0;
_CollidingLocations.Clear();
@@ -97,7 +98,10 @@ public class FloorMapMarker : UdonSharpBehaviour
bool FoundCorrectResponse = ConfirmChoice(Location.Country, Location.City);
if (FoundCorrectResponse)
{
SendCorrectResponse(Location);
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this,
NetworkEventTarget.All,
nameof(SendCorrectResponse),
Location.transform.position);
return;
}
}
@@ -111,17 +115,20 @@ public class FloorMapMarker : UdonSharpBehaviour
}
else
{
SendIncorrectResponse();
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this,
NetworkEventTarget.All,
nameof(SendIncorrectResponse));
}
_CollisionCheckCounter++;
}
else
{
_NoCollisionCounter++;
Debug.Log("No collisions for " + _NoCollisionCounter + " ticks.");
if (_NoCollisionCounter >= MAX_TIME_WITH_NO_COLLISIONS)
{
SendIncorrectResponse();
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this,
NetworkEventTarget.All,
nameof(SendIncorrectResponse));
}
else
{
@@ -144,7 +151,8 @@ public class FloorMapMarker : UdonSharpBehaviour
return false;
}
private void SendCorrectResponse(FloorMapLocation CorrectLocation)
[NetworkCallable]
public void SendCorrectResponse(Vector3 CorrectLocation)
{
DisableMovementCompletely(CorrectLocation);
@@ -159,7 +167,8 @@ public class FloorMapMarker : UdonSharpBehaviour
_GameManager.CorrectResponse();
}
private void SendIncorrectResponse()
[NetworkCallable]
public void SendIncorrectResponse()
{
DisableMovementCompletely();
@@ -179,7 +188,7 @@ public class FloorMapMarker : UdonSharpBehaviour
}
public void DisableMovementCompletely(FloorMapLocation CorrectLocation = null)
public void DisableMovementCompletely(Vector3 CorrectLocation = new Vector3())
{
Rigidbody Body;
if (Body = GetComponent<Rigidbody>())
@@ -188,11 +197,9 @@ public class FloorMapMarker : UdonSharpBehaviour
}
transform.eulerAngles = new Vector3(0.0f, transform.eulerAngles.y, 0.0f);
LocationFindingEnabled = false;
if (CorrectLocation != null)
if (CorrectLocation != Vector3.zero)
{
transform.position = CorrectLocation.transform.position;
transform.position = CorrectLocation;
}
}