[Feature] Added text of powerups

This commit is contained in:
Pasha Bibko
2025-11-28 18:10:10 +00:00
parent 569056a9a5
commit 9265cbbf99
3 changed files with 105 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ public class PlayerController : OrbitalBehaviour
[Header("References")]
[SerializeField] private MeshRenderer m_Renderer;
[SerializeField] private Text m_ScoreText;
[SerializeField] private Text m_ModifierText;
[SerializeField] private Material m_DefaultMaterial;
[SerializeField] private Material m_FreeHitMaterial;
[SerializeField] private PostProcessVolume m_PostProcessVolume;
@@ -118,7 +119,10 @@ public class PlayerController : OrbitalBehaviour
else if (other.CompareTag("PlayerMod"))
{
switch (((PlayerModifier)other).Modifier)
PlayerModifier mod = (PlayerModifier)other;
m_ModifierText.text = PlayerModifier.ModifierToString(mod.Modifier);
switch (mod.Modifier)
{
case PlayerModifier.Modifiers.GainPoints:
s_PlayerScore += 100;
@@ -145,7 +149,7 @@ public class PlayerController : OrbitalBehaviour
break;
default:
Debug.Log($"Collision with unknown modifier occured [{((PlayerModifier)other).Modifier}]");
Debug.Log($"Collision with unknown modifier occured [{mod.Modifier}]");
break;
}
}

View File

@@ -14,6 +14,18 @@ public class PlayerModifier : OrbitalBehaviour
SpeedUp
}
public static string ModifierToString(Modifiers mod) =>
mod switch
{
Modifiers.GainPoints => "100 Points",
Modifiers.FreeHit => "Temporary Shield",
Modifiers.GrowPlayer => "Grow Player",
Modifiers.ShrinkPlayer => "Shrink Player",
Modifiers.ClearAllEnemies => "Clear all enemies",
Modifiers.SpeedUp => "Speed Boost",
_ => "NULL"
};
private static readonly System.Random s_RandomGenerator = new();
public Modifiers Modifier { get; private set; }