public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ   = _target.GetTarget <object>(arg);
            var source = _source.GetTarget <object>(arg);

            var twn = SPTween.Tween(targ)
                      .TweenWithToken(_mode, EaseMethods.GetEase(_ease), _duration.Seconds, source, _sourceAlt)
                      .Use(_duration.TimeSupplier)
                      .SetId(targ);

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true, _tweenToken);
            return(true);
        }
예제 #2
0
        public override bool Trigger(object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var twn = SPTween.Tween(_target);

            for (int i = 0; i < _data.Length; i++)
            {
                twn.ByAnimMode(_data[i].Mode, _data[i].MemberName, EaseMethods.GetEase(_data[i].Ease), _data[i].ValueS.Value, _data[i].Duration, _data[i].ValueE.Value);
            }
            twn.Use(_timeSupplier.TimeSupplier);
            twn.SetId(_target);

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger());
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger());
            }

            twn.Play(true, _tweenToken);
            return(true);
        }
예제 #3
0
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = _target.GetTarget <Transform>(arg);

            if (targ == null)
            {
                return(false);
            }

            //var curve = new WaypointPathTweenCurve("position", EaseMethods.GetEase(this._ease), _path.Path.GetArcLength() / this._speed, _path.Path);
            var curve = new AdvancedWaypointPathTweenCurve(EaseMethods.GetEase(this._ease), _path.Path.GetArcLength() / this._speed, _path)
            {
                UpdateTranslation = _updateTranslation,
                UpdateRotation    = _updateRotation
            };

            if (_updateModifierTypes != null && _updateModifierTypes.Length > 0)
            {
                for (int i = 0; i < _updateModifierTypes.Length; i++)
                {
                    var tp = _updateModifierTypes[i].Type;
                    if (tp != null)
                    {
                        curve.AddNodeModifierType(tp);
                    }
                }
            }

            var tween = SPTween.Tween(targ)
                        .UseCurve(curve)
                        .Wrap(this._wrapMode, ((DiscreteFloat.IsInfinity(this._wrapCount)) ? 0 : Mathf.RoundToInt(this._wrapCount)))
                        .Use(this._updateType)
                        .Use(_timeSupplier.TimeSupplier)
                        .Reverse(this._reverse)
                        .OnFinish(this.OnFinishHandler)
                        .Play(false);

            if (this._stopMovementOnDisable)
            {
                if (_activeTweens == null)
                {
                    _activeTweens = new HashSet <Tweener>();
                }
                _activeTweens.Add(tween);
            }

            return(true);
        }
예제 #4
0
    IEnumerator MoveToNewPositionRoutine(Vector2Int newPosition)
    {
        GameController._gameController._isMovingBubbles = true;
        _positionOnGrid = newPosition;
        Vector2 startingPosition  = transform.position;
        Vector2 finishingPosition = new Vector2(transform.position.x, newPosition.y * GameController._yDistanceBetweenCircles);

        for (float i = 0; i < 1; i += Time.fixedDeltaTime * 2)
        {
            transform.position = EaseMethods.EaseVector2(EaseMethods.GetEase(EaseStyle.BackEaseInOut), startingPosition, finishingPosition, i, 1);
            yield return(new WaitForFixedUpdate());
        }
        transform.position = finishingPosition;
        GameController._gameController._isMovingBubbles = false;
    }
예제 #5
0
    void Start()
    {
        SeasonText.text = "Winter";
        //isSummer = ArcticController.Instance.visits % 2 == 0;
        isSummer = false;
        var srs = GetComponentsInChildren <SpriteRenderer>();

        (summerSR, winterSR) = (srs[0], srs[1]);

        // init fade funcs
        fadeIn  = (float step, float dur) => EaseMethods.CubicEaseOut(step, 0, 1, dur);
        fadeOut = (float step, float dur) => EaseMethods.CubicEaseIn(dur - step, 0, 1, dur);

        //Invoke("ChangeSeasons", dayDuration);
        StartCoroutine(ChangeSeasons(dayDuration));
    }
예제 #6
0
    void UpdateMovingBubbles()
    {
        float stepSize = Time.fixedDeltaTime * 5;

        for (int i = 0; i < _movingBubbles.Count; i++)
        {
            _movingBubbles[i].SetTime(_movingBubbles[i].time + stepSize);
            _movingBubbles[i].bubble.transform.position = EaseMethods.EaseVector3(EaseMethods.GetEase(EaseStyle.LinearEaseInOut), _movingBubbles[i].origin, _movingBubbles[i].objective, _movingBubbles[i].time, 1);
            if (_movingBubbles[i].time + stepSize > 1 || Mathf.Abs(Vector3.Distance(_movingBubbles[i].bubble.transform.position, _movingBubbles[i].objective)) < 0.05f)
            {
                _movingBubbles[i].bubble.transform.position = _movingBubbles[i].objective;
                Destroy(_movingBubbles[i].bubble.gameObject);
                _movingBubbles.Remove(_movingBubbles[i]);
            }
        }
    }
