Пример #1
0
        private void PlayAnimation()
        {
            Vector3Animator fingerAnimator   = fingerTransform.gameObject.GetOrAdd <Vector3Animator>();
            var             fingerSecondData = fingerTransform.ConstructScaleAnimationData(0.7f * Vector3.one, Vector3.one, 1,
                                                                                           BosAnimationMode.Single,
                                                                                           EaseType.EaseInOutQuad, () => { });

            var fingerFirstData = fingerTransform.ConstructScaleAnimationData(Vector3.one, 0.7f * Vector3.one, 1,
                                                                              BosAnimationMode.Single,
                                                                              EaseType.EaseInOutQuad, () => {
                fingerAnimator.StartAnimation(fingerSecondData);
            });

            fingerAnimator.StartAnimation(fingerFirstData);

            Vector3Animator pointAnimator   = pointTransform.gameObject.GetOrAdd <Vector3Animator>();
            var             pointSecondData = pointTransform.ConstructScaleAnimationData(1.5f * Vector3.one, Vector3.one, 1,
                                                                                         BosAnimationMode.Single,
                                                                                         EaseType.EaseInOutQuad, () => { });

            var pointFirstData = pointTransform.ConstructScaleAnimationData(Vector3.one, 1.5f * Vector3.one, 1,
                                                                            BosAnimationMode.Single,
                                                                            EaseType.EaseInOutQuad, () => {
                pointAnimator.StartAnimation(pointSecondData);
            });

            pointAnimator.StartAnimation(pointFirstData);
            StartCoroutine(StartWaves());
        }
Пример #2
0
        public void ActivateTarget()
        {
            if (!IsActive)
            {
                image.enabled = true;
                IsActive      = true;
                Vector3Animator scaleAnimator = gameObject.GetOrAdd <Vector3Animator>();
                RectTransform   rts           = GetComponent <RectTransform>();

                Vector3AnimationData scaleData = new Vector3AnimationData {
                    StartValue = Vector3.one,
                    EndValue   = Vector3.one * 3,
                    Duration   = 0.25f,
                    EaseType   = EaseType.EaseOutSin,
                    Target     = gameObject,
                    OnStart    = (s, o) => rts.localScale = s,
                    OnUpdate   = (s, t, o) => rts.localScale = s,
                    OnEnd      = (s, o) => {
                        rts.localScale = s;
                        Vector3AnimationData scale2Data = new Vector3AnimationData {
                            StartValue = Vector3.one * 3,
                            EndValue   = Vector3.one,
                            Duration   = 0.25f,
                            EaseType   = EaseType.EaseInOutSin,
                            Target     = gameObject,
                            OnStart    = (s2, o2) => rts.localScale = s2,
                            OnUpdate   = (s2, t2, o2) => rts.localScale = s2,
                            OnEnd      = (s2, o2) => rts.localScale = s2
                        };
                        scaleAnimator.StartAnimation(scale2Data);
                    }
                };
                scaleAnimator.StartAnimation(scaleData);
            }
        }
Пример #3
0
        private void ScaleEffect()
        {
            Vector3Animator scaleAnimator = gameObject.GetOrAdd <Vector3Animator>();
            RectTransform   rectTransform = GetComponent <RectTransform>();

            scaleAnimator.StartAnimation(rectTransform.ConstructScaleAnimationData(Vector3.one, 0.85f * Vector3.one, 0.2f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => {
                scaleAnimator.StartAnimation(rectTransform.ConstructScaleAnimationData(0.85f * Vector3.one, Vector3.one, 0.2f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => { }));
            }));
        }
