示例#1
0
        protected override void Start()
        {
            base.Start();

            m_OkButton.onClick.AddListener(OnOkClicked);
            m_CancelButton.onClick.AddListener(CloseWindow);

            m_LoggerWindow      = Instantiate(OpenTibiaUnity.GameManager.PopupWindowPrefab, transform.parent);
            m_LoggerWindow.name = "PopupWindow_CharactersWindow";
            m_LoggerWindow.gameObject.SetActive(false);
            m_LoggerWindow.PopupType = PopupMenuType.Cancel;

            m_LoggerWindow.OnClickCancel.AddListener(() => {
                m_LoggerWindow.gameObject.SetActive(false);
                if (!!OpenTibiaUnity.ProtocolGame && OpenTibiaUnity.ProtocolGame.IsConnected)
                {
                    OpenTibiaUnity.ProtocolGame.Disconnect();
                    OpenTibiaUnity.ProtocolGame.onDisconnect.AddListener(() => {
                        gameObject.SetActive(true);
                        EventSystem.current.SetSelectedGameObject(gameObject);
                    });
                }
                else
                {
                    gameObject.SetActive(true);
                    EventSystem.current.SetSelectedGameObject(gameObject);
                }
            });

            OpenTibiaUnity.InputHandler.AddKeyUpListener((Event e, bool repeat) => {
                if (!InputHandler.IsHighlighted(this))
                {
                    return;
                }

                switch (e.keyCode)
                {
                case KeyCode.Return:
                case KeyCode.KeypadEnter:
                    OnOkClicked();
                    break;

                case KeyCode.Escape:
                    CloseWindow();
                    break;

                case KeyCode.UpArrow:
                case KeyCode.DownArrow:
                    m_LastReaction = OpenTibiaUnity.TicksMillis;
                    break;
                }
            });
        }
示例#2
0
        protected override void Start()
        {
            base.Start();

            // setup input
            OpenTibiaUnity.InputHandler.AddKeyDownListener(Core.Utils.EventImplPriority.High, OnKeyDown);
            OpenTibiaUnity.InputHandler.AddKeyUpListener(Core.Utils.EventImplPriority.High, OnKeyUp);

            // setup events
            _oKButton.onClick.AddListener(OnOkButtonClick);
            _cancelButton.onClick.AddListener(OnCancelButtonClick);
            _getPremiumLegacyButton.onClick.AddListener(OnGetPremiumButtonClicked);
            _getPremiumV12Button.onClick.AddListener(OnGetPremiumButtonClicked);

            // setup popup message
            _popupWindow      = Instantiate(OpenTibiaUnity.GameManager.PopupWindowPrefab, transform.parent);
            _popupWindow.name = "PopupWindow_CharactersWindow";
            _popupWindow.Hide();

            _popupWindow.onOKClick.AddListener(OnPopupOkClick);
            _popupWindow.onCancelClick.AddListener(OnPopupCancelClick);

            // setup game events
            OpenTibiaUnity.GameManager.onGameStart.AddListener(OnGameStart);
            OpenTibiaUnity.GameManager.onProcessChangeCharacter.AddListener(OnProcessChangeCharacter);
            OpenTibiaUnity.GameManager.onGameEnd.AddListener(OnGameEnd);

            // select first character
            if (OpenTibiaUnity.GameManager.ClientVersion < 1200)
            {
                OpenTibiaUnity.GameManager.InvokeOnMainThread(() => SelectFirstCharacter());
            }
            else
            {
                UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(gameObject);
            }

            // layout update based on client version
            ForceClientVersionUpdate();
        }