Exemplo n.º 1
0
    public bool OnTouchPressed(Vector3 position)
    {
        if (!_isInteractable)
        {
            return(false);
        }

        _isTouchInside = Contains(position);

        if (_isTouchInside)
        {
            if (_quantity > 0)
            {
                OnSelected();
            }
            else if (_quantity < 0)
            {
                _lock.StopAction();
                _lock.transform.SetRotation(0);

                _lock.Play(SequenceAction.Create(RotateAction.RotateBy(45.0f, 0.1f), RotateAction.RotateBy(-90.0f, 0.2f), RotateAction.RotateBy(45.0f, 0.1f)));
            }

            _listener.OnBoosterPressed(this);

            return(true);
        }

        return(false);
    }
Exemplo n.º 2
0
    void SetShowFBButton(bool show, bool start)
    {
        connectFBButton.StopAction();

        float y = connectFBButton.GetComponent <RectTransform>().anchoredPosition.y;

        if (show)
        {
            var move = AnchoredMoveAction.Create(new Vector2(FBButtonX, y), false, 0.5f, Ease.SineOut);

            if (start)
            {
                connectFBButton.Play(SequenceAction.Create(DelayAction.Create(1.0f), move));
            }
            else
            {
                connectFBButton.Play(move);
            }
        }
        else
        {
            var move = AnchoredMoveAction.Create(new Vector2(FBButtonX + FBButtonOffsetX, y), false, 0.5f, Ease.SineIn);

            connectFBButton.Play(move);
        }
    }
Exemplo n.º 3
0
    public static void ShowPopup(GameObject popup, Action callback = null)
    {
        // Reset button scale
        popup.ResetButtonScale(true);

        // Show popup
        popup.Show();

        // Fade-in
        popup.Play(FadeAction.FadeTo(popupEndOpacity, popupDuration));

        // Content
        GameObject content = popup.FindInChildren("Popup");

        if (content != null)
        {
            content.transform.localScale = popupStartScale;

            var zoomOut = ScaleAction.ScaleTo(popupEndScale, popupDuration * 0.7f);
            var zoomIn  = ScaleAction.ScaleTo(Vector3.one, popupDuration * 0.3f);
            var action  = SequenceAction.Create(zoomOut, zoomIn);

            content.Play(action, callback);
        }
        else
        {
            if (callback != null)
            {
                callback();
            }
        }
    }
Exemplo n.º 4
0
    public override void OnAnimalExit(Animal animal)
    {
        if (_enterCount == 1)
        {
            // Set animal to null
            _animal = null;

            GameManager.Instance.OnAnimalExitFoothold(this);

            _isDouble = false;

            var delay         = DelayAction.Create(0.5f);
            var playExplosion = CallFuncAction.Create(() => {
                // Play sound
                SoundManager.Instance.PlaySound(SoundID.Explose);

                if (explosionPrefab != null)
                {
                    GameObject explosion = explosionPrefab.Create(transform, icon.transform.position);
                    explosion.AddSortingOrder(icon.GetSortingOrder() + 1);
                }
            });
            var fadeOut = FadeAction.FadeOut(0.25f);
            var hide    = HideAction.Create();

            // Hide icon
            icon.Play(SequenceAction.Create(delay, playExplosion, fadeOut, hide));
        }
        else
        {
            base.OnAnimalExit(animal);
        }
    }
Exemplo n.º 5
0
    public static BaseAction GetJellyAction()
    {
        var scale1   = ScaleAction.ScaleTo(new Vector3(1.1f, 0.9f, 1), 0.1f);
        var scale2   = ScaleAction.ScaleTo(new Vector3(0.9f, 1.1f, 1), 0.1f);
        var scale3   = ScaleAction.ScaleTo(new Vector3(1f, 1f, 1), 0.1f);
        var sequence = SequenceAction.Create(scale1, scale2, scale3);

        return(sequence);
    }
Exemplo n.º 6
0
    public void OnSelected()
    {
        if (!_isUnlocked)
        {
            _lock.StopAction();
            _lock.transform.SetRotation(0);

            _lock.Play(SequenceAction.Create(RotateAction.RotateBy(45.0f, 0.1f), RotateAction.RotateBy(-90.0f, 0.2f), RotateAction.RotateBy(45.0f, 0.1f)));
        }
    }
