Exemplo n.º 1
0
        protected override void LoadContent()
        {
            IO.Options op = new IO.Options()
            {
                AutoConnect = true
            };
            ws = IO.Socket("http://192.168.0.12:8081", op);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            font  = Content.Load <SpriteFont>("font/SourceCodePro48SB");
            point = createTexture(1, 1);

            corner_solid_ul = Content.Load <Texture2D>("corner_solid_ul");
            corner_solid_ur = Content.Load <Texture2D>("corner_solid_ur");
            corner_solid_dr = Content.Load <Texture2D>("corner_solid_dr");
            corner_solid_dl = Content.Load <Texture2D>("corner_solid_dl");

            corner_ul = Content.Load <Texture2D>("corner_ul");
            corner_ur = Content.Load <Texture2D>("corner_ur");
            corner_dr = Content.Load <Texture2D>("corner_dr");
            corner_dl = Content.Load <Texture2D>("corner_dl");

            stroke_ul = Content.Load <Texture2D>("stroke_ul");
            stroke_ur = Content.Load <Texture2D>("stroke_ur");
            stroke_dl = Content.Load <Texture2D>("stroke_dl");
            stroke_dr = Content.Load <Texture2D>("stroke_dr");

            icon_activity = Content.Load <Texture2D>("icon_activity");

            /*****************I'M GOING TO BUILD A WALL, AND MEXICO WILL PAY FOR IT*******************/
            #region Connection


            ws.On(Socket.EVENT_CONNECT, () => {
                output = "Connected";
                ScreenController.set(Screen.HOME);
            });

            ws.On("success", (data) => {
                System.Console.WriteLine("Data:" + data);
                if ((bool)data)
                {
                    output = "Registered!";
                    ScreenController.set(Screen.LOGIN);
                }
                else
                {
                    output = "Error en el Registro";
                }
            });

            ws.On("logged", (data) => {
                output = data.ToString();
                if ((bool)data)
                {
                    ScreenController.set(Screen.HALL);
                }
            });

            ws.On("profile", (data) => {
                var Json = data as JToken;

                //User.id = Json.Value<int>("id");
                User.name = Json.Value <string>("name");
                output    = "@" + User.name;
            });

            /*ws.On("text", (data) => {
             *
             *  var Json = data as JToken;
             *  output = "Loading Question";
             *
             *  ScreenController.setQuestion(
             *      Json.Value<string>("q"), Json.Value<string>("op1"),
             *      Json.Value<string>("op2"), Json.Value<string>("op3")
             *  );
             *
             *  ScreenController.set(Screen.GAME);
             * });*/

            ws.On("question", (data) => {
                var Jarray           = data as JArray;
                ScreenGame.questions = Jarray;

                output   = Jarray.Count.ToString();
                var Json = Jarray.First;

                ScreenController.setQuestion(
                    Json.Value <string>("q"), Json.Value <string>("op0"),
                    Json.Value <string>("op1"), Json.Value <string>("op2"),
                    Json.Value <string>("op3")
                    );

                ScreenController.set(Screen.GAME);
            });

            ws.On("finish", (data) => {
                ScreenController.set(Screen.FINISH);
            });

            #endregion
            /***************************************** THE WALL **************************************/
        }