Example #1
0
    void FixedUpdate()
    {
        scale = Smoothing.SpringSmooth(scale, scaleTarget, ref scaleSpeed, 0.1f, Time.deltaTime);
        if (scaleTargetTransform != null)
        {
            ///wtf unity
            if (baseScale == Vector3.zero)
            {
                baseScale   = scaleTargetTransform.localScale;
                targetScale = baseScale * hoverScale;
            }

            scaleTargetTransform.localScale = scale * targetScale + (1 - scale) * baseScale;
        }
        if (backPlate != null)
        {
            Color c = backPlate.material.color;
            c.a = scale * backplateAlpha * plateAlpha;
            backPlate.material.color = c;
            if (backplateScale == Vector3.zero)
            {
                backplateScale = backPlate.transform.localScale;
                targetScale    = baseScale * hoverScale;
            }
            backPlate.transform.localScale = (1 - scale) * backplateScale + scale * (hoverScale * backplateScale);
        }

        if (text != null)
        {
            //Color c = text.color;
            //c.a = scale;
            //text.color = c;
        }
    }
Example #2
0
    void UpdateReticle()
    {
        //if( target!= null && reticle != null){
        //reticle.SetTarget(target.Position);
        reticle.UpdateReticlePosition();

        if (target == null || target.Invisible)
        {
            reticlePointAlpha       = 1;
            reticleRingAlpha        = 0;
            reticleTransitionTarget = 0;
        }
        else
        {
            reticlePointAlpha = 0;
            reticleRingAlpha  = 1;

            reticleTransitionTarget = 1;
        }
        reticleRotationPercent = 1;
        reticleTransition      = Smoothing.SpringSmooth(reticleTransition, reticleTransitionTarget, ref reticleTransitionSpeed, 0.1f, Time.deltaTime);

        Shader.SetGlobalVector("_Reticle", new Vector4(Mathf.Clamp01(1 - 3f * reticleTransition), reticleTransition, reticleRotationPercent, (1.0f - reticleTransition) * 0.7f));
        //}
    }
Example #3
0
    void UpdateScroll(bool forceLayout = false)
    {
        if (!wasScrolling)
        {
            scrollTarget += momentum * Time.deltaTime;
            momentum     *= Mathf.Clamp01(1 - 10 * Time.deltaTime);
            if (scrollTarget < 0)
            {
                scrollTarget = Smoothing.SpringSmooth(scrollTarget, 0, ref scrollClampVelocity, 0.2f, Time.deltaTime);
                if (Mathf.Abs(scrollTarget) < 0.1f)
                {
                    scrollTarget        = 0;
                    scrollClampVelocity = 0;
                }
            }
            else if (scrollTarget > TotalHeight)
            {
                scrollTarget = Smoothing.SpringSmooth(scrollTarget, TotalHeight, ref scrollClampVelocity, 0.2f, Time.deltaTime);
                if (Mathf.Abs(TotalHeight - scrollTarget) < 0.1f)
                {
                    scrollTarget        = TotalHeight;
                    scrollClampVelocity = 0;
                }
            }
        }
        else
        {
            momentum = scrollVelocity;
        }


        if (scroll != scrollTarget || forceLayout)
        {
            scroll = Smoothing.SpringSmooth(scroll, scrollTarget, ref scrollVelocity, 0.025f, Time.deltaTime);
            if (Mathf.Abs(scroll - scrollTarget) < 0.1f)
            {
                scroll         = scrollTarget;
                scrollVelocity = 0;
            }


            int   newOffset    = (int)(scroll / elementHeight);
            float scrollOffset = -scroll % elementHeight;

            if (indexOffset != newOffset)
            {
                indexOffset = newOffset;
                UpdateOffset();
            }


            for (int i = 0; i < elementPool.Length; i++)
            {
                elementPool[i].root.Position = new Vector2(0, elementHeight * i + scrollOffset);
                //elementPool[i].UpdateTexture();
            }
        }
    }
 protected override void DoUpdate()
 {
     base.DoUpdate();
     if (current != target)
     {
         current          = Smoothing.SpringSmooth(current, target, ref speed, 0.1f, Time.deltaTime);
         material.color   = new Color(1, 1, 1, current);
         frame.localScale = (1f + 0.2f * current) * initialScale;
     }
 }
Example #5
0
 void Update()
 {
     if (currentColor != targetColor)
     {
         currentColor.r = Smoothing.SpringSmooth(currentColor.r, targetColor.r, ref colorSpeed.x, 0.1f, Time.deltaTime);
         currentColor.g = Smoothing.SpringSmooth(currentColor.g, targetColor.g, ref colorSpeed.y, 0.1f, Time.deltaTime);
         currentColor.b = Smoothing.SpringSmooth(currentColor.b, targetColor.b, ref colorSpeed.z, 0.1f, Time.deltaTime);
         currentColor.a = Smoothing.SpringSmooth(currentColor.a, targetColor.a, ref colorSpeed.w, 0.1f, Time.deltaTime);
         meshRenderer.material.color = currentColor;
     }
 }
Example #6
0
 void Update()
 {
     // scale enlarging
     scale = Smoothing.SpringSmooth(scale, scaleTarget, ref scaleSpeed, 0.1f, Time.deltaTime);
     if (scaleTargetTransform != null)
     {
         ///wtf unity
         if (baseScale == Vector3.zero)
         {
             baseScale   = scaleTargetTransform.localScale;
             targetScale = baseScale * hoverScale;
         }
         scaleTargetTransform.localScale = scale * targetScale + (1 - scale) * baseScale;
     }
 }
