public static void CreateWorkEffect(Transform mechanic, GameObject effectPrefab) {
            GameObject inst = Instantiate<GameObject>(effectPrefab);
            RectTransform effectRect = inst.GetComponent<RectTransform>();
            effectRect.SetParent(mechanic.parent, false);
            effectRect.anchoredPosition = mechanic.GetComponent<RectTransform>().anchoredPosition + new Vector2(0, 120);

            var colorData = AnimUtils.GetColorAnimData(Color.white, Color.white.ChangeAlpha(0), 2, EaseType.EaseInOutQuad, effectRect);
            var rotateData = new FloatAnimationData {
                StartValue = -40,
                EndValue = 40,
                Duration = 0.5f,
                EaseType = EaseType.EaseInOutQuad,
                OnStart = effectRect.UpdateZRotation(),
                OnUpdate = effectRect.UpdateZRotationTimed(),
                OnEnd = effectRect.UpdateZRotation(),
                Target = inst,
                AnimationMode = BosAnimationMode.PingPong
            };
            var posData = new Vector2AnimationData {
                StartValue = effectRect.anchoredPosition,
                EndValue = effectRect.anchoredPosition + new Vector2(0, 250),
                Duration = 2,
                EaseType = EaseType.EaseInOutQuad,
                OnStart = effectRect.UpdatePositionFunctor(),
                OnUpdate = effectRect.UpdatePositionTimedFunctor(),
                OnEnd = effectRect.UpdatePositionFunctor()
            };
            inst.GetOrAdd<ColorAnimator>().StartAnimation(colorData);
            inst.GetOrAdd<FloatAnimator>().StartAnimation(rotateData);
            inst.GetOrAdd<Vector2Animator>().StartAnimation(posData);
            Destroy(inst, 2);
        }
        /*
         * private void AnimateTextScroll() {
         *  textScroll.verticalNormalizedPosition = 1;
         *  textScrollAnimator.StartAnimation(new FloatAnimationData {
         *      StartValue = 1,
         *      EndValue = 0,
         *      Duration = 1,
         *      EaseType = EaseType.Linear,
         *      Target = textScroll.gameObject,
         *      OnStart = (v, o) => textScroll.verticalNormalizedPosition = v,
         *      OnUpdate = (v, t, o) => textScroll.verticalNormalizedPosition = v,
         *      OnEnd = (v, o) => textScroll.verticalNormalizedPosition = v
         *  });
         * }*/

        private IEnumerator FadeInBack()
        {
            yield return(new WaitForEndOfFrame());

            ColorAnimator colorAnimator = back.gameObject.GetOrAdd <ColorAnimator>();
            var           colorData     = AnimUtils.GetColorAnimData(Color.black.ChangeAlpha(0), Color.black.ChangeAlpha(0.74f), .1f, EaseType.EaseInOutQuad, back.GetComponent <RectTransform>(), BosAnimationMode.Single, () => {
                StartCoroutine(ShowGirlImpl());
            });

            colorAnimator.StartAnimation(colorData);
        }
Beispiel #3
0
        public override void Setup(ViewData data)
        {
            base.Setup(data);

            ColorAnimator colorAnimator = background.gameObject.GetOrAdd <ColorAnimator>();

            colorAnimator.StartAnimation(
                AnimUtils.GetColorAnimData(
                    new Color(0, 0, 0, 0),
                    new Color(0, 0, 0, 0.83f),
                    0.3f,
                    EaseType.EaseInOutQuartic,
                    background.GetComponent <RectTransform>(),
                    BosAnimationMode.Single));
        }
Beispiel #4
0
        private IEnumerator ShowMoveTextFailImpl(UnofficialTransferCashInfo info)
        {
            yield return(new WaitForSeconds(interval));

            GameObject textPrefab   = Services.ResourceService.Prefabs.GetPrefab("movetext");
            GameObject textInstance = Instantiate(textPrefab);

            Text text = textInstance.GetComponent <Text>();

            text.text = $"-{BosUtils.GetCurrencyString(info.LooseValue.ToCurrencyNumber(), "", "")}";
            //text.SetAllDirty();

            RectTransform textTransform = textInstance.GetComponent <RectTransform>();

            textTransform.SetParent(transform, false);
            textTransform.anchoredPosition = endObject.anchoredPosition;
            textTransform.localScale       = new Vector3(2, 2, 1);
            Color startColor = Color.red;
            Color endColor   = Color.red.ChangeAlpha(0.1f);
            var   colorData  = AnimUtils.GetColorAnimData(startColor, endColor, 1.5f, EaseType.EaseOutQuintic,
                                                          textTransform, BosAnimationMode.Single,
                                                          () => { });
            var positionData = new Vector2AnimationData()
            {
                StartValue = textTransform.anchoredPosition,
                EndValue   = textTransform.anchoredPosition - new Vector2(0, 300),
                Duration   = 1.5f,
                EaseType   = EaseType.EaseOutQuintic,
                Target     = textInstance,
                OnStart    = (p, o) => textTransform.anchoredPosition = p,
                OnUpdate   = (p, t, o) => textTransform.anchoredPosition = p,
                OnEnd      = (p, o) => {
                    textTransform.anchoredPosition = p;
                    Destroy(textInstance);
                }
            };
            ColorAnimator   colorAnimator    = textInstance.GetComponent <ColorAnimator>();
            Vector2Animator positionAnimator = textInstance.GetComponent <Vector2Animator>();

            colorAnimator.StartAnimation(colorData);
            positionAnimator.StartAnimation(positionData);
            Sounds.PlayOneShot(SoundName.slotFail);
            ViewService.ShowDelayed(ViewType.TransferWarningView, 0.5f, new ViewData {
                ViewDepth = ViewService.NextViewDepth,
                UserData  = info.LooseValue
            });
            animObjects.Add(textInstance);
        }
