Beispiel #1
0
        public virtual void OpenMenu(IUserInterface userInterface, MenuArgs args)
        {
            m_userInterface = userInterface;

            if (m_experienceMachine.CurrentExperience == ExperienceType.HOME && m_standaloneMenu != null)
            {
                m_standaloneMenu.SetActive(false);
            }
            m_menuItems.Clear();
            Blocked    = args.Block;
            Persist    = args.Persist;
            m_onAction = args.OnAction;
            gameObject.SetActive(true);

            Populate(args.Items);

            if (m_uiEngine == null)
            {
                m_uiEngine = IOCCore.Resolve <IUIEngine>();
            }

            if (m_okButton != null)
            {
                m_okButton.onClick.AddListener(() => m_uiEngine.CloseLastScreen());
            }
            if (m_closeButton != null)
            {
                m_closeButton.onClick.AddListener(() => m_uiEngine.CloseLastScreen());
            }
        }
Beispiel #2
0
        private void OnContextItemClick(MenuClickArgs arg0)
        {
            var    targetPlayerId = (int)arg0.Data;
            var    targetPlayer   = Array.Find(PhotonNetwork.PlayerList, item => item.ActorNumber == targetPlayerId);
            object userId         = null;

            if (targetPlayer != null)
            {
                var customProperties = targetPlayer.CustomProperties;
                if (customProperties != null)
                {
                    customProperties.TryGetValue(Network.UserIdKey, out userId);
                }
            }

            if (arg0.CommandType == MenuCommandType.SEND_FRIEND_REQUEST)
            {
                m_webInterface.SendFriendRequest((string)userId, (error, message) =>
                {
                    var jsonObject = JsonMapper.ToObject(message);
                    var success    = !error && Convert.ToString(jsonObject["success"]) == "true";
                    if (success)
                    {
                        m_photonView.RPC("RPC_Request", targetPlayer, PhotonNetwork.LocalPlayer.ActorNumber, (int)arg0.CommandType);
                        m_uiEngine.CloseLastScreen();
                    }
                });
            }
            else
            {
                m_uiEngine.CloseLastScreen();

                if (arg0.CommandType == MenuCommandType.OTHER)
                {
                    return;
                }
                m_photonView.RPC("RPC_Request", targetPlayer, PhotonNetwork.LocalPlayer.ActorNumber, (int)arg0.CommandType);
            }
        }
Beispiel #3
0
        public void Show(PopupInfo popupInfo)
        {
            m_info        = popupInfo;
            m_onPopupClck = popupInfo.Action;
            gameObject.SetActive(true);
            m_action = popupInfo.Action;

            Blocked = popupInfo.Block;
            Persist = popupInfo.Persist;

            if (m_title != null && !string.IsNullOrEmpty(popupInfo.Title))
            {
                m_title.text = popupInfo.Title;
            }
            else if (m_title != null)
            {
                m_title.text = "";
            }

            if (!string.IsNullOrEmpty((string)popupInfo.Content))
            {
                m_text.text = (string)popupInfo.Content;
            }
            else
            {
                m_text.text = "";
            }
            if (popupInfo.Preview != null)
            {
                m_icon.sprite = popupInfo.Preview;
                m_icon.transform.parent.gameObject.SetActive(true);
            }
            else if (m_icon != null)
            {
                m_icon.transform.parent.gameObject.SetActive(false);
            }
            if (m_okButton != null)
            {
                m_okButton.onClick.AddListener(() =>
                {
                    m_selectedAction = PopupInfo.PopupAction.ACCEPT;
                    m_uiEngine.CloseLastScreen();
                });
            }
            if (m_closeButton != null)
            {
                m_closeButton.onClick.AddListener(() =>
                {
                    m_selectedAction = PopupInfo.PopupAction.CANCEL;
                    m_uiEngine.CloseLastScreen();
                });
            }
            if (m_info.TimeInSeconds.HasValue)
            {
                Observable.Timer(new TimeSpan(0, 0, m_info.TimeInSeconds.Value)).Subscribe(_ =>
                {
                    if (this != null && this.gameObject != null)
                    {
                        m_uiEngine.CloseLastScreen();
                    }
                });
            }
        }