Ejemplo n.º 1
0
    IEnumerator CreateLine2()
    {
        var sp = new SplineParams();

        sp.spline = new BezierSpline2D(
            RV(), RV(), RV(), RV());
        sp.spline.AddCurve(RV(), RV(), RV());
        sp.spline.AddCurve(RV(), RV(), RV());
        sp.spline.AddCurve(RV(), RV(), RV());
        sp.color = Color.Lerp(blue, red, Random.value).WithAlpha(0);
        sp.width = Random.Range(0.02f, 0.2f);
        Animatable2[] anims = NoteFactory.CreateLine(sp);
        foreach (var l in anims)
        {
            l.AddAnimationCurve(AnimationKeyPath.Opacity, AnimationCurve.Linear(0, 0, 1, 1));
            yield return(new WaitForSeconds(0.01f));
        }

        yield return(new WaitForSeconds(2f));

        foreach (var l in anims)
        {
            //l.velocity = RandomHelper.RandomVector2(-0.5f, 0.5f, -0.5f, 0.5f);
            //l.angularVelocity = Random.Range(-90f, 90f);
            l.AddAnimationCurve(AnimationKeyPath.Opacity, AnimationCurve.EaseInOut(0, 1, 3, 0));
            l.DestroyIn(4f);
        }
    }
Ejemplo n.º 2
0
    void _Box(Vector2 scale, Vector2 pos, Color color, float rotation, float level)
    {
        var lp = new LineParams2 {
            position = pos,
            color    = color,
            scale    = scale,
            rotation = rotation,
            level    = level
        };
        var mp = new MotionParams();

        NoteFactory.CreateLine(lp, mp);
    }
Ejemplo n.º 3
0
    void _FixedLine(float width, float xOffset, Color color, float level)
    {
        var scale = new Vector2(width, CameraHelper.Height * 2);
        var lp    = new LineParams2 {
            position = new Vector2(CameraHelper.Width * xOffset - CameraHelper.HalfWidth, 0),
            color    = color,
            scale    = scale,
            rotation = 0,
            level    = level
        };
        var mp = new MotionParams();

        NoteFactory.CreateLine(lp, mp);
    }
Ejemplo n.º 4
0
    void AnimateRect(Direction dir, float speed, Vector2 scale, Color color, Vector2 position, float rotation = 0, float level = 0)
    {
        var lp = new LineParams2 {
            position = position,
            color    = color,
            scale    = scale,
            rotation = rotation,
            level    = level
        };
        var mp = new MotionParams {
            velocity = dir.ToVelocity(speed)
        };

        NoteFactory.CreateLine(lp, mp);
    }
Ejemplo n.º 5
0
    void AnimateRect(Direction dir, float speed, Vector2 scale, Color color, float offset = 0, float rotation = 0, float level = 0)
    {
        var lp = new LineParams2 {
            position = CameraHelper.PerimeterPositionForMovingObject(dir, offset, scale, rotation),
            color    = color,
            scale    = scale,
            rotation = rotation,
            level    = level
        };
        var mp = new MotionParams {
            velocity = dir.ToVelocity(speed)
        };

        NoteFactory.CreateLine(lp, mp);
    }
Ejemplo n.º 6
0
Archivo: VBottom.cs Proyecto: kijun/art
    void _Box(Vector2 scale, Vector2 pos, Color color, float rotation, float level)
    {
        var lp = new LineParams2 {
            position = pos,
            color    = color,
            scale    = scale,
            rotation = rotation,
            level    = level
        };
        var mp = new MotionParams();

        var anim = NoteFactory.CreateLine(lp, mp);

        anim.DestroyIn(BeatDurationInSeconds * destroyInMeasures * 4);
    }
Ejemplo n.º 7
0
    void _Line(Direction dir, float height, float offset, float deltaSpeed = 0)
    {
        var scale = dir.Align(new Vector2(defaultLineWidth, height * (Random.value * 0.7f + 0.65f)));
        var lp    = new LineParams2 {
            position = CameraHelper.PerimeterPositionForMovingObject(dir, offset, scale, 0),
            color    = lineColor,
            scale    = scale,
            rotation = 0,
            level    = ShapeZLevel.Front
        };
        var mp = new MotionParams {
            velocity = dir.ToVelocity(defaultLineSpeed + deltaSpeed)
        };

        NoteFactory.CreateLine(lp, mp);
    }
Ejemplo n.º 8
0
    void _Line2(Direction dir, float width, float height, float offset, float speed, Color color, float level)
    {
        var scale = new Vector2(width, height);
        var lp    = new LineParams2 {
            position = CameraHelper.PerimeterPositionForMovingObject(dir, 0, scale, 0),
            color    = color,
            scale    = scale,
            rotation = 0,
            level    = level
        };
        var mp = new MotionParams {
            velocity = dir.ToVelocity(speed)
        };

        NoteFactory.CreateLine(lp, mp);
    }
