Skip to content

fix: Global rendering fixes#36

Merged
Thomlam merged 6 commits intodevelopfrom
fix/global_rendering_fixes
Oct 27, 2024
Merged

fix: Global rendering fixes#36
Thomlam merged 6 commits intodevelopfrom
fix/global_rendering_fixes

Conversation

@AyakorK
Copy link
Copy Markdown
Contributor

@AyakorK AyakorK commented Oct 27, 2024

Summary by CodeRabbit

  • Nouvelles fonctionnalités

    • Ajout de nouveaux objets de jeu dans le prefab CorridorX7, y compris AltarSpawnPoint, Floor et Walls.
    • Introduction de nouveaux champs pour gérer l'état des portes dans le prefab WaitingRoom.
    • Ajout d'un nouveau tag "Door" pour une identification améliorée dans le système de gestion des objets.
  • Améliorations

    • Mise à jour des composants de collision pour améliorer la détection des collisions.
    • Amélioration de la gestion des états de porte avec des transitions visuelles lors du déverrouillage.
  • Corrections de bugs

    • Ajustements des propriétés de rendu pour garantir un affichage correct des éléments graphiques.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 27, 2024

Walkthrough

Les modifications apportées dans cette demande de tirage concernent principalement des fichiers de préfabriqués et de scripts dans un projet Unity. Des objets de jeu tels que AltarSpawnPoint, Floor, et Walls ont été ajoutés ou modifiés dans le préfabriqué CorridorX7, tandis que des ajustements ont été effectués sur les composants de collision et de rendu. D'autres préfabriqués comme Room, Door, et WaitingRoom ont également été mis à jour pour améliorer la gestion des interactions et des états des portes. De plus, des modifications ont été apportées aux scripts pour gérer les états des portes et les ennemis.

Changes

Fichier Résumé des modifications
Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab Ajout de nouveaux GameObjects (AltarSpawnPoint, Floor, Walls), mise à jour des propriétés de TilemapRenderer, ajout de BoxCollider2D pour Walls, Floor, et AltarSpawnPoint.
Assets/Prefabs/RoomSystem/Corridor/Room.prefab Modification de plusieurs GameObjects, activation de BoxCollider2D, mise à jour des propriétés de transformation et des configurations de Tilemap.
Assets/Prefabs/RoomSystem/Doors/Door.prefab Changement de l'étiquette du GameObject Door de Untagged à Door, mise à jour de la position et des propriétés de SpriteRenderer.
Assets/Prefabs/RoomSystem/WaitingRoom.prefab Ajout de nouveaux champs sérialisés (playerMovement, lockedDoor, unlockedDoor) dans la classe MonoBehaviour.
Assets/Scripts/Map Control/DoorSystem.cs Ajout d'une logique pour gérer les ennemis lors de l'entrée dans CorridorX7 et conservation de la structure existante pour la gestion des états de jeu.
Assets/Scripts/WaitingTrapper.cs Changement de la visibilité de spawnOfPoint à privé, ajout de door, lockedDoor, et unlockedDoor, et mise à jour des méthodes pour gérer l'état de la porte et les transitions visuelles.
ProjectSettings/TagManager.asset Ajout d'un nouveau tag Door dans le gestionnaire de tags.

Possibly related PRs

  • feat: Add Socket to props to send them to back-end #8: Les modifications dans Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab impliquent l'ajout de nouveaux GameObjects et composants, ce qui est en lien direct avec les modifications apportées dans cette même préfabrique dans la demande de tirage principale.
  • feat: Adapt Waiting Room #33: Les mises à jour de Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab dans cette PR impliquent également des modifications des GameObjects et de leurs propriétés, suggérant une connexion avec les améliorations apportées au système de couloir.

Suggested reviewers

  • Thomlam

Poem