Пример #4
0
        private void CreateAccumulatedText(double val, bool isManual)
        {
            if (textPull.HasObject)
            {
                float duration = 1;                                                                            //isManual ? 0.6f : 0.3f;

                GameObject inst = textPull.UseAtPosition(new Vector2(UnityEngine.Random.Range(0, 330), -353)); //Instantiate(AccumulatedTextPrefab, transform, false);
                Text       txt  = inst.GetComponent <Text>();
                txt.text = val.ToCurrencyNumber().PrefixedAbbreviation();
                RectTransform textTrs = inst.GetComponent <RectTransform>();

                float finalDuration = duration + UnityEngine.Random.Range(-.2f, .2f);

                Vector2Animator vec2Animator = inst.GetComponent <Vector2Animator>();
                vec2Animator.StartAnimation(new Vector2AnimationData {
                    StartValue = textTrs.anchoredPosition,
                    EndValue   = textTrs.anchoredPosition + Vector2.down * 5 /* + Vector2.up * 60*/,
                    Duration   = finalDuration,
                    EaseType   = EaseType.EaseInOutQuad,
                    Target     = inst,
                    OnStart    = textTrs.UpdatePositionFunctor(),
                    OnUpdate   = textTrs.UpdatePositionTimedFunctor(),
                    OnEnd      = textTrs.UpdatePositionFunctor(() => textPull.Free(inst))
                });



                FloatAnimator alphaAnimator = inst.GetComponent <FloatAnimator>();
                CanvasGroup   cg            = inst.GetComponent <CanvasGroup>();
                alphaAnimator.Stop();
                cg.alpha = 1;
                alphaAnimator.StartAnimation(new FloatAnimationData {
                    Duration   = finalDuration * 1.5f,
                    EaseType   = EaseType.EaseInOutQuad,
                    StartValue = 1,
                    EndValue   = 0,
                    Target     = inst,
                    OnStart    = cg.UpdateAlphaFunctor(),
                    OnUpdate   = cg.UpdateAlphaTimedFunctor(),
                    OnEnd      = cg.UpdateAlphaFunctor()
                });

                Vector3Animator v3animator = inst.GetOrAdd <Vector3Animator>();
                v3animator.Stop();
                v3animator.StartAnimation(textTrs.ConstructScaleAnimationData(Vector3.one * .1f, Vector3.one, finalDuration * 0.5f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => {
                    v3animator.StartAnimation(textTrs.ConstructScaleAnimationData(Vector3.one, Vector3.one * .1f, finalDuration * 0.5f, BosAnimationMode.Single, EaseType.EaseInOutQuad));
                }));

                //ColorAnimator colorAnimator = inst.GetComponent<ColorAnimator>();

                //colorAnimator.StartAnimation(AnimUtils.GetColorAnimData(txt.color, txt.color.ChangeAlpha(0), finalDuration, EaseType.EaseInOutQuad, textTrs));
            }
        }
Пример #5
0
        private void AnimateCashText()
        {
            RectTransform   trs      = cashText.GetComponent <RectTransform>();
            Vector3Animator animator = cashText.GetComponent <Vector3Animator>();

            var thirdScale  = trs.ConstructScaleAnimationData(new Vector3(1.5f, 1.5f, 1), Vector3.one, 0.15f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => { });
            var secondScale = trs.ConstructScaleAnimationData(new Vector3(1, 1.5f, 1), new Vector3(1.5f, 1.5f, 1), 0.2f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => {
                animator.StartAnimation(thirdScale);
            });
            var firstScale = trs.ConstructScaleAnimationData(Vector3.one, new Vector3(1, 1.5f, 1), 0.2f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => {
                animator.StartAnimation(secondScale);
            });

            animator.StartAnimation(firstScale);
        }
Пример #6
0
        public void DeactivateTarget()
        {
            if (IsActive)
            {
                InactiveTimer = 0;
            }
            IsActive = false;
            Vector3Animator scaleAnimator = gameObject.GetOrAdd <Vector3Animator>();
            RectTransform   rts           = GetComponent <RectTransform>();

            Vector3AnimationData scaleData = new Vector3AnimationData {
                StartValue = Vector3.one * 1.5f,
                EndValue   = Vector3.one * 0.01f,
                Duration   = 0.4f,
                EaseType   = EaseType.EaseOutSin,
                Target     = gameObject,
                OnStart    = (s, o) => rts.localScale = s,
                OnUpdate   = (s, t, o) => rts.localScale = s,
                OnEnd      = (s, o) => {
                    rts.localScale = s;
                    image.enabled  = false;
                }
            };

            scaleAnimator.StartAnimation(scaleData);
        }
Пример #7
0
        public static GameObject MessageBoxAnimateOut(this RectTransform background, Action endAction = null)
        {
            CanvasGroup     canvasGroup   = background.gameObject.GetOrAdd <CanvasGroup>();
            FloatAnimator   floatAnimator = background.gameObject.GetOrAdd <FloatAnimator>();
            Vector3Animator scaleAnimator = background.gameObject.GetOrAdd <Vector3Animator>();

            floatAnimator.StartAnimation(new FloatAnimationData {
                StartValue = 1,
                EndValue   = 0,
                Duration   = .15f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = background.gameObject,
                OnStart    = canvasGroup.UpdateAlphaFunctor(),
                OnUpdate   = canvasGroup.UpdateAlphaTimedFunctor(),
                OnEnd      = canvasGroup.UpdateAlphaFunctor()
            });

            scaleAnimator.StartAnimation(
                background.ConstructScaleAnimationData(
                    startValue: new Vector3(1.0f, 1.0f, 1f),
                    endValue: Vector3.one * .5f,
                    duration: .15f,
                    mode: BosAnimationMode.Single,
                    easeType: EaseType.EaseInOutQuad,
                    endAction: () => endAction?.Invoke())
                );
            return(background.gameObject);
        }