Exemplo n.º 7
0
    void Sink()
    {
        var delay        = DelayAction.Create(0.5f);
        var disableSwing = CallFuncAction.Create(() => { _swingEnabled = false; });
        var move         = MoveAction.MoveBy(new Vector3(0, -sinkDelta, 0), 0.5f, Ease.SineIn);
        var fadeOut      = FadeAction.RecursiveFadeOut(0.5f);

        gameObject.Play(SequenceAction.Create(delay, disableSwing, ParallelAction.ParallelAll(move, fadeOut)), () => {
            SelfDestroy();
        });
    }
Exemplo n.º 8
0
    void Start()
    {
        if (actions != null)
        {
            int count = actions.Length;

            if (count > 0)
            {
                BaseAction action;

                if (count == 1)
                {
                    action = actions[0].GetAction();
                }
                else
                {
                    BaseAction[] baseActions = new BaseAction[count];

                    for (int i = 0; i < count; i++)
                    {
                        baseActions[i] = actions[i].GetAction();
                    }

                    action = SequenceAction.Create(baseActions);
                }

                if (repeat != 0)
                {
                    if (delay > 0)
                    {
                        gameObject.Play(SequenceAction.Create(DelayAction.Create(delay), RepeatAction.Create(action, repeat)));
                    }
                    else
                    {
                        gameObject.Play(RepeatAction.Create(action, repeat));
                    }
                }
                else
                {
                    if (delay > 0)
                    {
                        gameObject.Play(SequenceAction.Create(DelayAction.Create(delay), action));
                    }
                    else
                    {
                        gameObject.Play(action);
                    }
                }
            }
        }

        Destroy(this);
    }
Exemplo n.º 9
0
    void Unsink()
    {
        gameObject.SetAlpha(0, true);

        Vector3 position = transform.position;

        position.y -= sinkDelta;

        var delay       = DelayAction.Create(0.05f);
        var setPosition = SetPositionAction.Create(position);
        var move        = MoveAction.MoveBy(new Vector3(0, sinkDelta, 0), 0.5f, Ease.SineOut);
        var fadeIn      = FadeAction.RecursiveFadeIn(0.5f);

        gameObject.Play(SequenceAction.Create(delay, setPosition, ParallelAction.ParallelAll(move, fadeIn)), () => { _swingEnabled = true; });
    }
Exemplo n.º 10
0
    void Start()
    {
        var fade = FadeAction.Create(end, isRelative, isRecursive, duration, Ease.FromType(easeType), direction);

        if (delay > 0)
        {
            gameObject.Play(SequenceAction.Create(DelayAction.Create(delay), fade));
        }
        else
        {
            gameObject.Play(fade);
        }

        // Self-destroy
        Destroy(this);
    }
Exemplo n.º 11
0
    public void Show(string message, Action callback)
    {
        _isShowing = true;

        // Set message
        _messageText.text = message;

        var move1  = AnchoredMoveAction.Create(Vector2.zero, false, 0.5f, Ease.SineOut);
        var delay  = DelayAction.Create(1.0f);
        var move2  = AnchoredMoveAction.Create(new Vector2(0, OffsetY), false, 0.5f, Ease.SineIn);
        var action = SequenceAction.Create(move1, delay, move2);

        gameObject.Play(action, () => {
            _isShowing = false;

            if (callback != null)
            {
                callback();
            }
        });
    }
Exemplo n.º 12
0
    public void OnNextRound(int nextRound)
    {
        int index = (nextRound > 3) ? 2 : nextRound - 1;

        round.SetImageSprite(rounds[index]);
        target.SetImageSprite(targets[index]);

        round.Show();
        target.Show();

        var roundMove1 = AnchoredMoveAction.MoveTo(new Vector2(0, _roundPosition.y), 0.25f, Ease.SineOut);
        var roundDelay = DelayAction.Create(1.0f);
        var roundMove2 = AnchoredMoveAction.MoveTo(new Vector2(_targetPosition.x, _roundPosition.y), 0.25f, Ease.SineIn);

        var targetMove1 = AnchoredMoveAction.MoveTo(new Vector2(0, _targetPosition.y), 0.25f, Ease.SineOut);
        var targetDelay = DelayAction.Create(1.0f);
        var targetMove2 = AnchoredMoveAction.MoveTo(new Vector2(_roundPosition.x, _targetPosition.y), 0.25f, Ease.SineIn);

        round.Play(SequenceAction.Create(roundMove1, roundDelay, roundMove2, SetAnchoredPositionAction.Create(_roundPosition), HideAction.Create()));
        target.Play(SequenceAction.Create(targetMove1, targetDelay, targetMove2, SetAnchoredPositionAction.Create(_targetPosition), HideAction.Create()));
    }
