rabidus-test/Assets/Plugins/QFSW/Quantum Console/Source/Demo Scene/Scripts/RobotCollector.cs

33 lines
969 B
C#

using QFSW.QC.Utilities;
using UnityEngine;
using UnityEngine.UI;
namespace QFSW.QC.Demo
{
public class RobotCollector : MonoBehaviour
{
[SerializeField] private Text text = null;
[SerializeField] private QuantumTheme theme = null;
public int RescueCount { [Command("demo.rescue-count")] get; set; }
private void Start() { UpdateText(); }
private void UpdateText()
{
if (!theme) { text.text = $"{RescueCount} robots saved"; }
else { text.text = $"{RescueCount.ToString().ColorText(theme.DefaultReturnValueColor)} robots saved"; }
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Player"))
{
Robot robot = collision.gameObject.GetComponent<Robot>();
robot.Die();
RescueCount++;
UpdateText();
}
}
}
}