Пример #8
0
        private IEnumerator MoveInPlaceImpl(MechanicAnimObject mechanicView, TempMechanicInfo info)
        {
            yield return(new WaitForSeconds(.2f));

            Vector3Animator scaleAnimator    = mechanicView.gameObject.GetOrAdd <Vector3Animator>();
            Vector2Animator positionAnimator = mechanicView.gameObject.GetOrAdd <Vector2Animator>();
            FloatAnimator   rotateAnimator   = mechanicView.gameObject.GetOrAdd <FloatAnimator>();

            RectTransform rectTransform = mechanicView.GetComponent <RectTransform>();

            Vector2 startPosition = rectTransform.anchoredPosition;
            Vector2 endPosition   = mechanicView.leftPosition;

            Vector2AnimationData positionData = new Vector2AnimationData {
                StartValue = startPosition,
                EndValue   = endPosition,
                Duration   = .3f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = rectTransform.UpdatePositionFunctor(),
                OnUpdate   = rectTransform.UpdatePositionTimedFunctor(),
                OnEnd      = rectTransform.UpdatePositionFunctor(() => {
                    Debug.Log($"setup temp mechanic on state => {info.State}");
                    mechanicView.Setup(info);
                    mechanicViews.Add(mechanicView.TempMechanic.Id, mechanicView);
                    animatedViews.Remove(mechanicView.TempMechanic.Id);
                })
            };
            Vector3AnimationData scaleData = new Vector3AnimationData {
                StartValue = 2f * Vector3.one,
                EndValue   = Vector3.one,
                Duration   = .3f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = rectTransform.UpdateScaleFunctor(),
                OnUpdate   = rectTransform.UpdateScaleTimedFunctor(),
                OnEnd      = rectTransform.UpdateScaleFunctor()
            };

            FloatAnimationData rotateData = new FloatAnimationData {
                StartValue = rectTransform.localRotation.eulerAngles.z,
                EndValue   = 0,
                Duration   = .3f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = rectTransform.UpdateZRotation(),
                OnUpdate   = rectTransform.UpdateZRotationTimed(),
                OnEnd      = rectTransform.UpdateZRotation()
            };

            positionAnimator.StartAnimation(positionData);
            scaleAnimator.StartAnimation(scaleData);
            rotateAnimator.StartAnimation(rotateData);
        }
Пример #9
0
        private IEnumerator StartWaveImpl()
        {
            yield return(new WaitUntil(() => IsAvailable));

            rectTransform.localScale = Vector3.one;
            image.color   = Color.white;
            image.enabled = true;

            isScaleCompleted = false;
            isColorCompleted = false;
            IsAvailable      = false;
            var scaleData = new Vector3AnimationData {
                StartValue    = Vector3.one,
                EndValue      = endScale * Vector3.one,
                AnimationMode = BosAnimationMode.Single,
                Duration      = interval,
                EaseType      = EaseType.EaseInOutQuad,
                Target        = rectTransform.gameObject,
                OnStart       = (s, o) => { rectTransform.localScale = s; },
                OnUpdate      = (s, t, o) => { rectTransform.localScale = s; },
                OnEnd         = (s, o) => {
                    rectTransform.localScale = s;
                    isScaleCompleted         = true;
                },
                Events = new List <AnimationEvent <Vector3> > {
                    new AnimationEvent <Vector3>()
                    {
                        Mode    = AnimationEventMode.Single,
                        IsValid = (s, t, o) => t >= 0.5f,
                        OnEvent = (s, t, o) => {
                            var colorData = new ColorAnimationData {
                                StartValue    = Color.white,
                                EndValue      = Color.white.ChangeAlpha(0),
                                AnimationMode = BosAnimationMode.Single,
                                Duration      = interval * (1f - t),
                                EaseType      = EaseType.EaseInOutQuad,
                                Target        = image.gameObject,
                                OnStart       = image.UpdateColorFunctor(),
                                OnUpdate      = image.UpdateColorTimedFunctor(),
                                OnEnd         = image.UpdateColorFunctor(() => {
                                    isColorCompleted = true;
                                    StartCoroutine(EndWaveImpl());
                                })
                            };
                            colorAnimator.StartAnimation(colorData);
                        }
                    }
                }
            };

            scaleAnimator.StartAnimation(scaleData);
        }