예제 #7
0
    IEnumerator PushRoutine(Vector3 origin)
    {
        Vector2 startingPosition  = transform.position;
        Vector2 finishingPosition = transform.position + ((transform.position - origin).normalized) * 0.2f;

        for (float i = 0; i < 0.2f; i += Time.fixedDeltaTime * 2)
        {
            transform.position = EaseMethods.EaseVector2(EaseMethods.GetEase(EaseStyle.SineEaseOut), startingPosition, finishingPosition, i, 0.2f);
            yield return(new WaitForFixedUpdate());
        }
        for (float i = 0; i < 0.2f; i += Time.fixedDeltaTime * 2)
        {
            transform.position = EaseMethods.EaseVector2(EaseMethods.GetEase(EaseStyle.SineEaseInOut), finishingPosition, startingPosition, i, 0.2f);
            yield return(new WaitForFixedUpdate());
        }
        transform.position = startingPosition;
    }
        public override bool Trigger(object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            switch (_mode)
            {
            case TweenHash.AnimMode.To:
                _transition.Values[0].Value = _transition.GetValue();
                break;

            case TweenHash.AnimMode.From:
                _transition.Values[_transition.Values.Count - 1].Value = _transition.GetValue();
                break;
            }

            var twn = SPTween.Tween(_transition)
                      .FromTo("Position", 0f, 1f, _duration)
                      .SetId(this.AutoKillId)
                      .Use(_timeSupplier.TimeSupplier)
                      .Ease(EaseMethods.GetEase(_ease));

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true);

            return(true);
        }
예제 #9
0
    /// <summary> expands and collapses bubble </summary>
    IEnumerator Bubble(bool entering, float dur, Vector2 pos = default(Vector2))
    {
        active = entering;
        if (entering)
        {
            bubble.SetActive(true);
        }
        for (var(start, step) = (Time.time, 0f); step < dur; step = Time.time - start)
        {
            yield return(null);

            float scale = entering ?
                          EaseMethods.CubicEaseOut(step / dur, minSize, size, size) :
                          EaseMethods.CubicEaseIn(1 - step / dur, minSize, size, size);
            bubble.transform.localScale = scale * Vector3.one;
            col.radius = scale / size * 7 + 3;
            // bubble.transform.localPosition = entering ? Vector3.Lerp(transform.position, startPos, step / dur) : Vector3.Lerp(startPos, transform.position, step / dur);
        }
        if (!entering)
        {
            bubble.SetActive(false);
        }
    }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var target = _target.GetTarget <UnityEngine.Object>(arg);

            if (target == null)
            {
                return(false);
            }

            var twn = SPTween.Tween(target);

            for (int i = 0; i < _data.Length; i++)
            {
                twn.ByAnimMode(_data[i].Mode, _data[i].MemberName, EaseMethods.GetEase(_data[i].Ease), _data[i].Duration, _data[i].ValueS.Value, _data[i].ValueE.Value, _data[i].Option);
            }
            twn.Use(_timeSupplier.TimeSupplier);
            twn.SetId(target);

            if (_onComplete?.HasReceivers ?? false)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick?.HasReceivers ?? false)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true, _tweenToken);
            return(true);
        }
