Beispiel #1
0
        private async UniTask CircleTest()
        {
            using (var shapeObjects = new DisposableGameObjectList(new[]
            {
                new Vector3(0f, 3f, 0f),
                new Vector3(0f, 3f, 0f),
                new Vector3(0f, 3f, 0f)
            }))
            {
                var shapes = shapeObjects.AddComponent <Disc>().Select(shape =>
                {
                    shape.Type      = Disc.DiscType.Ring;
                    shape.Color     = new Color32(255, 242, 173, 255);
                    shape.Radius    = 0.3f;
                    shape.Thickness = 0.1f;
                    return(shape);
                }).ToArray();

                await Anime.Delay(1f);

                await UniTask.WhenAll(
                    CircleTestElement(shapes[0], 0.0f),
                    CircleTestElement(shapes[1], 0.2f),
                    CircleTestElement(shapes[2], 0.4f)
                    );
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        private async UniTask CircleTestElement(Component go, float delay)
        {
            await Anime.Delay(delay);

            await Anime.Play(
                Animator.Convert(Easing.Create <OutCubic>(0.0f, Mathf.PI * 2.0f, 2f),
                                 x => new Vector3(Mathf.Sin(x), Mathf.Cos(x), 0.0f) * 3.0f),
                TranslateTo.LocalPosition(go)
                );
        }
Beispiel #4
0
        private async Task CircleAnimation(GameObject go, float delay)
        {
            await Anime.Delay(delay);

            await Anime.Play(
                Easing.Create <OutCubic>(0.0f, Mathf.PI * 2.0f, 2f),
                TranslateTo.Action <float>(x =>
            {
                var p = new Vector3(Mathf.Sin(x), Mathf.Cos(x), 0.0f) * 3.0f;
                go.transform.localPosition = p;
            }));
        }
Beispiel #5
0
        public async Task Sample01()
        {
            using (var cubes = new SampleCubes(new Vector3(-5f, 0f, 0f)))
            {
                await Anime.Delay(1f);

                await Anime.PlayTo(
                    Easing.Create <OutCubic>(new Vector3(5f, 0f, 0f), 2f),
                    TranslateTo.LocalPosition(cubes[0])
                    );

                await Anime.Delay(1f);
            }
        }
Beispiel #6
0
        public async Task Sample02()
        {
            using (var cubes = new SampleCubes(new Vector3(0f, 3f, 0f), new Vector3(0f, 3f, 0f), new Vector3(0f, 3f, 0f)))
            {
                await Anime.Delay(1f);

                await Task.WhenAll(
                    CircleAnimation(cubes[0], 0.0f),
                    CircleAnimation(cubes[1], 0.2f),
                    CircleAnimation(cubes[2], 0.4f)
                    );

                await Anime.Delay(1f);
            }
        }
Beispiel #7
0
        public async Task Sample03()
        {
            using (var cubes = new SampleCubes(new Vector3(-5f, 0f, 0f)))
            {
                await Anime.Delay(1f);

                CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
                cancellationTokenSource.Token.Register(() => Debug.Log("Cancel"));
                cancellationTokenSource.CancelAfter(500);

                await Anime.PlayTo(
                    Easing.Create <OutCubic>(new Vector3(5f, 0f, 0f), 2f),
                    TranslateTo.LocalPosition(cubes[0]),
                    cancellationTokenSource.Token
                    );

                await Anime.Delay(1f);
            }
        }
Beispiel #8
0
        public async Task Sample04()
        {
            using (var cubes = new SampleCubes(new Vector3(-5f, 0f, 0f)))
            {
                await Anime.Delay(1f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Moving.Linear(2f, 2f),
                        TranslateTo.LocalPositionX(cubes[0])
                        ),
                    Anime.PlayTo(
                        Animator.Delay(1.8f, Easing.Create <Linear>(Vector2.zero, 0.2f)),
                        TranslateTo.LocalScale(cubes[0])
                        )
                    );

                await Anime.Delay(1f);
            }
        }
Beispiel #9
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);
            }
        }