Example #7
0
    void LateUpdate()
    {
        float cameraDistance = bird.NormalizedVelocityMagnitude * (maxDistance - minDistance) + minDistance;

        Vector3 currentPosition = transform.position;
        Vector3 targetPosition  = target.position + cameraDistance * cameraTransform.forward;      //prev -10 distance

        currentPosition.x = Smoothing.SpringSmooth(currentPosition.x, targetPosition.x, ref speed.x, 0.5f, Time.deltaTime);
        currentPosition.y = Smoothing.SpringSmooth(currentPosition.y, targetPosition.y, ref speed.y, 0.5f, Time.deltaTime);
        currentPosition.z = Smoothing.SpringSmooth(currentPosition.z, targetPosition.z, ref speed.z, 0.5f, Time.deltaTime);

        transform.position = currentPosition;
        Quaternion targetRotation = target.rotation * Quaternion.AngleAxis(20f, Vector3.right);

        transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Mathf.Clamp01(Time.deltaTime * 5f));
    }
Example #8
0
    void Update()
    {
        // if(Input.GetMouseButtonDown(0)){
        //  Toast();
        // }
        time += Time.deltaTime;

        arrowTransform.localPosition = initialArrowPosition + new Vector3(0, amplitude * Mathf.Sin(frequency * Time.time), 0);
        if (time < toastTime)
        {
            val = Smoothing.SpringSmooth(val, 1, ref valSpeed, 0.25f, Time.deltaTime);
            Color c = textMesh.color;
            c.a            = val;
            textMesh.color = c;
            c   = backplate.material.color;
            c.a = val;
            backplate.material.color = c;

            c   = arrow.material.color;
            c.a = val;
            arrow.material.color = c;
            currentPitch         = (1 - val) * startPitch + val * endPitch;
            menu.Pitch           = currentPitch;
        }
        else
        {
            if (val != 0)
            {
                val = Smoothing.SpringSmooth(val, 0, ref valSpeed, 0.1f, Time.deltaTime);
                if (Mathf.Abs(val) < 0.01f)
                {
                    val = 0;
                }
                Color c = textMesh.color;
                c.a            = val;
                textMesh.color = c;

                c   = backplate.material.color;
                c.a = val;
                backplate.material.color = c;

                c   = arrow.material.color;
                c.a = val;
                arrow.material.color = c;
            }
        }
    }
Example #9
0
    public void UpdateReticlePosition()
    {
        float springSpeed = 0.05f;

        if (targetFocalDepth < currentFocalDepth)
        {
            springSpeed = 0.05f;
        }
        else
        {
            springSpeed = .5f;
        }

        currentFocalDepth = Smoothing.SpringSmooth(currentFocalDepth, targetFocalDepth, ref focalDepthSpeed, springSpeed, Time.deltaTime);
        //currentFocalDepth = targetFocalDepth;
        transform.localPosition = new Vector3(0, 0, currentFocalDepth);
    }
Example #10
0
    void Update()
    {
        //We don't want to be setting the material values every frame.
        if (currentBlackoutValue != targetBlackoutValue)
        {
            currentBlackoutValue = Smoothing.SpringSmooth(currentBlackoutValue, targetBlackoutValue, ref blackoutSpeed, smoothPower, Time.deltaTime);

            if (Mathf.Abs(currentBlackoutValue - targetBlackoutValue) < epsilon)
            {
                currentBlackoutValue = targetBlackoutValue;
                blackoutSpeed        = 0;
            }

            SetMeshRendererVisibility();

            blackoutMaterial.color = new Color(color.r, color.g, color.b, currentBlackoutValue);
        }
    }
Example #11
0
    IEnumerator SlideMenu()
    {
        sliding = true;

        while (true)
        {
            slidePosition = Smoothing.SpringSmooth(slidePosition, slideTo, ref slideSpeed, 0.16f, Time.deltaTime);
            slideRect.anchoredPosition = new Vector2(slidePosition, slideRect.anchoredPosition.y);

            if (Mathf.Abs(slidePosition - slideTo) < 0.01f)
            {
                break;
            }

            yield return(null);
        }

        // snap to final position
        slideRect.SetAnchoredHorizontalPosition(slideTo);
        sliding = false;
    }
Example #12
0
    /// <summary>
    /// fade the signs in and out
    /// </summary>
    void UpdateSigns(bool force = false)
    {
        for (int i = 0; i < signs.Length; i++)
        {
            RedwoodSign rs = signs[i];
            if (rs.node == currentTarget && !PlayerMover.Instance.Moving)
            {
                rs.targetAlpha = 0.75f;
            }
            else
            {
                rs.targetAlpha = 0;
            }

            if (rs.targetAlpha != rs.currentAlpha || force)
            {
                rs.currentAlpha = Smoothing.SpringSmooth(rs.currentAlpha, rs.targetAlpha, ref rs.alphaSpeed, 0.25f, Time.deltaTime);
                if (Mathf.Abs(rs.currentAlpha - rs.targetAlpha) < 0.005)
                {
                    rs.currentAlpha = rs.targetAlpha;
                }

                Color c = rs.text.color;
                c.a           = rs.currentAlpha;
                rs.text.color = c;

                c              = rs.title.color;
                c.a            = rs.currentAlpha;
                rs.title.color = c;

                c   = rs.plate.material.color;
                c.a = rs.currentAlpha;
                rs.plate.material.color = c;
            }
        }
    }
