コード例 #1
0
        private void PrepareAnimationObject(GameObject obj)
        {
            RectTransform trs   = obj.GetComponent <RectTransform>();
            Image         image = obj.GetComponent <Image>();

            Vector3Animator             scaleAnimator  = obj.GetComponent <Vector3Animator>();
            ColorAnimator               colorAnimator  = obj.GetComponent <ColorAnimator>();
            BezierMover                 mover          = obj.GetComponent <BezierMover>();
            RectTransformPositionObject positionObject = obj.GetComponent <RectTransformPositionObject>();

            Vector3AnimationData scaleData = new Vector3AnimationData()
            {
                AnimationMode = BosAnimationMode.Single,
                Duration      = interval * 0.5f,
                EaseType      = EaseType.EaseInOutQuad,
                EndValue      = Vector3.one * 1.25f,
                Events        = null,
                StartValue    = Vector3.one,
                Target        = obj,
                OnStart       = (s, o) => trs.localScale = s,
                OnUpdate      = (s, t, o) => trs.localScale = s,
                OnEnd         = (s, o) => {
                    trs.localScale = s;

                    Vector3AnimationData scale2Data = new Vector3AnimationData()
                    {
                        StartValue = Vector3.one * 1.25f,
                        EndValue   = Vector3.one,
                        Duration   = interval * 0.5f,
                        EaseType   = EaseType.EaseInOutQuad,
                        Target     = obj,
                        OnStart    = (s2, o2) => trs.localScale = s2,
                        OnUpdate   = (s2, t2, o2) => trs.localScale = s2,
                        OnEnd      = (s2, o2) => trs.localScale = s2
                    };
                    scaleAnimator.StartAnimation(scale2Data);

                    ColorAnimationData colorData = new ColorAnimationData()
                    {
                        StartValue = Color.white,
                        EndValue   = new Color(1, 1, 1, 0.2f),
                        Duration   = interval * 0.5f,
                        EaseType   = EaseType.EaseInOutQuad,
                        Target     = obj,
                        OnStart    = (c2, o2) => image.color = c2,
                        OnUpdate   = (c2, t2, o2) => image.color = c2,
                        OnEnd      = (c2, o2) => image.color = c2
                    };

                    colorAnimator.StartAnimation(colorData);
                }
            };

            scaleAnimator.StartAnimation(scaleData);

            var bezierData = AnimUtils.GetBizerQuadData(positionObject,
                                                        startObject.anchoredPosition,
                                                        endObject.anchoredPosition,
                                                        interval * 1.1f, (go) => Destroy(go),
                                                        linerFactor,
                                                        orthoFactor);

            mover.Setup(bezierData);
        }
コード例 #2
0
        private IEnumerator EmitEffectImpl(GameObject prefab, int count, RectTransform startPoint, RectTransform endPoint, string rewardType, int rewardIndex)
        {
            float interval           = 1;
            float controlPointLength = 400;

            for (int i = 0; i < count; i++)
            {
                yield return(new WaitForSeconds(0.06f));

                GameObject    instance      = Instantiate <GameObject>(prefab);
                RectTransform rectTransform = instance.GetComponent <RectTransform>();
                rectTransform.SetParent(transform, false);
                rectTransform.anchoredPosition = startPoint.anchoredPosition;

                BezierMover mover      = instance.GetComponent <BezierMover>();
                BezierData  bezierData = null;
                Vector2     diff       = endPoint.anchoredPosition - startPoint.anchoredPosition;
                if (rewardType == "playercash")
                {
                    bezierData = new BezierData {
                        Interval = interval,
                        Type     = BezierType.Quadratic,
                        Target   = instance.GetComponent <RectTransformPositionObject>(),
                        Points   = new Vector3[] {
                            startPoint.anchoredPosition,
                            diff * 0.5f + diff.normalized.Orthogonal() * UnityEngine.Random.Range(-controlPointLength, 0),
                            endPoint.anchoredPosition
                        },
                        OnComplete = g => Destroy(g)
                    };
                }
                else if (rewardType == "companycash")
                {
                    bezierData = new BezierData {
                        Interval = interval,
                        Type     = BezierType.Quadratic,
                        Target   = instance.GetComponent <RectTransformPositionObject>(),
                        Points   = new Vector3[] {
                            startPoint.anchoredPosition,
                            diff * 0.5f + diff.normalized.Orthogonal() * UnityEngine.Random.Range(0, controlPointLength),
                            endPoint.anchoredPosition
                        },
                        OnComplete = g => Destroy(g)
                    };
                }
                else
                {
                    bezierData = new BezierData {
                        Interval = interval,
                        Type     = BezierType.Quadratic,
                        Target   = instance.GetComponent <RectTransformPositionObject>(),
                        Points   = new Vector3[] {
                            startPoint.anchoredPosition,
                            diff * 0.5f + diff.normalized.Orthogonal() * UnityEngine.Random.Range(-controlPointLength * 0.5f, controlPointLength * 0.5f),
                            endPoint.anchoredPosition
                        },
                        OnComplete = g => Destroy(g)
                    };
                }

                mover.Setup(bezierData);

                ColorAnimator colorAnimator = instance.GetComponent <ColorAnimator>();
                colorAnimator.StartAnimation(AnimUtils.GetColorAnimData(new Color(1, 1, 1, 1f), Color.white, 0.3f,
                                                                        EaseType.EaseInOutQuad, rectTransform, BosAnimationMode.Single, () => {
                    colorAnimator.StartAnimation(AnimUtils.GetColorAnimData(Color.white, new Color(1, 1, 1, 1f), 0.4f,
                                                                            EaseType.EaseInOutQuad, rectTransform,
                                                                            BosAnimationMode.Single, () => { }));
                }));

                Vector3Animator scaleAnimator = instance.GetComponent <Vector3Animator>();
                scaleAnimator.StartAnimation(new Vector3AnimationData {
                    AnimationMode = BosAnimationMode.PingPong,
                    Duration      = 0.2f,
                    EaseType      = EaseType.EaseInOutQuad,
                    StartValue    = new Vector3(1, 1, 1),
                    EndValue      = new Vector3(2f, 2f, 1),
                    Target        = instance,
                    OnStart       = rectTransform.UpdateScaleFunctor(),
                    OnUpdate      = rectTransform.UpdateScaleTimedFunctor(),
                    OnEnd         = rectTransform.UpdateScaleFunctor()
                });

                FloatAnimator rotationAnimator = instance.GetComponent <FloatAnimator>();
                rotationAnimator.StartAnimation(new FloatAnimationData {
                    Duration      = interval,
                    AnimationMode = BosAnimationMode.Single,
                    EaseType      = EaseType.Linear,
                    StartValue    = 0,
                    EndValue      = 720,
                    Target        = instance,
                    OnStart       = rectTransform.UpdateZRotation(),
                    OnUpdate      = rectTransform.UpdateZRotationTimed(),
                    OnEnd         = rectTransform.UpdateZRotation()
                });
            }

            yield return(new WaitForSeconds(interval - 0.1f));

            CompleteRewardIndex(rewardIndex);
        }