Skip to content

Commit 82fd4cf

Browse files
committed
Update SimulationManager.cs
Add some comments and possible sections for future use
1 parent 97ff969 commit 82fd4cf

File tree

1 file changed

+86
-26
lines changed

1 file changed

+86
-26
lines changed

URP Quang Binh v2/Assets/Scripts/Gama Provider/Simulation/SimulationManager.cs

Lines changed: 86 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using UnityEngine;
88
using UnityEngine.XR.Interaction.Toolkit;
99
using UnityEngine.InputSystem;
10-
using UnityEngine.UI;
1110
using UnityEngine.XR.Interaction.Toolkit.Interactors;
1211

1312

@@ -18,36 +17,38 @@ public class SimulationManager : MonoBehaviour
1817
[SerializeField] protected XRRayInteractor leftXRRayInteractor;
1918
[SerializeField] protected XRRayInteractor rightXRRayInteractor;
2019

21-
22-
[Header("Base GameObjects")]
23-
[SerializeField] protected GameObject player;
20+
21+
[Header("Base GameObjects")] [SerializeField]
22+
protected GameObject player;
23+
2424
[SerializeField] protected GameObject Ground;
2525

2626

2727
// optional: define a scale between GAMA and Unity for the location given
2828
[Header("Coordinate conversion parameters")]
2929
protected float GamaCRSCoefX = 1.0f;
30+
3031
protected float GamaCRSCoefY = 1.0f;
3132
protected float GamaCRSOffsetX = 0.0f;
3233
protected float GamaCRSOffsetY = 0.0f;
3334

34-
35+
3536
protected Transform XROrigin;
36-
37+
3738
// Z offset and scale
3839
protected float GamaCRSOffsetZ = 0.0f;
39-
40+
4041
protected List<GameObject> toFollow;
41-
42+
4243
XRInteractionManager interactionManager;
43-
44+
4445
// ################################ EVENTS ################################
4546
// called when the current game state changes
4647
public static event Action<GameState> OnGameStateChanged;
4748

4849
// called when the game is restarted
4950
public static event Action OnGameRestarted;
50-
51+
5152

5253
// called when the world data is received
5354
// public static event Action<WorldJSONInfo> OnWorldDataReceived;
@@ -72,7 +73,7 @@ public class SimulationManager : MonoBehaviour
7273

7374
// allows to define the minimal time bewteen two interactions
7475
protected float timeWithoutInteraction = 1.0f; //in second
75-
76+
7677
protected float remainingTime = 0.0f;
7778

7879

@@ -84,17 +85,17 @@ public class SimulationManager : MonoBehaviour
8485
protected List<GameObject> toDelete;
8586

8687
protected bool readyToSendPosition = false;
87-
88+
8889
protected bool readyToSendPositionInit = true;
8990

9091
protected float TimeSendPosition = 0.05f;
9192
protected float TimeSendPositionAfterMoving = 1.0f;
9293
protected float TimerSendPosition = 0.0f;
93-
94+
9495
protected List<GameObject> locomotion;
9596
protected MoveHorizontal mh = null;
9697
protected MoveVertical mv = null;
97-
98+
9899
protected DEMData data;
99100
protected DEMDataLoc dataLoc;
100101
protected TeleportAreaInfo dataTeleport;
@@ -103,7 +104,7 @@ public class SimulationManager : MonoBehaviour
103104

104105
protected float TimeSendInit = 0.5f;
105106
protected float TimerSendInit;
106-
107+
107108
protected Coroutine activeCoroutine = null;
108109

109110
protected Vector3 StartPoint;
@@ -113,7 +114,7 @@ public class SimulationManager : MonoBehaviour
113114
protected GameObject endPoint;
114115

115116
protected ScoreMessage scoreM;
116-
117+
117118
protected Vector3 originalStartPosition;
118119
protected bool firstPositionStored;
119120

@@ -130,12 +131,12 @@ public class SimulationManager : MonoBehaviour
130131
[SerializeField] protected GameObject FinalScene;
131132
[SerializeField] protected GameObject WinAnimtion;
132133
[SerializeField] protected GameObject LooseAnimtion;
133-
134+
134135
[SerializeField] protected InputActionReference mainButton = null;
135136
[SerializeField] protected InputActionReference secondButton = null;
136137

137138
//[SerializeField] protected GameObject tutorial;
138-
139+
139140
[SerializeField] protected StatusEffectManager timer;
140141
[SerializeField] protected StatusEffectManager safeRateCount;
141142
[SerializeField] private TextMeshProUGUI timerText;
@@ -145,14 +146,13 @@ public class SimulationManager : MonoBehaviour
145146
protected float RemainingSeconds;
146147

