-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Adapt Waiting Room #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d92c9f5
975d0de
ddff816
b3c971e
8275899
dbb09c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,8 @@ public class GameTracker : MonoBehaviour | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public GameObject blacksmithPrefab; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public GameObject altarPrefab; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public GameObject waitingRoomPrefab; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Points de spawn (ils seront trouvés dynamiquement) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private Transform blacksmithSpawnPoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private Transform altarSpawnPoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -27,6 +29,8 @@ public class GameTracker : MonoBehaviour | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private GameObject currentBlacksmith; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private GameObject currentAltar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private GameObject waitingRoom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void Start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stageText.text = "Stage: " + stageCounter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -44,10 +48,23 @@ void Update() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void NextStage() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (stageCounter == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| instantiateWaitingRoom(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stageCounter++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stageText.text = "Stage: " + stageCounter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void instantiateWaitingRoom() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| waitingRoom = GameObject.Find("WaitingRoom"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (waitingRoom == null && waitingRoomPrefab != null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Instantiate(waitingRoomPrefab, new Vector3(0, 0, 0), Quaternion.identity); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+59
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Optimisez la recherche de la salle d'attente. La méthode
Suggestion de refactorisation : private void instantiateWaitingRoom()
{
- waitingRoom = GameObject.Find("WaitingRoom");
- if (waitingRoom == null && waitingRoomPrefab != null)
+ if (waitingRoomPrefab == null)
+ {
+ Debug.LogError("Le préfab de la salle d'attente n'est pas assigné !");
+ return;
+ }
+
+ if (waitingRoom != null)
{
- Instantiate(waitingRoomPrefab, new Vector3(0, 0, 0), Quaternion.identity);
+ Debug.LogWarning("Une instance de la salle d'attente existe déjà !");
+ return;
}
+
+ waitingRoom = Instantiate(waitingRoomPrefab, Vector3.zero, Quaternion.identity);
+ if (waitingRoom == null)
+ {
+ Debug.LogError("Échec de l'instanciation de la salle d'attente !");
+ }
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void SpawnCorridorEvents() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ public class RoomManager : MonoBehaviour | |
| private SocketIOUnity clientSocket; | ||
| public static bool isInCorridorX7 = false; | ||
|
|
||
| private bool isGameCreated = false; | ||
|
|
||
| private void Start() | ||
| { | ||
| clientSocket = SocketManager.Instance.ClientSocket; | ||
|
|
@@ -56,6 +58,12 @@ private void OnTriggerEnter2D(Collider2D other) | |
| } | ||
| if (newRoom.name.Contains("CorridorX7")) | ||
| { | ||
| if (!isGameCreated) | ||
| { | ||
| isGameCreated = true; | ||
| clientSocket.Emit("rooms:create"); | ||
| } | ||
|
|
||
|
Comment on lines
+61
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Suggestions d'amélioration pour la gestion des événements socket
Voici une suggestion de refactorisation : if (newRoom.name.Contains("CorridorX7"))
{
- if (!isGameCreated)
- {
- isGameCreated = true;
- clientSocket.Emit("rooms:create");
- }
+ EmitRoomCreationEventOnce();
gameTracker.SpawnCorridorEvents();
gameTracker.NextStage();
isInCorridorX7 = true;
SocketEmitter();
}Ajoutez cette nouvelle méthode : private async void EmitRoomCreationEventOnce()
{
if (isGameCreated) return;
try
{
await clientSocket.EmitAsync("rooms:create");
isGameCreated = true;
}
catch (System.Exception e)
{
Debug.LogError($"Erreur lors de l'émission de l'événement rooms:create : {e.Message}");
}
} |
||
| gameTracker.SpawnCorridorEvents(); | ||
| gameTracker.NextStage(); | ||
| isInCorridorX7 = true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,7 @@ public void Update() | |
|
|
||
| if (godPrefabDictionary.TryGetValue(godId, out GodInfo godInfo)) | ||
| { | ||
| Debug.Log("NTR"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Améliorer la qualité des messages de débogage Les messages de débogage "NTR" ne sont pas descriptifs et n'apportent aucune information utile pour le débogage. De plus, ils risquent de polluer les logs en production. Suggestions d'amélioration : - Debug.Log("NTR");
+ Debug.Log($"Message traité pour le dieu {godId}: {messageText.Substring(0, Math.Min(messageText.Length, 50))}...");- Debug.Log("NTR");
+ Debug.Log($"Affichage du dialogue: {nextMessage.title} - {nextMessage.dialogue.Substring(0, Math.Min(nextMessage.dialogue.Length, 50))}...");Also applies to: 106-106 |
||
| EnqueueMessage(godInfo.godSprite, messageText, godInfo.godName); | ||
| } | ||
| else | ||
|
|
@@ -102,7 +103,7 @@ private IEnumerator ProcessMessageQueue() | |
| if (messageQueue.Count > 0 && !isDisplayingMessage) | ||
| { | ||
| GodMessage nextMessage = messageQueue.Dequeue(); | ||
|
|
||
| Debug.Log("NTR"); | ||
| DisplayDialogue(nextMessage.godSprite, nextMessage.dialogue, nextMessage.title); | ||
| isDisplayingMessage = true; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Attention : Incohérence dans les couches de rendu détectée
La modification du SortingLayer de 3 à 4 pour Door.prefab n'est pas totalement cohérente avec l'ensemble des préfabriqués. Les résultats montrent une division :
Cette différence pourrait créer des problèmes de rendu avec les éléments d'événements de corridor (Forgeron, Altar). Une harmonisation complète des SortingLayers devrait être envisagée.
🔗 Analysis chain
Ajustement cohérent de la couche de rendu.
La modification du SortingLayer de 3 à 4 maintient la cohérence visuelle avec les autres préfabriqués, notamment le CorridorX7.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 309
Script:
Length of output: 1226