示例#1
0
        public override void InitUI()
        {
            base.InitUI();

            Properties = new UIProperties(
                UIframework.UIManager.SceneUIs.LeaderBoardUI,
                UIframework.UIManager.DisplayUIMode.Normal,
                UIframework.UIManager.UITypes.AboveBlurEffect, true, true);

            // Store all the leaderborad list
            m_lists.Clear();
            foreach (var item in ListRoot.GetComponentsInChildren <LeaderBoradSingleList>())
            {
                item.Init();
                m_lists.Add(item);
            }

            // Get current room information form the server.
            Room currentRoom = PhotonNetwork.room;

            if (RoomProperties.ContantsKey(currentRoom, RoomProperties.MapIndex))
            {
                m_GameMap = GameMapManager.GetGameMap((int)currentRoom.customProperties[RoomProperties.MapIndex]).GameMapName;
            }

            if (RoomProperties.ContantsKey(currentRoom, RoomProperties.GameModeIndex))
            {
                m_GameMode = GameModeManager.GetGameModeDetail(
                    (int)currentRoom.customProperties[RoomProperties.GameModeIndex]).GameModeName.ToUpper();
            }

            if (RoomProperties.ContantsKey(currentRoom, RoomProperties.RoundTimeLimit))
            {
                m_TimeLimit = (int)currentRoom.customProperties[RoomProperties.RoundTimeLimit];
            }

            // Initialize the leader board header and the room info.
            UpdateHeaederText();
        }
示例#2
0
        /// <summary>
        /// Use this for initialization
        /// </summary>
        public override void InitUI()
        {
            base.InitUI();

            Properties = new UIProperties(
                UIframework.UIManager.SceneUIs.CreateRoomUI,
                UIframework.UIManager.DisplayUIMode.Normal,
                UIframework.UIManager.UITypes.UnderBlurEffect,
                false, true);

            #region Init variables
            // The user inserted room name.
            m_RoomName = "";

            // The user selected game map scene name.
            m_GameMapID = 0;

            // The user selected game mode.
            m_GameModeID = 0;

            // The maximun player count limit.
            m_PlayerLimit = 0;

            // The time limit pre round.
            m_TimeLimit = 0;

            // The health limit for every player pre life.
            m_HealthLimit = 0;
            #endregion

            #region Room name
            if (RoomNameInput)
            {
                RoomNameInput.onValueChanged.AddListener((Value) => SetRoomName(Value));
            }
            #endregion

            #region Map select
            if (MapSelect)
            {
                for (int index = 0; index < GameMapManager.GetMapCount; index++)
                {
                    MapSelect.options.Add(new Dropdown.OptionData()
                    {
                        text = GameMapManager.GetGameMap(index).GameMapName
                    });
                }

                // We need this step to refresh the options list.
                MapSelect.value = 1;
                MapSelect.value = 0;

                // Set default values.
                m_GameMapID = 0;
                SetMapPreview(0);

                // Add event listener to the drop down menu.
                MapSelect.onValueChanged.AddListener((value) => SetGameMap(value));
            }
            #endregion

            #region Player limit setting
            if (PlayerLimit)
            {
                for (int index = 0; index < CustomRoomOptions.AvaliablePlayerLimitOptions.Length; index++)
                {
                    PlayerLimit.options.Add(new Dropdown.OptionData()
                    {
                        text = CustomRoomOptions.AvaliablePlayerLimitOptions[index].ToString() + " 人"
                    });
                }

                // We need this step to refresh the options list.
                PlayerLimit.value = 1;
                PlayerLimit.value = 0;

                // Set default value.
                m_PlayerLimit = CustomRoomOptions.AvaliablePlayerLimitOptions[0];

                // Add event listener to the drop down menu.
                PlayerLimit.onValueChanged.AddListener((value) => SetPlayerLimit(value));
            }
            #endregion

            #region Game mode setting
            if (GameMode)
            {
                for (int index = 0; index < GameModeManager.GetGameModeCount; index++)
                {
                    GameMode.options.Add(new Dropdown.OptionData()
                    {
                        text = GameModeManager.GetGameModeDetail(index).GameModeName
                    });
                }

                // We need this step to refresh the options list.
                GameMode.value = 1;
                GameMode.value = 0;

                // Set default value.
                m_GameModeID = 0;

                // Add event listener to the drop down menu.
                GameMode.onValueChanged.AddListener((value) => SetGameMode(value));
            }
            #endregion

            #region Time limit setting
            if (TimeLimit)
            {
                for (int index = 0; index < CustomRoomOptions.AvaliableTimeLimitOptions.Length; index++)
                {
                    TimeLimit.options.Add(new Dropdown.OptionData()
                    {
                        text = CustomRoomOptions.AvaliableTimeLimitOptions[index].ToString() + " 分"
                    });
                }

                // We need this step to refresh the options list.
                TimeLimit.value = 1;
                TimeLimit.value = 0;

                // Set default value.
                m_TimeLimit = CustomRoomOptions.AvaliableTimeLimitOptions[0];

                // Add event listener to the drop down menu.
                TimeLimit.onValueChanged.AddListener((value) => SetTimeLimit(value));
            }
            #endregion

            #region Health limit setting
            if (HealthLimit)
            {
                for (int index = 0; index < CustomRoomOptions.AvaliableHealthLimitOptions.Length; index++)
                {
                    HealthLimit.options.Add(new Dropdown.OptionData()
                    {
                        text = CustomRoomOptions.AvaliableHealthLimitOptions[index].ToString() + " ポイント"
                    });
                }

                // We need this step to refresh the options list.
                HealthLimit.value = 1;
                HealthLimit.value = 0;

                // Set default value.
                m_HealthLimit = CustomRoomOptions.AvaliableHealthLimitOptions[0];

                // Add event listener to the drop down menu.
                HealthLimit.onValueChanged.AddListener((value) => SetHealthLimit(value));
            }
            #endregion

            #region Create room buttom
            if (CreateRoomButton)
            {
                CreateRoomButton.onClick.AddListener(delegate { OnClikedCreateRoomButton(); });
                CreateRoomButton.interactable = false;
                CreateRoomButton.GetComponentInChildren <Text>().text =
                    GameLanguageManager.GetText(GameLanguageManager.KeyWord.CreR_NeedAName, GameLanguageManager.CurrentLanguage);
            }
            #endregion

            SetLanguage(GameLanguageManager.CurrentLanguage);
        }