Example #13
0
    void Update()
    {
        if (vrHead.rotation.eulerAngles.x > 22 && vrHead.rotation.eulerAngles.x < 90)
        {
            targetMenuAlpha = 1;
        }
        else
        {
            targetMenuAlpha = 0;
        }

        bool updateAll = false;

        if (currentMenuAlpha != targetMenuAlpha)
        {
            float menuSpringSpeed = 0.2f;
            if (targetMenuAlpha < currentMenuAlpha)
            {
                menuSpringSpeed = 0.1f;
            }

            currentMenuAlpha = Smoothing.SpringSmooth(currentMenuAlpha, targetMenuAlpha, ref alphaMenuSpeed, menuSpringSpeed, Time.deltaTime);
            if (Mathf.Abs(currentMenuAlpha - targetMenuAlpha) < 0.005f)
            {
                currentMenuAlpha = targetMenuAlpha;
            }
            updateAll = true;
        }

        if (currentMenuAlpha == 0)
        {
            menu.Reset();
        }

        for (int i = 0; i < lookDownElements.Length; i++)
        {
            LookDownElement el = lookDownElements[i];
            // TODO: add the check for if el's target (to be implemented) is the reticle's target
            if (el.target.IsTarget)
            {
                el.targetAlpha = 1;
            }
            else
            {
                el.targetAlpha = 0;
            }

            if (el.currentAlpha != el.targetAlpha || updateAll)
            {
                float springSpeed = 0.2f;
                if (el.targetAlpha < el.currentAlpha)
                {
                    springSpeed = 0.1f;
                }

                // gradual change in alpha for the fading effect
                el.currentAlpha = Smoothing.SpringSmooth(el.currentAlpha, el.targetAlpha, ref el.alphaSpeed, springSpeed, Time.deltaTime);
                // if current is basically the target alpha, just set it to the target
                if (Mathf.Abs(el.currentAlpha - el.targetAlpha) < 0.005f)
                {
                    el.currentAlpha = el.targetAlpha;
                }

                // text mesh's colour
                Color c = el.text.color;
                c.a           = el.currentAlpha * currentMenuAlpha;
                el.text.color = c;

                // scale icon and translate text up
                el.iconTransform.localScale    = el.initialScale + 0.2f * el.currentAlpha * el.initialScale;
                el.textTransform.localPosition = el.currentAlpha * el.endTextPosition + (1 - el.currentAlpha) * el.initialTextPosition;
            }
            // makes icon show when you look down
            Color col = el.plane.material.color;
            col.a = currentMenuAlpha;
            el.plane.material.color = col;
        }
    }
Example #14
0
    public override void DoUpdate(SceneManager context)
    {
        if (menu.IsClicked)
        {
            SceneManager.Instance.StateTransition(SceneManager.Instance.menuScene);
        }
        else if (restart.IsClicked)
        {
            SceneManager.Instance.StateTransition(SceneManager.Instance.visionScene);
        }
        else if (nextLab.IsClicked)
        {
            SceneManager.Instance.StateTransition(SceneManager.Instance.minecartScene);
        }
        else
        {
            if (VRInput.Instance.PrimaryButton.Pressed)
            {
                IncrementCarouselAngle();
            }
        }
        if ((VRInput.Instance.Pitch) < -30)
        {
            VRInput.Instance.ReticleColor = new Color(0, 0, 0, 0.5f);
        }
        else
        {
            VRInput.Instance.ReticleColor = new Color(0, 0, 0, 0);
        }
        currentAngle           = Smoothing.SpringSmoothAngle(currentAngle, targetAngle, ref angleSpeed, 0.25f, Time.deltaTime);
        carousel.localRotation = Quaternion.AngleAxis(currentAngle, Vector3.up);

        if (!completedCycle)
        {
            for (int i = 0; i < elements.Length; i++)
            {
                elements[i].targetAlpha = 0;
            }
            elements[carouselIdx].targetAlpha = 1;
        }
        for (int i = 0; i < elements.Length; i++)
        {
            CarouselElement e = elements[i];
            if (e.targetAlpha != e.currentAlpha)
            {
                e.currentAlpha = Smoothing.SpringSmooth(e.currentAlpha, e.targetAlpha, ref e.alphaSpeed, 0.25f, Time.deltaTime);
                Color c = e.titleTextRenderer.color;
                c.a = e.currentAlpha;
                e.titleTextRenderer.color = c;
                e.bodyTextRenderer.color  = c;

                if (e.lineMeshRenderer != null)
                {
                    c   = e.lineMeshRenderer.material.color;
                    c.a = e.currentAlpha;
                    e.lineMeshRenderer.material.color = c;
                }

                if (e.ringMeshRenderer != null)
                {
                    c   = e.ringMeshRenderer.material.color;
                    c.a = e.currentAlpha;
                    e.ringMeshRenderer.material.color = c;
                }

                if (e.dotMeshRenderer != null)
                {
                    c   = e.dotMeshRenderer.material.color;
                    c.a = e.currentAlpha;
                    e.dotMeshRenderer.material.color = c;
                }
                if (e.otherRenderer != null)
                {
                    c   = e.otherRenderer.color;
                    c.a = e.currentAlpha;
                    e.otherRenderer.color = c;
                }
                if (e.plateRenderer != null)
                {
                    c   = e.plateRenderer.material.color;
                    c.a = e.currentAlpha * e.plateAlpha;
                    e.plateRenderer.material.color = c;
                }
            }
        }
    }