Exemplo n.º 13
0
    void Jump()
    {
        Direction direction = _solution.Dequeue();

        int nextRow    = -1;
        int nextColumn = -1;

        if (NextCell(direction, ref nextRow, ref nextColumn))
        {
            // Set direction
            SetDirection(direction);

            // Get foothold type
            FootholdType type = _types[_curRow, _curColumn];

            // Update foothold
            if (type == FootholdType.Double)
            {
                // Set foothold
                SetFoothold(_curRow, _curColumn, FootholdType.Normal);
            }
            else if (type != FootholdType.None)
            {
                // Set foothold
                SetFoothold(_curRow, _curColumn, FootholdType.None);
            }

            // Set next cell
            _curRow    = nextRow;
            _curColumn = nextColumn;

            // Jump
            var jump     = MoveAction.MoveTo(GetPosition(nextRow, nextColumn), jumpDuration * 0.5f);
            var delay    = DelayAction.Create(jumpDuration * 0.5f);
            var callFunc = CallFuncAction.Create(JumpCallback);
            var action   = SequenceAction.Create(jump, delay, callFunc);

            _frog.gameObject.Play(action);
        }
    }
Exemplo n.º 14
0
    void UpdateTime()
    {
        // Get current time
        int time = Mathf.CeilToInt(_time);

        if (time != _currentTime)
        {
            if (_currentTime > 0)
            {
                // Frame
                frame.StopAction();
                frame.Show();
                frame.Play(BlinkAction.Create(2, 0.3f, false, false), () => { frame.Hide(); });

                // Play effect
                GameObject effect = numberEffect.gameObject;
                effect.StopAction(true);
                effect.Show();
                effect.transform.localScale = Vector3.one;
                effect.SetColor(_currentTime > 3 ? Color.white : alarmColor, true);

                numberEffect.Number = _currentTime;

                var zoomOut = ScaleAction.ScaleTo(alarmScale, alarmDuration);
                var fadeOut = FadeAction.RecursiveFadeOut(alarmDuration);
                var hide    = HideAction.Create();

                effect.Play(SequenceAction.Create(ParallelAction.ParallelAll(zoomOut, fadeOut), hide));
            }

            // Set current time
            _currentTime = time;

            // Update number
            number.Number = time;
        }
    }
Exemplo n.º 15
0
    void OnStart()
    {
        if (!FB.IsLoggedIn)
        {
            // Check to show login FB
            if (UserData.Instance.ShowLoginFBTimes < 3 &&
                !Manager.Instance.isShowLoginFB &&
                UserData.Instance.Level >= 10)
            {
                UserData.Instance.ShowLoginFBTimes++;
                Manager.Instance.isShowLoginFB = true;
                Manager.Instance.ShowConfirm("Connect Facebook", "Please connect with facebook to save your progress and see your friends",
                                             (isOK) =>
                {
                    if (isOK)
                    {
                        Debug.Log("Connect FB, choosse OK ...");
                        ConnectFacebook();

                        UserData.Instance.ShowLoginFBTimes = 3;
                    }
                    else
                    {
                        Debug.Log("Cancel, no connect FB ...");
                    }
                });
            }
        }

        if (!Manager.Instance.isShowNewVersion && UserData.Instance.Level >= 4)
        {
            SCross.Instance.ShowMessage("cyrus_bean_jump", "1.6.0", (result, message) => {
            });
            Manager.Instance.isShowNewVersion = true;
        }


        if (UserData.Instance.Level > 15)
        {
            SCross.Instance.GetImage("cyrus_bean_jump", (result, message) => {
                if (result)
                {
                    SCross.Instance.ShowPopupScross();
                }
            });
        }

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        // Update Facebook
        FBManager.Instance.OnUpdate();

        // Play BGM
        SoundManager.Instance.PlayMusic(SoundID.MainMenu);

        // Sunlight
        if (sunlight != null)
        {
            // Get top
            float top = Camera.main.orthographicSize;

            // Get right
            float right = Camera.main.GetOrthographicWidth();

            sunlight.transform.position      = new Vector3(right - Random.Range(0.0f, 0.1f), top + 2.0f, 0);
            sunlight.transform.localRotation = Quaternion.Euler(0, 0, Random.Range(240.0f, 250.0f));

            int count = sunlight.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                sunlight.transform.GetChild(i).localScale = new Vector3(Random.Range(9.0f, 10.0f), Random.Range(0.85f, 1.0f), 1.0f);
            }

            float startOpacity = Random.value * 0.1f;
            sunlight.SetAlpha(startOpacity, true);

            var rotate  = RotateAction.RotateBy(Random.Range(-20.0f, -25.0f), 18.0f, Ease.Linear, LerpDirection.PingPongForever);
            var fadeIn  = FadeAction.RecursiveFadeTo(Random.Range(0.6f, 0.7f), 18.0f);
            var delay1  = DelayAction.Create(6.0f);
            var fadeOut = FadeAction.RecursiveFadeTo(startOpacity, 18.0f);
            var delay2  = DelayAction.Create(6.0f);
            var fade    = SequenceAction.Create(fadeIn, delay1, fadeOut, delay2);
            var action  = ParallelAction.ParallelAll(rotate, RepeatAction.RepeatForever(fade, false));

            sunlight.Play(action);
        }

        // Get ignore raycast
        _ignoreRaycast = GameObject.FindObjectOfType <IgnoreRaycast>();

        if (!UserData.Instance.PlayedCutscene1)
        {
            UserData.Instance.PlayedCutscene1 = true;
            cutscene1.SetActive(true);
        }

        // Update Connect button
        UpdateConnectFacebook(true);

        googleAnalytics.LogScreen("Main Menu");

        _requestUpdater.Play(UpdateRequests);

        Manager.Instance.SetUpdateSendRequests(true);
    }