Ejemplo n.º 9
0
Archivo: VBottom.cs Proyecto: kijun/art
    void _FixedLine(float width, float xOffset, Color color, float level)
    {
        var scale = new Vector2(width, CameraHelper.Height * 2);
        var lp    = new LineParams2 {
            position = new Vector2(CameraHelper.Width * xOffset - CameraHelper.HalfWidth, 0),
            color    = color,
            scale    = scale,
            rotation = 0,
            level    = level
        };
        var mp = new MotionParams();

        var anim = NoteFactory.CreateLine(lp, mp);

        anim.DestroyIn(BeatDurationInSeconds * destroyInMeasures * 4);
    }
Ejemplo n.º 10
0
Archivo: VBottom.cs Proyecto: kijun/art
    void _Line(Direction dir, float width, float speed, Color color, float level)
    {
        var scale = new Vector2(width, CameraHelper.Height * 2);
        var lp    = new LineParams2 {
            position = CameraHelper.PerimeterPositionForMovingObject(dir, 0, scale, 0),
            color    = color,
            scale    = scale,
            rotation = 0,
            level    = level
        };
        var mp = new MotionParams {
            velocity = dir.ToVelocity(speed)
        };

        var anim = NoteFactory.CreateLine(lp, mp);

        anim.DestroyIn(BeatDurationInSeconds * destroyInMeasures * 4);
    }
Ejemplo n.º 11
0
    void CreateLineGraph()
    {
        int numberOfLines = 10;

        float baseLength            = 2;
        float lengthIncrement       = 0.5f;
        int   lengthInflectionCount = 5;

        float baseSpeed            = 0.5f;
        float speedIncrement       = 0.04f;
        int   speedInflectionCount = 2;

        float baseWidth = 0.05f;
        float baseGap   = 0.1f;


        var equalizerWidth    = numberOfLines * baseWidth + (numberOfLines - 1) * baseGap;
        var lengthInflections = RandomHelper.Points(0, numberOfLines, lengthInflectionCount);

        lengthInflections.Add(int.MaxValue);
        var nextLenInflection = lengthInflections[0];

        lengthInflections.RemoveAt(0);

        var speedInflections = RandomHelper.Points(0, numberOfLines, speedInflectionCount);

        speedInflections.Add(int.MaxValue);
        var nextSpeedInflection = speedInflections[0];

        speedInflections.RemoveAt(0);

        var currXPos     = (CameraHelper.Width - equalizerWidth) * Random.value - CameraHelper.HalfWidth;
        var currLenDir   = 1;
        var currLen      = baseLength;
        var currSpeedDir = 1;
        var currSpeed    = baseSpeed;

        for (int i = 0; i < numberOfLines; i++)
        {
            var line = new LineParams2();
            line.length = currLen;
            line.width  = baseWidth;
            line.x      = currXPos;
            line.y      = (CameraHelper.Height + baseLength * 2) / -2f - 2f;
            line.color  = lineColor;
            NoteFactory.CreateLine(line, new MotionParams {
                velocity = Vector2.up * currSpeed
            });

            // next
            currXPos  += baseWidth + baseGap;
            currLen   += currLenDir * lengthIncrement;
            currSpeed += speedIncrement * currSpeedDir;

            if (nextLenInflection <= i)
            {
                // reverse dir
                currLenDir       *= -1;
                nextLenInflection = lengthInflections[0];
                lengthInflections.RemoveAt(0);
            }

            if (nextSpeedInflection <= i)
            {
                // reverse dir
                currSpeedDir       *= -1;
                nextSpeedInflection = speedInflections[0];
                speedInflections.RemoveAt(0);
            }
        }
    }
Ejemplo n.º 12
0
    IEnumerator Trace()
    {
        while (true)
        {
            if (Input.GetMouseButtonDown(0))
            {
                var   sp  = new SplineParams();
                float sec = 0.04f;
                var   p1  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                yield return(new WaitForSeconds(sec));

                var p2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                yield return(new WaitForSeconds(sec));

                var p3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                yield return(new WaitForSeconds(sec));

                var p4 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                yield return(new WaitForSeconds(sec));

                sp.spline = new BezierSpline2D(p1, p2, p3, p4);
                while (Input.GetMouseButton(0))
                {
                    yield return(new WaitForSeconds(sec));

                    p1 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    yield return(new WaitForSeconds(sec));

                    p2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    yield return(new WaitForSeconds(sec));

                    p3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    sp.spline.AddCurve(p1, p2, p3);
                }
                sp.color = Color.white.WithAlpha(0);
                //sp.width = Random.Range(0.2f, 2f);
                sp.width = 0.6f;
                Animatable2[] anims = NoteFactory.CreateLine(sp);
                int           idx   = 0;
                foreach (var l in anims)
                {
                    l.AddAnimationCurve(AnimationKeyPath.Opacity, AnimationCurve.Linear(0, 0, 1, 1));
                    idx++;
                    if (idx % 15 == 0)
                    {
                        //yield return null;// new WaitForSeconds(0.01f);
                        yield return(new WaitForSeconds(0.01f));
                    }
                }

                yield return(new WaitForSeconds(2f));

                foreach (var l in anims)
                {
                    //l.velocity = RandomHelper.RandomVector2(-0.5f, 0.5f, -0.5f, 0.5f);
                    //l.angularVelocity = Random.Range(-90f, 90f);
                    l.AddAnimationCurve(AnimationKeyPath.Opacity, AnimationCurve.EaseInOut(0, 1, 3, 0));
                    l.DestroyIn(2f);
                }
            }
            yield return(null);
        }
    }
