using System; using System.Collections.Generic; using UnityEngine; using Script.Gameplay.Connect; namespace Script.Gameplay.Facility { // 号码枚举类型 public enum NumberType { Circle, Cloud, Flower, Leaf, Wave, } // 号码槽 public class NumberSlotController : BaseFacilityController { [Header("号码槽设置")] [SerializeField] private NumberType currentNumber = NumberType.Circle; [SerializeField] private NumberType correctNumber = NumberType.Cloud; [Header("图标")] [SerializeField] private GameObject CircleIcon; [SerializeField] private GameObject CloudIcon; [SerializeField] private GameObject FlowerIcon; [SerializeField] private GameObject LeafIcon; [SerializeField] private GameObject WaveIcon; private bool lastSendSignal = false; private void Awake() { } private void Start() { // 初始化图标显示 UpdateIconDisplay(); // 检查初始号码并发送信号 CheckNumberAndSendSignal(); } // 接收信号 public override void OnSignalReceived(bool active, GameObject sender) { base.OnSignalReceived(active, sender); if (active) { SwitchToNextNumber(); } } // 切换到下一个号码 private void SwitchToNextNumber() { currentNumber = (NumberType)(((int)currentNumber + 1) % System.Enum.GetValues(typeof(NumberType)).Length); CheckNumberAndSendSignal(); // 更新图标显示 UpdateIconDisplay(); } private void UpdateIconDisplay() { // 隐藏所有图标 CircleIcon.SetActive(false); CloudIcon.SetActive(false); FlowerIcon.SetActive(false); LeafIcon.SetActive(false); WaveIcon.SetActive(false); // 根据当前号码显示对应图标 switch (currentNumber) { case NumberType.Circle: CircleIcon.SetActive(true); break; case NumberType.Cloud: CloudIcon.SetActive(true); break; case NumberType.Flower: FlowerIcon.SetActive(true); break; case NumberType.Leaf: LeafIcon.SetActive(true); break; case NumberType.Wave: WaveIcon.SetActive(true); break; } } // 检查号码并发信号 private void CheckNumberAndSendSignal() { bool isCorrect = currentNumber == correctNumber; if (lastSendSignal == false && isCorrect) { // 发送true信号 SendSignal(true, this.gameObject); lastSendSignal = true; } else if (lastSendSignal == true && !isCorrect) { // 发送false信号 SendSignal(false, this.gameObject); lastSendSignal = false; } } } }