Beispiel #10
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;
                })
                        )
                    );
            }
        }
Beispiel #11
0
        private static async UniTask Tweet1()
        {
            using (var shapeObjects = new DisposableGameObjectList(new[]
            {
                new Vector3(-5f, 0f),
                new Vector3(-2.5f, 0f),
                new Vector3(0.0f, 0f),
                new Vector3(2.5f, 0f),
                new Vector3(5f, 0f),
            }))

            {
                var shapes = shapeObjects.GameObjects.Select(x =>
                {
                    var shape              = x.AddComponent <Rectangle>();
                    shape.Type             = Rectangle.RectangleType.RoundedHollow;
                    shape.Width            = 1f;
                    shape.Height           = 1f;
                    shape.Color            = new Color32(255, 242, 173, 0);
                    shape.Thickness        = 0f;
                    shape.CornerRadiusMode = Rectangle.RectangleCornerRadiusMode.PerCorner;
                    shape.CornerRadiii     = Vector4.zero;
                    return(shape);
                }).ToArray();

                async UniTask Anime1(Rectangle shape, int index)
                {
                    await Anime.Delay(index * 0.2f);

                    await UniTask.WhenAll(
                        Anime.Play(
                            Easing.Create <OutSine>(0f, 0.15f, 0.5f),
                            TranslateTo.Action <float>(x => shape.Thickness = x)
                            ),
                        Anime.Play(
                            Easing.Create <OutSine>(0f, 1f, 0.1f),
                            TranslateTo.Action <float>(x =>
                    {
                        var tmp     = shape.Color;
                        tmp.a       = x;
                        shape.Color = tmp;
                    })
                            )
                        );

                    await Anime.Delay(0.5f);

                    for (var i = 0; i < 4; ++i)
                    {
                        const float duration = 0.3f;
                        await Anime.Play(
                            Easing.Create <InOutCubic>(0f, 0.5f, duration),
                            TranslateTo.Action <float>(x =>
                        {
                            var tmp = shape.CornerRadiii;
                            tmp[(i + index) % 4] = x;
                            shape.CornerRadiii   = tmp;
                        })
                            );

                        var tmp2 = shape.CornerRadiii;
                        tmp2[(i + index) % 4] = 100;
                        shape.CornerRadiii    = tmp2;
                    }
                }

                async UniTask Anime2(Rectangle shape, int index)
                {
                    const float duration = 1f;
                    await UniTask.WhenAll(
                        Anime.PlayTo(
                            Easing.Create <InOutExpo>(0f, duration),
                            TranslateTo.LocalPositionX(shape.gameObject)
                            )
                        );

                    if (index != 0)
                    {
                        await UniTask.WhenAll(
                            Anime.Play(
                                Easing.Create <OutSine>(1f, 0f, 0.1f),
                                TranslateTo.Action <float>(x =>
                        {
                            var tmp     = shape.Color;
                            tmp.a       = x;
                            shape.Color = tmp;
                        })
                                )
                            );
                    }
                }

                async UniTask Anime3(Rectangle shape)
                {
                    await Anime.Play(
                        Easing.Create <InOutExpo>(0.5f, 0f, 0.5f),
                        TranslateTo.Action <float>(x => shape.CornerRadiii = Vector4.one *x)
                        );

                    await Anime.Play(
                        Easing.Create <InOutExpo>(0f, -20f, 0.5f),
                        TranslateTo.Action <float>(x => shape.transform.localRotation = Quaternion.Euler(0f, 0f, x))
                        );

                    await Anime.Play(
                        Easing.Create <InCubic>(0f, -7f, 0.5f),
                        TranslateTo.LocalPositionY(shape.gameObject)
                        );
                }

                await UniTask.WhenAll(shapes.Select((x, i) => Anime1(x, i)));

                await Anime.Delay(0.25f);

                await UniTask.WhenAll(shapes.Select((x, i) => Anime2(x, i)));
                await Anime3(shapes[0]);

                await Anime.Delay(0.5f);
            }
        }