Exemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(ArcState pArcState, ArcSegmentState pSegState, float pArcAngle,
                            ISettings pSettings)
        {
            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             = pSettings.GetUiArcSegmentRendererType(vSegState.NavItem);
            ArcSegmentSettings colors = pSettings.GetArcSegmentSettings(vSegState.NavItem);

            var rendObj = new GameObject("Renderer");

            rendObj.transform.SetParent(gameObject.transform, false);

            vRenderer = (IUiArcSegmentRenderer)rendObj.AddComponent(rendType);
            vRenderer.Build(vArcState, vSegState, pArcAngle, colors);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        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));
        }
Exemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public virtual void Build(ArcState pArcState, float pAngle0, float pAngle1)
        {
            vArcState  = pArcState;
            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.º 4
0
 void DoOffering()
 {
     SetPlayerFocus(true);
     arcState          = ArcState.OFFERING;
     followCam.subject = sacrifice.transform;
     offerMachine.DoOffering(loot.GetSprite());
     loot.ResetSlots();
 }
Exemplo n.º 5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(ArcState pArc, ICustomSegment pCustom)
        {
            vArcState = pArc;
            vCustom   = pCustom;

            vArcState.OnLevelChange += HandleLevelChange;
            UpdateAfterSideChange();
        }
Exemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(ArcState pArc, ISettings pSettings)
        {
            vArcState = pArc;
            vSettings = pSettings;

            vArcState.OnLevelChange += HandleLevelChange;
            UpdateAfterSideChange();
        }
Exemplo n.º 7
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(ArcState pArc, ISettings pSettings)
        {
            vArcState = pArc;
            vSettings = pSettings;

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

            vArcState.OnLevelChange += HandleLevelChange;
            UpdateAfterSideChange();
        }
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();
        }
Exemplo n.º 9
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void Build(ArcState pArcState, ArcSegmentState pSegState,
                                   float pArcAngle, ArcSegmentSettings 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.º 10
0
    // Use this for initialization
    void Start()
    {
        dialogue     = FindObjectOfType <StoryDialog>();
        loot         = FindObjectOfType <LootTracker>();
        player       = FindObjectOfType <Player>();
        followCam    = FindObjectOfType <FollowCamera>();
        offerMachine = FindObjectOfType <OfferMachine>();
        levelUpAudio = GetComponent <AudioSource>();

        arcState = ArcState.INITIAL;

        player.enabled = false;
        FadeIn();
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        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.º 12
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(ArcState pArcState, CursorState pCursorState, ISettings pSettings,
                            Transform pCameraTransform)
        {
            vArcState    = pArcState;
            vCursorState = pCursorState;
            vCameraTx    = pCameraTransform;

            ////

            Type rendType = pSettings.GetUiCursorRendererType();

            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, pSettings.GetCursorSettings());
        }
Exemplo n.º 13
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;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        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;
        }
Exemplo n.º 15
0
 public void DialogueFinished()
 {
     if (arcState == ArcState.INITIAL)
     {
         SetPlayerFocus(false);
         arcState = ArcState.ON_QUEST;
         GrantPower(storyProgress);
         AudioSource.PlayClipAtPoint(levelUpAudio.clip, followCam.transform.position);
         followCam.subject = player.transform;
     }
     else if (arcState == ArcState.ON_QUEST)
     {
         followCam.subject = player.transform;
         SetPlayerFocus(false);
     }
     else if (arcState == ArcState.OFFERING_FINISHED)
     {
         storyProgress++;
         arcState          = ArcState.INITIAL;
         followCam.subject = player.transform;
         FadeOut();
     }
 }
Exemplo n.º 16
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(ArcState pArcState, ISettings pSettings)
        {
            vArcState       = pArcState;
            vSegmentObjList = new List <GameObject>();

            gameObject.transform.localPosition = PushFromHand;

            ArcSegmentState[] 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++)
            {
                ArcSegmentState 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);

                UiArcSegment uiSeg = segObj.AddComponent <UiArcSegment>();
                uiSeg.Build(vArcState, segState, segAngle, pSettings);

                degree -= segDegHalf;
                segObj.transform.localRotation = Quaternion.AngleAxis(degree, Vector3.up);
                degree -= segDegHalf;
            }
        }
Exemplo n.º 17
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public virtual void Build(ArcState pArcState, ArcSegmentState pSegState,
                                  float pArcAngle, ArcSegmentSettings pSettings)
        {
            vArcState  = pArcState;
            vSegState  = pSegState;
            vAngle0    = -pArcAngle / 2f + AngleInset;
            vAngle1    = pArcAngle / 2f - AngleInset;
            vSettings  = pSettings;
            vMeshSteps = (int)Math.Round(Math.Max(2, (vAngle1 - vAngle0) / Math.PI * 60));

            ////

            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 -= 300;
            vBackground.renderer.sharedMaterial.color        = Color.clear;

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

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

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

            ////

            Mesh bgMesh = vBackground.GetComponent <MeshFilter>().mesh;

            BuildMesh(bgMesh, 1);

            vSelectionPoints = new List <Vector3>();

            for (int i = 1; i < bgMesh.vertices.Length; i += 2)
            {
                vSelectionPoints.Add(bgMesh.vertices[i]);
            }

            MeshUtil.BuildRingMesh(vEdge.GetComponent <MeshFilter>().mesh,
                                   0.99f, 1.0f, vAngle0, vAngle1, vMeshSteps);

            ////

            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;
        }
Exemplo n.º 18
0
 public void OfferingFinished()
 {
     arcState          = ArcState.OFFERING_FINISHED;
     followCam.subject = wiseManTalking;
     StartDialogueWithPlayer(4);
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        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");
        }
Exemplo n.º 20
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public virtual void Build(ArcState pArcState, ArcSegmentState pSegState,
                                  float pArcAngle, ArcSegmentSettings pSettings)
        {
            vArcState  = pArcState;
            vSegState  = pSegState;
            vAngle0    = -pArcAngle / 2f + UiSelectRenderer.AngleInset;
            vAngle1    = pArcAngle / 2f - UiSelectRenderer.AngleInset;
            vSettings  = pSettings;
            vNavSlider = (NavItemSlider)vSegState.NavItem;
            vMeshSteps = (int)Math.Round(Math.Max(2, (vAngle1 - vAngle0) / Math.PI * 60));

            const float pi = (float)Math.PI;

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

            ////

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

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

            vTrackMesh = vTrack.GetComponent <MeshFilter>().mesh;
            vFillMesh  = vFill.GetComponent <MeshFilter>().mesh;

            ////

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

            if (vNavSlider.Ticks > 1)
            {
                Vector3 quadScale   = new Vector3(UiSelectRenderer.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, vSliderAngleHalf * 2, pSettings);
        }