Пример #10
0
        private void SpawnCoinObject(int coin)
        {
            GameObject coinObject = Instantiate <GameObject>(coinPrefab);
            var        coinView   = coinObject.GetComponent <SplitLinerCoin>();

            coinView.CoinText.text = $"+{coin}";

            RectTransform coinRectTransform = coinObject.GetComponent <RectTransform>();

            coinRectTransform.SetParent(canvasTransform, false);

            coinRectTransform.anchoredPosition = Services?.ViewService.Utils.WorldPosToCanvasPos(Camera.main, canvas, playerTransform.position) ?? Vector2.zero;

            FloatAnimator   floatAnimator = coinObject.GetComponent <FloatAnimator>();
            Vector3Animator vec3Animator  = coinObject.GetComponent <Vector3Animator>();

            CanvasGroup canvasGroup = coinObject.GetComponent <CanvasGroup>();

            FloatAnimationData alphaAnimData = new FloatAnimationData {
                StartValue    = 1,
                EndValue      = 0,
                Duration      = 0.4f,
                AnimationMode = BosAnimationMode.Single,
                EaseType      = EaseType.EaseInOutQuad,
                Target        = coinObject,
                OnStart       = (v, o) => canvasGroup.alpha = v,
                OnUpdate      = (v, t, o) => canvasGroup.alpha = v,
                OnEnd         = (v, o) => {
                    canvasGroup.alpha = v;
                    Destroy(coinObject);
                }
            };

            Vector3AnimationData scaleAnimData = new Vector3AnimationData {
                StartValue    = Vector3.one,
                EndValue      = 1.4f * Vector3.one,
                Duration      = 0.3f,
                AnimationMode = BosAnimationMode.Single,
                EaseType      = EaseType.EaseInOutQuad,
                Target        = coinObject,
                OnStart       = (s, o) => coinRectTransform.localScale = s,
                OnUpdate      = (s, t, o) => coinRectTransform.localScale = s,
                OnEnd         = (s, o) => {
                    coinRectTransform.localScale = s;
                    floatAnimator.StartAnimation(alphaAnimData);
                }
            };

            vec3Animator.StartAnimation(scaleAnimData);
        }
Пример #11
0
        private void SpawnPercentText(int count)
        {
            GameObject    textInstance      = Instantiate <GameObject>(percentPrefab);
            RectTransform textRectTransform = textInstance.GetComponent <RectTransform>();

            textRectTransform.SetParent(canvasTransform, false);

            textRectTransform.anchoredPosition = Services?.ViewService.Utils.WorldPosToCanvasPos(Camera.main, canvas, playerTransform.position) ?? Vector2.zero;

            TMPro.TextMeshProUGUI txt = textRectTransform.GetComponent <TMPro.TextMeshProUGUI>();
            txt.text = $"+{count}%";

            FloatAnimator   floatAnimator = txt.GetComponent <FloatAnimator>();
            Vector3Animator vec3Animator  = txt.GetComponent <Vector3Animator>();

            FloatAnimationData alphaAnimData = new FloatAnimationData {
                StartValue    = 1,
                EndValue      = 0,
                Duration      = 0.4f,
                AnimationMode = BosAnimationMode.Single,
                EaseType      = EaseType.EaseInOutQuad,
                Target        = textRectTransform.gameObject,
                OnStart       = (a, o) => {
                    txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, a);
                },
                OnUpdate = (a, t, o) => txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, a),
                OnEnd    = (a, o) => {
                    txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, a);
                    Destroy(textRectTransform.gameObject);
                }
            };

            Vector3AnimationData scaleAnimData = new Vector3AnimationData {
                StartValue    = Vector3.one,
                EndValue      = 1.4f * Vector3.one,
                Duration      = 0.3f,
                AnimationMode = BosAnimationMode.Single,
                EaseType      = EaseType.EaseInOutQuad,
                Target        = textRectTransform.gameObject,
                OnStart       = (s, o) => textRectTransform.localScale = s,
                OnUpdate      = (s, t, o) => textRectTransform.localScale = s,
                OnEnd         = (s, o) => {
                    textRectTransform.localScale = s;
                    floatAnimator.StartAnimation(alphaAnimData);
                }
            };

            vec3Animator.StartAnimation(scaleAnimData);
        }
