Exemplo n.º 1
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void Build(ArcState pArc, ICustomSegment pCustom) {
			vArcState = pArc;
			vCustom = pCustom;

			vArcState.OnLevelChange += HandleLevelChange;
			UpdateAfterSideChange();
		}
Exemplo n.º 2
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void Build(ArcState pArcState, ICustomSegment pCustom) {
			vArcState = pArcState;
			vSegmentObjList = new List<GameObject>();

			gameObject.transform.localPosition = PushFromHand;

			SegmentState[] segStates = vArcState.GetSegments();
			int segCount = segStates.Length;
			float degree = 170 + DegreeFull/2f;
			float sizeSum = 0;

			for ( int i = 0 ; i < segCount ; i++ ) {
				sizeSum += segStates[i].NavItem.RelativeSize;
			}

			for ( int i = 0 ; i < segCount ; i++ ) {
				SegmentState segState = segStates[i];
				float segPerc = segState.NavItem.RelativeSize/sizeSum;
				float segAngle = AngleFull*segPerc;
				float segDegHalf = segAngle*ToDegrees/2f;

				var segObj = new GameObject("Segment"+vSegmentObjList.Count);
				segObj.transform.SetParent(gameObject.transform, false);
				vSegmentObjList.Add(segObj);

				UiSegment uiSeg = segObj.AddComponent<UiSegment>();
				uiSeg.Build(vArcState, segState, segAngle, pCustom);

				degree -= segDegHalf;
				segObj.transform.localRotation = Quaternion.AngleAxis(degree, Vector3.up);
				degree -= segDegHalf;
			}
		}