Exemplo n.º 16
0
    IEnumerator Try()
    {
        int nextRow    = -1;
        int nextColumn = -1;

        for (int i = 0; i < 4; i++)
        {
            Direction dir = Directions[i];

            if (!dir.IsOpposite(_curDirection))
            {
                if (NextCell(dir, ref nextRow, ref nextColumn))
                {
                    // Push
                    _cells.Push(new Cell(_curRow, _curColumn));

                    // Save cell
                    int row    = _curRow;
                    int column = _curColumn;

                    // Save direction
                    Direction direction = _curDirection;

                    FootholdType type1 = _types[_curRow, _curColumn];
                    FootholdType type2 = _types[nextRow, nextColumn];

                    // Set direction
                    SetDirection(dir);

                    // Update current cell
                    if (type1 == FootholdType.Double)
                    {
                        // Set foothold
                        SetFoothold(_curRow, _curColumn, FootholdType.Normal);

                        // Increase counter
                        _count++;
                    }
                    else if (type1 != FootholdType.None)
                    {
                        // Set foothold
                        SetFoothold(_curRow, _curColumn, FootholdType.None);

                        // Increase counter
                        _count++;
                    }

                    // Jump
                    var jump = MoveAction.MoveTo(GetPosition(nextRow, nextColumn), jumpDuration * 0.5f);

                    if (type2.IsRedirect())
                    {
                        Direction newDirection = type2.GetDirection();

                        _frog.gameObject.Play(SequenceAction.Create(jump, CallFuncAction.Create(() => {
                            SetDirection(newDirection);
                        })));
                    }
                    else
                    {
                        _frog.gameObject.Play(jump);
                    }

                    // Set current cell to next one
                    _curRow    = nextRow;
                    _curColumn = nextColumn;

                    yield return(new WaitForSeconds(jumpDuration));

                    // Check if finished
                    if (_count == _total - 1)
                    {
                        Show();
                    }
                    else
                    {
                        yield return(StartCoroutine(Try()));
                    }

                    // Restore cell
                    _curRow    = row;
                    _curColumn = column;

                    // Restore position
                    _frog.transform.position = GetPosition(_curRow, _curColumn);

                    // Restore type
                    if (type1 != FootholdType.None)
                    {
                        // Set foothold
                        SetFoothold(_curRow, _curColumn, type1);

                        // Decrease counter
                        _count--;
                    }

                    // Restore direction
                    SetDirection(direction);

                    // Pop
                    _cells.Pop();

                    yield return(new WaitForSeconds(unjumpDuration));
                }
            }
        }
    }
