示例#1
0
        static void Main(string[] args)
        {
            CoroutineFacade ctr = new CoroutineFacade();

            ctr.Initialize();

            ctr.StartContorine(test1());
            ctr.StartContorine(test2());

            float maxTime  = 11;
            float timeSum  = 0;
            float timeStep = 0.016f;

            while (true)
            {
                //模拟运行,每一帧为0.016s
                ctr.Update(CoroutineCtrEnum.Default, timeStep);
                ctr.Update(CoroutineCtrEnum.Wait, timeStep);
                timeSum += timeStep;


                Thread.Sleep(16);

                if (timeSum > maxTime)
                {
                    Console.WriteLine("timeSum greate than maxTime");
                    break;
                }
            }
            ctr.Release();
        }
 /// <summary>
 /// 为了不使用单例模式,采取了注入的方式
 /// </summary>
 /// <param name="facade">外观实例</param>
 public void SetFacade(CoroutineFacade facade)
 {
     _facade = facade;
 }