Ejemplo n.º 13
0
    IEnumerator CreateLine1()
    {
        var sp = new SplineParams();

        /*
         * sp.spline = new BezierSpline2D(
         *      RV(), RV(), RV(), RV());
         * sp.spline.AddCurve(RV(), RV(), RV());
         * sp.spline.AddCurve(RV(), RV(), RV());
         * sp.spline.AddCurve(RV(), RV(), RV());
         */
        /*
         * sp.spline = new BezierSpline2D(
         *      RV2(-10), RV2(-9), RV2(-8), RV2(-7));
         * sp.spline.AddCurve(RV2(-6), RV2(-5), RV2(-4));
         * sp.spline.AddCurve(RV2(-3), RV2(-2), RV2(-1));
         * sp.spline.AddCurve(RV2(0), RV2(1), RV2(2));
         * sp.spline.AddCurve(RV2(3), RV2(4), RV2(5));
         * sp.spline.AddCurve(RV2(6), RV2(7), RV2(8));
         * sp.spline.AddCurve(RV2(9), RV2(10), RV2(11));
         */
        /*
         * sp.spline = new BezierSpline2D(
         *      RV2(-9), RV2(-7), RV2(-5), RV2(-2));
         * sp.spline.AddCurve(RV2(2), RV2(6), RV2(10));
         */
        sp.spline = new BezierSpline2D(
            RV2(-9), RV2(-8), RV2(-7), RV2(-6));
        sp.spline.AddCurve(RV2(-5), RV2(-4), RV2(-3));
        sp.spline.AddCurve(RV2(-2), RV2(-1), RV2(0));
        sp.spline.AddCurve(RV2(1), RV2(2), RV2(3));
        sp.spline.AddCurve(RV2(-2), RV2(-1), RV2(0));
        sp.spline.AddCurve(RV2(1), RV2(2), RV2(3));
        sp.spline.AddCurve(RV2(4), RV2(5), RV2(6));
        sp.spline.AddCurve(RV2(4), RV2(5), RV2(6));
        sp.spline.AddCurve(RV2(7), RV2(8), RV2(9));
        sp.spline.AddCurve(RV2(-2), RV2(-1), RV2(0));
        sp.spline.AddCurve(RV2(1), RV2(2), RV2(3));
        sp.spline.AddCurve(RV2(4), RV2(5), RV2(6));

        /*
         * sp.spline.AddCurve(RV2(0), RV2(1), RV2(2));
         * sp.spline.AddCurve(RV2(3), RV2(4), RV2(5));
         * sp.spline.AddCurve(RV2(6), RV2(7), RV2(8));
         * sp.spline.AddCurve(RV2(9), RV2(10), RV2(11));
         */
        //sp.spline.AddCurve(RV(), RV(), RV());
        //sp.spline.AddCurve(RV(), RV(), RV());
        //sp.spline.AddCurve(RV(), RV(), RV());
        //sp.color = Color.Lerp(blue, red, Random.value).WithAlpha(0);
        sp.color = Color.white.WithAlpha(0);
        //sp.width = Random.Range(0.2f, 2f);
        sp.width = 0.3f;
        Animatable2[] anims = NoteFactory.CreateLine(sp);
        int           idx   = 0;

        foreach (var l in anims)
        {
            l.AddAnimationCurve(AnimationKeyPath.Opacity, AnimationCurve.Linear(0, 0, 1, 1));
            idx++;
            if (idx % 15 == 0)
            {
                //yield return null;// new WaitForSeconds(0.01f);
                yield return(new WaitForSeconds(0.01f));
            }
        }

        yield return(new WaitForSeconds(2f));

        foreach (var l in anims)
        {
            //l.velocity = RandomHelper.RandomVector2(-0.5f, 0.5f, -0.5f, 0.5f);
            //l.angularVelocity = Random.Range(-90f, 90f);
            l.AddAnimationCurve(AnimationKeyPath.Opacity, AnimationCurve.EaseInOut(0, 1, 3, 0));
            l.DestroyIn(4f);
        }
    }