Exemplo n.º 17
0
    protected override void OnShowFinished(Action callback)
    {
        // Play firework
        if (fireworkPrefab != null)
        {
            int   total     = fireworkPositions.Length;
            int[] positions = total.RandomIndices();
            int   count     = total > minFirework?UnityEngine.Random.Range(minFirework, total) : total;

            float delay = 0.0f;

            for (int i = 0; i < count; i++)
            {
                GameObject firework = Instantiate(fireworkPrefab);
                firework.transform.position = fireworkPositions[positions[i]].transform.position;

                if (delay > 0)
                {
                    ParticleSystem ps = firework.GetComponent <ParticleSystem>();
                    ps.Pause();

                    firework.Play(SequenceAction.Create(DelayAction.Create(delay), CallFuncAction.Create(() => {
                        SoundManager.Instance.PlaySound(SoundID.BigFirework, SoundType.New);
                        ps.Play();
                    })));
                }
                else
                {
                    SoundManager.Instance.PlaySound(SoundID.BigFirework, SoundType.New);
                }

                delay += 0.3f;
            }

            if (UserData.Instance.Map == 99 && !UserData.Instance.PlayedCutscene4)
            {
                ShowEndgameStory();
            }
        }

        int level = UserData.Instance.Map;

        // Check if win new map
        if (!UserData.Instance.IsWinned(level))
        {
            UserData.Instance.SetWinned(level);

            // Add bonus coins
            int coins = Settings.GetBonusCoins(level);
            NotificationManager.CoinChanged(UserData.Instance.Coin + coins);

            if (bonus != null)
            {
                // Show bonus
                bonus.Show();
                bonus.SetAlpha(1.0f, true);

                if (coinText != null)
                {
                    // Play sound
                    SoundManager.Instance.PlaySound(SoundID.Coin, SoundType.Loop);

                    var action = LerpIntAction.Create(1, coins, 0.5f, (coin) => {
                        coinText.text = coin.ToString();
                    });

                    gameObject.Play(action, () => {
                        // Stop sound
                        SoundManager.Instance.StopSound(SoundID.Coin);
                    });
                }
            }
        }

        // Show touch and overlay
        SetShowTouchAndOverlay(true);

        Invoke("CheckShowAds", 1.2f);
        Invoke("OnReady", 2f);

        if (callback != null)
        {
            callback();
        }
    }
Exemplo n.º 18
0
    public void JumpToMap(float delay1, Vector3 position, float delay2, Action callback)
    {
        Vector2   start = transform.position;
        Vector2   end   = position;
        Vector2   control;
        Direction direction = DirectionHelper.GetDirection(start, end);

        // Up
        if (direction.IsUp())
        {
            // Left
            if (direction.IsLeft())
            {
                animator.SetTrigger(nhayNgang);
                transform.SetHorizontalFlip(false);

                control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor);
            }
            // Right
            else if (direction.IsRight())
            {
                animator.SetTrigger(nhayNgang);
                transform.SetHorizontalFlip(true);

                control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor);
            }
            else
            {
                animator.SetTrigger(nhayLen);
                transform.SetHorizontalFlip(false);

                control = new Vector2(start.x, end.y + controlDeltaY);
            }
        }
        else
        {
            // Left
            if (direction.IsLeft())
            {
                animator.SetTrigger(nhayNgang);
                transform.SetHorizontalFlip(false);

                control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor);
            }
            // Right
            else if (direction.IsRight())
            {
                animator.SetTrigger(nhayNgang);
                transform.SetHorizontalFlip(true);

                control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor);
            }
            else
            {
                animator.SetTrigger(nhayXuong);
                transform.SetHorizontalFlip(false);

                control = new Vector2(start.x, start.y + controlDeltaY);
            }
        }

        var        jump   = SequenceAction.Create(QuadBezierAction.BezierTo(control, end, 0.5f), CallFuncAction.Create(() => { animator.SetTrigger(nghiXuong); }));
        BaseAction action = null;

        if (delay1 > 0)
        {
            if (delay2 > 0)
            {
                action = SequenceAction.Create(DelayAction.Create(delay1), jump, DelayAction.Create(delay2));
            }
            else
            {
                action = SequenceAction.Create(DelayAction.Create(delay1), jump);
            }
        }
        else
        {
            if (delay2 > 0)
            {
                action = SequenceAction.Create(jump, DelayAction.Create(delay2));
            }
            else
            {
                action = jump;
            }
        }

        // Jump
        gameObject.Play(action, callback);
    }
Exemplo n.º 19
0
    public void RunAction(GameObject target, List <FiniteTimeAction> list)
    {
        SequenceAction seq = SequenceAction.Create(list);

        RunAction(target, seq);
    }