Example #15
0
    void Update()
    {
        if (activated)
        {
            if (entity == null)
            {
                entity = ItemManagement.Instance.GetItem(item);
                if (entity != null)
                {
                    DrawItem();
                }
            }
            else
            {
                UpdateScrollers();
                if (Input.GetKey(KeyCode.Mouse0))
                {
                    Ray        ray = customizerCamera.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, 100))
                    {
                        string name = hit.collider.name;
                        for (int i = 0; i < entity.Parameters.Count; i++)
                        {
                            if (name == entity.Parameters[i].name)
                            {
                                if (i < 4)
                                {
                                    downParam = i;

                                    // hit.collider.gameObject.renderer.material.color = new Color(1,1,0.5f,1);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (downParam != -1)
                    {
                        selectedParameter = downParam;

                        if (currentObject != null)
                        {
                            SetObjectColors(currentObject.transform);
                        }
                        downParam = -1;
                    }
                }
                if (icon.Texture == null)
                {
                    icon.Texture = PhotoManager.Instance.GetImage(entity.Id);
                }
            }
        }
        if (animating)
        {
            time = Mathf.Clamp01(2f * Time.deltaTime + time);
            float val = Smoothing.QuinticEaseOut(time);
            val = val * xTarget + (1 - val) * xStart;
            uiTransform.RelativePosition = new Vector2(val, 0);
            //SetCameraX(Screen.width*val);
            if (time == 1)
            {
                animating = false;
                if (!activating)
                {
                    gameObject.SetActive(false);
                }
            }
        }
        pitch = Smoothing.SpringSmooth(pitch, targetPitch, ref pitchVelocity, 0.2f, Time.deltaTime);
        float tYaw = Mathf.DeltaAngle(yaw, targetYaw);

        yaw = Smoothing.SpringSmooth(yaw, targetYaw, ref yawVelocity, 0.2f, Time.deltaTime);
        cameraParent.rotation = Quaternion.AngleAxis(yaw, Vector3.up) * Quaternion.AngleAxis(pitch, Vector3.right);
    }
    void DepricatedLateUpdate()
    {
        float deviceYaw = VRInput.Instance.Yaw;

        float deltaYaw = Mathf.DeltaAngle(deviceYaw, previousYaw);

        float targetYaw = currentYaw + deltaYaw;

        currentYaw = targetYaw;
        if (targetYaw < minYaw)
        {
            //currentYaw = targetYaw;

            /*if(deltaYaw < 0){
             *      float power = Mathf.Clamp01( Mathf.Abs(targetYaw - minYaw)/10f );
             *      currentYaw = (1-power)*targetYaw + (power)*currentYaw;//Smoothing.SpringSmooth(currentYaw, minYaw, ref yawSpeed, springPower, Time.deltaTime);
             * }
             * else{
             *      currentYaw = targetYaw;
             * }*/
            float power = Mathf.Clamp01(Mathf.Abs(targetYaw - minYaw) / buffer);
            targetYawSpeed = maxYawSpeed * (power);


            //currentYaw = Smoothing.SpringSmooth(currentYaw, minYaw, ref yawSpeed, springPower, Time.deltaTime);
        }
        else if (targetYaw > maxYaw)
        {
            //currentYaw = targetYaw;

            /*if(deltaYaw > 0){
             *      float power = Mathf.Clamp01( Mathf.Abs(targetYaw - maxYaw)/10f );
             *      power = Mathf.Sqrt(power);
             *      currentYaw = (1-power)*targetYaw + (power)*currentYaw;//Smoothing.SpringSmooth(currentYaw, minYaw, ref yawSpeed, springPower, Time.deltaTime);
             * }
             * else{
             *      currentYaw = targetYaw;
             * }*/
            float power = Mathf.Clamp01(Mathf.Abs(targetYaw - maxYaw) / buffer);
            targetYawSpeed = -maxYawSpeed * (power);


            //currentYaw = Smoothing.SpringSmooth(currentYaw, maxYaw, ref yawSpeed, springPower, Time.deltaTime);
        }
        else
        {
            targetYawSpeed = 0;
        }

        yawSpeed   = Smoothing.SpringSmooth(yawSpeed, targetYawSpeed, ref yawAcceleration, springPower, Time.deltaTime);
        currentYaw = currentYaw + yawSpeed * Time.deltaTime;
        //float targetLeftYaw = Mathf.Clamp(-currentYaw, menuMinYaw, menuMaxYaw);
        //leftMenuYaw = targetLeftYaw;//Smoothing.SpringSmooth(leftMenuYaw, targetLeftYaw, ref leftMenuYawSpeed, 0.25f, Time.deltaTime);

        //leftTransform.localRotation = Quaternion.AngleAxis(leftMenuYaw , Vector3.up);

        //float targetRightYaw = Mathf.Clamp(-currentYaw, -menuMaxYaw, -menuMinYaw);
        //rightMenuYaw = targetRightYaw;//Smoothing.SpringSmooth(rightMenuYaw, targetRightYaw, ref rightMenuYawSpeed, 0.25f, Time.deltaTime);

        //rightTransform.localRotation = Quaternion.AngleAxis(rightMenuYaw , Vector3.up);
        //currentYaw = Mathf.Clamp(targetYaw, -maxYaw,maxYaw);

        transform.position = VRInput.Instance.Position;


        previousYaw = deviceYaw;
        Quaternion menuPitch      = Quaternion.AngleAxis(pitch, Vector3.right);
        Quaternion deviceRotation = Quaternion.AngleAxis(deviceYaw, Vector3.up);

        ///TODO: try an ease on this to smooth out the edges

        if (!lockPitch)
        {
            transform.localRotation = deviceRotation * Quaternion.AngleAxis(currentYaw, Vector3.up) * menuPitch;
        }
        else
        {
            transform.localRotation = VRInput.Instance.Rotation * Quaternion.AngleAxis(currentYaw, Vector3.up) * menuPitch;
        }

        if (counterRotateUI)
        {
            UI.localRotation = Quaternion.AngleAxis(-pitch, Vector3.right);
        }
    }
Example #17
0
    /// <summary>
/// If we are at a specific node, draw the constellations if the player is looking at a specific place in the sky.  The stars and constellations are procedural meshes, created at startup.  This is mostly color fades and transitions to make them fade in/out nicely.
/// </summary>
    void Constellations()
    {
        if (currentTarget == 14)
        {
            if (!PlayerMover.Instance.Moving)
            {
                if (hasLookedConstellation)
                {
                    Color c = starsArrow.material.color;
                    c.a = Mathf.Clamp01(c.a - Time.deltaTime);
                    starsArrow.material.color = c;
                }
                else
                {
                    Color c = starsArrow.material.color;
                    c.a = Mathf.Clamp01(c.a + Time.deltaTime);
                    starsArrow.material.color = c;
                }
            }

            starsArrowTransform.localPosition = starsArrowTransformPosition + new Vector3(0, amplitude * Mathf.Sin(frequency * Time.time), 0);
            if (bigDipperTarget.IsTargetThisFrame)
            {
                stars1.Play();
                hasLookedConstellation = true;
            }

            if (bigDipperTarget.IsTarget)
            {
                //StarRendering.Instance.constellations[1].Color
                targetColor2 = constellationColor;
            }
            else
            {
                //StarRendering.Instance.constellations[1].Color
                targetColor2 = Color.black;
            }
            if (littleDipperTarget.IsTargetThisFrame)
            {
                stars2.Play();
                hasLookedConstellation = true;
            }
            if (littleDipperTarget.IsTarget)
            {
                //StarRendering.Instance.constellations[0].Color
                targetColor = constellationColor;
            }
            else
            {
                //StarRendering.Instance.constellations[0].Color
                targetColor = Color.black;
            }
            if (androidTarget.IsTargetThisFrame)
            {
                stars3.Play();
                hasLookedConstellation = true;
            }
            if (androidTarget.IsTarget)
            {
                //StarRendering.Instance.constellations[0].Color
                targetColor3 = constellationColor;
            }
            else
            {
                //StarRendering.Instance.constellations[0].Color
                targetColor3 = Color.black;
            }
        }
        else
        {
            Color c = starsArrow.material.color;
            if (c.a > 0)
            {
                c.a = Mathf.Clamp01(c.a - Time.deltaTime);
                starsArrow.material.color = c;
            }
            //StarRendering.Instance.constellations[1].Color
            targetColor2 = Color.black;


            //StarRendering.Instance.constellations[0].Color
            targetColor = Color.black;

            targetColor3 = Color.black;
        }
        if (Mathf.Abs(targetColor.r - currentColor.r) > 0.001f)
        {
            currentColor.r = Smoothing.SpringSmooth(currentColor.r, targetColor.r, ref starSpeed.x, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor.g - currentColor.g) > 0.001f)
        {
            currentColor.g = Smoothing.SpringSmooth(currentColor.g, targetColor.g, ref starSpeed.y, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor.b - currentColor.b) > 0.001f)
        {
            currentColor.b = Smoothing.SpringSmooth(currentColor.b, targetColor.b, ref starSpeed.z, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor.a - currentColor.a) > 0.001f)
        {
            currentColor.a = Smoothing.SpringSmooth(currentColor.a, targetColor.a, ref starSpeed.w, 0.25f, Time.deltaTime);
        }

        if (Mathf.Abs(targetColor2.r - currentColor2.r) > 0.001f)
        {
            currentColor2.r = Smoothing.SpringSmooth(currentColor2.r, targetColor2.r, ref starSpeed2.x, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor2.g - currentColor2.g) > 0.001f)
        {
            currentColor2.g = Smoothing.SpringSmooth(currentColor2.g, targetColor2.g, ref starSpeed2.y, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor2.b - currentColor2.b) > 0.001f)
        {
            currentColor2.b = Smoothing.SpringSmooth(currentColor2.b, targetColor2.b, ref starSpeed2.z, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor2.a - currentColor2.a) > 0.001f)
        {
            currentColor2.a = Smoothing.SpringSmooth(currentColor2.a, targetColor2.a, ref starSpeed2.w, 0.25f, Time.deltaTime);
        }

        if (Mathf.Abs(targetColor3.r - currentColor3.r) > 0.001f)
        {
            currentColor3.r = Smoothing.SpringSmooth(currentColor3.r, targetColor3.r, ref starSpeed3.x, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor3.g - currentColor3.g) > 0.001f)
        {
            currentColor3.g = Smoothing.SpringSmooth(currentColor3.g, targetColor3.g, ref starSpeed3.y, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor3.b - currentColor3.b) > 0.001f)
        {
            currentColor3.b = Smoothing.SpringSmooth(currentColor3.b, targetColor3.b, ref starSpeed3.z, 0.25f, Time.deltaTime);
        }
        if (Mathf.Abs(targetColor3.a - currentColor3.a) > 0.001f)
        {
            currentColor3.a = Smoothing.SpringSmooth(currentColor3.a, targetColor3.a, ref starSpeed3.w, 0.25f, Time.deltaTime);
        }
        StarRendering.Instance.constellations[0].Color = currentColor;
        StarRendering.Instance.constellations[1].Color = currentColor2;
        StarRendering.Instance.constellations[2].Color = currentColor3;
    }
Example #18
0
    void Update()
    {
        if (VRInput.Instance != null)
        {
            if (VRInput.Instance.Pitch < -15)
            {
                if (Toaster.Instance != null)
                {
                    Toaster.Instance.ClearToast();
                }
            }
            if (VRInput.Instance.Pitch < -22)
            {
                targetMenuAlpha = 1;
                if (Toaster.Instance != null)
                {
                    Toaster.Instance.ClearToast();
                }
            }
            else
            {
                targetMenuAlpha = 0;
            }
        }

        bool updateAll = false;

        if (currentMenuAlpha != targetMenuAlpha)
        {
            float menuSpringSpeed = 0.2f;
            if (targetMenuAlpha < currentMenuAlpha)
            {
                menuSpringSpeed = 0.1f;
            }

            currentMenuAlpha = Smoothing.SpringSmooth(currentMenuAlpha, targetMenuAlpha, ref alphaMenuSpeed, menuSpringSpeed, Time.deltaTime);
            if (Mathf.Abs(currentMenuAlpha - targetMenuAlpha) < 0.005f)
            {
                currentMenuAlpha = targetMenuAlpha;
            }
            updateAll = true;
        }
        if (currentMenuAlpha == 0)
        {
            menu.Reset();
        }

        for (int i = 0; i < lookDownElements.Length; i++)
        {
            LookDownElement el = lookDownElements[i];
            if (el.target.IsTarget)
            {
                el.targetAlpha = 1;
            }
            else
            {
                el.targetAlpha = 0;
            }



            if (el.currentAlpha != el.targetAlpha || updateAll)
            {
                float springSpeed = 0.2f;
                if (el.targetAlpha < el.currentAlpha)
                {
                    springSpeed = 0.1f;
                }


                el.currentAlpha = Smoothing.SpringSmooth(el.currentAlpha, el.targetAlpha, ref el.alphaSpeed, springSpeed, Time.deltaTime);
                if (Mathf.Abs(el.currentAlpha - el.targetAlpha) < 0.005f)
                {
                    el.currentAlpha = el.targetAlpha;
                }
                Color c = el.text.color;
                c.a           = el.currentAlpha * currentMenuAlpha;
                el.text.color = c;

                el.iconTransform.localScale    = el.initialScale + 0.2f * el.currentAlpha * el.initialScale;
                el.textTransform.localPosition = el.currentAlpha * el.endTextPosition + (1 - el.currentAlpha) * el.initialTextPosition;
            }
            Color col = el.plane.material.color;
            col.a = currentMenuAlpha;
            el.plane.material.color = col;
        }
    }
Example #19
0
    /// <summary>
    /// There is a lot of code in here, but it's really just controlling the visual effect in the menu, and a little bit of logic.  There are also responders for click events in if blocks.  Easy enough.
    /// </summary>
    public override void DoUpdate(SceneManager context)
    {
        if (mode == MenuMode.Main)
        {
            if (labs.IsClicked)
            {
                hike.Invisible = true;
                mode           = MenuMode.Labs;
                menu.gameObject.SetActive(true);
                hikeMenu.gameObject.SetActive(false);
                hikeTitleAlphaTarget = -1;
                labsTitleAlphaTarget = -1f;
                springMenu.minYaw    = springMenu.maxYaw = -7;
                //Debug.Log("labs");
            }

            if (hike.IsClicked)
            {
                labs.Invisible = true;
                mode           = MenuMode.Hike;
                hikeMenu.gameObject.SetActive(true);
                menu.gameObject.SetActive(false);
                labsTitleAlphaTarget = -1;
                hikeTitleAlphaTarget = -1f;
                springMenu.minYaw    = springMenu.maxYaw = 7;
                //Debug.Log("labs");
            }
        }

        if (mode == MenuMode.Labs || (mode == MenuMode.Main && labs.IsTarget))           //|| (mode == MenuMode.Main && (labs.IsTarget ||  (mode == MenuMode.Main && springMenu.Direction == -1 ) ) )

        //	realTarget = 1;
        {
            if (fadeValue < 0)
            {
                spring = 0.75f;
                //targetFade = 0;
            }
            else
            {
                spring = 0.25f;
                //targetFade = 1;
            }
            targetFade = 1;
        }
        else if (mode == MenuMode.Hike || (mode == MenuMode.Main && hike.IsTarget))           //|| (mode == MenuMode.Main && ( hike.IsTarget || (mode == MenuMode.Main && springMenu.Direction == 1) ) )
        //realTarget = -1;
        {
            if (fadeValue > 0)
            {
                spring = 0.75f;
                //targetFade = 0;
            }
            else
            {
                spring = 0.25f;
                //targetFade = -1;
            }
            targetFade = -1;
        }
        else
        {
            targetFade = 0;
            //realTarget = 0;
        }


        if (mode == MenuMode.Labs)
        {
            if (back.IsClicked)
            {
                hike.Invisible = false;
                mode           = MenuMode.Main;
                //menu.gameObject.SetActive(false);
                springMenu.minYaw    = -7;
                springMenu.maxYaw    = 7;
                labsTitleAlphaTarget = 1;
                hikeTitleAlphaTarget = 1;
                //Debug.Log("labs");
            }
            else if (targeting.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.targetScene);
                //Debug.Log("labs");
            }
            else if (motion.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.minecartScene);
                //Debug.Log("labs");
            }
            else if (text.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.visionScene);
                //Debug.Log("labs");
            }
            else if (relativity.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.relativityScene);
                //Debug.Log("labs");
            }
            else if (tracking.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.trackingScene);
                //Debug.Log("labs");
            }
        }

        if (mode == MenuMode.Hike)
        {
            if (hikeBack.IsClicked)
            {
                labs.Invisible = false;
                mode           = MenuMode.Main;
                //hikeMenu.gameObject.SetActive(false);
                springMenu.minYaw    = -7;
                springMenu.maxYaw    = 7;
                labsTitleAlphaTarget = 1;
                hikeTitleAlphaTarget = 1;
                //Debug.Log("labs");
            }
            else if (hike1.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, 0);
            }
            else if (hike2.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, 1);
            }
            else if (hike3.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, 2);
            }
            else if (hike4.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, 3);
            }
            else if (hike5.IsClicked)
            {
                SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, 4);
            }
        }

        //if( Mathf.Abs(fadeValue) < 0.05f ){
        //	targetFade = realTarget;
        //}

        hikeTitleAlpha = Smoothing.SpringSmooth(hikeTitleAlpha, hikeTitleAlphaTarget, ref hikeTitleAlphaSpeed, 0.4f, Time.deltaTime);
        labsTitleAlpha = Smoothing.SpringSmooth(labsTitleAlpha, labsTitleAlphaTarget, ref labsTitleAlphaSpeed, 0.4f, Time.deltaTime);

        Color col = labTitle.color;

        col.a          = labsTitleAlpha;
        labTitle.color = col;


        col             = hikeTitle.color;
        col.a           = hikeTitleAlpha;
        hikeTitle.color = col;


        col   = labIcon.material.color;
        col.a = labsTitleAlpha;
        labIcon.material.color = col;

        col   = hikeIcon.material.color;
        col.a = hikeTitleAlpha;
        hikeIcon.material.color = col;

        if (hikeMenu.gameObject.activeSelf)
        {
            if (mode != MenuMode.Hike && -hikeTitleAlpha < 0)
            {
                hikeMenu.gameObject.SetActive(false);
            }
            else
            {
                for (int i = 0; i < hikeListItems.Length; i++)
                {
                    col   = hikeListItems[i].material.color;
                    col.a = Mathf.Clamp01(-hikeTitleAlpha);
                    hikeListItems[i].material.color = col;
                }
            }
            hike1.PlateAlpha = Mathf.Clamp01(-hikeTitleAlpha);
            hike2.PlateAlpha = Mathf.Clamp01(-hikeTitleAlpha);
            hike3.PlateAlpha = Mathf.Clamp01(-hikeTitleAlpha);
            hike4.PlateAlpha = Mathf.Clamp01(-hikeTitleAlpha);
            hike5.PlateAlpha = Mathf.Clamp01(-hikeTitleAlpha);
        }
        if (menu.gameObject.activeSelf)
        {
            if (mode != MenuMode.Labs && -labsTitleAlpha < 0)
            {
                menu.gameObject.SetActive(false);
            }
            else
            {
                for (int i = 0; i < labsListItems.Length; i++)
                {
                    col   = labsListItems[i].material.color;
                    col.a = Mathf.Clamp01(-labsTitleAlpha);
                    labsListItems[i].material.color = col;
                }
            }

            motion.PlateAlpha     = Mathf.Clamp01(-labsTitleAlpha);
            targeting.PlateAlpha  = Mathf.Clamp01(-labsTitleAlpha);
            tracking.PlateAlpha   = Mathf.Clamp01(-labsTitleAlpha);
            text.PlateAlpha       = Mathf.Clamp01(-labsTitleAlpha);
            relativity.PlateAlpha = Mathf.Clamp01(-labsTitleAlpha);
        }



        if (fadeValue != targetFade)
        {
            fadeValue = Smoothing.SpringSmooth(fadeValue, targetFade, ref fadeSpeed, spring, Time.deltaTime);
            ResetUIColor();

            if (fadeValue > 0)
            {
                for (int i = 0; i < labsRenderers.Length; i++)
                {
                    labsRenderers[i].enabled = true;
                    Color c = labsRenderers[i].material.color;
                    c.a = fadeValue;
                    labsRenderers[i].material.color = c;
                }
                for (int i = 0; i < redwoodsRenderers.Length; i++)
                {
                    if (redwoodsRenderers[i] != null)
                    {
                        redwoodsRenderers[i].enabled = false;
                        //Color c = redwoodsRenderers[i].material.color;
                        //c.a = 0;
                        //redwoodsRenderers[i].material.color = c;
                    }
                }
            }
            else if (fadeValue < 0)
            {
                for (int i = 0; i < labsRenderers.Length; i++)
                {
                    labsRenderers[i].enabled = false;
                    //Color c = labsRenderers[i].material.color;
                    //c.a = 0;
                    //labsRenderers[i].material.color = c;
                }
                for (int i = 0; i < redwoodsRenderers.Length; i++)
                {
                    if (redwoodsRenderers[i] != null)
                    {
                        redwoodsRenderers[i].enabled = true;
                        Color c = redwoodsRenderers[i].material.color;
                        c.a = -fadeValue;
                        redwoodsRenderers[i].material.color = c;
                    }
                }
            }
            else
            {
                for (int i = 0; i < labsRenderers.Length; i++)
                {
                    labsRenderers[i].enabled = false;
                }
                for (int i = 0; i < redwoodsRenderers.Length; i++)
                {
                    if (redwoodsRenderers[i] != null)
                    {
                        redwoodsRenderers[i].enabled = false;
                    }
                }
            }
        }

        //// If the user rotates the screen too far away from the sub-menu, fade back to the splash screen
        if (Mathf.Abs(Mathf.DeltaAngle(OrientationYaw, VRInput.Instance.Yaw)) > 50)
        {
            MainMenu();
            SceneManager.Instance.StateTransition(SceneManager.Instance.splashScene);
        }
        if (Mathf.Abs(Mathf.DeltaAngle(0, VRInput.Instance.Pitch)) > 35)
        {
            MainMenu();
            SceneManager.Instance.StateTransition(SceneManager.Instance.splashScene);
        }
    }
