Ejemplo n.º 1
0
    public void AddCoins(int _numCoins)
    {
        // Play coin get animation.
        MoveByAction moveUp = new MoveByAction(mCoinTransform, Graph.Linear, Vector3.up * 1.4f, kfCoinAnimDuration);

        moveUp.OnActionStart += () => {
            mCoinTransform.position = transform.position;
            mCoinSpriteRen.enabled  = true;
            mPlayerData.Coins++;
            AudioManager.PlayCoinGetSound();
            PlayerInfoManager.Instance.UpdateCoins(mPlayerData.Coins);
        };
        ActionRepeat repeatedCoinGet = new ActionRepeat(moveUp, _numCoins);
        DelayAction  hideCoin        = new DelayAction(kfCoinAnimDuration * _numCoins + 0.5f);

        hideCoin.OnActionFinish += () => {
            mCoinSpriteRen.enabled = false;
        };
        ActionHandler.RunAction(repeatedCoinGet, hideCoin);
    }
    private void SetupTitleWithLogo()
    {
        sbLoadedGame         = true;
        mSplashPanelCG.alpha = 1.0f;

        // Logo Animation
        DelayAction prePulseDelay = new DelayAction(1.5f);
        PulseAction clickPulse    = new PulseAction(
            mLogoTransform,
            1,
            Graph.Exponential,
            0.25f,
            Vector3.one,
            Vector3.one * 0.8f);

        clickPulse.OnActionStart += () => { AudioManager.PlayPenClickSound(); };
        DelayAction postPulseDelay = new DelayAction(0.25f);

        MoveByAction   anticipateLeft      = new MoveByAction(mLogoTransform, Graph.InverseExponential, Vector3.left * (100) * (Screen.height / 1920.0f), 0.5f);
        ScaleToAction  anticipateSquash    = new ScaleToAction(mLogoTransform, Graph.InverseExponential, new Vector3(0.75f, 1.25f, 1.25f), 0.5f);
        ActionParallel anticipateParallel  = new ActionParallel(anticipateLeft, anticipateSquash);
        DelayAction    postAnticipateDelay = new DelayAction(0.1f);
        MoveByAction   zoomRight           = new MoveByAction(mLogoTransform, Graph.InverseExponential, Vector3.right * (1024 + 400) * (Screen.height / 1920.0f), 0.3f);
        ScaleToAction  scaleDown           = new ScaleToAction(mLogoTransform, Graph.InverseExponential, new Vector3(1.5f, 0.5f, 0.5f), 0.5f);
        ActionParallel zoomRightParallel   = new ActionParallel(zoomRight, scaleDown);

        DelayAction preFadeDelay = new DelayAction(0.2f);
        CanvasGroupAlphaFadeToAction fadeCGAway = new CanvasGroupAlphaFadeToAction(mSplashPanelCG, 0.0f, 1.5f);

        fadeCGAway.OnActionFinish += () => {
            mSplashPanelCG.blocksRaycasts = false;
        };

        // Tap to Start text.
        DelayAction TurnOn = new DelayAction(0.5f);

        TurnOn.OnActionFinish += () => {
            mTapToStartText.enabled = true;
            if (mStartButton.interactable == false)
            {
                mStartButton.interactable = true;
            }
        };
        DelayAction TurnOff = new DelayAction(1.0f);

        TurnOff.OnActionFinish += () => { mTapToStartText.enabled = false; };
        ActionSequence      tapTextFlashSeq = new ActionSequence(TurnOn, TurnOff);
        ActionRepeatForever repeatFlash     = new ActionRepeatForever(tapTextFlashSeq);

        ActionSequence splashSeq = new ActionSequence(
            prePulseDelay, clickPulse, postPulseDelay,
            anticipateParallel, postAnticipateDelay, zoomRightParallel,
            preFadeDelay, fadeCGAway,
            repeatFlash
            );

        ActionHandler.RunAction(splashSeq);



        // Card Animations.
        // Card is already spinning in the background.
        // 0 to 90, snap -90, -90 to 0
        mSpiningCard.localEulerAngles = Vector3.zero;
        // Timing here doesn't matter. Is used to sync. 0.5f just nice to have card back show when canvas fades.
        RotateByAction initSpin = new RotateByAction(mSpiningCard, Graph.Linear, Vector3.up * 90.0f, 0.5f);

        initSpin.OnActionFinish += () => {
            mCardSpriteRen.transform.localScale -= Vector3.right * 2.0f;
            mCardSpriteRen.sprite = mCardSprites[Random.Range(0, mCardSprites.Length)];
        };
        RotateByAction spinA = new RotateByAction(mSpiningCard, Graph.Linear, Vector3.up * 180.0f, 3.0f);

        spinA.OnActionFinish += () => {
            mCardSpriteRen.transform.localScale += Vector3.right * 2.0f;
            mCardSpriteRen.sprite = mSpriteCardBack;
        };
        RotateByAction spinB = new RotateByAction(mSpiningCard, Graph.Linear, Vector3.up * 180.0f, 3.0f);

        spinB.OnActionFinish += () => {
            mCardSpriteRen.transform.localScale -= Vector3.right * 2.0f;
            mCardSpriteRen.sprite = mCardSprites[Random.Range(0, mCardSprites.Length)];
        };

        ActionSequence cardSpinSeq = new ActionSequence(spinA, spinB);

        ActionHandler.RunAction(new ActionSequence(initSpin, new ActionRepeatForever(cardSpinSeq)));
    }