Esempio n. 1
0
 protected override void OnModelCreating(ModelBuilder builder)
 {
     UserMap.Configure(builder);
     PersonMap.Configure(builder);
     PersonCheckListItemMap.Configure(builder);
     PersonCheckListMap.Configure(builder);
     QuizMap.Configure(builder);
     QuestionMap.Configure(builder);
     AnswerMap.Configure(builder);
     TopicCategoryMap.Configure(builder);
     TopicMap.Configure(builder);
     SupportingScriptureMap.Configure(builder);
     PersonAnswerMap.Configure(builder);
 }
Esempio n. 2
0
    public void OnSocket()
    {
        #region DEFAULT ON
        socketIO.On("open", (SocketIOEvent ev) =>
        {
            Debug.Log("conectou " + ev.data);
        });

        socketIO.On("close", (SocketIOEvent ev) =>
        {
            Debug.Log("Disconnected.");
        });

        socketIO.On("error", (SocketIOEvent ev) =>
        {
            Debug.Log("error" + ev.data);
        });

        #endregion

        socketIO.On("pergunta", (SocketIOEvent ev) =>
        {
            Debug.Log("PERGUNTA");

            QuestionMap map = Mapper.MapCreate <QuestionMap>(ev.data.ToString(), new QuestionMap());
            Dictionary <string, string> dir = new Dictionary <string, string>()
            {
                { "estado", "pergunta" },
                { "time", TeamsController.Instance.myTeam.teamName }
            };
            SockeEmitEstado(dir);

            #region MAP
            List <Alternative> alt = new List <Alternative>();
            Debug.Log(map.alternativas.Count);
            for (int i = 0; i < map.alternativas.Count; i++)
            {
                Alternative newAlt = new Alternative();
                newAlt.atributo1   = new Attribute()
                {
                    score = map.alternativas[i].atributo1, attributeName = "FORÇA"
                };
                newAlt.atributo2 = new Attribute()
                {
                    score = map.alternativas[i].atributo2, attributeName = "SAÚDE"
                };
                newAlt.atributo3 = new Attribute()
                {
                    score = map.alternativas[i].atributo3, attributeName = "HEMAN"
                };
                newAlt.atributo4 = new Attribute()
                {
                    score = map.alternativas[i].atributo4, attributeName = "EU"
                };
                newAlt.atributo5 = new Attribute()
                {
                    score = map.alternativas[i].atributo5, attributeName = "TENHO"
                };
                newAlt.texto = map.alternativas[i].texto;
                alt.Add(newAlt);
            }

            Question question = new Question()
            {
                titulo       = map.titulo,
                id           = map.id,
                alternativas = alt
            };

            #endregion

            GameManager.Instance.ReceiverAnswer(question);
            GameManager.Instance.GameStart();
            Pagination.Instance.OpenPage(2);
        });

        socketIO.On("resposta", (SocketIOEvent ev) =>
        {
            Debug.Log("RESPOSTA");
            Dictionary <string, string> dir = new Dictionary <string, string>()
            {
                { "estado", "resposta" },
                { "time", TeamsController.Instance.myTeam.teamName }
            };
            SockeEmitEstado(dir);
            GameManager.Instance.RespostaActive();
        });

        socketIO.On("home", (SocketIOEvent ev) =>
        {
            Debug.Log("HOME");
            Dictionary <string, string> dir = new Dictionary <string, string>()
            {
                { "estado", "home" },
                { "time", TeamsController.Instance.myTeam.teamName }
            };
            SockeEmitEstado(dir);

            Pagination.Instance.OpenPage(1);
        });

        socketIO.On("tela-instrucoes", (SocketIOEvent ev) =>
        {
            Debug.Log("INSTRUCOES");
            Dictionary <string, string> dir = new Dictionary <string, string>()
            {
                { "estado", "tela-instrucoes" },
                { "time", TeamsController.Instance.myTeam.teamName }
            };
            SockeEmitEstado(dir);

            Pagination.Instance.OpenPage(4);
        });

        socketIO.On("ranking", (SocketIOEvent ev) =>
        {
            Debug.Log("RANKING");
            Dictionary <string, string> dir = new Dictionary <string, string>()
            {
                { "estado", "ranking" },
                { "time", TeamsController.Instance.myTeam.teamName }
            };
            SockeEmitEstado(dir);

            GameRequest.Instance.LoadTeamPostion();
            Pagination.Instance.OpenPage(5);
        });

        socketIO.On("pontos", (SocketIOEvent ev) =>
        {
            Debug.Log("PONTOS");
            Dictionary <string, string> dir = new Dictionary <string, string>()
            {
                { "estado", "pontos" },
                { "time", TeamsController.Instance.myTeam.teamName }
            };
            SockeEmitEstado(dir);
            GameManager.Instance.ViewPontos();
        });

        socketIO.On("tempo", (SocketIOEvent ev) =>
        {
            Debug.Log("TEMPO");
            string temp = JsonConvert.DeserializeObject <string>(ev.data.ToString());
            Debug.Log(temp);
            GameManager.Instance.UpdateTime(temp);
        });
    }
    public void OnSocket()
    {
        #region DEFAULT ON
        socketIO.On("open", (SocketIOEvent ev) =>
        {
            Debug.Log("conectou " + ev.data);
        });

        socketIO.On("close", (SocketIOEvent ev) =>
        {
            Debug.Log("Disconnected.");
        });

        socketIO.On("error", (SocketIOEvent ev) =>
        {
            Debug.Log("error" + ev.data);
        });

        #endregion

        socketIO.On("pergunta", (SocketIOEvent ev) =>
        {
            Debug.Log("PERGUNTA");

            QuestionMap map = Mapper.MapCreate <QuestionMap>(ev.data.ToString(), new QuestionMap());

            #region MAP
            List <Alternative> alt = new List <Alternative>();
            for (int i = 0; i < map.alternativas.Count; i++)
            {
                Alternative newAlt = new Alternative();
                newAlt.atributo1   = new Attribute()
                {
                    score = map.alternativas[i].atributo1, attributeName = "FORÇA"
                };
                newAlt.atributo2 = new Attribute()
                {
                    score = map.alternativas[i].atributo2, attributeName = "SAÚDE"
                };
                newAlt.atributo3 = new Attribute()
                {
                    score = map.alternativas[i].atributo3, attributeName = "HEMAN"
                };
                newAlt.atributo4 = new Attribute()
                {
                    score = map.alternativas[i].atributo4, attributeName = "EU"
                };
                newAlt.atributo5 = new Attribute()
                {
                    score = map.alternativas[i].atributo5, attributeName = "TENHO"
                };
                newAlt.texto = map.alternativas[i].texto;
                alt.Add(newAlt);
            }

            Question question = new Question()
            {
                titulo       = map.titulo,
                id           = map.id,
                alternativas = alt
            };

            #endregion

            ScreenGameManager.Instance.ReceiverAnswer(question);
            ScreenGameManager.Instance.GameStart();
            Pagination.Instance.OpenPage(1);
        });

        socketIO.On("home", (SocketIOEvent ev) =>
        {
            Debug.Log("HOME");
            Pagination.Instance.OpenPage(0);
        });

        socketIO.On("ranking", (SocketIOEvent ev) =>
        {
            Debug.Log("RANKING");

            ScreenGameRequest.Instance.LoadTeamsPositions();
            Pagination.Instance.OpenPage(2);
        });

        socketIO.On("media", (SocketIOEvent ev) =>
        {
            Debug.Log("Media");

            //var data = JsonConvert.DeserializeObject<string>(ev.data.ToString());

            ScreenGameRequest.Instance.LoadMedias(ev.data.ToString().Substring(1, ev.data.ToString().Length - 2));
            Pagination.Instance.OpenPage(3);
        });

        socketIO.On("tempo", (SocketIOEvent ev) =>
        {
            Debug.Log("TEMPO");
            string temp = JsonConvert.DeserializeObject <string>(ev.data.ToString());
            ScreenGameManager.Instance.UpdateTime(temp);
        });

        socketIO.On("tela-instrucoes", (SocketIOEvent ev) =>
        {
            Debug.Log("INSTRUCOES");

            Pagination.Instance.OpenPage(4);
        });
    }