using UnityEngine; using System.Collections; using AX.MessageSystem; using System; public class HaveOneSelectfloor : MonoBehaviour { [HideInInspector] public int floor; public BuildType buildType = BuildType.TypeA; // Use this for initialization void Awake() { MessageDispatcher.AddListener("SELECTFLOOR_EVENT", SelectFloor); MessageDispatcher.AddListener("RESETFLOOR_EVENT", ResetFloor); string floorStr = gameObject.name.Substring(3); floor = int.Parse(floorStr); } bool One = true; private void SelectFloor(IMessage message) { if (buildType == (BuildType)message.Sender) { if (floor > (int)message.Data) { this.gameObject.SetActive(false); } else { this.gameObject.SetActive(true); } } } private void ResetFloor(IMessage message) { if (buildType == (BuildType)message.Sender) { if (floor > (int)message.Data) { gameObject.SetActive(false); } else { gameObject.SetActive(true); } } } void OnDestroy() { MessageDispatcher.RemoveListener("SELECTFLOOR_EVENT", SelectFloor); MessageDispatcher.RemoveListener("RESETFLOOR_EVENT", SelectFloor); } }