コード例 #1
0
 private void Start()
 {
     m_isKeyboardAndMouse = m_input.IsKeyboardAndMouse(m_localPlayerIndex);
     if (m_gameView != null)
     {
         if (m_gameView.IsInitialized)
         {
             m_cameraController = m_gameView.GetCameraController(m_localPlayerIndex);
         }
         else
         {
             m_gameView.Initialized += OnGameViewInitialized;
         }
     }
 }
コード例 #2
0
        private void UpdateIsOpenedState()
        {
            bool isOpened = m_settingsPanel.IsOpened || m_resultsPanel.IsOpened || m_menuPanel.IsOpened || m_consolePanel.IsOpened;

            if (!isOpened)
            {
                m_eventSystem.SetSelectedGameObjectOnLateUpdate(null);
                m_virtualMouse.RestoreVirtualMouse();
            }
            else
            {
                m_virtualMouse.BackupVirtualMouse();
                m_virtualMouse.IsVirtualMouseEnabled       = m_inputManager.IsKeyboardAndMouse(m_localPlayerIndex);
                m_virtualMouse.IsVirtualMouseCursorVisible = m_inputManager.IsKeyboardAndMouse(m_localPlayerIndex);
            }

            m_gameState.IsMenuOpened(LocalPlayerIndex, isOpened);
        }
コード例 #3
0
 private void AddListeners(Selectable selectable)
 {
     AddListener(selectable, EventTriggerType.Select, OnSelect);
     AddListener(selectable, EventTriggerType.Deselect, OnDeselect);
     if (m_inputManager.IsKeyboardAndMouse(LocalPlayerIndex))
     {
         AddListener(selectable, EventTriggerType.PointerEnter, OnPointerEnter);
         AddListener(selectable, EventTriggerType.PointerExit, OnPointerExit);
     }
 }
コード例 #4
0
        protected override void Start()
        {
            base.Start();

            GameViewport parentViewport = GetComponentInParent <GameViewport>();

            InputFieldWithVirtualKeyboard ifwk = m_inputField.GetComponent <InputFieldWithVirtualKeyboard>();

            ifwk.VirtualKeyboardEnabled = !m_inputManager.IsKeyboardAndMouse(parentViewport.LocalPlayerIndex);
        }
コード例 #5
0
        private void Start()
        {
            LocalPlayerIndex   = m_viewport.LocalPlayerIndex;
            m_cameraController = Dependencies.GameView.GetCameraController(LocalPlayerIndex);

            if (m_inputManager.IsKeyboardAndMouse(LocalPlayerIndex))
            {
                m_boxSelector            = Dependencies.GameView.GetBoxSelector(LocalPlayerIndex);
                m_boxSelector.Filtering += OnBoxSelectionFiltering;
                m_boxSelector.Selected  += OnBoxSelection;
            }
        }
コード例 #6
0
        protected override void Start()
        {
            var nav = m_selectableMinimap.navigation;

            nav.mode = m_input.IsKeyboardAndMouse(m_viewport.LocalPlayerIndex) ? UnityEngine.UI.Navigation.Mode.None : UnityEngine.UI.Navigation.Mode.Explicit;
            m_selectableMinimap.navigation = nav;

            m_eventSystem      = Dependencies.EventSystemManager.GetEventSystem(m_viewport.LocalPlayerIndex);
            m_cameraController = Dependencies.GameView.GetCameraController(m_viewport.LocalPlayerIndex);
            m_camCtrlSettings  = Dependencies.Settings.PlayerCamCtrl[m_viewport.LocalPlayerIndex];

            if (m_minimap.IsLoaded)
            {
                OnMinimapTextureChanged(this, EventArgs.Empty);
            }
            m_minimap.TextureChanged += OnMinimapTextureChanged;

            base.Start();
            StartCoroutine(Fit());
            UpdateVisibility();
        }
