示例#1
0
    public static void AddFn(LuaFunction fn, float delaytime, object arg)
    {
        float    next  = Time.unscaledTime + delaytime;
        LuaFnArg fnarg = new LuaFnArg(fn, next, arg);

        times.Add(fnarg);
        //times.Sort((left, right) =>
        //{
        //    if (left.time > right.time)
        //        return -1;
        //    else if (left.time == right.time)
        //        return 0;
        //    else
        //        return 1;
        //});
    }
示例#2
0
 public static void AddFn(LuaFunction fn,float delaytime, object arg)
 {
     float next = Time.unscaledTime + delaytime;
     LuaFnArg fnarg = new LuaFnArg(fn, next, arg);
     times.Add(fnarg);
     //times.Sort((left, right) =>
     //{
     //    if (left.time > right.time)
     //        return -1;
     //    else if (left.time == right.time)
     //        return 0;
     //    else
     //        return 1;
     //});
     
 }
示例#3
0
    public static void RemoveFn(LuaFunction fn)
    {
        LuaFnArg remItem = null;

        foreach (LuaFnArg arg in times)
        {
            if (arg.LuaFn.Equals(fn))
            {
                remItem = arg;
            }
        }

//        if (remItem != null) {
//			removes.Add(remItem);
//				}
        times.Remove(remItem);
    }
示例#4
0
    public static void Update()
    {
        List <LuaFnArg> .Enumerator enmu = times.GetEnumerator();

        //int i = 0;
//        removes.Clear();
//        while (enmu.MoveNext())
//        {
//            LuaFnArg item = enmu.Current;
//            if (Time.unscaledTime >= item.time)
//            {
//                item.LuaFn.Call(item.arg);
//                removes.Add(item);
//            }
//            //i++;
//        }

        for (int i = 0; i < times.Count; i++)
        {
            LuaFnArg item = times[i];
            if (Time.unscaledTime >= item.time)
            {
                item.LuaFn.Call(item.arg);
                removes.Add(item);
            }
        }

        if (removes.Count > 0)
        {
            foreach (LuaFnArg item in removes)
            {
                times.Remove(item);
            }
            removes.Clear();
        }
    }