Example #20
0
    public override void DoUpdate(SceneManager context)
    {
        if ((VRInput.Instance.Pitch) < -30)
        {
            VRInput.Instance.ReticleColor = new Color(0, 0, 0, 0.5f);
        }
        else
        {
            VRInput.Instance.ReticleColor = new Color(0, 0, 0, 0);
        }
        if (menu.IsClicked)
        {
            SceneManager.Instance.StateTransition(SceneManager.Instance.menuScene);
        }
        else if (restart.IsClicked)
        {
            SceneManager.Instance.StateTransition(SceneManager.Instance.trackingScene);
        }
        else if (nextLab.IsClicked)
        {
            SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, -1);
        }
        else
        {
            if (VRInput.Instance.PrimaryButton.Pressed)
            {
                StopTracking();
            }
        }



        if (tracking == TrackingMode.Off)
        {
            targetWarningAlpha = 1;
            trackingTimer     += Time.deltaTime;
            if (trackingTimer > disabledTime)
            {
                head.trackRotation = true;
                tracking           = TrackingMode.On;
                StartCoroutine(AllowDisableHeadTracking(1.5f));
                windmillTargetSpeed = windmillSpeed;
                StartCoroutine(Popup());
            }
            src.volume += Time.deltaTime;
        }
        else
        {
            targetWarningAlpha = 0;
            if (src.volume > 0)
            {
                src.volume -= 2f * Time.deltaTime;
            }
            else
            {
                src.Stop();
            }
        }

        currentWarningAlpha = Smoothing.SpringSmooth(currentWarningAlpha, targetWarningAlpha, ref alphaSpeed, 0.2f, Time.deltaTime);
        Color c = warningText.color;

        c.a = currentWarningAlpha;
        warningText.color = c;

        c   = warningBacking.material.color;
        c.a = currentWarningAlpha;
        warningBacking.material.color = c;

        windmillCurrentSpeed = Smoothing.SpringSmooth(windmillCurrentSpeed, windmillTargetSpeed, ref windmillAcceleration, 0.25f, Time.deltaTime);
        for (int i = 0; i < windmills.Length; i++)
        {
            Windmill windmill = windmills[i];
            windmill.RotationSpeed = windmillCurrentSpeed;
        }
    }
