Example #1
0
    protected virtual void Hide(bool fadeOut, Action callback)
    {
        // Disable UI
        SetUIEnabled(false);

        // Hide touch and overlay
        SetShowTouchAndOverlay(false);

        // Delay
        gameObject.Play(DelayAction.Create(0.1f), () => {
            if (fadeOut)
            {
                // Fade-out overlay
                gameObject.Play(FadeAction.FadeOut(fadeDuration));

                // Fade-out background
                background.Play(FadeAction.RecursiveFadeOut(fadeDuration), () => {
                    // Hide
                    gameObject.Hide();

                    // Enable UI
                    SetUIEnabled(true);

                    callback();
                });
            }
            else
            {
                // Enable UI
                SetUIEnabled(true);

                callback();
            }
        });
    }
Example #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);
        }
    }
Example #3
0
    public BaseAction GetAction()
    {
        if (actionType == ActionType.Move)
        {
            return(MoveAction.Create(v31, b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Scale)
        {
            return(ScaleAction.Create(v31, b1, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Rotate)
        {
            return(RotateAction.Create(f1, b1, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Fade)
        {
            return(FadeAction.Create(f1, b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Tint)
        {
            return(TintAction.Create(c1.RGB(), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Delay)
        {
            return(DelayAction.Create(duration));
        }

        return(null);
    }
Example #4
0
    public override void OnAnimalEnter(Animal animal)
    {
        base.OnAnimalEnter(animal);

        // Save direction
        _oldDirection = animal.Direction;
        // Change direction
        animal.Direction = direction;

        gameObject.Play(DelayAction.Create(0.5f), () => {
            if (effectPrefab != null)
            {
                // Play sound
                SoundManager.Instance.PlaySound(SoundID.ChangeDirection, SoundType.New);

                // Create effect
                Vector3 position = transform.position;
                position.y      += 0.25f;

                effectPrefab.Create(transform.parent, position);
            }



            GameManager.Instance.OnAnimalDidFinishJump(animal);
        });
    }
Example #5
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);
        }
    }
Example #6
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();
        });
    }
Example #7
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);
    }
Example #8
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; });
    }
    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);
    }
Example #10
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();
            }
        });
    }
Example #11
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()));
    }
    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);
        }
    }
Example #13
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);
    }
Example #14
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();
        }
    }
Example #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);
    }
Example #16
0
    public BaseAction GetAction()
    {
        if (actionType == ActionType.Move)
        {
            return(MoveAction.Create(v31.VarianceXY(variance), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.HorizontalMove)
        {
            return(HMoveAction.Create(f1.Variance(variance), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.VerticalMove)
        {
            return(VMoveAction.Create(f1.Variance(variance), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Scale)
        {
            return(ScaleAction.Create(v31.VarianceXY(variance), b1, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Rotate)
        {
            return(RotateAction.Create(f1.Variance(variance), b1, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Fade)
        {
            return(FadeAction.Create(f1.Variance(variance), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Tint)
        {
            return(TintAction.Create(c1.RGB().Variance(variance), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.SetPosition)
        {
            return(SetPositionAction.Create(v31, v32, b1, b2));
        }

        if (actionType == ActionType.SetScale)
        {
            return(SetScaleAction.Create(v31, v32, b1));
        }

        if (actionType == ActionType.SetRotation)
        {
            return(SetRotationAction.Create(f1, f2));
        }

        if (actionType == ActionType.SetAlpha)
        {
            return(SetAlphaAction.Create(f1, f2, b1));
        }

        if (actionType == ActionType.SetRGB)
        {
            return(SetRGBAction.Create(c1.RGB(), c2.RGB(), b1));
        }

        if (actionType == ActionType.Delay)
        {
            return(DelayAction.Create(duration, f2));
        }

        if (actionType == ActionType.AnimatorTrigger)
        {
            return(AnimatorTriggerAction.Create(s1));
        }

        if (actionType == ActionType.PlaySound)
        {
            return(PlaySoundAction.Create(soundId, soundType, f1));
        }

        if (actionType == ActionType.CallEvent)
        {
            return(CallEventAction.Create(e1));
        }

        if (actionType == ActionType.PlayParticleSystem)
        {
            return(PlayPSAction.Create(b1));
        }

        return(null);
    }