示例#3
0
        /// <summary>
        /// Update the room preview UI when user selceted a room detail.
        /// </summary>
        /// <param name="soruce">The selected room detail class.</param>
        /// <param name="args">All the information you need to know about the room details.</param>
        public void OnUpdateRoomPreview(int index, string roomName)
        {
            RoomInfo roomInfo = null;

            foreach (var item in PhotonNetwork.GetRoomList())
            {
                if (item.name.CompareTo(roomName) == 0)
                {
                    roomInfo = item;
                    break;
                }
            }
            if (roomInfo == null)
            {
#if UNITY_EDITOR
                Debug.Log("Can't find such room with room name: " + roomName + " in RoomPreview.");
#endif
                return;
            }

            SetLanguage(GameLanguageManager.CurrentLanguage);

            if (roomInfo.customProperties.ContainsKey(RoomProperties.MapIndex))
            {
                m_MapPreviewImage.sprite = GameMapManager.GetGameMap((int)roomInfo.customProperties[RoomProperties.MapIndex]).GameMapPreviewImage;
                m_MapNameText.text       = GameMapManager.GetGameMap((int)roomInfo.customProperties[RoomProperties.MapIndex]).GameMapName;
            }

            SelectedRoomName    = roomInfo.name;
            m_RoomNameText.text = SelectedRoomName;

            if (roomInfo.customProperties.ContainsKey(RoomProperties.RoomCreateDate))
            {
                RoomCreateDate = (double)roomInfo.customProperties[RoomProperties.RoomCreateDate];
            }

            if (roomInfo.customProperties.ContainsKey(RoomProperties.GameModeIndex))
            {
                GameModeManager.GameModeDetail detail = GameModeManager.GetGameModeDetail((int)roomInfo.customProperties[RoomProperties.GameModeIndex]);
                m_GameModeText.text = detail.GameModeName + "(" + detail.GameModeForShort + ")";
            }

            if (roomInfo.playerCount < roomInfo.maxPlayers)
            {
                m_PlayerCountText.text = roomInfo.playerCount + " / " + roomInfo.maxPlayers;
            }
            else
            {
                m_PlayerCountText.text = "< Color = red > " + roomInfo.playerCount + " / " + roomInfo.maxPlayers + " </ Color > ";
            }

            if (roomInfo.customProperties.ContainsKey(RoomProperties.HealthLimit))
            {
                m_HealthLimitText.text = ((int)roomInfo.customProperties[RoomProperties.HealthLimit]).ToString();
            }

            if (roomInfo.customProperties.ContainsKey(RoomProperties.RoundTimeLimit))
            {
                m_TimeLimitText.text = roomInfo.customProperties[RoomProperties.RoundTimeLimit].ToString() + " " + GameLanguageManager.TimeUnit;
            }

            m_ScoreLimitText.text = "N/A";



            if (roomInfo.playerCount == roomInfo.maxPlayers)
            {
                m_JoinRoomButton.interactable = false;
                m_JoinRoomButton.GetComponentInChildren <Text>().text = m_RoomFull;
            }
            else
            {
                m_JoinRoomButton.interactable = true;
                m_JoinRoomButton.GetComponentInChildren <Text>().text = m_Join;
            }
        }