Files
Crash-Course/Assets/Scripts/Game/ObjectVisibility.cs

44 lines
1.0 KiB
C#
Raw Permalink Normal View History

2025-04-18 15:54:50 -04:00
using UnityEngine;
using Game;
using Music;
using Player;
2025-04-16 19:57:54 -04:00
namespace Game
{
2025-04-18 15:54:50 -04:00
/// <summary>
/// This class controls the visibility of an object based on the current game mode.
/// </summary>
public class ObjectVisibility : MonoBehaviour
2025-03-20 14:45:29 -04:00
{
2025-04-18 15:54:50 -04:00
/// <summary>
/// Initializes the visibility of the object when the game starts.
/// </summary>
private void Start()
{
UpdateVisibility();
}
2025-03-20 14:45:29 -04:00
2025-04-18 15:54:50 -04:00
/// <summary>
/// Updates the visibility of the object every frame.
/// </summary>
private void Update()
2025-03-20 14:45:29 -04:00
{
2025-04-18 15:54:50 -04:00
UpdateVisibility();
2025-03-20 14:45:29 -04:00
}
2025-04-18 15:54:50 -04:00
/// <summary>
/// Sets the object to be visible only if the game mode is "Keep Away".
/// </summary>
private void UpdateVisibility()
2025-03-20 14:45:29 -04:00
{
2025-04-18 15:54:50 -04:00
if (GameManager.gameMode == GameManager.GameMode.keepAway)
{
gameObject.SetActive(true);
}
else
{
gameObject.SetActive(false);
}
2025-03-20 14:45:29 -04:00
}
}
2025-04-16 19:57:54 -04:00
}