private void ClearAction()
 {
     extender.ClearAction();
     foreach (GameObject go in ReplayBehavior.GetGameObjectsWithRAETag(ReplayBehavior.RAETag.Action))
     {
         GameObject.Destroy(go);
     }
 }
示例#2
0
    IEnumerator WaitForStop(StudentAction action)
    {
        List <GameObject> state = new List <GameObject>(ReplayBehavior.GetGameObjectsWithRAETag(ReplayBehavior.RAETag.State));

        state.AddRange(ReplayBehavior.GetGameObjectsWithRAETag(ReplayBehavior.RAETag.Action));
        Rigidbody rigidbody;
        float     callTime = Time.time;

        switch (stopCondition)
        {
        case StoppingCondition.Instant:
            break;

        case StoppingCondition.WaitForStop:
            bool allSleeping = false;
            while (!allSleeping)
            {
                allSleeping = true;
                if (Time.time - callTime > timeOut)
                {
                    break;
                }

                foreach (GameObject go in state)
                {
                    rigidbody = go.GetComponent <Rigidbody>();
                    if (go != null && rigidbody != null && rigidbody.IsSleeping())
                    {
                        allSleeping = false;
                        yield return(null);

                        break;
                    }
                }
            }
            break;

        case StoppingCondition.Time:
            while (Time.time - callTime < timeOut)
            {
                yield return(null);
            }
            break;

        case StoppingCondition.Custom:
            yield return(extender.StoppingCoroutine());

            break;
        }
        Stop(action);
    }