Пример #12
0
        private void Animate()
        {
            Vector3Animator animator = gameObject.GetOrAdd <Vector3Animator>();

            animator.Stop();

            animator.StartAnimation(new Vector3AnimationData {
                StartValue    = startValue,
                EndValue      = endValue,
                Duration      = duration,
                EaseType      = easeType,
                AnimationMode = mode,
                Target        = gameObject,
                OnStart       = rectTransform.UpdateScaleFunctor(),
                OnUpdate      = rectTransform.UpdateScaleTimedFunctor(),
                OnEnd         = rectTransform.UpdateScaleFunctor()
            });
        }
        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));
            }));
        }
Пример #14
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);
        }
Пример #15
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);
        }
Пример #16
0
        public void Setup(int generatorId)
        {
            textPull.Setup(10, AccumulatedTextPrefab, transform);

            generator = Services.GenerationService.Generators.GetGeneratorInfo(generatorId);
            updateProfitTimer.Setup(0.3f, (delta) => {
                UpdateProfitValues();
            }, true);

            updateBuyGeneratorCountControls.Setup(0.5f, (deltaTime) => {
                if (generatorCountButton.State == GeneratorButtonState.MAX)
                {
                    UpdateBuyGeneratorControls(generatorCountButton.GetBuyInfo());
                }
            });

            generatorCountButton.Setup(generatorId);
            UpdateBuyGeneratorControls(generatorCountButton.GetBuyInfo());
            UpdateGeneratorLevelProgress();
            buyManagerButton.SetListener(() => {
                Services.ViewService.Show(ViewType.ManagementView, new ViewData()
                {
                    UserData = generator.GeneratorId
                });
                Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
            });

            //disable buy manager button for planet transport
            if (generator.Data.Type == GeneratorType.Planet)
            {
                buyManagerButton.interactable = false;
                buyManagerButton.Deactivate();
            }

            updateBuyManagerTimer.Setup(1.0f, (delta) => {
                UpdateBuyManagerButton();
            }, true);

            Vector3Animator buyButtonAnimator = buyGeneratorButton.gameObject.GetOrAdd <Vector3Animator>();

            buyGeneratorButton.SetListener(() => {
                if (generator.IsGenerationStarted)
                {
                    generator.ForceFinalization();
                }
                if (Services.GenerationService.BuyGenerator(generator, generatorCountButton.GetBuyInfo().Count) > 0)
                {
                    UpdateGeneratorLevelProgress();
                    UpdateBuyGeneratorControls(generatorCountButton.GetBuyInfo());
                }
                buyGeneratorParticlesTrigger.TriggerAnimation();
                Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);
                buyButtonAnimator.StartAnimation(BuyGeneratorButtonAnimationData);
            });

            generateButton.SetListener(() => {
                if (generator.IsManual)
                {
                    if (!generator.IsGenerationStarted)
                    {
                        generator.StartGeneration();
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
                        if (generator.IsEnhanced)
                        {
                            enhancedParticles.Activate();
                        }
                        GameEvents.OnTutorialEvent(new TutorialEventData(TutorialEventName.GenerationButtonClicked, generatorId));
                    }
                }
            });

            if (IsAlwaysProgressFull)
            {
                progressImage.fillAmount = 1;
                //isAccumulationStarted = true;
                generator.SetGenerationStarted(true);
            }
            else
            {
                progressImage.fillAmount = 0;
                if (generator.IsAutomatic)
                {
                    generator.SetGenerationStarted(true);
                    //isAccumulationStarted = true;
                }
            }

            UpdateUnitCountText();

            /*
             * if(generator.Data.Type == GeneratorType.Planet ) {
             *  PlanetNameData planetNameData =
             *      Services.ResourceService.PlanetNameRepository.GetPlanetNameData(
             *          generator.PlanetId);
             *  nameText.text = Services.ResourceService.Localization.GetString(
             *      planetNameData.name);
             * } else {
             *  nameText.text = Services.ResourceService.Localization.GetString(generator.Data.Name);
             * }*/
            //var generatorLocalData = Services.res

            Services.ViewService.Utils.ApplyGeneratorName(nameText, generator);

            UpdateGeneratorLevelProgress();

            UpdateEnhancementViews(generator);
            UpdateAutomaticParticles();

            var soundService = Services.SoundService;

            enhanceButton.SetListener(() => {
                if (generator.Data.Type == GeneratorType.Normal)
                {
                    StartEnhance();
                    soundService.PlayOneShot(SoundName.click);
                }
            });
            UpdateTimerText(generator.RemainTime);

            //make automatic planet transport and hire manager
            if (generator.IsManual && generator.Data.Type == GeneratorType.Planet)
            {
                Services.GetService <IManagerService>().Hire(generator.GeneratorId);
                Services.GetService <IGenerationService>().Generators.SetAutomatic(generator.GeneratorId, true);
            }

            UpdateGeneratorIcon();
            UpdateManagerIcon();
            UpdateMegaObject();

            automaticParticlesUpdater.Setup(2, (dt) => UpdateAutomaticParticles(), true);

            if (generator.Data.Type == GeneratorType.Normal)
            {
                UpdateReportObject(Services.SecretaryService.GetReportCount(generator.GeneratorId));
                UpdateToolObject(Services.TransportService.GetUnitBrokenedCount(generator.GeneratorId));
                if (reportButton != null)
                {
                    reportButton.OnClickAsObservable().Subscribe(_ => {
                        ShowManagementView();
                    }).AddTo(gameObject);
                }
                if (toolButton != null)
                {
                    toolButton.OnClickAsObservable().Subscribe(_ => {
                        ShowManagementView();
                    }).AddTo(gameObject);
                }
            }
        }