Dans le couloir, une porte s'ouvre,
Des murs et des sols, la magie recouvre.
Avec des ennemis à vaincre,
La lumière et l'ombre se synchronisent.
Oh, joyeuse mise à jour,
Dans notre monde, tu fais briller le jour! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AyakorK AyakorK changed the title Fix/global rendering fixes fix: Global rendering fixes Oct 27, 2024
@AyakorK AyakorK marked this pull request as ready for review October 27, 2024 12:00
@AyakorK AyakorK requested a review from Thomlam October 27, 2024 12:00
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (7)
Assets/Prefabs/RoomSystem/WaitingRoom.prefab (1)

Le tag "Temporary" semble être une anomalie dans le système de salles

D'après l'analyse du code, le tag "Temporary" n'est utilisé que dans deux fichiers : le prefab WaitingRoom et la scène Menu. Dans le contexte du système de salles, les autres prefabs utilisent des tags plus descriptifs et appropriés comme "Wall", "Map", "Door", "SpawnPoint", "Props" et "Respawn". Le tag "Temporary" ne semble pas cohérent avec cette nomenclature établie.

  • Le tag devrait être changé pour mieux refléter le rôle de ce GameObject dans le système de salles
  • Considérez utiliser un tag plus approprié comme "Room" ou un tag similaire aux autres prefabs du système
🔗 Analysis chain

Line range hint 15-15: Vérifier l'utilisation du tag "Temporary"

Le GameObject utilise le tag "Temporary". Est-ce intentionnel pour ce prefab de salle d'attente ? Si ce n'est pas un état temporaire, envisagez d'utiliser un tag plus approprié.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Vérifier l'utilisation du tag "Temporary" dans le projet
rg -l "Temporary" --type yaml

Length of output: 178


Script:

#!/bin/bash
# Search for files with "Temporary" tag in Unity prefabs and scenes
find . -type f \( -name "*.prefab" -o -name "*.unity" \) -exec grep -l "Temporary" {} \;

# Also search in any YAML files (Unity's meta files and settings)
find . -type f -name "*.yaml" -o -name "*.yml" -exec grep -l "Temporary" {} \;

Length of output: 252


Script:

#!/bin/bash
# Search for other tags used in prefabs in the RoomSystem folder
find ./Assets/Prefabs/RoomSystem -type f -name "*.prefab" -exec grep "m_TagString:" {} \;

Length of output: 859

Assets/Scripts/Map Control/DoorSystem.cs (2)

65-65: Améliorer la clarté des messages de débogage

Le message de débogage pourrait être plus descriptif pour faciliter le dépannage.

- UnityEngine.Debug.Log("No arrows found");
+ UnityEngine.Debug.Log("[CorridorX7] Aucun projectile ennemi trouvé lors du nettoyage");

61-61: Suggestion d'utilisation de FindObjectsOfType pour plus de sécurité

L'utilisation de tags est sujette aux erreurs de frappe. Considérez l'utilisation de Object.FindObjectsOfType<EnemyProjectile>() si vous avez une classe spécifique pour les projectiles ennemis.

Assets/Scripts/WaitingTrapper.cs (1)

29-34: Ajoutez l'attribut [SerializeField] pour les variables privées

Pour maintenir l'encapsulation tout en permettant l'édition dans l'inspecteur Unity, ajoutez l'attribut [SerializeField] aux variables privées qui nécessitent une configuration dans l'éditeur.

-    private GameObject spawnOfPoint;
-    private GameObject door;
+    [SerializeField] private GameObject spawnOfPoint;
+    [SerializeField] private GameObject door;

     // Set a public sprite for the door when it's locked and unlocked
-    public Sprite lockedDoor;
-    public Sprite unlockedDoor;
+    [SerializeField] public Sprite lockedDoor;
+    [SerializeField] public Sprite unlockedDoor;
Assets/Prefabs/RoomSystem/Corridor/Room.prefab (3)

Line range hint 4557-4582: Correction : Paramétrage du TilemapCollider2D

