2025-10-28 23:19:52 +08:00
|
|
|
using System;
|
2025-10-20 19:59:44 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Script.Gameplay.Connect;
|
|
|
|
|
|
2025-10-22 17:34:58 +08:00
|
|
|
namespace Script.Gameplay.Facility
|
2025-10-20 19:59:44 +08:00
|
|
|
{
|
|
|
|
|
// 号码枚举类型
|
|
|
|
|
public enum NumberType
|
|
|
|
|
{
|
2025-10-28 23:19:52 +08:00
|
|
|
Circle,
|
|
|
|
|
Cloud,
|
|
|
|
|
Flower,
|
|
|
|
|
Leaf,
|
|
|
|
|
Wave,
|
2025-10-20 19:59:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 号码槽
|
2025-10-22 17:34:58 +08:00
|
|
|
public class NumberSlotController : BaseFacilityController
|
2025-10-20 19:59:44 +08:00
|
|
|
{
|
|
|
|
|
[Header("号码槽设置")]
|
2025-10-28 23:19:52 +08:00
|
|
|
[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 void Start()
|
|
|
|
|
{
|
|
|
|
|
// 初始化图标显示
|
|
|
|
|
UpdateIconDisplay();
|
|
|
|
|
// 检查初始号码并发送信号
|
|
|
|
|
CheckNumberAndSendSignal();
|
|
|
|
|
}
|
2025-10-20 19:59:44 +08:00
|
|
|
|
|
|
|
|
// 接收信号
|
2025-10-22 17:34:58 +08:00
|
|
|
public override void OnSignalReceived(bool active, GameObject sender)
|
2025-10-20 19:59:44 +08:00
|
|
|
{
|
2025-10-22 17:34:58 +08:00
|
|
|
base.OnSignalReceived(active, sender);
|
2025-10-20 19:59:44 +08:00
|
|
|
if (active)
|
|
|
|
|
{
|
|
|
|
|
SwitchToNextNumber();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 切换到下一个号码
|
|
|
|
|
private void SwitchToNextNumber()
|
|
|
|
|
{
|
|
|
|
|
currentNumber = (NumberType)(((int)currentNumber + 1) % System.Enum.GetValues(typeof(NumberType)).Length);
|
|
|
|
|
CheckNumberAndSendSignal();
|
2025-10-28 23:19:52 +08:00
|
|
|
// 更新图标显示
|
|
|
|
|
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;
|
|
|
|
|
}
|
2025-10-20 19:59:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查号码并发信号
|
|
|
|
|
private void CheckNumberAndSendSignal()
|
|
|
|
|
{
|
|
|
|
|
bool isCorrect = currentNumber == correctNumber;
|
2025-10-22 17:34:58 +08:00
|
|
|
SendSignal(isCorrect, this.gameObject);
|
2025-10-20 19:59:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|