コード例 #7
0
        private void Update()
        {
            m_playersBot.Update(Time.realtimeSinceStartup);

            if (m_gameState.IsActionsMenuOpened(LocalPlayerIndex))
            {
                return;
            }

            if (m_gameState.IsContextActionInProgress(LocalPlayerIndex))
            {
                return;
            }

            if (m_gameState.IsMenuOpened(LocalPlayerIndex))
            {
                return;
            }

            if (m_gameState.IsPaused || m_gameState.IsPauseStateChanging)
            {
                return;
            }

            if (m_inputManager.GetButtonDown(InputAction.A, LocalPlayerIndex) || m_inputManager.GetButtonDown(InputAction.RMB, LocalPlayerIndex))
            {
                m_wasAButtonDown = true;

                CreateMovementCmd(false, cmd =>
                {
                    if (cmd != null && cmd.Count > 0)
                    {
                        MovementCmd movementCmd = (MovementCmd)cmd[0];

                        if (!m_inputManager.IsKeyboardAndMouse(LocalPlayerIndex))
                        {
                            m_cameraController.SetVirtualMousePosition(movementCmd.Coordinates.Last(), true, true);
                        }
                    }
                });
            }
            else if (m_inputManager.GetButtonUp(InputAction.A, LocalPlayerIndex) || m_inputManager.GetButtonUp(InputAction.RMB, LocalPlayerIndex))
            {
                if (m_wasAButtonDown)
                {
                    CreateMovementCmd(false, cmd =>
                    {
                        if (cmd != null && cmd.Count > 0)
                        {
                            MovementCmd movementCmd = (MovementCmd)cmd[0];
                            if (!m_inputManager.IsKeyboardAndMouse(LocalPlayerIndex))
                            {
                                m_cameraController.SetVirtualMousePosition(movementCmd.Coordinates.Last(), true, true);
                            }
                            SubmitToEngine(m_gameState.LocalToPlayerIndex(LocalPlayerIndex), cmd);
                        }
                    });
                    m_wasAButtonDown = false;
                }
            }
            else if (m_inputManager.GetButtonDown(InputAction.B, LocalPlayerIndex, false, false))
            {
                OnCancel();
            }
            else if (m_inputManager.GetButtonDown(InputAction.Y, LocalPlayerIndex, false, false))
            {
                m_commandsPanel.IsOpen = true;
            }
        }
コード例 #8
0
        private void GetPlayers()
        {
            m_progress.IsVisible = true;

            m_readyToGo = 0;

            for (int i = 0; i < m_playerMenu.Length; ++i)
            {
                m_playerMenu[i].LocalPlayerIndex = i;
            }

            for (int i = 0; i < m_playerMenu.Length; ++i)
            {
                m_playerMenu[i].Player = null;
            }

            IGameServer gameServer = Dependencies.GameServer;

            gameServer.GetPlayers(m_gSettings.ClientId, (error, players) =>
            {
                if (gameServer.HasError(error))
                {
                    m_progress.IsVisible = false;
                    m_notification.ShowError(error);
                    return;
                }

                HandleDevicesChange();

                int playersCount = Mathf.Min(m_inputManager.DeviceCount, players.Length);
                for (int i = 0; i < playersCount; ++i)
                {
                    m_playerMenu[i].Player = players[i];
                }

                for (int i = 0; i < m_inputManager.DeviceCount; ++i)
                {
                    m_playerMenu[i].IsVirtualKeyboardEnabled = !m_inputManager.IsKeyboardAndMouse(i);
                }

                if (m_inputManager.DeviceCount < players.Length)
                {
                    List <Guid> logoffPlayers = new List <Guid>();
                    for (int i = m_inputManager.DeviceCount; i < players.Length; ++i)
                    {
                        logoffPlayers.Add(players[i].Id);
                    }

                    gameServer.Logoff(m_gSettings.ClientId, logoffPlayers.ToArray(), (error2, playerIds) =>
                    {
                        m_progress.IsVisible = false;
                        if (gameServer.HasError(error2))
                        {
                            m_notification.ShowError(error2);
                            return;
                        }
                    });
                }
                else
                {
                    m_progress.IsVisible = false;
                }

                for (int i = players.Length; i < m_inputManager.DeviceCount; ++i)
                {
                    m_playerMenu[i].TryAutoLogin();
                }
            });
        }