147148

148-
149149
// ############################################ UNITY FUNCTIONS ############################################
150150
void Awake()
151151
{
152152
Instance = this;
153153
SelectedObjects = new List<GameObject>();
154154
// toDelete = new List<GameObject>();
155-
155+
156156
startPoint = GameObject.FindGameObjectWithTag("startPoint");
157157
endPoint = GameObject.FindGameObjectWithTag("endPoint");
158158

@@ -262,6 +262,38 @@ void FixedUpdate()
262262
infoWorld = null;
263263
}
264264

265+
if (converter != null && data != null)
266+
{
267+
//manageUpdateTerrain();
268+
}
269+
270+
if (converter != null && dataLoc != null)
271+
{
272+
//manageSetValueTerrain();
273+
}
274+
275+
if (converter != null && dataTeleport != null)
276+
{
277+
//manageTeleportationArea();
278+
}
279+
280+
if (converter != null && dataWall != null)
281+
{
282+
//manageWalls();
283+
}
284+
285+
if (enableMove != null)
286+
{
287+
//playerMovement(enableMove.enableMove);
288+
//enableMove = null;
289+
}
290+
291+
if (infoAnimation != null)
292+
{
293+
//updateAnimation();
294+
//infoAnimation = null;
295+
}
296+
265297
if (IsGameState(GameState.LOADING_DATA) && ConnectionManager.Instance.getUseMiddleware())
266298
{
267299
if (TimerSendInit > 0)
@@ -407,7 +439,7 @@ private void Update()
407439
{
408440
TriggerMainButton();
409441
}
410-
442+
411443
// Debug.Log("currentStage: " + currentStage + " IsGameState(GameState.GAME) :" +IsGameState(GameState.GAME));
412444
if (IsGameState(GameState.GAME) && UIController.Instance.DikingStart)
413445
ProcessRightHandTrigger();
@@ -900,8 +932,7 @@ private async void HandleServerMessageReceived(String firstKey, String content)
900932
// handlePlayerParametersRequested = true;
901933
handleGroundParametersRequested = true;
902934
handleGeometriesRequested = true;
903-
904-
935+
905936
break;
906937
case "score":
907938
scoreM = ScoreMessage.CreateFromJSON(content);
@@ -926,6 +957,35 @@ private async void HandleServerMessageReceived(String firstKey, String content)
926957

927958
break;
928959

960+
case "endOfGame":
961+
// Currently, the project does not use the same end-of-game logic as the template
962+
// Implement end-of-game logic
963+
break;
964+
965+
case "rows":
966+
data = DEMData.CreateFromJSON(content);
967+
break;
968+
case "wallId":
969+
dataWall = WallInfo.CreateFromJSON(content);
970+
break;
971+
case "teleportId":
972+
// The Quang Binh Project currently does not use the teleport feature
973+
// Uncomment the line below in case the project needs the teleport feature in the future
974+
// dataTeleport = TeleportAreaInfo.CreateFromJSON(content);
975+
break;
976+
case "indexX":
977+
dataLoc = DEMDataLoc.CreateFromJSON(content);
978+
break;
979+
case "enableMove":
980+
// Move is enable by default
981+
// Uncomment the line below in case the project does not enable movement by default in the future
982+
// enableMove = EnableMoveInfo.CreateFromJSON(content);
983+
break;
984+
case "triggers":
985+
infoAnimation = AnimationInfo.CreateFromJSON(content);
986+
break;
987+
988+
929989
default:
930990
ManageOtherMessages(content);
931991
break;
@@ -948,7 +1008,7 @@ protected void ProcessRightHandTrigger()
9481008
}
9491009
}
9501010
}
951-
1011+
9521012
if (rightHandTriggerButton != null && !rightHandTriggerButton.action.inProgress)
9531013
{
9541014
if (_inTriggerPress)
@@ -968,8 +1028,8 @@ protected void ProcessRightHandTrigger()
9681028

9691029
FutureDike = null;
9701030
}
971-
APITest.Instance.TestDrawDykeWithParams(StartPoint, EndPoint);
9721031

1032+
APITest.Instance.TestDrawDykeWithParams(StartPoint, EndPoint);
9731033
}
9741034
}
9751035
}
@@ -1046,7 +1106,7 @@ public enum GameState
10461106
}
10471107

10481108

1049-
[System.Serializable]
1109+
[Serializable]
10501110
public class ScoreMessage
10511111
{
10521112
public int score;

0 commit comments

Comments
 (0)