Le composant TilemapCollider2D a m_UsedByComposite défini sur 0. Si vous utilisez des composite colliders, il serait approprié de définir m_UsedByComposite sur 1 pour optimiser les collisions.

Appliquez ce diff pour corriger le paramètre :

 m_UsedByComposite: 0
+m_UsedByComposite: 1

Line range hint 7758324542606305000-7758324542606305000: Correction : Mise à jour du tag de l'objet Door

L'objet Door a son m_TagString défini sur Untagged. Selon les conventions du projet et pour une identification cohérente, il serait préférable de le définir sur Door.

Appliquez ce diff pour mettre à jour le tag :

 m_Name: Door
-m_TagString: Untagged
+m_TagString: Door

Line range hint 4875-5837: Suggestion : Utiliser un CompositeCollider2D pour les Props

Étant donné le grand nombre de colliders pour l'objet Props, envisagez d'utiliser un CompositeCollider2D avec le TilemapCollider2D en mode composite. Cela simplifiera la gestion des colliders et améliorera les performances.

[performance]

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bb134a0 and b970968.

📒 Files selected for processing (7)
  • Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab (9 hunks)
  • Assets/Prefabs/RoomSystem/Corridor/Room.prefab (22 hunks)
  • Assets/Prefabs/RoomSystem/Doors/Door.prefab (1 hunks)
  • Assets/Prefabs/RoomSystem/WaitingRoom.prefab (1 hunks)
  • Assets/Scripts/Map Control/DoorSystem.cs (1 hunks)
  • Assets/Scripts/WaitingTrapper.cs (3 hunks)
  • ProjectSettings/TagManager.asset (1 hunks)
🔇 Additional comments (9)
ProjectSettings/TagManager.asset (1)

15-15: Ajout approprié du tag "Door"

L'ajout du tag "Door" est cohérent avec la convention de nommage existante et s'intègre bien dans le système de gestion des portes.

Exécutons le script suivant pour vérifier l'utilisation du tag dans la base de code :

✅ Verification successful

Vérification réussie de l'utilisation du tag "Door"

L'analyse du code confirme que le tag "Door" est correctement utilisé dans le script WaitingTrapper.cs pour :

  • Localiser l'objet porte via GameObject.FindGameObjectWithTag("Door")
  • Gérer les états verrouillé/déverrouillé de la porte
  • Contrôler l'apparence visuelle de la porte avec des sprites différents

L'implémentation est cohérente avec le système de gestion des portes décrit dans le résumé.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Vérifier l'utilisation du tag "Door" dans les fichiers Unity

# Rechercher les références au tag "Door" dans les fichiers
rg -l "tag\s*=\s*[\"']Door[\"']" || \
rg -l "CompareTag\s*\(\s*[\"']Door[\"']\s*\)" || \
rg -l "FindGameObjectsWithTag\s*\(\s*[\"']Door[\"']\s*\)" || \
rg -l "FindWithTag\s*\(\s*[\"']Door[\"']\s*\)"

Length of output: 207


Script:

#!/bin/bash
# Rechercher toutes les références au mot "Door" dans les fichiers C# et les prefabs
rg -i "door" --type cs -C 2

# Rechercher dans les fichiers .prefab pour les références au tag Door
rg -i "tag: Door" --type yaml

Length of output: 4474

Assets/Prefabs/RoomSystem/WaitingRoom.prefab (2)

49-50: Les sprites de porte sont correctement référencés

Les références aux sprites lockedDoor et unlockedDoor sont bien configurées avec leurs GUID respectifs.


48-48: ⚠️ Potential issue

Attention : Référence nulle potentielle pour playerMovement

La référence playerMovement n'est pas assignée, ce qui pourrait provoquer une exception lors de l'exécution. Veuillez assigner cette référence dans l'inspecteur Unity.

Assets/Prefabs/RoomSystem/Doors/Door.prefab (2)

106-106: Modification appropriée du tag de la porte

Le changement du tag de "Untagged" à "Door" est une amélioration pertinente qui facilitera l'identification et la gestion des portes dans le système de jeu.


