示例#1
0
    // Update is called once per frame
    void Update()
    {
        if(m_controller.m_liveController != null)
            m_controller.m_liveController.ProcessController();

        if (Input.GetKey("p"))
        {
            BinaryMessage t_msg = new BinaryMessage();
            t_msg.Init(1024);
            GameMessageWriter t_writer = new GameMessageWriter();
            t_writer.InitAdapter(ref t_msg);
            t_writer.Encode_FunctionRequestLeaveGame();
            m_controller.m_liveController.QueueMessage(t_msg);
        }
    }
示例#2
0
    void OnGUI()
    {
        if(m_chatClientState == (int)ChatState.LOGON)
        {
            GUI.Box(new Rect(((Screen.width / 2) - 100), 200, 200, 108),
                     "Accts. disabled, enter any info.");
            GUI.Label(new Rect((Screen.width / 2) - 90, 225, 70, 20), "Username:"******"Password:"******"Login"))
            {
                loginButton = true;
            }
        }
        if (m_chatClientState == (int)ChatState.CHAT)
        {

            if (GUI.Button(new Rect(GetPercent(.785F, Screen.width),
                                    GetPercent(.857F, Screen.height),
                                    GetPercent(.205F, Screen.width),
                                    GetPercent(.07F, Screen.height)),
                           "Play Game"))
            {
                BinaryMessage t_msg = new BinaryMessage();
                t_msg.Init();
                GameMessageWriter t_writer = new GameMessageWriter();
                t_writer.InitAdapter(ref t_msg);
                t_writer.Encode_FunctionRequestGame();
                m_controller.m_liveController.QueueMessage(t_msg);
            }
            if (GUI.Button(new Rect(GetPercent(.785F, Screen.width),
                                   GetPercent(.928F, Screen.height),
                                   GetPercent(.205F, Screen.width),
                                   GetPercent(.07F, Screen.height)),
                          "Exit."))
            {

            }

            GUI.Box(new Rect(GetPercent(.015F, Screen.width),
                             GetPercent(.19F, Screen.height),
                             GetPercent(.749F, Screen.width),
                             GetPercent(.61F, Screen.height)), "");

            GUI.Box(new Rect(GetPercent(.785F, Screen.width),
                             GetPercent(.066F, Screen.height),
                             GetPercent(.2F, Screen.width),
                             GetPercent(.773F, Screen.height)), "");

            //GUI.Label(new Rect(GetPercent(.1F, Screen.width),
            //                   GetPercent(.02F, Screen.height),
            //                   300,
            //                   25), "Vesmar Entertainment - Chat Client Alpha");

            // Begin the ScrollView ----- ChatWindow
            int numChatMsg = m_currentRoom.GetChatWindowLen();
            float extraLines = (float)(((numChatMsg + 1) - 28) * 13.1F);
            if (numChatMsg < 28)
            {

                chatWindow = GUI.BeginScrollView(new Rect(GetPercent(.015F, Screen.width),
                                                          GetPercent(.19F, Screen.height),
                                                          GetPercent(.749F, Screen.width),
                                                          GetPercent(.61F, Screen.height))
                                                , chatWindow,
                                                new Rect(0,
                                                         0,
                                                         GetPercent(.55F, Screen.width),
                                                         GetPercent(.61F, Screen.height)));
                //, false, true);

                GUI.Label(new Rect(5,
                             0,
                             GetPercent(.72F, Screen.width),
                             GetPercent(.65F, Screen.height)),
                    //GetPercent(.8F, Screen.height)),
                    m_currentRoom.GetChatWindowString());
            }
            else
            {
                //Debug.Log(chatWindow);
                float size = GetPercent(.61F, Screen.height) + extraLines;
                //print(m_chatBarPriorFramePos.ToString() + System.Convert.ToInt32(chatWindow.y).ToString());
                //if (m_lastFrameNumChatLines != System.Convert.ToInt32(chatWindow.y))
                //{
                //    //Debug.Log("Oh noes");
                //}

                chatWindow = GUI.BeginScrollView(new Rect(GetPercent(.015F, Screen.width),
                                                          GetPercent(.19F, Screen.height),
                                                          GetPercent(.749F, Screen.width),
                                                          GetPercent(.6F, Screen.height))
                                                , chatWindow,
                                                new Rect(0,
                                                         0,
                                                         GetPercent(.55F, Screen.width),
                                                         GetPercent(.61F, Screen.height) + extraLines));
                if (GUI.changed && (numChatMsg == m_lastFrameNumChatLines))
                {
                    m_chatBarPinned = false;

                    if (extraLines - chatWindow.y <= 0.5)
                    {
                        m_chatBarPinned = true;
                    }
                    //print("Pls work");
                }

                if (m_chatBarPinned)
                {
                    chatWindow.y = GetPercent(.61F, Screen.height) + extraLines;
                }
                m_lastFrameNumChatLines = m_currentRoom.GetChatWindowLen();
                GUI.Label(new Rect(5,
                             0,
                             GetPercent(.72F, Screen.width),
                             5000),
                    //GetPercent(.8F, Screen.height)),
                    m_currentRoom.GetChatWindowString());
            }

            // Put something inside the ScrollView
            //innerText = m_currentRoom.GetChatWindowString();

            //innerText = "";
            // End the ScrollView
            GUI.EndScrollView();
            int numUsers = m_currentRoom.GetUserWindowLen();
            //int x = 50;
            float extraLines2 = (float)(((numUsers + 1) - 36) * 13.1F);
            if (numUsers < 36)
            {

                // Begin the ScrollView  -- UserWindow
                userWindow = GUI.BeginScrollView(new Rect(GetPercent(.79F, Screen.width),
                                                          GetPercent(.066F, Screen.height),
                                                          GetPercent(.198F, Screen.width),
                                                          GetPercent(.775F, Screen.height))
                                                , userWindow,
                                                 new Rect(0,
                                                          0,
                                                          GetPercent(.09F, Screen.width),
                                                          GetPercent(.775F, Screen.height)));//m_currentRoom.GetUserWindowLen())
                //,false, true);
                //string testString = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n";
                // Put something inside the ScrollView --- UserWindow
                //innerText = m_currentRoom.GetChatWindowString();
                GUI.Label(new Rect(0,
                                   0,
                                   GetPercent(.9F, Screen.width),
                                   GetPercent(.765F, Screen.height)),
                                   m_currentRoom.GetUserWindowString());
                //GetPercent(.8F, Screen.height)),
                //m_currentRoom.GetUserWindowString());
                //innerText = "";

            }
            else
            {
                userWindow = GUI.BeginScrollView(new Rect(GetPercent(.79F, Screen.width),
                                                         GetPercent(.066F, Screen.height),
                                                         GetPercent(.1955F, Screen.width),
                                                         GetPercent(.772F, Screen.height))
                                               , userWindow,
                                                new Rect(0,
                                                         0,
                                                         GetPercent(.09F, Screen.width),
                                                         GetPercent(.765F, Screen.height) + extraLines2));//m_currentRoom.GetUserWindowLen())
                //,false, true);
                //string testString = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n";
                // Put something inside the ScrollView --- UserWindow
                //innerText = m_currentRoom.GetChatWindowString();
                GUI.Label(new Rect(0,
                                   0,
                                   GetPercent(.9F, Screen.width),
                                   5000),
                                   //testString);
                                   m_currentRoom.GetUserWindowString());
            }
            // End the ScrollView
            GUI.EndScrollView();

            GUI.Box(new Rect(0,
                             GetPercent(.85F, Screen.height),
                             GetPercent(.78F, Screen.width),
                             GetPercent(.61F, Screen.height)), "$Banner Advertisement$");
            GUI.Label(new Rect(0, -3, Screen.width + 8, Screen.height + 9), GUITexture);

            textfield = GUI.TextField(new Rect(GetPercent(.115F, Screen.width),
                                               GetPercent(.807F, Screen.height),
                                               GetPercent(.649F, Screen.width),
                                               18)
                                   , textfield);

            if(GUI.Button(new Rect(GetPercent(.0155F, Screen.width),
                                GetPercent(.805F, Screen.height),
                                GetPercent(.096F, Screen.width),
                                19), "Send"))
            {
                sendButton = true;
            }

            GUI.Label(new Rect(GetPercent(.82F, Screen.width),
                               GetPercent(.008F, Screen.height),
                               300,
                               25), m_currentRoom.GetRoomName());

            m_currentRoom.UpdateChatWindows();
        }
    }
