Esempio n. 1
0
    void Awake()
    {
        TinyCoro.SpawnNext(DoPreform);
        var cameraRotate = new UnityObject(GameObject.Find("CameraRotate"));

        cameraRotate.UnityUpdate += u => u.Transform.Rotate(Vector3.up, -2f * Time.deltaTime);


        var guiRect = new Rect(0, 0, Screen.width, Screen.height);

        cameraRotate.UnityGUI += (u) =>
        {
            var guiText = string.Format("Generation: {0}\nBest Score: {1} (distance + head height + waist height, in gen: {2})\nv0.4 running for {3}",
                                        Generation,
                                        TopScore,
                                        TopScoreGen,
                                        TimeSpan.FromSeconds(Time.timeSinceLevelLoad));
            if (_configLines != null)
            {
                guiText += "\n" + string.Join("\n", _configLines);
            }

            GUI.Label(guiRect, guiText);
        };
    }
Esempio n. 2
0
    private static IEnumerator PreformThreadedOperation(Action threadedOperation)
    {
        var thread = new Thread(new ThreadStart(threadedOperation));

        thread.Start();

        yield return(TinyCoro.WaitUntil(() => !thread.IsAlive));
    }
Esempio n. 3
0
    /// <summary>
    /// Adds an new TinyCoro to the pool after the currently exceutiny one (or last if none are running) 
    /// </summary>
    /// <param name="threadedOperation"></param>
    /// <returns></returns>
    public static TinyCoro SpawnNext(Func<IEnumerator> operation, string name = null)
    {
        var coro = new TinyCoro(operation);
        coro.Name = name;
        var index = _allCoros.Count;
        if (Current != null)
            index = _allCoros.IndexOf(Current) + 1;
        _allCoros.Insert(index, coro);

        Debug.Log(coro + " created at index " + index);
        return coro;
    }
Esempio n. 4
0
    /// <summary>
    /// Adds an new TinyCoro to the pool after the currently exceutiny one (or last if none are running)
    /// </summary>
    /// <param name="threadedOperation"></param>
    /// <returns></returns>
    public static TinyCoro SpawnNext(Func <IEnumerator> operation, string name = null)
    {
        var coro = new TinyCoro(operation);

        coro.Name = name;
        var index = _allCoros.Count;

        if (Current != null)
        {
            index = _allCoros.IndexOf(Current) + 1;
        }
        _allCoros.Insert(index, coro);

        Debug.Log(coro + " created at index " + index);
        return(coro);
    }
Esempio n. 5
0
 public static void StepAllCoros()
 {
     for (int i = 0; i < _allCoros.Count; )
     {
         //Step normal
         Current = _allCoros[i];
         if (Current.Alive)
             Current.Step();
         if (!Current.Alive)
         {
             _allCoros.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
     Current = null;
 }
Esempio n. 6
0
 public static void StepAllCoros()
 {
     for (int i = 0; i < _allCoros.Count;)
     {
         //Step normal
         Current = _allCoros[i];
         if (Current.Alive)
         {
             Current.Step();
         }
         if (!Current.Alive)
         {
             _allCoros.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
     Current = null;
 }
Esempio n. 7
0
 void Update()
 {
     TinyCoro.StepAllCoros();
 }
Esempio n. 8
0
 public static TinyCoro SpawnAfter(Action threadedOperation)
 {
     return(TinyCoro.SpawnNext(() => PreformThreadedOperation(threadedOperation)));
 }