Example #21
0
    protected override void DoUpdate()
    {
        base.DoUpdate();

        if (alpha != targetAlpha)
        {
            alpha = Smoothing.SpringSmooth(alpha, targetAlpha, ref alphaSpeed, 0.5f, Time.deltaTime);
            if (Mathf.Abs(targetAlpha - alpha) < 0.005f)
            {
                alpha = targetAlpha;
            }
            if (alpha == 0)
            {
                meshRenderer.enabled = false;
                if (floorGlow != null)
                {
                    floorGlow.enabled = false;
                }
            }
            else
            {
                meshRenderer.enabled = true;
                if (floorGlow != null)
                {
                    floorGlow.enabled = true;
                }
            }
            color.a = alpha;
            meshRenderer.material.color = color;
            if (floorGlow != null)
            {
                Color fC = floorGlow.material.color;
                fC.a = alpha;
                floorGlow.material.color = fC;
            }
        }

        if (alpha != 0)
        {
            if (floorTransform != null)
            {
                floorTransform.LookAt(PlayerMover.Instance.Position);
            }
        }

        /*
         * if(PlayerMover.Instance.CurrentTarget == this){
         *
         *
         *      collider.enabled = false;
         *
         *      if(alpha > 0){
         *              alpha = 1-2f*PlayerMover.Instance.SmoothedBlend;
         *              color.a = alpha;
         *              meshRenderer.material.color = color;
         *      }
         *
         * }
         * else{
         *
         *      float dist = (PlayerMover.Instance.Position - transform.position).magnitude;
         *      if(dist > 3){
         *              collider.enabled = true;
         *              if(alpha < 0.99f){
         *                      alpha = Smoothing.SpringSmooth(alpha, 1, ref alphaSpeed, 0.5f, Time.deltaTime);
         *                      color.a = alpha;
         *                      meshRenderer.material.color = color;
         *
         *              }
         *              else if(alpha < 1){
         *                      alpha = 1;
         *                      alphaSpeed = 0;
         *                      color.a = alpha;
         *                      meshRenderer.material.color = color;
         *              }
         *      }
         * }
         */
    }