示例#3
0
    //Helper functions for the client class and interfacing into the GUI
    void KeyUpdater()
    {
        if (m_chatClientState == (int)ChatState.CHAT)
        {
            if ((Input.GetKey("enter") || sendButton || Input.GetKey("return")) && textfield != "")
            {
                //do something with textfieldstring here... send it off in chat message
                //ProcessChatMessage( textfield) ????
                m_currentRoom.AddMessageToChatWindow(ClientUser.m_username + ": " + textfield);
                BinaryMessage t_msg = new BinaryMessage();
                t_msg.Init();
                GameMessageWriter t_writer = new GameMessageWriter();
                t_writer.InitAdapter(ref t_msg);

                t_writer.Encode_FunctionUserChat(ref ClientUser.m_username, ref textfield,
                                                  ref ClientUser.m_id);

                m_controller.m_liveController.QueueMessage(t_msg);
                sendButton = false;

                textfield = "";
            }
        }
        else if( m_chatClientState == (int)ChatState.LOGON)
        {
            if ((Input.GetKey("enter") || loginButton || Input.GetKey("return")) && t_userName != "" && t_password != "")
            {
                BinaryMessage t_msg = new BinaryMessage();
                t_msg.Init();
                GameMessageWriter t_writer = new GameMessageWriter();
                t_writer.InitAdapter(ref t_msg);
                t_writer.Encode_FunctionUserLogin(ref t_userName, ref t_password);

                m_controller.m_liveController.QueueMessage(t_msg);

                m_chatClientState = (int)ChatState.CHAT;
            }
        }
    }