//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public ProjectionState(ICursorState pCursor, InteractionSettings pSettings, Transform pBaseTx) { Cursor = pCursor; vSettings = pSettings; vBaseTx = pBaseTx; IsActive = true; }
/*--------------------------------------------------------------------------------------------*/ public void UpdateAfterInput() { var isMenuOnLeft = vInteractSettings.IsMenuOnLeftSide; IInputMenu inputMenu = vInput.GetMenu(isMenuOnLeft); HovercastCursorType[] cursorTypes = vInteractSettings.Cursors; ReadOnlyCollection<BaseItemState> items = FullMenu.GetItems(); Dictionary<HovercastCursorType, CursorType> convertMap = (vInteractSettings.IsMenuOnLeftSide ? vRightCursorConvertMap : vLeftCursorConvertMap); vActiveCursorTypes.Clear(); vActiveCursorInteractions.Clear(); FullMenu.ClearCursors(); foreach ( HovercastCursorType unsidedCursorType in cursorTypes ) { CursorType cursorType = convertMap[unsidedCursorType]; ICursorState cursor = vHovercursorSetup.State.GetCursorState(cursorType); vActiveCursorTypes.Add(cursorType); FullMenu.AddCursor(cursor); } for ( int i = 0 ; i < items.Count ; i++ ) { vActiveCursorInteractions.Add(items[i]); } FullMenu.UpdateAfterInput(inputMenu); if ( isMenuOnLeft != vCurrIsMenuOnLeftSide ) { vCurrIsMenuOnLeftSide = isMenuOnLeft; FullMenu.ResetAllItemCursorInteractions(); OnSideChange(); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateWithCursor(ICursorState pCursor) { bool allowSelect = (pCursor.IsInputAvailable && DisplayStrength > 0); Vector3? cursorWorldPos = (allowSelect ? pCursor.GetWorldPosition() : (Vector3?)null); CursorType cursorType = pCursor.Type; float nearestDist = float.MaxValue; NearestItem = null; foreach (BaseItemState item in vAllItems) { item.UpdateWithCursor(cursorType, cursorWorldPos); if (!allowSelect) { continue; } float itemDist = item.GetHighlightDistance(cursorType); if (itemDist >= nearestDist) { continue; } NearestItem = item; nearestDist = itemDist; } foreach (BaseItemState item in vAllItems) { item.SetAsNearestItem(cursorType, (item == NearestItem)); } }
public void SetState(ICursorState NewState) { if(State != null) { State.ExitState(); } State = NewState; State.EnterState(); }
/*--------------------------------------------------------------------------------------------*/ public ProjectionState GetProjection(CursorType pCursorType) { if (!vProjectionMap.ContainsKey(pCursorType)) { ICursorState state = Hovercursor.GetCursorState(pCursorType); var proj = new ProjectionState(state, vInteractSett, vBaseTx); vProjectionMap.Add(pCursorType, proj); } return(vProjectionMap[pCursorType]); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ internal void Build(ICursorState pCursorState, ICursorSettings pSettings, Transform pCameraTx) { vCursorState = pCursorState; vCameraTx = pCameraTx; vCursorRendererHold = new GameObject("CursorRendererHold"); vCursorRendererHold.transform.SetParent(gameObject.transform, false); vCursorRendererObj = new GameObject("CursorRenderer"); vCursorRendererObj.transform.SetParent(vCursorRendererHold.transform, false); vCursorRenderer = (IUiCursorRenderer)vCursorRendererObj.AddComponent(pSettings.Renderer); vCursorRenderer.Build(vCursorState, pSettings); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public virtual void Build(ICursorState pCursorState, ICursorSettings pSettings) { vCursorState = pCursorState; vSettings = (CursorSettingsStandard)pSettings; vRingObj = new GameObject("Ring"); vRingObj.transform.SetParent(gameObject.transform, false); MeshRenderer meshRend = vRingObj.AddComponent<MeshRenderer>(); meshRend.sharedMaterial = Materials.GetCursorLayer(); vRingObj.AddComponent<MeshFilter>(); vRingMeshBuilder = new MeshBuilder(); vRingObj.GetComponent<MeshFilter>().sharedMesh = vRingMeshBuilder.Mesh; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Build(ICursorState pCursorState, ICursorSettings pSettings) { vCursorState = pCursorState; vSettings = (CursorSettingsStandard)pSettings; vRingObj = new GameObject("Ring"); vRingObj.transform.SetParent(gameObject.transform, false); vRingObj.AddComponent <MeshRenderer>(); vRingObj.AddComponent <MeshFilter>(); vRingObj.renderer.sharedMaterial = new Material(Shader.Find("Unlit/AlphaSelfIllumTop")); vRingMesh = vRingObj.GetComponent <MeshFilter>().mesh; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ internal void Build(ICursorState pCursorState, ICursorSettings pSettings, Transform pCameraTx) { vCursorState = pCursorState; vCameraTx = pCameraTx; vCursorRendererHold = new GameObject("CursorRendererHold"); vCursorRendererHold.transform.SetParent(gameObject.transform, false); vCursorRendererObj = new GameObject("CursorRenderer"); vCursorRendererObj.transform.SetParent(vCursorRendererHold.transform, false); vCursorRenderer = (IUiCursorRenderer)vCursorRendererObj.AddComponent(pSettings.Renderer); vCursorRenderer.Build(vCursorState, pSettings); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public virtual void Build(ICursorState pCursorState, ICursorSettings pSettings) { vCursorState = pCursorState; vSettings = (CursorSettingsStandard)pSettings; vRingObj = new GameObject("Ring"); vRingObj.transform.SetParent(gameObject.transform, false); MeshRenderer meshRend = vRingObj.AddComponent <MeshRenderer>(); meshRend.sharedMaterial = Materials.GetCursorLayer(); vRingObj.AddComponent <MeshFilter>(); vRingMesh = vRingObj.GetComponent <MeshFilter>().mesh; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateProjection(ProjectionState pProj) { ICursorState cursor = pProj.Cursor; CursorType cursorType = cursor.Type; bool allowSelect = (cursor.IsInputAvailable && pProj.IsActive); Vector3? cursorWorldPos = (allowSelect ? cursor.GetWorldPosition() : (Vector3?)null); ItemTree nearestTree = new ItemTree(); float nearestDist = float.MaxValue; foreach (ItemTree itemTree in vAllItems) { itemTree.Item.UpdateWithCursor(cursorType, cursorWorldPos); if (!allowSelect) { continue; } float itemDist = itemTree.Item.GetHighlightDistance(cursorType); if (itemDist >= nearestDist) { continue; } nearestTree = itemTree; nearestDist = itemDist; } foreach (ItemTree itemTree in vAllItems) { BaseItemState item = itemTree.Item; item.SetAsNearestItem(cursorType, (item == nearestTree.Item)); } if (nearestTree.Panel == null || nearestTree.Item.MaxHighlightProgress <= 0) { pProj.SetNearestPanelTransform(null); pProj.NearestItemHighlightProgress = 0; return; } GameObject panelObj = (GameObject)nearestTree.Panel.ItemPanel.DisplayContainer; pProj.SetNearestPanelTransform(panelObj.transform); pProj.NearestItemHighlightProgress = nearestTree.Item.GetHighlightProgress(cursorType); }
/*--------------------------------------------------------------------------------------------*/ public void Update() { if (vState == null || Input.IsFailure) { return; } vState.UpdateBeforeInput(); Input.UpdateInput(); vState.UpdateAfterInput(); ReadOnlyCollection <CursorType> activeTypes = vState.ActiveCursorTypes; ICursorSettings visualSett = DefaultVisualSettings.GetSettings(); Transform cameraTx = CenterCamera.gameObject.transform; CursorTypeUtil.Exclude(vPrevActiveCursorTypes, activeTypes, vHideCursorTypes); CursorTypeUtil.Exclude(activeTypes, vPrevActiveCursorTypes, vShowCursorTypes); foreach (CursorType type in vHideCursorTypes) { vCursorMap[type].gameObject.SetActive(false); } foreach (CursorType type in vShowCursorTypes) { if (vCursorMap.ContainsKey(type)) { vCursorMap[type].gameObject.SetActive(true); continue; } ICursorState cursor = vState.GetCursorState(type); var cursorObj = new GameObject("Cursor-" + type); cursorObj.transform.SetParent(gameObject.transform, false); UiCursor uiCursor = cursorObj.AddComponent <UiCursor>(); uiCursor.Build(cursor, visualSett, cameraTx); vCursorMap.Add(type, uiCursor); vState.SetCursorTransform(type, cursorObj.transform); } vPrevActiveCursorTypes.Clear(); vPrevActiveCursorTypes.AddRange(activeTypes); }
/*--------------------------------------------------------------------------------------------*/ public void Update() { if (vState == null || Input.IsFailure) { return; } vState.UpdateBeforeInput(); Input.UpdateInput(); vState.UpdateAfterInput(); CursorType[] activeTypes = vState.ActiveCursorTypes; IEnumerable <CursorType> hideTypes = vPrevActiveCursorTypes.Except(activeTypes); IEnumerable <CursorType> showTypes = activeTypes.Except(vPrevActiveCursorTypes); ICursorSettings visualSett = DefaultVisualSettings.GetSettings(); foreach (CursorType type in hideTypes) { vCursorMap[type].gameObject.SetActive(false); } foreach (CursorType type in showTypes) { if (vCursorMap.ContainsKey(type)) { vCursorMap[type].gameObject.SetActive(true); continue; } ICursorState cursor = vState.GetCursorState(type); var cursorObj = new GameObject("Cursor-" + type); cursorObj.transform.SetParent(gameObject.transform, false); UiCursor uiCursor = cursorObj.AddComponent <UiCursor>(); uiCursor.Build(cursor, visualSett, CameraTransform); vCursorMap.Add(type, uiCursor); vState.SetCursorTransform(type, cursorObj.transform); } vPrevActiveCursorTypes = activeTypes; }
/*--------------------------------------------------------------------------------------------*/ public void Update() { ICursorState cursorState = vProjectionState.Cursor; bool isActive = (cursorState.IsInputAvailable && vProjectionState.ProjectedPanelPosition != null && vProjectionState.ProjectedPanelDistance > 0.001f && vProjectionState.ProjectedPanelProgress > 0); vRendererHold.SetActive(isActive); if (!isActive) { return; } Vector3 projPos = (Vector3)vProjectionState.ProjectedPanelPosition; Vector3 projPosToCursor = cursorState.Position - projPos; vRendererHold.transform.localPosition = projPos; vRendererHold.transform.localRotation = Quaternion.FromToRotation(Vector3.up, projPosToCursor); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ internal void UpdateAfterInput(IInputMenu pInputMenu, ICursorState[] pCursors) { vCurrentCursors = pCursors; IsInputAvailable = pInputMenu.IsAvailable; IsOnLeftSide = pInputMenu.IsLeft; Center = pInputMenu.Position; Rotation = pInputMenu.Rotation; Size = pInputMenu.Radius; DisplayStrength = pInputMenu.DisplayStrength; NavBackStrength = pInputMenu.NavigateBackStrength; CheckNavigateBackAction(pInputMenu); foreach ( BaseItemState item in vAllItems ) { item.UpdateBeforeCursors(); } foreach ( ICursorState cursor in vCurrentCursors ) { UpdateWithCursor(cursor); } foreach ( BaseItemState item in vAllItems ) { if ( item.UpdateSelectionProcess() ) { //returns true if selection occurred break; //exit loop, since the items list changes after a selection } } }
public void CursorRestoreState(ICursorState state) { }
/*--------------------------------------------------------------------------------------------*/ internal void AddCursor(ICursorState pCursor) { vCurrentCursors.Add(pCursor); }
/*--------------------------------------------------------------------------------------------*/ internal void AddCursor(ICursorState pCursor) { vCurrentCursors.Add(pCursor); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateWithCursor(ICursorState pCursor) { bool allowSelect = (pCursor.IsInputAvailable && DisplayStrength > 0); Vector3? cursorWorldPos = (allowSelect ? pCursor.GetWorldPosition() : (Vector3?)null); CursorType cursorType = pCursor.Type; float nearestDist = float.MaxValue; NearestItem = null; foreach ( BaseItemState item in vAllItems ) { item.UpdateWithCursor(cursorType, cursorWorldPos); if ( !allowSelect ) { continue; } float itemDist = item.GetHighlightDistance(cursorType); if ( itemDist >= nearestDist ) { continue; } NearestItem = item; nearestDist = itemDist; } foreach ( BaseItemState item in vAllItems ) { item.SetAsNearestItem(cursorType, (item == NearestItem)); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public ProjectionState(ICursorState pCursor, InteractionSettings pSettings, Transform pBaseTx) { Cursor = pCursor; vSettings = pSettings; vBaseTx = pBaseTx; IsActive = true; }
public void CursorRestoreState(ICursorState state) { logger.WarnFormat("CursorRestoreState"); }