コード例 #1
0
        /// <summary>
        /// 添加触发器脚本
        /// </summary>
        public static void AddTriggerEvent(GameObject go, LuaTable ed)
        {
            TriggerEventDispatcher dispatcher = go.GetComponent <TriggerEventDispatcher>();

            if (dispatcher == null)
            {
                dispatcher = go.AddComponent <TriggerEventDispatcher>();
            }
            dispatcher.ed = ed;
        }
コード例 #2
0
ファイル: EventManager.cs プロジェクト: webcyou/beaver_room
 public EventManager(GameObject pGameObject)
 {
     gameObject          = pGameObject;
     dispatcher          = gameObject.GetComponent <TriggerEventDispatcher>();
     dispatcher.onEnter += delegate(Collider pTarget){
         GameEvent tGameEvent = pTarget.gameObject.GetComponent <GameEvent>();
         if (tGameEvent == null)
         {
             return;
         }
         for (int i = 0; i < gameEvents.Count; i++)
         {
             if (gameEvents[i].id == tGameEvent.id)
             {
                 return;
             }
         }
         gameEvents.Add(tGameEvent);
     };
     dispatcher.onExit += delegate(Collider pTarget){
         GameEvent tGameEvent = pTarget.gameObject.GetComponent <GameEvent>();
         if (tGameEvent == null)
         {
             return;
         }
         for (int i = 0; i < gameEvents.Count; i++)
         {
             if (gameEvents[i].id == tGameEvent.id)
             {
                 textMessage = "";
                 gameEvents.RemoveAt(i);
                 return;
             }
         }
     };
 }