Ejemplo n.º 1
0
    private IEnumerator RunBehaviors()
    {
        DoRandomNonFlyingAnimation();
        yield return(new WaitForSeconds(3));

        FaceRandomGroundDirection();

        float TimeRunning = 0;

        dragon.Run();
        while (true)
        {
            yield return(new WaitForEndOfFrame());

            transform.position += (transform.forward * RunSpeed * Time.deltaTime);

            TimeRunning += Time.deltaTime;
            if (TimeRunning > 2.3f) // time the animation takes
            {
                int WhatToDoNext = Random.Range(0, 20);
                if (WhatToDoNext <= 4)
                {
                    State = (DragonState)Random.Range(0, 5);
                    yield return(null);
                }
                else
                {
                    dragon.Run();
                    TimeRunning = 0;
                }
            }
        }
    }