Beispiel #1
0
 IEnumerator SnakeWait()
 {
     while (sState == "wait")
     {
         RotationHandler.Allowed();
         if (RotationHandler.IsRotating())
         {
             UpdateState("grow");
             yield break;
         }
         yield return(null);
     }
 }
 IEnumerator LevelWait()
 {
     Debug.Log("Level State: Wait!\n");
     InputManager.Allowed();
     RotationHandler.Allowed();
     while (sLevelState == "wait")
     {
         if (RotationHandler.IsRotating())
         {
             UpdateLevelState("play");
             yield break;
         }
         yield return(null);
     }
 }
    IEnumerator LevelPlay()
    {
        InputManager.Allowed();
        WorldObjectManager.UpdateState("play");
        RotationHandler.Allowed();
        SnakeCollisionHandler.Allowed();
        Debug.Log("Level State: Play!\n");
        while (sLevelState == "play")
        {
            GameObject oCollision = SnakeCollisionHandler.CollisionObject();
            if (oCollision != null)
            {
                if (oCollision.tag == "Cube")
                {
                    sReason = "die_cube";
                    UpdateLevelState("die");
                    yield break;
                }
                else if (oCollision.tag == "SnakeBodyPart")
                {
                    sReason = "die_snake";
                    UpdateLevelState("die");
                    yield break;
                }
                else if (oCollision.tag == "Endpoint")
                {
                    UpdateLevelState("win");
                    yield break;
                }
                // }else if(oCollision.tag == "Obstacle"){
                //     oSnake.GetComponent<WorldObject_Snake>().UpdateState("decrease");
                //     oCollision.GetComponent<WorldObject_Obstacle>().UpdateState("into");

                //     GameObject currCollision = SnakeCollisionHandler.CollisionObject();

                //     while(oCollision == currCollision /*|| oCollision.GetComponent<WorldObject_Obstacle>().CurrentState()!="wait"*/){
                //         currCollision = SnakeCollisionHandler.CollisionObject();
                //         yield return null;
                //     }
                //     // Debug.Log("Leave the Obstacle!\n");
                // }
            }
            yield return(null);
        }
    }