Пример #17
0
        private void AnimateAuditorObject(SecretaryAnimObject mechanicView, Auditor info)
        {
            Vector3Animator scaleAnimator    = mechanicView.gameObject.GetOrAdd <Vector3Animator>();
            Vector2Animator positionAnimator = mechanicView.gameObject.GetOrAdd <Vector2Animator>();
            ColorAnimator   colorAnimator    = mechanicView.gameObject.GetOrAdd <ColorAnimator>();
            FloatAnimator   rotateAnimator   = mechanicView.gameObject.GetOrAdd <FloatAnimator>();


            RectTransform rectTransform = mechanicView.GetComponent <RectTransform>();
            Image         image         = mechanicView.GetComponent <Image>();

            Vector2 endOffset = Random.insideUnitCircle.normalized * 300;

            if (endOffset.y < 0)
            {
                endOffset.y = -endOffset.y;
            }
            Vector2 startPosition = buyButton.GetComponent <RectTransform>().anchoredPosition;
            Vector2 endPosition   = startPosition + endOffset;

            Vector2AnimationData positionData = new Vector2AnimationData {
                StartValue = startPosition,
                EndValue   = endPosition,
                Duration   = 0.3f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = rectTransform.UpdatePositionFunctor(),
                OnUpdate   = rectTransform.UpdatePositionTimedFunctor(),
                OnEnd      = rectTransform.UpdatePositionFunctor(() => {
                    StartCoroutine(MoveInPlaceImpl(mechanicView, info));
                })
            };

            Vector3AnimationData scaleData = new Vector3AnimationData {
                StartValue = Vector3.one,
                EndValue   = 2f * Vector3.one,
                Duration   = .3f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = rectTransform.UpdateScaleFunctor(),
                OnUpdate   = rectTransform.UpdateScaleTimedFunctor(),
                OnEnd      = rectTransform.UpdateScaleFunctor()
            };

            ColorAnimationData colorData = new ColorAnimationData {
                StartValue = new Color(1, 1, 1, 0),
                EndValue   = new Color(1, 1, 1, 1),
                Duration   = .1f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = image.UpdateColorFunctor(),
                OnUpdate   = image.UpdateColorTimedFunctor(),
                OnEnd      = image.UpdateColorFunctor()
            };

            FloatAnimationData rotateData = new FloatAnimationData {
                StartValue = 0,
                EndValue   = Random.Range(-40, 40),
                Duration   = .3f,
                EaseType   = EaseType.EaseInOutQuad,
                Target     = mechanicView.gameObject,
                OnStart    = rectTransform.UpdateZRotation(),
                OnUpdate   = rectTransform.UpdateZRotationTimed(),
                OnEnd      = rectTransform.UpdateZRotation()
            };

            positionAnimator.StartAnimation(positionData);
            scaleAnimator.StartAnimation(scaleData);
            colorAnimator.StartAnimation(colorData);
            rotateAnimator.StartAnimation(rotateData);
        }