Exemple #1
0
        private static async UniTask Sample4()
        {
            using (var shapeObject = new DisposableGameObject(new Vector3(-3f, 0f, 0f)))
            {
                var shape = shapeObject.AddComponent <Rectangle>();
                shape.Type      = Rectangle.RectangleType.RoundedHollow;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Thickness = 0.1f;

                var cube = shape;

                await Anime.Delay(0.3f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Moving.Linear(3f, 2f),
                        TranslateTo.LocalPositionX(cube)
                        ),
                    Anime.PlayTo(
                        Animator.Delay(1.8f, Easing.Create <Linear>(Vector3.zero, 0.2f)),
                        TranslateTo.LocalScale(cube)
                        )
                    );

                await Anime.Delay(0.3f);
            }
        }
Exemple #2
0
        private async UniTask LineTestElement()
        {
            const byte colorA = 64;

            /*
             * var colors = new[]
             * {
             *  // 114
             *  new Color32(78, 191, 214, colorA),
             *  new Color32(0, 85, 149, colorA),
             *  new Color32(25, 36, 74, colorA),
             *  new Color32(87, 189, 168, colorA),
             *  new Color32(246, 249, 228, colorA),
             *  new Color32(0, 0, 0, colorA),
             *  new Color32(162, 67, 137, colorA),
             *  new Color32(229, 230, 71, colorA),
             * };
             */
            var colors = new[]
            {
                new Color32(255, 0, 0, colorA),
                new Color32(0, 255, 0, colorA),
                new Color32(0, 0, 255, colorA),
                new Color32(255, 255, 0, colorA),
                new Color32(255, 0, 255, colorA),
                new Color32(0, 255, 255, colorA),
            };

            var unitCircle = Random.insideUnitCircle.normalized * Random.Range(2f, 8f);

            using (var shapeObject = new DisposableGameObject(
                       new Vector3(unitCircle.x, unitCircle.y, 50f)
                       ))
            {
                var shape = shapeObject.AddComponent <Line>();
                shape.Geometry  = LineGeometry.Volumetric3D;
                shape.BlendMode = ShapesBlendMode.Additive;
                shape.Color     = colors[Random.Range(0, colors.Length)];
                shape.Start     = new Vector3(0f, 0f, 0f);
                shape.End       = new Vector3(0f, 0f, Random.Range(4f, 10f));
                shape.Thickness = Random.Range(0.1f, 1.0f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Easing.Create <OutCubic>(-20f, Random.Range(1f, 3f)),
                        TranslateTo.LocalPositionZ(shape)
                        ),
                    Anime.Play(
                        Easing.Create <InCubic>(Vector3.zero, Vector3.one, 0.15f),
                        TranslateTo.LocalScale(shape)
                        )
                    );
            }
        }
Exemple #3
0
        private static async UniTask AnimationElement()
        {
            using (var shapeObjects = new DisposableGameObject(Vector3.zero))
            {
                var shape = shapeObjects.AddComponent <Disc>();
                shape.Type      = Disc.DiscType.Ring;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Radius    = 0.3f;
                shape.Thickness = 0.1f;

                const float xrange    = 5f;
                const float yrangeMin = 5f;
                const float yrangeMax = 10f;
                await Anime.PlayTo(
                    Moving.Gravity(new Vector3(Random.Range(-xrange, xrange), Random.Range(yrangeMin, yrangeMax)), Vector3.down * 9.8f, 3f),
                    TranslateTo.LocalPosition(shape)
                    );
            }
        }
Exemple #4
0
        private static async UniTask Sample3()
        {
            using (var shapeObject = new DisposableGameObject(new Vector3(1f, -2f, 0f)))
            {
                var shape = shapeObject.AddComponent <Rectangle>();
                shape.Type      = Rectangle.RectangleType.RoundedHollow;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Thickness = 0.1f;

                var cube = shape;

                await Anime.Delay(0.3f);

                await Anime.PlayTo(
                    Easing.Create <InCubic>(new Vector3(-5f, 3f, 0f), 2f),
                    TranslateTo.LocalPosition(cube)
                    );

                await Anime.Delay(0.3f);
            }
        }
Exemple #5
0
        private static async UniTask RandomBoxTest()
        {
            Random.InitState(12345);
            for (var i = 0; i < 1000; ++i)
            {
                var shapeObjects = new DisposableGameObject(Vector3.zero);
                var shape        = shapeObjects.AddComponent <Rectangle>();
                shape.Type      = Rectangle.RectangleType.RoundedHollow;
                shape.Width     = Random.Range(0.2f, 1.5f);
                shape.Height    = Random.Range(0.2f, 1.5f);
                shape.Color     = Random.ColorHSV();
                shape.Thickness = Random.Range(0.1f, 1.0f);

                shape.transform.localPosition = new Vector2(Random.Range(-5f, 5f), Random.Range(-5f, 5f));

                if (i % 100 == 0)
                {
                    Debug.Log(i);
                }
            }
            await UniTask.Delay(1000000000);
        }
Exemple #6
0
        private static async UniTask ExplosionTestElement()
        {
            using (var shapeObjects = new DisposableGameObject(Vector3.zero))
            {
                var shape = shapeObjects.AddComponent <Disc>();
                shape.Type      = Disc.DiscType.Ring;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Radius    = 0.3f;
                shape.Thickness = 0.1f;

                const float rangeMin = 1f;
                const float rangeMax = 3f;
                var         v        = Random.insideUnitCircle.normalized * Random.Range(rangeMin, rangeMax);

                const float duration      = 1f;
                const float eraseDuration = 0.5f;
                await Anime.Delay(0.5f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Easing.Create <OutExpo>(
                            new Vector3(v.x, v.y, 0f),
                            duration
                            ),
                        TranslateTo.LocalPosition(shape)
                        ),
                    Anime.Play(
                        Animator.Delay(duration - eraseDuration - 0.3f, Easing.Create <Linear>(1f, 0f, eraseDuration)),
                        TranslateTo.Action <float>(x =>
                {
                    var tmp     = shape.Color;
                    tmp.a       = x;
                    shape.Color = tmp;
                })
                        )
                    );
            }
        }