예제 #1
0
    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);
        }
    }