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 override void Awake() { base.Awake(); m_gameState = Dependencies.GameState; m_minimap = Dependencies.Minimap; m_input = Dependencies.InputManager; m_voxelMap = Dependencies.Map; m_scaler = GetComponentInParent <CanvasScaler>(); m_gameState.Menu += OnMenu; m_gameState.ActionsMenu += OnActionsMenu; m_rtChangeListener = m_selectableMinimap.GetComponent <RectTransformChangeListener>(); m_rtChangeListener.RectTransformChanged += OnMinimapRectTransformChanged; m_hudControlBehavior = m_selectableMinimap.GetComponent <HUDControlBehavior>(); m_hudControlBehavior.Selected += OnMinimapSelected; m_hudControlBehavior.Deselected += OnMinimapDeselected; }
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); } }