Beispiel #5
0
 private void ToggleAdditionalObjects(bool isActive)
 {
     foreach (var obj in additionalMegaObjects)
     {
         if (isActive)
         {
             obj.Activate();
             ColorAnimator colorAnimator = obj.GetComponent <ColorAnimator>();
             colorAnimator?.StartAnimation(AnimUtils.GetColorAnimData(new Color(1, 1, 1, 0.5f), new Color(1, 1, 1, 0), 2,
                                                                      EaseType.EaseInOutQuad, obj.GetComponent <RectTransform>(), BosAnimationMode.PingPong));
         }
         else
         {
             obj.Deactivate();
         }
     }
 }
        private void MoveIn()
        {
            CanvasGroup canvasGroup = background.GetComponent <CanvasGroup>();

            panelColorAnimator.StartAnimation(AnimUtils.GetColorAnimData(panel.color.ChangeAlpha(0), panel.color.ChangeAlpha(.5f), .1f,
                                                                         EaseType.Linear, panel.GetComponent <RectTransform>(), BosAnimationMode.Single, () => {
                backAlphaAnimator.StartAnimation(new FloatAnimationData {
                    StartValue    = 0,
                    EndValue      = 1,
                    Duration      = 0.15f,
                    AnimationMode = BosAnimationMode.Single,
                    EaseType      = EaseType.EaseInOutQuad,
                    Target        = background.gameObject,
                    OnStart       = canvasGroup.UpdateAlphaFunctor(),
                    OnUpdate      = canvasGroup.UpdateAlphaTimedFunctor(),
                    OnEnd         = canvasGroup.UpdateAlphaFunctor()
                });
                backScaleAnimator.StartAnimation(background.ConstructScaleAnimationData(new Vector3(1.5f, 1.5f, 1), new Vector3(1, 1, 1), 0.15f,
                                                                                        BosAnimationMode.Single, EaseType.EaseInOutQuad));
            }));
        }
        private void MoveOut()
        {
            CanvasGroup canvasGroup = background.GetComponent <CanvasGroup>();

            backAlphaAnimator.StartAnimation(new FloatAnimationData {
                StartValue = 1,
                EndValue   = 0,
                Duration   = 0.1f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = background.gameObject,
                OnStart    = canvasGroup.UpdateAlphaFunctor(),
                OnUpdate   = canvasGroup.UpdateAlphaTimedFunctor(),
                OnEnd      = canvasGroup.UpdateAlphaFunctor(() => {
                    panelColorAnimator.StartAnimation(
                        AnimUtils.GetColorAnimData(
                            panel.color.ChangeAlpha(.5f),
                            panel.color.ChangeAlpha(0),
                            0.1f,
                            EaseType.EaseInOutQuad,
                            panel.GetComponent <RectTransform>()));
                })
            });
        }
Beispiel #8
0
        public void Setup(TutorialFingerData data)
        {
            Data = data;
            GetComponent <RectTransform>().anchoredPosition = data.Position;

            if (data.IsTooltipVisible)
            {
                tooltipParent.gameObject.Activate();
                tooltipText.text = data.TooltipText;
                SetupTooltipLayout(data);
                var colorData = AnimUtils.GetColorAnimData(tooltipText.color.ChangeAlpha(0), tooltipText.color, 0.3f, EaseType.EaseInOutQuad, tooltipText.GetComponent <RectTransform>(), BosAnimationMode.Single);
                tooltipText.gameObject.GetOrAdd <ColorAnimator>().StartAnimation(colorData);
            }
            else
            {
                tooltipParent.gameObject.Deactivate();
            }

            if (Data.Timeout > 0f)
            {
                StartCoroutine(RemoveAfterTimeout(Data.Timeout));
            }
        }
Beispiel #9
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);
        }