示例#1
0
    //ゲームエンジンにイテレーターを登録致します。
    //WARNING:このメソッドの実行中に StartCoroutine() が呼ばれると再入するので注意。
    public static MyLib.Coroutine AddRoutine
        (MyLib.MonoBehaviour behaviour, string method_name, IEnumerator routine)
    {
        MyLib.BehaviourData b_data;
        //スクリプトと同じ名前のキーから、値を取得する
        if (_behavior_dict.TryGetValue(behaviour, out b_data))
        {
            //コルーチンを生成、初期化
            var coroutine = new MyLib.Coroutine(method_name, routine);

            //コルーチンを登録
            var coroutine_list = new LinkedList <MyLib.Coroutine> ();
            coroutine._node = coroutine_list.AddLast(coroutine);
            b_data._routine_list.AddLast(coroutine_list);

            // コルーチンの初回実行を行う。
            ProcessCoroutine(coroutine);

            return(coroutine);
        }
        else
        {
            UnityEngine.Debug.Log("登録が行われませんでした。Null値を返します");
            return(null);
        }
    }
示例#2
0
 public static void AddMonoBehaviour(MyLib.MonoBehaviour behaviour)
 {
     if (!behaviourDict.ContainsKey(behaviour))
     {
         behaviourDict.Add(behaviour, new MyLib.BehaviourData(behaviour));
     }
 }
示例#3
0
 public static void RemoveAllRoutines(MyLib.MonoBehaviour behaviour)
 {
     MyLib.BehaviourData bdata;
     if (behaviourDict.TryGetValue(behaviour, out bdata))
     {
         bdata.routineList.Clear();
     }
 }
示例#4
0
 //ユーザー定義のスクリプト(My.Libを継承したクラス)を
 //Dictionary(_behavior_dict)に登録.
 public static void AddMonoBehavior(MyLib.MonoBehaviour behaviour)
 {
     //すでに登録していなければ
     if (!_behavior_dict.ContainsKey(behaviour))
     {
         _behavior_dict.Add(behaviour, new MyLib.BehaviourData(behaviour));
     }
 }
示例#5
0
 //登録した全てのコルーチンを削除
 public static void RemoveAllRoutines(MyLib.MonoBehaviour behaviour)
 {
     MyLib.BehaviourData b_data;
     if (_behavior_dict.TryGetValue(behaviour, out b_data))
     {
         b_data._routine_list.Clear();
     }
 }
示例#6
0
 public static void RemoveRoutine(MyLib.MonoBehaviour behaviour, string methodName)
 {
     MyLib.BehaviourData bdata;
     if (behaviourDict.TryGetValue(behaviour, out bdata))
     {
         LinkedListNode <MyLib.Coroutine> node = bdata.routineList.First;
         while (node != null)
         {
             var oldNode = node;
             node = node.Next;
             if (oldNode.Value.methodName == methodName)
             {
                 bdata.routineList.Remove(oldNode);
             }
         }
     }
 }
示例#7
0
    public static MyLib.Coroutine AddRoutine(MyLib.MonoBehaviour behaviour, string methodName, IEnumerator routine)
    {
        MyLib.BehaviourData bdata;

        if (behaviourDict.TryGetValue(behaviour, out bdata))
        {
            var coroutine = new MyLib.Coroutine(methodName, routine);

            // ひとまず1回実行
            routine.MoveNext();
            bdata.routineList.AddLast(coroutine);
            return(coroutine);
        }
        else
        {
            // ここに来ることはない
            return(null);
        }
    }
示例#8
0
    public static void RemoveRoutine(MyLib.MonoBehaviour behaviour, string methodName)
    {
        MyLib.BehaviourData bdata;
        if (behaviourDict.TryGetValue(behaviour, out bdata))
        {
            LinkedListNode <LinkedList <MyLib.Coroutine> > node = bdata.routineList.First;
            while (node != null)
            {
                LinkedList <MyLib.Coroutine> list = node.Value;
                RemoveRoutineSub(list, methodName);

                var oldNode = node;
                node = node.Next;

                // listの要素が空になった場合は、list自体を除去。
                if (list.Count == 0)
                {
                    bdata.routineList.Remove(oldNode);
                }
            }
        }
    }
示例#9
0
    //名前で指定したコルーチンを、実行対象から外す。 ※MonoBehavior.StopCorotine()でよばれます
    public static void RemoveRoutine(MyLib.MonoBehaviour behaviour, string method_name)
    {
        MyLib.BehaviourData b_data;
        if (_behavior_dict.TryGetValue(behaviour, out b_data))
        {
            //リストの頭のデータを取得、頭から指定した名前と一致するコルーチンを検索
            LinkedListNode <LinkedList <MyLib.Coroutine> > node = b_data._routine_list.First;
            while (node != null)
            {
                LinkedList <MyLib.Coroutine> list = node.Value;
                RemoveRoutineSub(list, method_name);

                var old_node = node;
                node = node.Next;

                //listの要素が空になったら
                if (list.Count == 0)
                {
                    b_data._routine_list.Remove(old_node);
                }
            }
        }
    }
示例#10
0
    /// <summary>
    /// このメソッドの実行中に StartCoroutine() が呼ばれると再入するので注意。
    /// </summary>
    /// <returns>The routine.</returns>
    /// <param name="behaviour">Behaviour.</param>
    /// <param name="methodName">Method name.</param>
    /// <param name="routine">Routine.</param>
    public static MyLib.Coroutine AddRoutine(MyLib.MonoBehaviour behaviour, string methodName, IEnumerator routine)
    {
        MyLib.BehaviourData bdata;

        if (behaviourDict.TryGetValue(behaviour, out bdata))
        {
            var coroutine = new MyLib.Coroutine(methodName, routine);

            // 何はともあれまずコルーチンを登録
            var list = new LinkedList <MyLib.Coroutine>();
            coroutine.node = list.AddLast(coroutine);
            bdata.routineList.AddLast(list);

            // コルーチンの初回実行を行う。
            ProcessCoroutine(coroutine);

            return(coroutine);
        }
        else
        {
            // ここに来ることはない
            return(null);
        }
    }