106-106: Vérification nécessaire du TagManager

Assurons-nous que le tag "Door" est correctement configuré dans le projet.

✅ Verification successful

Tag "Door" correctement configuré dans le TagManager

Le tag "Door" est bien défini dans le TagManager du projet, ce qui confirme son utilisation valide dans le prefab.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Vérifier que le tag "Door" est défini dans le TagManager

# Test: Rechercher la définition du tag "Door" dans le TagManager
rg "Door" "ProjectSettings/TagManager.asset"

Length of output: 51

Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab (3)

326-327: Assurer la cohérence des paramètres de rendu

Les propriétés m_SortingLayerID et m_SortingLayer ont été modifiées. Vérifiez que ces changements sont cohérents avec le tri des calques dans tout le projet pour éviter des problèmes de rendu inattendus.

Also applies to: 1282-1283


2418-2425: Confirmer les modifications des calques de tri dans le PrefabInstance

Les propriétés m_SortingLayer et m_SortingLayerID ont été mises à jour dans le PrefabInstance. Assurez-vous que ces modifications sont nécessaires et n'affecteront pas négativement les autres instances du prefab.


646-649: 🛠️ Refactor suggestion

Vérifier l'utilisation de plusieurs BoxCollider2D sur le GameObject "Walls"

Plusieurs composants BoxCollider2D ont été ajoutés au GameObject "Walls". Assurez-vous que cette approche est intentionnelle. Si l'objectif est de créer des collisions complexes, il serait préférable d'utiliser un CompositeCollider2D avec des formes enfants pour améliorer les performances et faciliter la gestion des collisions.

Assets/Prefabs/RoomSystem/Corridor/Room.prefab (1)

5750-5794: Vérification : Alignement des BoxCollider2D avec les sprites

Assurez-vous que les BoxCollider2D ajoutés correspondent correctement aux sprites dans l'objet Props, notamment pour les offsets et les tailles personnalisées. Cela garantit des collisions précises et évite des comportements inattendus.

Comment on lines +61 to +74
GameObject[] arrows = GameObject.FindGameObjectsWithTag("Enemy");

