コード例 #1
0
        public Coroutine(Action action, YieldBase condition, string owner, string name = null, bool autoStart = true)
        {
            DoWork  = autoStart;
            Started = DateTime.Now;
            switch (condition)
            {
            case WaitTime _:
                TimeoutForAction = ((WaitTime)condition).Milliseconds.ToString();
                break;

            case WaitRender _:
                TimeoutForAction = ((WaitRender)condition).HowManyRenderCountWait.ToString();
                break;

            case WaitFunction _:
                TimeoutForAction = "Function -1";
                break;
            }
            Owner     = owner;
            Action    = action;
            Condition = condition;

            IEnumerator CoroutineAction(Action a)
            {
                while (true)
                {
                    a?.Invoke();
                    Ticks++;
                    yield return(Condition.GetEnumerator());
                }
            }

            Name        = name ?? MathHepler.GetRandomWord(13);
            _enumerator = CoroutineAction(action);
        }
コード例 #2
0
        public void UpdateCondtion(YieldBase condition)
        {
            switch (condition)
            {
            case WaitTime _:
                TimeoutForAction = ((WaitTime)condition).Milliseconds.ToString();
                break;

            case WaitRender _:
                TimeoutForAction = ((WaitRender)condition).HowManyRenderCountWait.ToString();
                break;

            case WaitFunction _:
                TimeoutForAction = "Function";
                break;
            }
            Condition = condition;
        }