// using System.Collections; // using System.Collections.Generic; // using UnityEngine; // // public class EventSvcForExample : MonoBehaviour // { // // ================================ // // 1. 定义事件类型和结构体 (EVENT_STRUCT)/(EVENT_ENUM) // // ================================ // // // private enum EVENT_REGISTER_EVENT_ENUM_EXAMPLE // // { // // EVENT_LET_OS_FOR_EXAMPLE, // 系统发牌 // // } // // // // ================================ // // 2. 绑定事件 (EventSvcHandler) // // ================================ // // // private readonly Dictionary actionBindMap = new() // 事件类型类型绑定 // // { // // // ========== 系统事件 ========== // // { EVENT_ENUM.EVENT_LET_OS_DEAL_CARD, typeof(EVENT_STRUCT.STRUCT_EVENT_OS_DEAL_CARD) }, // 系统发牌事件 // // // // // ========== 卡牌事件 ========== // // { EVENT_ENUM.EVENT_LET_CARD_DRAW_CARD, typeof(EVENT_STRUCT.STRUCT_EVENT_CARD_DRAW_CARD) } // 卡牌抽牌事件 // // }; // // // ================================ // // 3. 注册事件 // // ================================ // // // private void REGISTER_EVENT_drop_card() // 系统弃牌 // // { // // EventOS.EVENT_REGISTER(EVENT_ENUM.EVENT_LET_OS_DROP_CARD, callback); // // return; // // void callback(bool placeholder) // // { // // if (EventOS.LOCK_GET(EVENT_EXCLUSIVE_LOCK.LOCK_OS_DEAL_CARD)) return; // 系统是否正在发牌 // // if (!EventOS.LOCK_APPLY(EVENT_EXCLUSIVE_LOCK.LOCK_OS_DROP_CARD)) return; // 系统弃牌加锁失败 // // StartCoroutine(coroutine()); // // return; // // // // // // IEnumerator coroutine() // // { // // if (handCardList.Count > 0) // // { // // // for (var i = handCardList.Count; i >= 0; i--) // // for (var i = 0; i < handCardList.Count; i++) // // { // // EventOS.EVENT_TRIGGER(EventData.EVENT_REGISTER_EVENT_ENUM.EVENT_LET_CARD_DROP_SELF, // // new EventStruct.STRUCT_EVENT_DROP_CARD // // { // // ID = i, // // POSITION = drop_card_point_world_position, // // DURATION = cardDropDuration, // // }); // // yield return new WaitForSeconds(cardDropDuration); // // } // // } // // // // handCardList.Clear(); // 清空 // // EventOS.LOCK_RELEASE(EventLock.LOCK_EXCLUSIVE_CARD_ENUM.LOCK_OS_DROP_CARD); // // // REGISTER_EVENT_ENEMY_TURN_START(); // // } // // } // // } // }