Esempio n. 1
0
    void OnGUI()
    {
        if (CreateResult != -1)
        {
            GUI.depth = 10;
            GUI.skin  = CreateRoomResultSkin;
            GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Background);

            if (GUI.Button(new Rect(Screen.width / 25, Screen.height / 25, Properties.BackButtonSize, Properties.BackButtonSize), Properties.BackButton))
            {
                gameObject.SetActive(false);
                CreateRoomMenu.Hide();
            }

            float offset = Screen.height / 10;
            GUI.DrawTexture(new Rect(Screen.width / 2 - LOGO_SIZE, offset, LOGO_SIZE * 2, LOGO_SIZE), Logo);

            offset += LOGO_SIZE + offset;

            float button_size = Screen.width / 3;
            switch (CreateResult)
            {
            case -2:

                GUI.Box(new Rect(Screen.width / 4, offset, Screen.width / 2, Properties.TEXT_HEIGHT * 2), LanguageManager.getString("WAIT"));

                break;

            case 5:

                GUI.Box(new Rect(Screen.width / 20, offset, Screen.width - Screen.width / 10, Properties.TEXT_HEIGHT * 4), LanguageManager.getString("ROOMCRTERR"));
                offset += Properties.TEXT_HEIGHT * 5;

                if (GUI.Button(new Rect(Screen.width / 2 - button_size / 2, offset, button_size, Properties.TEXT_HEIGHT * 2), LanguageManager.getString("REGAGAIN")))
                {
                    CreateResult = -1;
                    Hide();
                    CreateRoomMenu.Show();
                }

                break;
            }

            GUI.EndGroup();
        }
    }
Esempio n. 2
0
    void OnGUI()
    {
        GUI.depth = 0;
        GUI.skin  = RoomSelectionGUISkin;

        GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Background);

        if (GUI.Button(new Rect(Screen.width / 25, Screen.height / 25, Properties.BackButtonSize, Properties.BackButtonSize), Properties.BackButton))
        {
            Hide();
            WarpClient.GetInstance().Disconnect();
            LoginScreen.Show();
        }

        scrollPosition = GUI.BeginScrollView(scrollViewPosition, scrollPosition, scrollViewInnerPosition);

        float offsetX = roomBoxPosition.x;
        float offsetY = roomBoxPosition.y;

        for (int i = 0; i < ActiveRooms.Count; i++)
        {
            LiveRoomInfoEvent currentRoom = ActiveRooms[i];
            string[]          joinedUsers = currentRoom.getJoinedUsers();
            string            roomId      = currentRoom.getData().getId();
            object            type        = string.Empty;
            object            goal        = string.Empty;
            object            pw          = string.Empty;
            selectedRoomProperties = currentRoom.getProperties();
            selectedRoomProperties.TryGetValue("PW", out pw);
            if (selectedRoomProperties.TryGetValue("TYPE", out type) && selectedRoomProperties.TryGetValue("GOAL", out goal))
            {
                string playersText = string.Empty;

                for (int j = 0; j < 4; j++)
                {
                    if (j == 0 && joinedUsers != null)
                    {
                        playersText = joinedUsers[j];
                    }
                    else if (j == 0)
                    {
                        playersText = "-";
                    }
                    else if (joinedUsers != null && j < joinedUsers.Length)
                    {
                        playersText += "\n" + joinedUsers[j];
                    }
                    else
                    {
                        playersText += "\n-";
                    }
                }

                if (selectedRoomId == roomId)
                {
                    GUI.DrawTexture(new Rect(offsetX, offsetY, roomBoxPosition.width, roomBoxPosition.height), SelectedRoomBoxBackground);
                }
                else if (GUI.Button(new Rect(offsetX, offsetY, roomBoxPosition.width, roomBoxPosition.height), ""))
                {
                    selectedRoomId = roomId;
                    selectedRoomPw = pw == null ? null : pw.ToString();
                }
                GUI.BeginGroup(new Rect(offsetX, offsetY, roomBoxPosition.width, roomBoxPosition.height));
                DrawRoomBox(currentRoom.getData().getName(), type.ToString(), goal.ToString(), playersText, joinedUsers == null ? 0 : joinedUsers.Length, pw == null? null : pw.ToString());
                GUI.EndGroup();
                offsetX += offsetWidth / 2 + roomBoxPosition.width;
                if (i % 2 == 1)
                {
                    offsetY += offsetHeight + roomBoxPosition.height;
                    offsetX  = roomBoxPosition.x;
                }
            }
        }

        GUI.EndScrollView();

        if (GUI.Button(createRoomButtonPos, LanguageManager.getString("CRTROOM")))
        {
            Hide();
            CreateRoomMenu.Show();
        }

        if (!string.IsNullOrEmpty(selectedRoomId) && GUI.Button(joinRoomButtonPos, LanguageManager.getString("JOINROOM")))
        {
            if (selectedRoomPw != null && !string.IsNullOrEmpty(selectedRoomPw.ToString()))
            {
                PasswordEnterMenu.Show(selectedRoomPw.ToString(), selectedRoomId);
                Hide();
            }
            else
            {
                StartCoroutine(JoinRoom(selectedRoomId));
            }
        }

        if (GUI.Button(renewButtonPos, LanguageManager.getString("RENEW")))
        {
            Renew();
        }
    }