Пример #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);
            }
        }
Пример #2
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)
                );
        }
Пример #3
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;
                })
                        )
                    );
            }
        }