[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

@@ -153,16 +153,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2895addc317815345b19503bab859a6a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_OrbitalPosition:
m_AttachedRing: 0
m_DistanceFromCentre: 0
m_DistanceAlongRadius: 0
m_ObjectRadius: 0
m_IsAttachedToRings: 0
m_Behaviour: {fileID: 0}
m_SpinSpeed: 0
m_AttachedRing: 0
m_DistanceAlongCircumference: 0
m_ObjectRadius: 0.1
m_SpinSpeed: 0.1
m_DistanceFromCentre: 0
<IsAttachedToRings>k__BackingField: 1
m_Renderer: {fileID: 104400500}
m_ScoreText: {fileID: 1501855168}
m_ModifierText: {fileID: 1227804579}
m_DefaultMaterial: {fileID: 2100000, guid: 2b4111cfdf7255c48b4c3dbcf9e202a6, type: 2}
m_FreeHitMaterial: {fileID: 2100000, guid: 22eb1f2017d2a15459d4c10b27104270, type: 2}
m_PostProcessVolume: {fileID: 519420033}
@@ -497,6 +496,7 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1501855167}
- {fileID: 1227804578}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -504,6 +504,85 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1227804577
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1227804578}
- component: {fileID: 1227804580}
- component: {fileID: 1227804579}
m_Layer: 5
m_Name: ModifierText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1227804578
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1227804577}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1158970873}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 100, y: -35}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1227804579
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1227804577}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 50
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 50
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text:
--- !u!222 &1227804580
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1227804577}
m_CullTransparentMesh: 1
--- !u!1 &1501855166
GameObject:
m_ObjectHideFlags: 0

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; }