Skip to content

Commit dce7b53

Browse files
committed
made transporters singleton instances
1 parent 206ca90 commit dce7b53

9 files changed

Lines changed: 597 additions & 141 deletions

File tree

Assets/Scenes/BasicMap.unity

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -495215,63 +495215,6 @@ PrefabInstance:
495215495215
m_AddedGameObjects: []
495216495216
m_AddedComponents: []
495217495217
m_SourcePrefab: {fileID: 100100000, guid: 5a285f82894dd414685382a4b5b0e93a, type: 3}
495218-
--- !u!1001 &1970871781455755056
495219-
PrefabInstance:
495220-
m_ObjectHideFlags: 0
495221-
serializedVersion: 2
495222-
m_Modification:
495223-
serializedVersion: 3
495224-
m_TransformParent: {fileID: 0}
495225-
m_Modifications:
495226-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495227-
propertyPath: m_LocalPosition.x
495228-
value: 250.37085
495229-
objectReference: {fileID: 0}
495230-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495231-
propertyPath: m_LocalPosition.y
495232-
value: 390.75745
495233-
objectReference: {fileID: 0}
495234-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495235-
propertyPath: m_LocalPosition.z
495236-
value: -2.500062
495237-
objectReference: {fileID: 0}
495238-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495239-
propertyPath: m_LocalRotation.w
495240-
value: 1
495241-
objectReference: {fileID: 0}
495242-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495243-
propertyPath: m_LocalRotation.x
495244-
value: 0
495245-
objectReference: {fileID: 0}
495246-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495247-
propertyPath: m_LocalRotation.y
495248-
value: 0
495249-
objectReference: {fileID: 0}
495250-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495251-
propertyPath: m_LocalRotation.z
495252-
value: 0
495253-
objectReference: {fileID: 0}
495254-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495255-
propertyPath: m_LocalEulerAnglesHint.x
495256-
value: 0
495257-
objectReference: {fileID: 0}
495258-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495259-
propertyPath: m_LocalEulerAnglesHint.y
495260-
value: 0
495261-
objectReference: {fileID: 0}
495262-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495263-
propertyPath: m_LocalEulerAnglesHint.z
495264-
value: 0
495265-
objectReference: {fileID: 0}
495266-
- target: {fileID: 4719801606227294180, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495267-
propertyPath: m_Name
495268-
value: CurrencyTransport
495269-
objectReference: {fileID: 0}
495270-
m_RemovedComponents: []
495271-
m_RemovedGameObjects: []
495272-
m_AddedGameObjects: []
495273-
m_AddedComponents: []
495274-
m_SourcePrefab: {fileID: 100100000, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
495275495218
--- !u!1001 &2814703976531271548
495276495219
PrefabInstance:
495277495220
m_ObjectHideFlags: 0
@@ -495455,7 +495398,6 @@ SceneRoots:
495455495398
- {fileID: 1620236552}
495456495399
- {fileID: 700794879}
495457495400
- {fileID: 1579540859}
495458-
- {fileID: 1970871781455755056}
495459495401
- {fileID: 2018510670}
495460495402
- {fileID: 1217881872}
495461495403
- {fileID: 439328707}

Assets/Scenes/Lobby Scene.unity

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5651,6 +5651,63 @@ CanvasRenderer:
56515651
m_PrefabAsset: {fileID: 0}
56525652
m_GameObject: {fileID: 1946232248}
56535653
m_CullTransparentMesh: 1
5654+
--- !u!1001 &1996281001
5655+
PrefabInstance:
5656+
m_ObjectHideFlags: 0
5657+
serializedVersion: 2
5658+
m_Modification:
5659+
serializedVersion: 3
5660+
m_TransformParent: {fileID: 0}
5661+
m_Modifications:
5662+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5663+
propertyPath: m_LocalPosition.x
5664+
value: 250.37085
5665+
objectReference: {fileID: 0}
5666+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5667+
propertyPath: m_LocalPosition.y
5668+
value: 390.75745
5669+
objectReference: {fileID: 0}
5670+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5671+
propertyPath: m_LocalPosition.z
5672+
value: -2.500062
5673+
objectReference: {fileID: 0}
5674+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5675+
propertyPath: m_LocalRotation.w
5676+
value: 1
5677+
objectReference: {fileID: 0}
5678+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5679+
propertyPath: m_LocalRotation.x
5680+
value: 0
5681+
objectReference: {fileID: 0}
5682+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5683+
propertyPath: m_LocalRotation.y
5684+
value: 0
5685+
objectReference: {fileID: 0}
5686+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5687+
propertyPath: m_LocalRotation.z
5688+
value: 0
5689+
objectReference: {fileID: 0}
5690+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5691+
propertyPath: m_LocalEulerAnglesHint.x
5692+
value: 0
5693+
objectReference: {fileID: 0}
5694+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5695+
propertyPath: m_LocalEulerAnglesHint.y
5696+
value: 0
5697+
objectReference: {fileID: 0}
5698+
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5699+
propertyPath: m_LocalEulerAnglesHint.z
5700+
value: 0
5701+
objectReference: {fileID: 0}
5702+
- target: {fileID: 4719801606227294180, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
5703+
propertyPath: m_Name
5704+
value: CurrencyTransport
5705+
objectReference: {fileID: 0}
5706+
m_RemovedComponents: []
5707+
m_RemovedGameObjects: []
5708+
m_AddedGameObjects: []
5709+
m_AddedComponents: []
5710+
m_SourcePrefab: {fileID: 100100000, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
56545711
--- !u!1 &2055078708
56555712
GameObject:
56565713
m_ObjectHideFlags: 0
@@ -6362,3 +6419,4 @@ SceneRoots:
63626419
- {fileID: 6554293267796997114}
63636420
- {fileID: 687501287}
63646421
- {fileID: 721643736}
6422+
- {fileID: 1996281001}

Assets/Scenes/Map2.unity

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -227,63 +227,6 @@ PrefabInstance:
227227
m_AddedGameObjects: []
228228
m_AddedComponents: []
229229
m_SourcePrefab: {fileID: 100100000, guid: 39cd311539218a3429999389d10ca2be, type: 3}
230-
--- !u!1001 &58337307
231-
PrefabInstance:
232-
m_ObjectHideFlags: 0
233-
serializedVersion: 2
234-
m_Modification:
235-
serializedVersion: 3
236-
m_TransformParent: {fileID: 0}
237-
m_Modifications:
238-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
239-
propertyPath: m_LocalPosition.x
240-
value: 250.37085
241-
objectReference: {fileID: 0}
242-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
243-
propertyPath: m_LocalPosition.y
244-
value: 390.75745
245-
objectReference: {fileID: 0}
246-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
247-
propertyPath: m_LocalPosition.z
248-
value: -2.500062
249-
objectReference: {fileID: 0}
250-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
251-
propertyPath: m_LocalRotation.w
252-
value: 1
253-
objectReference: {fileID: 0}
254-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
255-
propertyPath: m_LocalRotation.x
256-
value: 0
257-
objectReference: {fileID: 0}
258-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
259-
propertyPath: m_LocalRotation.y
260-
value: 0
261-
objectReference: {fileID: 0}
262-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
263-
propertyPath: m_LocalRotation.z
264-
value: 0
265-
objectReference: {fileID: 0}
266-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
267-
propertyPath: m_LocalEulerAnglesHint.x
268-
value: 0
269-
objectReference: {fileID: 0}
270-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
271-
propertyPath: m_LocalEulerAnglesHint.y
272-
value: 0
273-
objectReference: {fileID: 0}
274-
- target: {fileID: 3564669762799340075, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
275-
propertyPath: m_LocalEulerAnglesHint.z
276-
value: 0
277-
objectReference: {fileID: 0}
278-
- target: {fileID: 4719801606227294180, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
279-
propertyPath: m_Name
280-
value: CurrencyTransport
281-
objectReference: {fileID: 0}
282-
m_RemovedComponents: []
283-
m_RemovedGameObjects: []
284-
m_AddedGameObjects: []
285-
m_AddedComponents: []
286-
m_SourcePrefab: {fileID: 100100000, guid: 52492ba0fd87c644284522cfe2b5d741, type: 3}
287230
--- !u!1001 &158775429
288231
PrefabInstance:
289232
m_ObjectHideFlags: 0
@@ -138069,7 +138012,6 @@ SceneRoots:
138069138012
- {fileID: 1735487250}
138070138013
- {fileID: 851899854}
138071138014
- {fileID: 660671152}
138072-
- {fileID: 58337307}
138073138015
- {fileID: 496163688}
138074138016
- {fileID: 222409253}
138075138017
- {fileID: 1567060447}

Assets/Scripts/ClassInfoTransporter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ public class ClassInfoTransporter : MonoBehaviour {
1313
// Actions
1414
public static event System.Action<RuntimeAnimatorController, string> transportClassInfo;
1515

16+
// Singleton
17+
private static ClassInfoTransporter instance;
18+
1619
#region Setup Functions
1720
private void Awake() {
21+
if (instance != null && instance != this) {
22+
Destroy(gameObject);
23+
return;
24+
}
25+
instance = this;
1826
DontDestroyOnLoad(this.gameObject);
1927
}
2028
private void OnEnable() {

Assets/Scripts/CurrencyTransporter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ public class CurrencyTransporter : MonoBehaviour {
1919
// Action
2020
public static event Action<int> transportMoneyNow;
2121

22+
// Singleton
23+
private static CurrencyTransporter instance;
24+
2225
void Awake() {
26+
if (instance != null && instance != this) {
27+
Destroy(gameObject);
28+
return;
29+
}
30+
instance = this;
2331
activeScene = SceneManager.GetActiveScene().name;
2432
DontDestroyOnLoad(this.gameObject);
2533
}

Assets/Scripts/GodModeIndicator.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ public class GodModeIndicator : MonoBehaviour {
1818
[SerializeField] private string lobbySceneName;
1919
[SerializeField] private string activeSceneName;
2020

21+
// Singleton
22+
public static GodModeIndicator Instance { get; private set; }
23+
2124
// Actions
2225
public static event System.Action<bool> onGodModeActivated;
2326
#region Setup Functions
2427
void Awake() {
28+
if(Instance != null && Instance != this) {
29+
Destroy(gameObject);
30+
return;
31+
}
32+
Instance = this;
2533
lobbySceneName = SceneManager.GetActiveScene().name;
2634
DontDestroyOnLoad(this.gameObject);
2735
}

Assets/Scripts/ItemSceneTransporter.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@
88

99
public class ItemSceneTransporter : MonoBehaviour {
1010
// List
11-
private static List<ItemClass> itemList = new List<ItemClass>();
11+
[SerializeField] private List<ItemClass> itemList = new List<ItemClass>();
12+
13+
// Singleton
14+
public static ItemSceneTransporter Instance { get; private set; }
1215

1316
// Scene name
14-
private string lobbySceneName;
17+
private string lobbySceneName = "Lobby Scene";
1518
private string activeSceneName;
1619

1720
// Actions
1821
public static event Action<List<ItemClass>> startingItemsArrived;
1922

2023
void Awake() {
21-
lobbySceneName = SceneManager.GetActiveScene().name;
24+
if (Instance != null && Instance != this) {
25+
Destroy(gameObject);
26+
return;
27+
}
28+
Instance = this;
2229
DontDestroyOnLoad(this.gameObject);
2330
}
2431

@@ -39,6 +46,7 @@ private void OnDisable() {
3946
/// </summary>
4047
/// <param name="item"></param>
4148
private void AddPurchasedItemToList(ItemClass item) {
49+
Debug.Log($"add item: {item.itemName}");
4250
itemList.Add(item);
4351
}
4452
/// <summary>
@@ -49,17 +57,11 @@ private void AddPurchasedItemToList(ItemClass item) {
4957
/// <param name="mode"></param>
5058
private void OnSceneChanged(Scene scene, LoadSceneMode mode) {
5159
activeSceneName = SceneManager.GetActiveScene().name;
52-
60+
// If you are not in the lobby scene, call the signal.
61+
// Then, clear the list to avoid duplicates.
5362
if (activeSceneName != lobbySceneName) {
54-
Debug.Log($"Scene changed to {activeSceneName}.");
55-
Debug.Log($"Items in the list: {itemList.Count}");
56-
// Check if the list is empty. If not, send the items to the scene.
57-
if (itemList.Count <= 0) {
58-
Debug.Log("Nothing in here.");
59-
} else {
60-
startingItemsArrived?.Invoke(itemList);
61-
}
63+
startingItemsArrived?.Invoke(itemList);
64+
itemList.Clear();
6265
}
63-
itemList.Clear();
6466
}
6567
}

0 commit comments

Comments
 (0)