Exemplo n.º 3
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void Build(ArcState pArcState, SegmentState pSegState, float pArcAngle, 
																			ICustomSegment pCustom) {
			vArcState = pArcState;
			vSegState = pSegState;
			ArcAngle = pArcAngle;

			vSegState.SetCursorDistanceFunction(CalcCursorDistance);

			vCursorBaseTx = gameObject.transform.parent.parent.parent.parent; //HovercastSetup

			const float pi = (float)Math.PI;
			const float slideBufferAngle = pi/80f;

			vSlideDegrees = (pArcAngle-slideBufferAngle*2)/(float)Math.PI*180;
			vSlideDir0 = MeshUtil.GetRingPoint(1, -pArcAngle/2f+slideBufferAngle);

			////

			Type rendType = pCustom.GetSegmentRenderer(vSegState.NavItem);
			SegmentSettings sett = pCustom.GetSegmentSettings(vSegState.NavItem);

			var rendObj = new GameObject("Renderer");
			rendObj.transform.SetParent(gameObject.transform, false);

			vRenderer = (IUiSegmentRenderer)rendObj.AddComponent(rendType);
			vRenderer.Build(vArcState, vSegState, pArcAngle, sett);
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public virtual void Build(ArcState pArcState, SegmentSettings pSettings, 
																		float pAngle0, float pAngle1) {
			vArcState = pArcState;
			vSettings = pSettings;
			vAngle0 = pAngle0;
			vAngle1 = pAngle1;
			vMeshSteps = (int)Math.Round(Math.Max(2, (vAngle1-vAngle0)/Math.PI*60));

			vInnerRadius = 0.17f;
			vDiameter = UiSelectRenderer.ArcCanvasThickness;

			////

			vBackground = new GameObject("Background");
			vBackground.transform.SetParent(gameObject.transform, false);
			vBackground.AddComponent<MeshFilter>();
			vBackground.AddComponent<MeshRenderer>();
			vBackground.renderer.sharedMaterial = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
			vBackground.renderer.sharedMaterial.renderQueue -= 100;
			vBackground.renderer.sharedMaterial.color = Color.clear;

			BuildMesh(vBackground.GetComponent<MeshFilter>().mesh);

			////

			var labelObj = new GameObject("Label");
			labelObj.transform.SetParent(gameObject.transform, false);
			labelObj.transform.localPosition = new Vector3(0, 0, vInnerRadius);
			labelObj.transform.localScale = new Vector3(1, 1, (vArcState.IsLeft ? 1 : -1));

			vLabel = labelObj.AddComponent<UiLabel>();
			vLabel.IsLeft = vArcState.IsLeft;
		}
Exemplo n.º 5
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public MenuState(IInputProvider pInputProv, NavRoot pNavRoot,InteractionSettings pSettings){
			vInputProv = pInputProv;
			vSettings = pSettings;

			Arc = new ArcState(pNavRoot, vSettings);
			Cursor = new CursorState(vSettings);

			OnSideChange += (() => {});
		}
Exemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public MenuState(IInputProvider pInputProv, NavRoot pNavRoot, InteractionSettings pSettings)
        {
            vInputProv = pInputProv;
            vSettings  = pSettings;

            Arc    = new ArcState(pNavRoot, vSettings);
            Cursor = new CursorState(vSettings);

            OnSideChange += (() => {});
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public override void Build(ArcState pArcState, SegmentState pSegState,
														float pArcAngle, SegmentSettings pSettings) {
			base.Build(pArcState, pSegState, pArcAngle, pSettings);

			vIcon = GameObject.CreatePrimitive(PrimitiveType.Quad);
			vIcon.name = "Icon";
			vIcon.transform.SetParent(gameObject.transform, false);
			vIcon.renderer.sharedMaterial = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
			vIcon.renderer.sharedMaterial.color = Color.clear;
			vIcon.renderer.sharedMaterial.mainTexture = GetIconTexture();
			vIcon.transform.localRotation = vLabel.CanvasLocalRotation;
		}
Exemplo n.º 8
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void Build(ArcState pArc, ICustomPalm pCustom) {
			vArcState = pArc;
			vCustom = pCustom;

			vRendererHold = new GameObject("RendererHold");
			vRendererHold.transform.SetParent(gameObject.transform, false);
			vRendererHold.transform.localPosition = UiLevel.PushFromHand;
			vRendererHold.transform.localRotation = Quaternion.AngleAxis(170, Vector3.up);

			vArcState.OnLevelChange += HandleLevelChange;
			Rebuild();
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public void Build(ArcState pArcState, CursorState pCursorState, CursorSettings pSettings) {
			vArcState = pArcState;
			vCursorState = pCursorState;
			vSettings = 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;
		}
Exemplo n.º 10
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void Build(MenuState pMenuState, ICustomSegment pCustomSeg, ICustomPalm pCustomPalm) {
			vMenuState = pMenuState;
			vArcState = vMenuState.Arc;
			vLeftRot = Quaternion.identity;
			vRightRot = Quaternion.AngleAxis(180, Vector3.up);

			var palmObj = new GameObject("Palm");
			palmObj.transform.SetParent(gameObject.transform, false);
			vUiPalm = palmObj.AddComponent<UiPalm>();
			vUiPalm.Build(vArcState, pCustomPalm);

			var arcObj = new GameObject("Arc");
			arcObj.transform.SetParent(gameObject.transform, false);
			vUiArc = arcObj.AddComponent<UiArc>();
			vUiArc.Build(vArcState, pCustomSeg);

			vMenuState.OnSideChange += HandleSideChange;
		}
Exemplo n.º 11
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void Build(ArcState pArcState, CursorState pCursorState, ICustomCursor pCustom, 
																		Transform pCameraTransform) {
			vArcState = pArcState;
			vCursorState = pCursorState;
			vCameraTx = pCameraTransform;

			////
			
			Type rendType = pCustom.GetCursorRenderer();

			vRendererHold = new GameObject("RendererHold");
			vRendererHold.transform.SetParent(gameObject.transform, false);

			vRendererObj = new GameObject("Renderer");
			vRendererObj.transform.SetParent(vRendererHold.transform, false);

			vRenderer = (IUiCursorRenderer)vRendererObj.AddComponent(rendType);
			vRenderer.Build(vArcState, vCursorState, pCustom.GetCursorSettings());
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public virtual void Build(ArcState pArcState, SegmentState pSegState,
														float pArcAngle, SegmentSettings pSettings) {
			vArcState = pArcState;
			vSegState = pSegState;
			vSettings = pSettings;

			////

			vSlice = new UiSlice(gameObject);
			vSlice.Resize(pArcAngle);

			////

			var labelObj = new GameObject("Label");
			labelObj.transform.SetParent(gameObject.transform, false);
			labelObj.transform.localPosition = new Vector3(0, 0, 1);
			labelObj.transform.localScale = new Vector3(1, 1, (vArcState.IsLeft ? 1 : -1));
			
			vLabel = labelObj.AddComponent<UiLabel>();
			vLabel.IsLeft = vArcState.IsLeft;
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public virtual void Build(ArcState pArcState, SegmentState pSegState,
														float pArcAngle, SegmentSettings pSettings) {
			vArcState = pArcState;
			vSegState = pSegState;
			vAngle0 = -pArcAngle/2f+UiSlice.AngleInset;
			vAngle1 = pArcAngle/2f-UiSlice.AngleInset;
			vSettings = pSettings;
			vNavSlider = (NavItemSlider)vSegState.NavItem;

			const float pi = (float)Math.PI;
			const float radInner = 1.04f;
			const float radOuter = 1.46f;

			vGrabArcHalf = pi/80f;
			vSlideDegree0 = (vAngle0+vGrabArcHalf)/pi*180;
			vSlideDegrees = (vAngle1-vAngle0-vGrabArcHalf*2)/pi*180;

			////

			vHiddenSlice = new UiSlice(gameObject, true);
			vHiddenSlice.Resize(pArcAngle);
			vHiddenSlice.UpdateBackground(Color.clear);

			vTrackA = new UiSlice(gameObject, true, "TrackA", radInner, radOuter);
			vTrackB = new UiSlice(gameObject, true, "TrackB", radInner, radOuter);
			vFillA = new UiSlice(gameObject, true, "FillA", radInner, radOuter);
			vFillB = new UiSlice(gameObject, true, "FillB", radInner, radOuter);

			////

			vTickMat = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
			vTickMat.renderQueue -= 400;
			vTickMat.color = Color.clear;

			if ( vNavSlider.Ticks > 1 ) {
				Vector3 quadScale = new Vector3(UiSlice.AngleInset*2, 0.36f, 0.1f);
				float percPerTick = 1/(float)(vNavSlider.Ticks-1);

				vTicks = new GameObject[vNavSlider.Ticks];

				for ( int i = 0 ; i < vNavSlider.Ticks ; ++i ) {
					var tick = new GameObject("Tick"+i);
					tick.transform.SetParent(gameObject.transform, false);
					tick.transform.localRotation = Quaternion.AngleAxis(
						vSlideDegree0+vSlideDegrees*i*percPerTick, Vector3.up);
					vTicks[i] = tick;

					var quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
					quad.renderer.sharedMaterial = vTickMat;
					quad.transform.SetParent(tick.transform, false);
					quad.transform.localPosition = new Vector3(0, 0, 1.25f);
					quad.transform.localRotation = 
						Quaternion.FromToRotation(Vector3.back, Vector3.down);
					quad.transform.localScale = quadScale;
				}
			}

			////

			vGrabHold = new GameObject("GrabHold");
			vGrabHold.transform.SetParent(gameObject.transform, false);

			var grabObj = new GameObject("Grab");
			grabObj.transform.SetParent(vGrabHold.transform, false);

			vGrab = grabObj.AddComponent<UiSliderGrabRenderer>();
			vGrab.Build(vArcState, vSegState, vGrabArcHalf*2, pSettings);

			////

			vHoverHold = new GameObject("HoverHold");
			vHoverHold.transform.SetParent(gameObject.transform, false);

			var hoverObj = new GameObject("Hover");
			hoverObj.transform.SetParent(vHoverHold.transform, false);

			vHover = new UiSlice(hoverObj, false, "Hover");
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public static float GetArcAlpha(ArcState pArcState) {
			float alpha = 1-(float)Math.Pow(1-pArcState.DisplayStrength, 2);
			alpha -= (float)Math.Pow(pArcState.NavBackStrength, 2);
			return Math.Max(0, alpha);
		}