Added high score

Also made player always render on top of enemies
This commit is contained in:
Pasha Bibko
2025-11-25 15:08:04 +00:00
parent 3ae3d3e0d0
commit 6ee784bf4e
6 changed files with 12 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: RedMat m_Name: BlackMat
m_Shader: {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0} m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0 m_ModifiedSerializedProperties: 0

View File

@@ -80,7 +80,7 @@ Transform:
m_GameObject: {fileID: 4804673878835712602} m_GameObject: {fileID: 4804673878835712602}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: -1}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []

View File

@@ -14,7 +14,7 @@ public class EnemyController : OrbitalPositionBehaviour
public override void OnReachCentre() public override void OnReachCentre()
{ {
if (GlobalOrbitalPositionManager.IsSimulationRunning) if (GlobalOrbitalPositionManager.IsSimulationRunning)
PlayerController.PlayerScore++; PlayerController.s_PlayerScore++;
Destroy(gameObject); Destroy(gameObject);
} }

View File

@@ -155,7 +155,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
if (ring.transform.localScale.x < 0.5f) if (ring.transform.localScale.x < 0.5f)
{ {
if (IsSimulationRunning) if (IsSimulationRunning)
PlayerController.PlayerScore++; PlayerController.s_PlayerScore++;
toRemove.Add(ring); toRemove.Add(ring);
} }

View File

@@ -1,9 +1,11 @@
using System;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class PlayerController : OrbitalPositionBehaviour public class PlayerController : OrbitalPositionBehaviour
{ {
public static int PlayerScore = 0; public static int s_PlayerScore;
private static int s_HighScore = 20;
private static PlayerController s_Instance; private static PlayerController s_Instance;
public static bool IsPlayerAttached => s_Instance.m_OrbitalPosition.m_IsAttachedToRings; public static bool IsPlayerAttached => s_Instance.m_OrbitalPosition.m_IsAttachedToRings;
@@ -28,7 +30,9 @@ public class PlayerController : OrbitalPositionBehaviour
public void Update() public void Update()
{ {
m_ScoreText.text = PlayerScore.ToString(); m_ScoreText.text = s_PlayerScore.ToString();
if (s_PlayerScore > s_HighScore)
m_ScoreText.color = Color.yellow;
if (GlobalInput.IsScreenClicked() && GlobalOrbitalPositionManager.AllowPlayerInput) if (GlobalInput.IsScreenClicked() && GlobalOrbitalPositionManager.AllowPlayerInput)
{ {
@@ -60,7 +64,8 @@ public class PlayerController : OrbitalPositionBehaviour
m_Renderer.material.color = Color.green; m_Renderer.material.color = Color.green;
PlayerScore = 0; s_HighScore = Math.Max(s_HighScore, s_PlayerScore);
s_PlayerScore = 0;
} }
public override void OnReachCentre() public override void OnReachCentre()