예제 #11
0
    IEnumerator ShootBubbleRoutine(Vector2Int position, bool hasOffset)
    {
        _isShooting = true;

        //Shoot bubble to position
        Vector2 startingPosition  = _currentBubble.transform.position;
        Vector2 finishingPosition = new Vector2(position.x + (hasOffset ? 0.5f : 0), position.y * GameController._yDistanceBetweenCircles);

        Vector3 arrowMidPoint               = arrow.GetPosition(1);
        float   lengthOfFirstSegment        = Vector3.Distance(arrow.GetPosition(0), arrow.GetPosition(1));
        float   lengthOfSecondSegment       = Vector3.Distance(arrow.GetPosition(1), finishingPosition);
        float   timeToCompleteFirstSegment  = lengthOfFirstSegment / (lengthOfFirstSegment + lengthOfSecondSegment);
        float   timeToCompleteSecondSegment = 1 - timeToCompleteFirstSegment;

        float stepSize = Time.fixedDeltaTime * 5;

        for (float i = 0; i < timeToCompleteFirstSegment; i += stepSize)
        {
            _currentBubble.transform.position = EaseMethods.EaseVector2(EaseMethods.GetEase(EaseStyle.LinearEaseInOut), startingPosition, arrowMidPoint, i, timeToCompleteFirstSegment);
            yield return(new WaitForFixedUpdate());
        }
        for (float i = 0; i < timeToCompleteSecondSegment; i += stepSize)
        {
            _currentBubble.transform.position = EaseMethods.EaseVector2(EaseMethods.GetEase(EaseStyle.SineEaseOut), arrowMidPoint, finishingPosition, i, timeToCompleteSecondSegment);
            yield return(new WaitForFixedUpdate());
        }

        //Place bubble on grid
        _currentBubble.transform.position = finishingPosition;
        _currentBubble.GetComponent <CircleCollider2D>().enabled = true;
        BubbleBehaviour currentBubbleComponent = _currentBubble.GetComponent <BubbleBehaviour>();

        _bubblesGrid[position.x, position.y]   = currentBubbleComponent;
        currentBubbleComponent._hasOffset      = hasOffset;
        currentBubbleComponent._positionOnGrid = position;

        Vibration.VibrateGlobal(75);
        foreach (var bubble in GetSurroundingBubbles(currentBubbleComponent._positionOnGrid, true))
        {
            bubble.Push(currentBubbleComponent.transform.position);
        }

        //Try mergin bubbles;
        Vector2Int lastMergedBubblePosition;
        Vector2Int newMergedBubblePosition = position;
        int        comboSize = 0;

        do
        {
            lastMergedBubblePosition = newMergedBubblePosition;
            newMergedBubblePosition  = MergeBubbles(newMergedBubblePosition);
            Vibration.VibrateGlobal(75);
            yield return(new WaitWhile(() => _movingBubbles.Count > 0));

            comboSize++;
        } while (!newMergedBubblePosition.Equals(new Vector2Int(-1, -1)));

        //Explode if more than 2048
        if (GetBubbleAtPosition(lastMergedBubblePosition)._exponent > 10)
        {
            ExplodeAround(lastMergedBubblePosition, 2 + (int)(GetBubbleAtPosition(lastMergedBubblePosition)._exponent - 10));
        }

        yield return(new WaitForSeconds(0.2f));

        bool isAllEmpty = true;

        for (int y = 0; y < _bubblesGrid.GetLength(1); y++)
        {
            if (!IsRowEmpty(y))
            {
                isAllEmpty = false;
                break;
            }
        }

        if (isAllEmpty)
        {
            pool.CreatePerfectText();
            Vibration.VibrateGlobal(300);
        }

        if (position.y == 0)
        {
            MoveAllBubblesUp();
        }

        if (IsRowEmpty(1))
        {
            MoveAllBubblesDown();
        }

        if (IsRowEmpty(2))
        {
            MoveAllBubblesDown();
        }

        if (IsRowEmpty(3))
        {
            MoveAllBubblesDown();
        }

        if (IsRowEmpty(4))
        {
            MoveAllBubblesDown();
        }

        Vector3 currentScale = _nextBubble.transform.localScale;

        startingPosition = _nextBubble.transform.position;
        for (float i = 0; i < 1; i += Time.fixedDeltaTime * 5)
        {
            _nextBubble.transform.localScale = EaseMethods.EaseVector3(EaseMethods.GetEase(EaseStyle.BackEaseOut), currentScale, new Vector3(1, 1, 1), i, 1);
            _nextBubble.transform.position   = EaseMethods.EaseVector2(EaseMethods.GetEase(EaseStyle.SineEaseOut), startingPosition, new Vector2(2.75f, -3), i, 1);
            yield return(new WaitForFixedUpdate());
        }
        _nextBubble.transform.localScale = new Vector3(1, 1, 1);
        _nextBubble.transform.position   = new Vector2(2.75f, -3);
        _currentBubble = _nextBubble;
        _nextBubble    = pool.CreateBubble(new Vector3(1.5f, -3)).gameObject;
        _nextBubble.transform.localScale = new Vector3(0.75f, 0.75f, 1);
        _nextBubble.GetComponent <BubbleBehaviour>()._exponent = GetRandomExponent();
        _nextBubble.GetComponent <BubbleBehaviour>().Refresh();
        _nextBubble.GetComponent <CircleCollider2D>().enabled = false;
        _isShooting = false;
    }
 protected override object GetValueAt(float dt, float t)
 {
     return(VectorUtil.Lerp(_start, _target.position, EaseMethods.LinearEaseNone(t, 0f, 1f, this.Duration)));
 }