private void UpdateState() { int playerIndex = m_gameState.LocalToPlayerIndex(LocalPlayerIndex); long[] selection = m_selection.GetSelection(playerIndex, playerIndex); if (selection.Length == 0) { IsOpen = false; return; } for (int i = 0; i < m_buttons.Length; ++i) { m_buttons[i].gameObject.SetActive(selection.Length > 0); if (i != 12) { HUDControlBehavior hcb = m_buttons[i].GetComponent <HUDControlBehavior>(); hcb.IsDisabled = true; } } if (m_eventSystem.currentSelectedGameObject != null && m_eventSystem.currentSelectedGameObject.GetComponent <HUDControlBehavior>().IsDisabled) { m_eventSystem.SetSelectedGameObjectOnLateUpdate(m_buttons[0].gameObject); } }
protected virtual void SelectDefault() { if (m_sequence.Length > 0) { m_eventSystem.SetSelectedGameObjectOnLateUpdate(m_sequence[0].gameObject); m_sequence[0].OnSelect(null); } }
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); }
private void UpdateState() { int playerIndex = m_gameState.LocalToPlayerIndex(LocalPlayerIndex); long[] selection = m_selection.GetSelection(playerIndex, playerIndex); if (selection.Length == 0) { IsOpen = false; return; } m_cancelBtn.gameObject.SetActive(selection.Length > 0); m_attackBtn.gameObject.SetActive(selection.Length > 0); m_moveBtn.gameObject.SetActive(selection.Length > 0); m_autoBtn.gameObject.SetActive(selection.Length > 0); m_bombBtn.gameObject.SetActive(false); m_wallBtn.gameObject.SetActive(false); m_spawnButton.gameObject.SetActive(false); m_growButton.gameObject.SetActive(false); m_diminishButton.gameObject.SetActive(false); m_splitButton.gameObject.SetActive(false); m_split4Button.gameObject.SetActive(false); HUDControlBehavior hcbBomb = m_bombBtn.GetComponent <HUDControlBehavior>(); HUDControlBehavior hcbWall = m_wallBtn.GetComponent <HUDControlBehavior>(); HUDControlBehavior hcbSpawn = m_spawnButton.GetComponent <HUDControlBehavior>(); HUDControlBehavior hcbGrow = m_growButton.GetComponent <HUDControlBehavior>(); HUDControlBehavior hcbDiminish = m_diminishButton.GetComponent <HUDControlBehavior>(); HUDControlBehavior hcbSplit = m_splitButton.GetComponent <HUDControlBehavior>(); HUDControlBehavior hcbSplit4 = m_split4Button.GetComponent <HUDControlBehavior>(); hcbBomb.IsDisabled = true; hcbWall.IsDisabled = true; hcbSpawn.IsDisabled = true; hcbGrow.IsDisabled = true; hcbDiminish.IsDisabled = true; hcbSplit.IsDisabled = true; hcbSplit4.IsDisabled = true; for (int i = 0; i < selection.Length; ++i) { IVoxelDataController dc = m_gameState.GetVoxelDataController(playerIndex, selection[i]); if (dc != null) { CmdResultCode canBomb = dc.CanConvertImmediate((int)KnownVoxelTypes.Bomb); if (canBomb != CmdResultCode.Fail_NotSupported) { m_bombBtn.gameObject.SetActive(true); if (canBomb == CmdResultCode.Success) { hcbBomb.IsDisabled = false; } } CmdResultCode canGround = dc.CanConvertImmediate((int)KnownVoxelTypes.Ground); if (canGround != CmdResultCode.Fail_NotSupported) { m_wallBtn.gameObject.SetActive(true); if (canGround == CmdResultCode.Success) { hcbWall.IsDisabled = false; } } CmdResultCode canSpawner = dc.CanConvertImmediate((int)KnownVoxelTypes.Spawner); if (canSpawner != CmdResultCode.Fail_NotSupported) { m_spawnButton.gameObject.SetActive(true); if (canSpawner == CmdResultCode.Success) { hcbSpawn.IsDisabled = false; } } CmdResultCode canGrow = dc.CanGrowImmediate(); if (canGrow != CmdResultCode.Fail_NotSupported) { m_growButton.gameObject.SetActive(true); if (canGrow == CmdResultCode.Success) { hcbGrow.IsDisabled = false; } } CmdResultCode canDiminish = dc.CanDiminishImmediate(); if (canDiminish != CmdResultCode.Fail_NotSupported) { m_diminishButton.gameObject.SetActive(true); if (canDiminish == CmdResultCode.Success) { hcbDiminish.IsDisabled = false; } } CmdResultCode canSplit = dc.CanSplitImmediate(); if (canSplit != CmdResultCode.Fail_NotSupported) { m_splitButton.gameObject.SetActive(true); if (canSplit == CmdResultCode.Success) { hcbSplit.IsDisabled = false; } } CmdResultCode canSplit4 = dc.CanSplit4Immediate(); if (canSplit4 != CmdResultCode.Fail_NotSupported) { m_split4Button.gameObject.SetActive(true); if (canSplit4 == CmdResultCode.Success) { hcbSplit4.IsDisabled = false; } } } } if (m_eventSystem.currentSelectedGameObject != null && m_eventSystem.currentSelectedGameObject.GetComponent <HUDControlBehavior>().IsDisabled) { m_eventSystem.SetSelectedGameObjectOnLateUpdate(m_autoBtn.gameObject); } }
private void Update() { if (m_gameState.IsActionsMenuOpened(m_viewport.LocalPlayerIndex)) { return; } if (m_gameState.IsMenuOpened(m_viewport.LocalPlayerIndex)) { return; } if (m_gameState.IsPaused || m_gameState.IsPauseStateChanging) { return; } Transform camTransform = m_viewport.Camera.transform; if (camTransform.position != m_prevCamPos || camTransform.rotation != m_prevCamRot) { m_prevCamPos = camTransform.position; m_prevCamRot = camTransform.rotation; float angle = camTransform.eulerAngles.y; m_rtMapBounds.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); ProjectCamera(m_rtMapBounds.rotation); } if (m_input.GetButtonDown(InputAction.Start, m_viewport.LocalPlayerIndex, false, false)) { m_gotFocus = !m_gotFocus; if (m_gotFocus) { m_eventSystem.SetSelectedGameObjectOnLateUpdate(m_selectableMinimap.gameObject); } else { m_cameraController.CenterVirtualMouse(); m_eventSystem.SetSelectedGameObjectOnLateUpdate(null); } } if (m_input.GetButtonDown(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false)) { Vector2 pt; if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)m_rtMapBounds.parent, m_cameraController.VirtualMousePosition, null, out pt)) { float normalizedDistance = pt.magnitude / m_rootRadius; if (normalizedDistance <= 1) { m_mouseManipulation = true; m_virtualMousePostion = m_cameraController.VirtualMousePosition; Move(camTransform, true, 0, 0, 0, 0); } } } else if (m_input.GetButtonUp(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false)) { m_mouseManipulation = false; } if (m_gotFocus || m_input.GetButton(InputAction.LB, m_viewport.LocalPlayerIndex, false, false) && IsCursorInMinimapBounds()) { if (m_input.GetButtonDown(InputAction.B, m_viewport.LocalPlayerIndex, false, false)) { m_gotFocus = false; m_cameraController.CenterVirtualMouse(); m_eventSystem.SetSelectedGameObjectOnLateUpdate(null); } else if (m_input.GetButtonDown(InputAction.LB, m_viewport.LocalPlayerIndex, false, false)) { m_virtualMousePostion = m_cameraController.VirtualMousePosition; Move(camTransform, true, 0, 0, 0, 0); } else { bool aPressed = m_input.GetButton(InputAction.A, m_viewport.LocalPlayerIndex, false, false); bool pivotPreciseMode = aPressed | m_input.GetButton(InputAction.RightStickButton, m_viewport.LocalPlayerIndex, false, false); float pivotMultiplier = 1; if (!pivotPreciseMode) { pivotMultiplier = 5; } float deltaY = m_input.GetAxisRaw(InputAction.MoveForward, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.MoveSensitivity * pivotMultiplier; float deltaX = m_input.GetAxisRaw(InputAction.MoveSide, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.MoveSensitivity * pivotMultiplier; bool cursorPreciseMode = aPressed | m_input.GetButton(InputAction.LeftStickButton, m_viewport.LocalPlayerIndex, false, false); float cursorMultiplier = 4; if (!cursorPreciseMode) { cursorMultiplier = 12; } float cursorY = m_input.GetAxisRaw(InputAction.CursorY, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; float cursorX = m_input.GetAxisRaw(InputAction.CursorX, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; Move(camTransform, false, deltaY, deltaX, cursorY, cursorX); } } if (m_mouseManipulation) { if (m_input.GetButton(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false)) { float cursorMultiplier = 12; float cursorY = m_input.GetAxisRaw(InputAction.CursorY, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; float cursorX = m_input.GetAxisRaw(InputAction.CursorX, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier; Move(camTransform, false, cursorY, cursorX, 0, 0); } } }