示例#1
0
    private void InitializeDrawer(FlowRainDrawerContainer dc)
    {
        dc.TimeElapsed             = 0f;
        dc.lifetime                = RainDropTools.Random(Variables.LifetimeMin, Variables.LifetimeMax);
        dc.fluctuationRate         = RainDropTools.Random(Variables.fluctuationRateMin, Variables.fluctuationRateMax);
        dc.acceleration            = RainDropTools.Random(Variables.AccelerationMin, Variables.AccelerationMax);
        dc.transform.localPosition = RainDropTools.GetSpawnLocalPos(this.transform, camera, 0f, Variables.SpawnOffsetY);
        dc.startPos                = dc.transform.localPosition;

        dc.acceleration = RainDropTools.Random(Variables.AccelerationMin, Variables.AccelerationMax);
        Material mat = RainDropTools.CreateRainMaterial(ShaderType, RenderQueue);

        RainDropTools.ApplyRainMaterialValue(
            mat,
            ShaderType,
            Variables.NormalMap,
            Variables.OverlayTexture,
            Variables.DistortionValue,
            Variables.OverlayColor,
            Variables.ReliefValue,
            Variables.Blur,
            Variables.Darkness
            );
        dc.Drawer.lifeTime        = dc.lifetime;
        dc.Drawer.vertexDistance  = 0.01f;
        dc.Drawer.angleDivisions  = 20;
        dc.Drawer.material        = mat;
        dc.Drawer.widthCurve      = Variables.TrailWidth;
        dc.Drawer.widthMultiplier = RainDropTools.Random(Variables.SizeMinX, Variables.SizeMaxX);
        dc.Drawer.textureMode     = LineTextureMode.Stretch;
        dc.Drawer.vertexDistance  = (1f * this.Distance * RainDropTools.GetCameraOrthographicSize(this.camera).y) / (Variables.Resolution * 10f);
        dc.Drawer.Clear();
        dc.Drawer.enabled = false;
    }
示例#2
0
    private void UpdateTransform(FrictionFlowRainDrawerContainer dc)
    {
        float   progress = GetProgress(dc);
        float   t        = dc.TimeElapsed;
        Vector3 nextPos  = GetNextPositionWithFriction(
            dc: dc,
            downValue: ((1 / 2f) * t * t * dc.acceleration * 0.1f) + (Variables.InitialVelocity * t * 0.01f),
            resolution: 150,
            widthResolution: 8,
            dt: Time.deltaTime);

        nextPos  = new Vector3(nextPos.x, nextPos.y, 0f);
        nextPos += progress * new Vector3(GlobalWind.x, GlobalWind.y, 0f);
        dc.Drawer.vertexDistance   = (1f * this.Distance * RainDropTools.GetCameraOrthographicSize(this.camera).y) / (Variables.Resolution * 10f);
        dc.transform.localPosition = nextPos;
    }
示例#3
0
    /// <summary>
    /// Update rain variables
    /// </summary>
    /// <param name="dc">Dc.</param>
    private void UpdateInstance(StaticRainDrawerContainer dc)
    {
        AnimationCurve fadeCurve = Variables.FadeinCurve;

        // Update time
        if (!NoMoreRain)
        {
            dc.TimeElapsed = Mathf.Min(Variables.fadeTime, dc.TimeElapsed + Time.deltaTime);
        }
        else
        {
            dc.TimeElapsed = Mathf.Max(0f, dc.TimeElapsed - Time.deltaTime);
        }

        if (dc.TimeElapsed == 0f)
        {
            dc.Drawer.Hide();
            dc.currentState = DrawState.Disabled;
            return;
        }
        else
        {
            dc.currentState = DrawState.Playing;
        }

        if (Variables.FullScreen)
        {
            Vector2 orthSize    = RainDropTools.GetCameraOrthographicSize(this.camera);
            Vector3 targetScale = new Vector3(
                orthSize.x / 2f,
                orthSize.y / 2f,
                0f
                );
            if (VRMode)
            {
                targetScale += Vector3.one * 0.02f;
            }
            dc.transform.localScale    = targetScale;
            dc.transform.localPosition = Vector3.zero;
        }
        else
        {
            dc.transform.localScale = new Vector3(
                Variables.SizeX,
                Variables.SizeY,
                1f
                );

            Vector3 p = camera.ScreenToWorldPoint(
                new Vector3(
                    -Screen.width * Variables.SpawnOffsetX + Screen.width / 2,
                    -Screen.height * Variables.SpawnOffsetY + Screen.height / 2,
                    0f
                    ));
            dc.transform.localPosition  = transform.InverseTransformPoint(p);
            dc.transform.localPosition -= Vector3.forward * dc.transform.localPosition.z;
        }

        float progress = GetProgress(dc);

        dc.Drawer.RenderQueue   = RenderQueue;
        dc.Drawer.NormalMap     = Variables.NormalMap;
        dc.Drawer.ReliefTexture = Variables.OverlayTexture;
        dc.Drawer.OverlayColor  = new Color(
            Variables.OverlayColor.r,
            Variables.OverlayColor.g,
            Variables.OverlayColor.b,
            Variables.OverlayColor.a * fadeCurve.Evaluate(progress) * Alpha
            );
        dc.Drawer.DistortionStrength = Variables.DistortionValue * fadeCurve.Evaluate(progress) * Alpha;
        dc.Drawer.ReliefValue        = Variables.ReliefValue * fadeCurve.Evaluate(progress) * Alpha;
        dc.Drawer.Blur       = Variables.Blur * fadeCurve.Evaluate(progress) * Alpha;
        dc.Drawer.Darkness   = Variables.Darkness;
        dc.Drawer.ShaderType = ShaderType;
        dc.Drawer.Show();
    }