Example #22
0
    void LocalControl()
    {
        Quaternion targetRotation  = gyro.rotation;
        Quaternion currentRotation = transform.rotation;

        currentRotation = Quaternion.Slerp(currentRotation, targetRotation, Mathf.Clamp01(2f * Time.deltaTime));

        Vector3 targetEulerAngles = targetRotation.eulerAngles;

        //Vector3 eulerAngles = currentRotation.eulerAngles;
        rollControl  = Mathf.Clamp(((targetEulerAngles.z + 540f) % 360f - 180f) / 30f, -1f, 1f);
        pitchControl = Mathf.Clamp(((targetEulerAngles.x + 180f) % 360f - 180f - 20f) / 40f, -1f, 1f);

        targetYaw = targetEulerAngles.y;

        float height = transform.position.y;


        //roll = rollControl*rollControl*Mathf.Sign(rollControl)*30f;
        roll        = Smoothing.SpringSmooth(roll, rollControl * 40f, ref rollSpeed, 0.5f, Time.deltaTime);
        pitch       = Smoothing.SpringSmooth(pitch, pitchControl * 40f, ref pitchSpeed, 0.5f, Time.deltaTime);
        actualPitch = pitch;
        //if(height < 10){
        //	if(pitch > 0){
        //		float adjustment = Mathf.Clamp01( (height-5)/ 5f);
        //		actualPitch =  adjustment*pitch;
        //	}
        //}
        //else
        if (height > 200)
        {
            if (pitch < 0)
            {
                float adjustment = Mathf.Clamp01(1f - (height - 200) / 5f);
                actualPitch = adjustment * pitch;
            }
        }


        float maxVelocity  = normalVelocity;
        float acceleration = 1;

        if (actualPitch > 2)
        {
            float descent = Mathf.Clamp01((actualPitch - 2f) / 8f);            ///descent, 0 to 1
            maxVelocity  = normalVelocity + descent * (descentVelocity - normalVelocity);
            acceleration = 1 + descent * 10f;
        }
        else if (actualPitch < -10)
        {
            float ascent = Mathf.Clamp01((-actualPitch - 10f) / 10f);            ///ascent, 0 to 1
            maxVelocity  = ascent * ascentVelocity + (1 - ascent) * normalVelocity;
            acceleration = 1;
        }
        else
        {
            maxVelocity  = normalVelocity;
            acceleration = 1;
        }

        currentVelocity = Mathf.Clamp(currentVelocity + Mathf.Clamp01(acceleration * Time.deltaTime), ascentVelocity, descentVelocity);

        animationController.SetPlaybackSpeed(noise, 0.25f + Mathf.Clamp01(currentVelocity / normalVelocity - 1));

        float maxVSqr  = maxVelocity * maxVelocity;
        float dragCoef = acceleration / maxVSqr;

        currentVelocity = currentVelocity - dragCoef * currentVelocity * currentVelocity * Time.deltaTime;


        //Debug.Log(actualPitch + " : " + currentVelocity);
        //Debug.Log(pitch);
        //float deltaYaw = Mathf.DeltaAngle(yaw, targetYaw);
        //roll = Smoothing.SpringSmoothAngle(roll, -Mathf.Clamp(deltaYaw,-45,45), ref rollSpeed, 1, Time.deltaTime);
        //roll = Mathf.Clamp(roll-0.25f*Time.deltaTime*deltaYaw*deltaYaw*Mathf.Sign(deltaYaw) - Time.deltaTime*deltaYaw, -50,50);

        if (Mathf.Abs(roll) > 0.1f)
        {
            float turningRadius = (currentVelocity * currentVelocity) / (gravity * Mathf.Tan(Mathf.Deg2Rad * roll) * 0.4f);
            float circum        = Mathf.PI * 2f * turningRadius;
            float frameDistance = Time.deltaTime * currentVelocity;
            float degreesOfTurn = 360f * (frameDistance / circum);
            yaw -= degreesOfTurn;
        }
        //Debug.Log(yaw + " : yaw " );
        transform.rotation = Quaternion.AngleAxis(yaw, Vector3.up) * Quaternion.AngleAxis(actualPitch, Vector3.right) * Quaternion.AngleAxis(roll, Vector3.forward);
        //transform.eulerAngles = new Vector3(0, yaw, roll);//actualPitch



        velocityVector      = currentVelocity * transform.forward;
        transform.position += Time.deltaTime * velocityVector;


        UpdateNetwork();
    }