if (arrows.Length == 0)
{
UnityEngine.Debug.Log("No arrows found");
}
else
{
foreach (GameObject arrow in arrows)
{
Destroy(arrow);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Suggestion de refactorisation pour éliminer la duplication de code

Le code de nettoyage des flèches est très similaire à celui du nettoyage des pièges. Considérez l'extraction de cette logique dans une méthode réutilisable.

Voici une suggestion d'amélioration :

+ private void CleanupGameObjects(string tag, string objectTypeName) {
+     GameObject[] objects = GameObject.FindGameObjectsWithTag(tag);
+     if (objects.Length == 0) {
+         Debug.Log($"Aucun {objectTypeName} trouvé");
+     } else {
+         foreach (GameObject obj in objects) {
+             Destroy(obj);
+         }
+     }
+ }

  // Dans OnTriggerEnter2D :
- GameObject[] arrows = GameObject.FindGameObjectsWithTag("Enemy");
- if (arrows.Length == 0) {
-     UnityEngine.Debug.Log("No arrows found");
- } else {
-     foreach (GameObject arrow in arrows) {
-         Destroy(arrow);
-     }
- }
+ CleanupGameObjects("Enemy", "projectile");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
GameObject[] arrows = GameObject.FindGameObjectsWithTag("Enemy");
if (arrows.Length == 0)
{
UnityEngine.Debug.Log("No arrows found");
}
else
{
foreach (GameObject arrow in arrows)
{
Destroy(arrow);
}
}
private void CleanupGameObjects(string tag, string objectTypeName) {
GameObject[] objects = GameObject.FindGameObjectsWithTag(tag);
if (objects.Length == 0) {
Debug.Log($"Aucun {objectTypeName} trouvé");
} else {
foreach (GameObject obj in objects) {
Destroy(obj);
}
}
}
// Dans OnTriggerEnter2D :
CleanupGameObjects("Enemy", "projectile");

Comment on lines +213 to +221
door = GameObject.FindGameObjectWithTag("Door");
if (gameStart)
{
gameStart = false;
coroutineStarted = true;
StartCoroutine(StartCountdown(5)); // Start countdown for traps
}
if ( spawnOfPoint == GameObject.FindGameObjectWithTag("SpawnPoint") && !coroutineStarted){
if (spawnOfPoint == GameObject.FindGameObjectWithTag("SpawnPoint") && !coroutineStarted)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Optimisez les appels FindGameObjectWithTag

L'utilisation de FindGameObjectWithTag dans Update est coûteuse en performances. De plus, la condition de comparaison peut être simplifiée.

-    void Update()
+    void Awake()
     {
         spawnOfPoint = GameObject.FindGameObjectWithTag("SpawnPoint");
         door = GameObject.FindGameObjectWithTag("Door");
+    }
+
+    void Update()
+    {
         if (gameStart)
         {
             gameStart = false;
             coroutineStarted = true;
             StartCoroutine(StartCountdown(5));
         }
-        if (spawnOfPoint == GameObject.FindGameObjectWithTag("SpawnPoint") && !coroutineStarted)
+        if (spawnOfPoint != null && !coroutineStarted)
         {
             lockDoor();
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
door = GameObject.FindGameObjectWithTag("Door");
if (gameStart)
{
gameStart = false;
coroutineStarted = true;
StartCoroutine(StartCountdown(5)); // Start countdown for traps
}
if ( spawnOfPoint == GameObject.FindGameObjectWithTag("SpawnPoint") && !coroutineStarted){
if (spawnOfPoint == GameObject.FindGameObjectWithTag("SpawnPoint") && !coroutineStarted)
{
void Awake()
{
spawnOfPoint = GameObject.FindGameObjectWithTag("SpawnPoint");
door = GameObject.FindGameObjectWithTag("Door");
}
void Update()
{
if (gameStart)
{
gameStart = false;
coroutineStarted = true;
StartCoroutine(StartCountdown(5)); // Start countdown for traps
}
if (spawnOfPoint != null && !coroutineStarted)
{

Debug.LogError("Spawn point not found!");
return;
}
door.GetComponent<SpriteRenderer>().sprite = lockedDoor;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ajoutez une vérification de null pour door

Il manque une vérification de null pour l'objet door et son SpriteRenderer, ce qui pourrait provoquer une NullReferenceException.

     private void lockDoor()
     {
         if (spawnOfPoint == null)
         {
             Debug.LogError("Spawn point not found!");
             return;
         }
+        if (door == null || door.GetComponent<SpriteRenderer>() == null)
+        {
+            Debug.LogError("Door or SpriteRenderer not found!");
+            return;
+        }
         door.GetComponent<SpriteRenderer>().sprite = lockedDoor;
         spawnOfPoint.GetComponent<BoxCollider2D>().enabled = false;
     }

Committable suggestion was skipped due to low confidence.

Comment on lines +93 to +117
private IEnumerator FadeToUnlockedSprite()
{
SpriteRenderer doorRenderer = door.GetComponent<SpriteRenderer>();
float fadeDuration = 0.4f;
float elapsedTime = 0;

Sprite initialSprite = doorRenderer.sprite;

while (elapsedTime < fadeDuration)
{
elapsedTime += Time.deltaTime;
float alpha = Mathf.Lerp(1, 0, elapsedTime / fadeDuration);

doorRenderer.color = new Color(1, 1, 1, alpha);

if (alpha < 0.5f)
{
doorRenderer.sprite = unlockedDoor;
doorRenderer.color = new Color(1, 1, 1, 1 - alpha);
}

yield return null;
}

doorRenderer.sprite = unlockedDoor;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Optimisez la gestion des composants

La coroutine pourrait être optimisée en mettant en cache le SpriteRenderer et en définissant la durée comme constante.

+    private const float FADE_DURATION = 0.4f;
+    private SpriteRenderer doorRenderer;
+
     private IEnumerator FadeToUnlockedSprite()
     {
-        SpriteRenderer doorRenderer = door.GetComponent<SpriteRenderer>();
-        float fadeDuration = 0.4f;
+        if (doorRenderer == null)
+            doorRenderer = door.GetComponent<SpriteRenderer>();
         float elapsedTime = 0;

         Sprite initialSprite = doorRenderer.sprite;

-        while (elapsedTime < fadeDuration)
+        while (elapsedTime < FADE_DURATION)
         {
             elapsedTime += Time.deltaTime;
-            float alpha = Mathf.Lerp(1, 0, elapsedTime / fadeDuration);
+            float alpha = Mathf.Lerp(1, 0, elapsedTime / FADE_DURATION);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private IEnumerator FadeToUnlockedSprite()
{
SpriteRenderer doorRenderer = door.GetComponent<SpriteRenderer>();
float fadeDuration = 0.4f;
float elapsedTime = 0;
Sprite initialSprite = doorRenderer.sprite;
while (elapsedTime < fadeDuration)
{
elapsedTime += Time.deltaTime;
float alpha = Mathf.Lerp(1, 0, elapsedTime / fadeDuration);
doorRenderer.color = new Color(1, 1, 1, alpha);
if (alpha < 0.5f)
{
doorRenderer.sprite = unlockedDoor;
doorRenderer.color = new Color(1, 1, 1, 1 - alpha);
}
yield return null;
}
doorRenderer.sprite = unlockedDoor;
private const float FADE_DURATION = 0.4f;
private SpriteRenderer doorRenderer;
private IEnumerator FadeToUnlockedSprite()
{
if (doorRenderer == null)
doorRenderer = door.GetComponent<SpriteRenderer>();
float elapsedTime = 0;
Sprite initialSprite = doorRenderer.sprite;
while (elapsedTime < FADE_DURATION)
{
elapsedTime += Time.deltaTime;
float alpha = Mathf.Lerp(1, 0, elapsedTime / FADE_DURATION);
doorRenderer.color = new Color(1, 1, 1, alpha);
if (alpha < 0.5f)
{
doorRenderer.sprite = unlockedDoor;
doorRenderer.color = new Color(1, 1, 1, 1 - alpha);
}
yield return null;
}
doorRenderer.sprite = unlockedDoor;

Comment on lines +1329 to +1508
--- !u!61 &4961666462818913969
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6168419598805709018}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -2.5, y: 4.5}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 5, y: 14}
m_EdgeRadius: 0
--- !u!61 &7872246779378419752
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6168419598805709018}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 9.5, y: 4.5}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 5, y: 14}
m_EdgeRadius: 0
--- !u!61 &5883328970668218702
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6168419598805709018}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 3.5, y: -2}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 9, y: 4}
m_EdgeRadius: 0
--- !u!61 &9041205108107242711
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6168419598805709018}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 3.5, y: 12}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 9, y: 4}
m_EdgeRadius: 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Optimiser les colliders en utilisant un CompositeCollider2D

Au lieu d'ajouter plusieurs BoxCollider2D au même GameObject, envisagez d'utiliser un CompositeCollider2D. Cela permettra de combiner les colliders en une seule forme, améliorant ainsi les performances et la maintenabilité du code.

- component: {fileID: 3572327062455973037}
- component: {fileID: 6854233774248888068}
- component: {fileID: 4830675212851221459}
- component: {fileID: 3572327062455973037}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Suggestion : Vérifier la nécessité de multiples BoxCollider2D

Deux composants BoxCollider2D sont ajoutés à l'objet Walls. Assurez-vous que l'ajout de plusieurs colliders est intentionnel et nécessaire pour le comportement souhaité. Sinon, envisagez de combiner les colliders pour optimiser les performances.

Comment on lines +5556 to +5569
m_Offset: {x: 3, y: 12}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 2, y: 2}
m_EdgeRadius: 0
--- !u!61 &408787112702833230
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Suggestion : Combiner les BoxCollider2D pour améliorer les performances

Plusieurs composants BoxCollider2D sont ajoutés à l'objet Props. Il serait préférable de combiner ces colliders en un seul, ou d'utiliser un CompositeCollider2D si cela convient, pour optimiser les performances et faciliter la maintenance.

@Thomlam Thomlam merged commit 1331c6e into develop Oct 27, 2024
AyakorK added a commit that referenced this pull request Oct 27, 2024
* Chore/shadering map (#24)

* technical : add shadering and post-traitement system, adapt asset and sprite for using this

* feat: update Room2

* feat: Link the chat to the back sockets (#25)

* feat: Link chat to backend (#26)

* feat: Link the chat to the back sockets

* fix: Move the dialogue script outside the canvas to avoid it to be disabled while the canvas is going to be disabled

* fix: remove dual camera

* fix: fix crossbow system (#27)

* fix: add request to back (room name)

* fix: Revert trap manager

* hotfix: Fix things that weren't working

* feat: RPS (#29)

* feat : add multiple option and itemscollider for RockPaperCissor

* feat: Link Rock Paper Scissors to backend socket

* feat: Link RockPaperScissors, but display missing

---------

Co-authored-by: Thomas Lamiable <lamiablethomas@gmail.com>

* hotfix: Change RPS size to match the screen

* fix: fix Crossbow up sprite and arrow system, change color pixel dead font

* chore: change EmptyRoom2

* feat: add death system (#30)

* feat: add death system

* chore: add socket emiter for end game

* fix: fix heart generator if develop don't have socket

* fix: remove crossbow

* feature: add audio system and fix crossbow with sound (#32)

Co-authored-by: Guillaume MORET <90462045+AyakorK@users.noreply.github.com>

* chore: Fix env for windows (#31)

* feat: add death system

* chore: add socket emiter for end game

* fix: fix heart generator if develop don't have socket

* fix: remove crossbow

* chore: try to fix .env for Windows and Unity

* fix: Quick Fix in production

* fix: QuickFx PlayerHealth fail merge

* Fix: fix Room

* feat: Adapt Waiting Room (#33)

* feat: Instantiate waiting room when arriving in the corridor 0

* fix: Add a flag to change message one time and avoid repetition of it

* feat: Add the creation of the room when instanciating the WaitingRoom process

* feat: Try to remove the Door collider before game has started

* fix: fix lock and door system, add waiting room, last fix for dialogue system for pity

---------

Co-authored-by: Thomlam <lamiablethomas@gmail.com>

* fix: rename bear_trap to prefab

* fix: quick fix prefab room for crossbow

* fix: quickfix for bear_trap

* feat: Add room deletion when disconnection from a game

* Wip/streaming back (#35)

* feat: add streaming system with recording and sending frame jpeg

* feat: add config

* feat: first try to add socketIOSystem

* feat: Add the right socket

* feature : deploy for 60fps

---------

Co-authored-by: AyakorK <guillaume.moret@yahoo.com>

* hotfix: Get rid of a Debug

* fix: fix arrows component and stade 24 fps to streaming

* fix: Global rendering fixes (#36)

* fix: Update corridor displays + additions of colliders to avoid glitching

* fix: Add a door transition lock

* feat: Add collision to the walls in the room

* fix: Fix collisions of the hole

* fix: Fix glitched hitboxes

* fix: Destory arrows when going to an other room

---------

Co-authored-by: Guillaume MORET <90462045+AyakorK@users.noreply.github.com>
Co-authored-by: AyakorK <guillaume.moret@yahoo.com>
@AyakorK AyakorK deleted the fix/global_rendering_fixes branch October 28, 2024 02:49
This was referenced Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants