Ejemplo n.º 1
0
    public AudioMap GetAudioMapByName(string name)
    {
        AudioMap am = null;

        scache.TryGetValue(name, out am);
        return(am);
    }
Ejemplo n.º 2
0
 public void Cancel()
 {
     SDKManager.Instance.ShowAd(ShowAdType.VideoAD, 1, "冒险模式点开始");
     IsConfirm = false;
     if (garageShootRoutine != null)
     {
         StopCoroutine(garageShootRoutine);
         for (int i = 0; i < tanks.Length; i++)
         {
             tanks[i].Shoot(val: false);
         }
     }
     AudioMap.PlayClipAt(AudioMap.instance["tankIgnition"], Vector3.zero, AudioMap.instance.uiMixerGroup).transform.parent = MenuController.instance.transform;
     FinishTankFlash();
     SetTankSkin(PlayerDataManager.GetSelectedSkin(Variables.instance.GetTank(tankIndex)));
     TankAnalytics.Play(Variables.instance.levels[PlayerDataManager.GetSelectedLevel(PlayerDataManager.SelectedGameMode)].name, Variables.instance.tanks[PlayerDataManager.GetSelectedTank()].name);
     TankGame.Running = true;
     if (PlayerDataManager.SelectedGameMode == GameMode.Classic || PlayerDataManager.SelectedGameMode == GameMode.BossRush)
     {
         MenuController.HideMenu <ClassicModeMenu>();
     }
     LoadingScreen.ReloadGame(delegate
     {
         //SDKManager.Instance.RepeatShowBan(15,15);//展示Bannel
         MenuController.HideMenu <GarageMenu>();
         TankGame.Running = true;
     });
     TryPanel.SetActive(false);
 }
Ejemplo n.º 3
0
    private IEnumerator CardCountRollRoutine(int amountToAdd, int currentCount, int prevLevelMax, int nextLevelMin, bool nextIsMax)
    {
        float num         = 0.4f;
        float waitForStep = num / (float)amountToAdd;
        int   num4;

        for (int i = 0; i <= amountToAdd; i = num4)
        {
            int    num2 = currentCount + i - prevLevelMax;
            int    num3 = nextLevelMin - prevLevelMax;
            string text = $"{num2}/{num3}";
            countBlueContainer.SetActive(currentCount + i < nextLevelMin);
            countGreenContainer.SetActive(currentCount + i >= nextLevelMin);
            if (currentCount + i < nextLevelMin && num3 > 0)
            {
                AudioMap.PlayClipAt("progressBarTick", Vector3.zero, AudioMap.instance.uiMixerGroup);
                countBlueImage.fillAmount = (float)num2 / (float)num3;
                countBlueText.text        = text;
            }
            else if (currentCount + i >= nextLevelMin)
            {
                countGreenText.text = text;
                if (nextIsMax)
                {
                    break;
                }
            }
            yield return(new WaitForSecondsRealtime(waitForStep));

            num4 = i + 1;
        }
    }
Ejemplo n.º 4
0
    private void FinishedSong()
    {
        AudioMap map = new AudioMap();

        map.bpm   = beatCount * 60 / Length;
        map.beats = (float[])(this.beats).ToArray(typeof(float));
        Debug.Log("bpm" + map.bpm);
        finished = true;

        Transform parent = this.transform.parent;   //parent being menu

        parent.GetComponent <AudioSource>().Stop(); //get manu's sound source to stop

        //try to make a button before

        foreach (Transform child in parent.parent) //now go through canvas'schildren
        {
            if (child.name == "Game")
            {
                child.gameObject.SetActive(true);
                //child.gameObject.GetComponent<AudioSource>().clip = parent.GetComponent<AudioSource>().clip;
                Game game = child.GetComponent <Game>();
                game.enabled = true;
                game._map    = map;
                game._audio  = parent.GetComponent <AudioSource>().clip;
            }
        }

        parent.gameObject.SetActive(false);
        this.gameObject.SetActive(false);
    }
Ejemplo n.º 5
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (base.enabled && nextTime <= Time.time && collision.gameObject.layer == LayerMask.NameToLayer("Ground"))
     {
         AudioMap.PlayClipAt(TankGame.instance.audioMap, audioName, base.transform.position, TankGame.instance.audioMap.effectsMixerGroup);
         nextTime = Time.time + timeLimit;
     }
 }
Ejemplo n.º 6
0
    private IEnumerator PromotionSound()
    {
        yield return(AudioManager.FadeMusicTo(-80f, 0.5f));

        AudioSource audioSource = AudioMap.PlayClipAt("promotion", Vector3.zero, AudioMap.instance.uiMixerGroup);

        yield return(new WaitForSeconds(audioSource.clip.length));

        yield return(AudioManager.FadeMusicTo(0f, 0.5f));
    }
Ejemplo n.º 7
0
    private IEnumerator Start()
    {
        if (attachedVehicle.gameObject.layer == LayerMask.NameToLayer("PlayerTank"))
        {
            base.gameObject.layer = LayerMask.NameToLayer("ForceField");
        }
        else
        {
            base.gameObject.layer = LayerMask.NameToLayer("ForceFieldRight");
        }
        SpriteRenderer sr = GetComponent <SpriteRenderer>();

        sr.color        = new Color(0f, 0f, 0f, 0f);
        vehiclesDamaged = new HashSet <Vehicle>();
        float value = base.Booster.GetValue();
        float num   = Mathf.Lerp(minHealth, maxHealth, value);

        pushForce  = Mathf.Lerp(minPushForce, maxPushForce, value);
        fullHealth = (health = attachedVehicle.Stats.health * num);
        Vector3 position = attachedVehicle.transform.position;

        position.z = base.transform.position.z;
        base.transform.position   = position;
        base.transform.localScale = Vector3.zero;
        Bounds bounds = default(Bounds);

        for (int i = 0; i < attachedVehicle.spriteRenderers.Length; i++)
        {
            if (attachedVehicle.spriteRenderers[i] != null)
            {
                bounds.Encapsulate(attachedVehicle.spriteRenderers[i].transform.localPosition);
            }
        }
        AudioMap.PlayClipAt("forceFieldAppear", base.transform.position, AudioMap.instance.effectsMixerGroup);
        float   forceFieldScale = attachedVehicle.forceFieldScale;
        Vector3 targetScale     = new Vector3(forceFieldScale, forceFieldScale, 1f);

        for (float t = 0f; t < 0.5f; t += Time.deltaTime)
        {
            if (base.transform == null || sr == null)
            {
                yield break;
            }
            float t2 = LeanTween.easeInOutCirc(0f, 1f, t / 0.5f);
            base.transform.localScale = Vector3.Lerp(Vector3.zero, targetScale, t2);
            if (t > 0.3f)
            {
                float t3 = LeanTween.easeInOutCirc(0f, 1f, (t - 0.3f) / 0.2f);
                sr.color = Color.Lerp(new Color(1f, 1f, 1f, 0f), Color.white, t3);
            }
            yield return(null);
        }
        base.transform.localScale = targetScale;
        sr.color = Color.white;
    }
Ejemplo n.º 8
0
    public static IEnumerator FadeMusicForSound(string clipName)
    {
        yield return(FadeMusicTo(-20f, 0.5f));

        SetGameAudioTo(-20f);
        AudioSource audioSource = AudioMap.PlayClipAt(clipName, Vector3.zero, AudioMap.instance.uiMixerGroup);

        yield return(new WaitForSeconds(audioSource.clip.length));

        SetGameAudioTo(0f);
        yield return(FadeMusicTo(0f, 0.5f));
    }
Ejemplo n.º 9
0
    public void BuyBoosterVideoAd()//购买观看视频的提升道具
    {
        AudioMap.PlayClipAt("upgradeBooster", Vector3.zero, AudioMap.instance.uiMixerGroup);
        TankAnalytics.BoughtWithVideoAd("Upgrade " + selectedBoosterId);
        Booster booster   = PlayerDataManager.GetBooster(selectedBoosterId);
        int     cardsUsed = booster.NextLevelCount - booster.ThisLevelCount;

        TankAnalytics.BoosterUpgraded(booster.id, cardsUsed);
        PlayerDataManager.AddBoosterLevel(selectedBoosterId);
        currentBoosters = PlayerDataManager.GetTankBoosters(Variables.instance.GetTank(PlayerDataManager.GetSelectedTank()));
        SetSelectedBooster(selectedBoosterId);
    }
Ejemplo n.º 10
0
 public void GetFreeGems()
 {
     LeanTween.delayedCall(1.2f, (Action) delegate
     {
         ShopMenu shopMenu = this;
         AnimatedCurrencyController.AnimateGems((int)1, MenuController.UICamera.WorldToViewportPoint(shopMenu.gemIAPItems[1].transform.position), MenuController.TotalGemsPositionViewport, 1, null, delegate(int tc)
         {
         });
         AudioMap.PlayClipAt(AudioMap.instance["gemCollect"], Vector3.zero, AudioMap.instance.uiMixerGroup);
         MenuController.UpdateTopMenu();
         Debug.Log(PlayerDataManager.GetGems());
     });
 }
Ejemplo n.º 11
0
    protected void _LoadAudio(GameObject prefab)
    {
        if (scache.ContainsKey(prefab.name))
        {
            return;
        }

        GameObject ao = GameObject.Instantiate(prefab) as GameObject;

        ao.transform.parent = transform;
        AudioMap am = ao.GetComponent <AudioMap>();

        cache.Add(prefab, am);
        scache.Add(prefab.name, am);
    }
Ejemplo n.º 12
0
    static void loopAddAudio(DirectoryInfo dirInfo, AudioMap audioMap, string fileExt)
    {
        foreach (FileInfo pngFile in dirInfo.GetFiles(fileExt, SearchOption.TopDirectoryOnly))
        {
            string allPath = pngFile.FullName;

            string assetPath = allPath.Substring(allPath.IndexOf("Assets"));

            AudioClip clip = AssetDatabase.LoadAssetAtPath(assetPath, typeof(AudioClip)) as AudioClip;
            if (clip == null)
            {
                continue;
            }
            audioMap.AddAudioClip(clip);
        }
    }
Ejemplo n.º 13
0
    static private void makeAudios( )
    {
        string spriteDir = Application.dataPath + "/Resources/Audio";


        if (!Directory.Exists(spriteDir))
        {
            Directory.CreateDirectory(spriteDir);
        }

        string path = AssetDatabase.GetAssetPath(Selection.activeObject);

        DirectoryInfo dirInfo  = new DirectoryInfo(path);
        GameObject    newGo    = null;
        AudioMap      audioMap = null;

        FileInfo[] mp3s = dirInfo.GetFiles("*.mp3", SearchOption.TopDirectoryOnly);
        FileInfo[] oggs = dirInfo.GetFiles("*.ogg", SearchOption.TopDirectoryOnly);
        FileInfo[] wavs = dirInfo.GetFiles("*.wav", SearchOption.TopDirectoryOnly);
        if (mp3s.Length > 0 || oggs.Length > 0 || wavs.Length > 0)
        {
            newGo    = new GameObject(dirInfo.Name);
            audioMap = newGo.AddComponent <AudioMap>();
        }
        else
        {
            return;
        }

        loopAddAudio(dirInfo, audioMap, "*.mp3");
        loopAddAudio(dirInfo, audioMap, "*.ogg");
        loopAddAudio(dirInfo, audioMap, "*.wav");


        string allPath = spriteDir + "/" + dirInfo.Name + ".prefab";

        if (File.Exists(allPath))
        {
            File.Delete(allPath);
        }

        string prefabPath = allPath.Substring(allPath.IndexOf("Assets"));

        PrefabUtility.CreatePrefab(prefabPath, newGo);

        GameObject.DestroyImmediate(newGo);
    }
Ejemplo n.º 14
0
    public static void AnimateGoldenStars(int count, Vector3 fromViewportSpace, Vector3 toViewportSpace, int countPerSprite = 1, Action <int> onLeaveTick = null, Action <int> onArriveTick = null)
    {
        AudioMap.PlayClipAt(AudioMap.instance["starCollect"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        AnimatedCurrencySettings animatedCurrencySettings = default(AnimatedCurrencySettings);

        animatedCurrencySettings.onLeave           = onLeaveTick;
        animatedCurrencySettings.onArrive          = onArriveTick;
        animatedCurrencySettings.count             = count;
        animatedCurrencySettings.countPerSprite    = countPerSprite;
        animatedCurrencySettings.audioName         = "starCollected";
        animatedCurrencySettings.icon              = instance.goldenStarSprite;
        animatedCurrencySettings.fromViewportSpace = fromViewportSpace;
        animatedCurrencySettings.toViewportSpace   = toViewportSpace;
        AnimatedCurrencySettings settings = animatedCurrencySettings;

        instance.AnimateCurrencies(settings);
    }
Ejemplo n.º 15
0
 private void BuyBoosterCoins()
 {
     if (PlayerDataManager.BuyBooster(selectedBoosterId))
     {
         AudioMap.PlayClipAt("upgradeBooster", Vector3.zero, AudioMap.instance.uiMixerGroup);
         AudioMap.PlayClipAt("purchase", Vector3.zero, AudioMap.instance.uiMixerGroup);
         currentBoosters = PlayerDataManager.GetTankBoosters(Variables.instance.GetTank(PlayerDataManager.GetSelectedTank()));
         SetSelectedBooster(selectedBoosterId);
         TankPrefs.Save();
         TankPrefs.CloudSyncComplete = true;
         PlayerDataManager.SaveToCloudOnNextInterval = true;
     }
     else
     {
         MenuController.ShowMenu <OutOfCurrencyPopup>().SetCurrency(CurrencyType.Coins);
     }
 }
Ejemplo n.º 16
0
    private IEnumerator Start()
    {
        GetComponent <Collider2D>().enabled = false;
        AudioMap audioMap = TankGame.instance.audioMap;

        AudioMap.PlayClipAt(audioMap, "mineSpawn", base.transform.position, audioMap.effectsMixerGroup);
        for (float t = 0f; t < 0.75f; t += Time.deltaTime)
        {
            float t2 = LeanTween.easeOutElastic(0f, 1f, t / 0.75f);
            base.transform.localScale = Vector3.Lerp(Vector3.zero, new Vector3(2f, 2f, 2f), t2);
            yield return(null);
        }
        GetComponent <Collider2D>().enabled = true;
        Detonated = false;
        yield return(new WaitForSeconds(2f));

        body.simulated = false;
    }
Ejemplo n.º 17
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Vehicle componentInParent = collision.gameObject.GetComponentInParent <Vehicle>();

        if (componentInParent != null && componentInParent != attachedVehicle && !vehiclesDamaged.Contains(componentInParent))
        {
            componentInParent.rigidbodies[0].AddForce((componentInParent.transform.position - base.transform.position).normalized * pushForce, ForceMode2D.Impulse);
            vehiclesDamaged.Add(componentInParent);
        }
        BulletContainer componentInParent2 = collision.gameObject.GetComponentInParent <BulletContainer>();

        if (componentInParent2 != null && componentInParent2.Bullet.owner != attachedVehicle.transform)
        {
            Absorb(componentInParent2.transform.position, componentInParent2.Bullet.damage);
            componentInParent2.Bullet.explodeDelayed = false;
            TankGame.instance.DestroyBullet(componentInParent2.Bullet, 0f);
            AudioMap.PlayClipAt("forceFieldAbsorbBig", base.transform.position, TankGame.instance.audioMap.effectsMixerGroup);
        }
    }
Ejemplo n.º 18
0
    private IEnumerator DoubleRewardsRoutine()
    {
        yield return(new WaitForSeconds(0.25f));

        doubleRewardsActiveContainer.SetActive(value: true);
        Vector3 origPos = doubleRewardsTextContainer.position;

        doubleRewardsTextContainer.position = Vector3.zero;
        float   time2 = 0.6f;
        Vector2 scale = Vector2.one * 2f;

        AudioMap.PlayClipAt("vipDoubleSplash", Vector3.zero, AudioMap.instance.uiMixerGroup);
        for (float t2 = 0f; t2 < time2; t2 += Time.deltaTime)
        {
            doubleRewardsTextContainer.localScale = Vector2.Lerp(Vector2.one, scale, LeanTween.easeOutCirc(0f, 1f, t2 / time2));
            yield return(null);
        }
        yield return(new WaitForSeconds(0.25f));

        Vector2 centerPos = doubleRewardsTextContainer.position;

        time2 = 0.4f;
        for (float t2 = 0f; t2 < time2; t2 += Time.deltaTime)
        {
            doubleRewardsTextContainer.position   = Vector2.Lerp(centerPos, origPos, LeanTween.easeOutCirc(0f, 1f, t2 / time2));
            doubleRewardsTextContainer.localScale = Vector2.Lerp(scale, Vector2.one, LeanTween.easeOutCubic(0f, 1f, t2 / time2));
            yield return(null);
        }
        doubleRewardsTextContainer.anchoredPosition = Vector2.zero;
        yield return(new WaitForSeconds(0.25f));

        AudioMap.PlayClipAt("vipDoubleRoll", Vector3.zero, AudioMap.instance.uiMixerGroup);
        int num;

        for (int i = 0; i != elements.Count; i = num)
        {
            elements[i].SetDoubleValues(shopItems[i]);
            yield return(null);

            num = i + 1;
        }
        StartCoroutine(DoubleRewardsEOFRoutine());
    }
Ejemplo n.º 19
0
    public static void AnimateCoins(int count, Vector3 fromViewportSpace, Vector3 toViewportSpace, int countPerSprite = 1, Action <int> onLeaveTick = null, Action <int> onArriveTick = null, bool departureSound = true)
    {
        if (departureSound)
        {
            AudioMap.PlayClipAt("coinDeparture", Vector3.zero, AudioMap.instance.uiMixerGroup);
        }
        AnimatedCurrencySettings animatedCurrencySettings = default(AnimatedCurrencySettings);

        animatedCurrencySettings.onLeave           = onLeaveTick;
        animatedCurrencySettings.onArrive          = onArriveTick;
        animatedCurrencySettings.count             = count;
        animatedCurrencySettings.countPerSprite    = countPerSprite;
        animatedCurrencySettings.audioName         = "coinroll";
        animatedCurrencySettings.icon              = instance.coinSprite;
        animatedCurrencySettings.fromViewportSpace = fromViewportSpace;
        animatedCurrencySettings.toViewportSpace   = toViewportSpace;
        AnimatedCurrencySettings settings = animatedCurrencySettings;

        instance.AnimateCurrencies(settings);
    }
Ejemplo n.º 20
0
    AudioMap GetAudioMap(GameObject prefab)
    {
        AudioMap am = null;

        if (cache.TryGetValue(prefab, out am))
        {
            return(am);
        }

        GameObject ao = GameObject.Instantiate(prefab) as GameObject;

        ao.transform.parent = transform;
        am = ao.GetComponent <AudioMap> ();
        if (am == null)
        {
            Debug.LogError("can not get atlias map from prefab");
            return(null);
        }
        cache.Add(prefab, am);
        return(am);
    }
Ejemplo n.º 21
0
    private IEnumerator Explosion()
    {
        AudioMap audioMap = TankGame.instance.audioMap;
        float    time     = Mathf.Lerp(timeAtMinLevel, timeAtMaxLevel, base.Booster.GetValue());
        int      num;

        for (int i = 0; i < 5; i = num)
        {
            glowSprite.enabled = !glowSprite.enabled;
            if (glowSprite.enabled)
            {
                AudioMap.PlayClipAt(audioMap, "mineBeep", base.transform.position, audioMap.effectsMixerGroup);
            }
            yield return(new WaitForSeconds(time / 5f));

            num = i + 1;
        }
        AudioMap.PlayClipAt(audioMap, "mineExplode", base.transform.position, audioMap.effectsMixerGroup);
        glowSprite.enabled = false;
        mainSprite.enabled = false;
        float radius = Mathf.Lerp(damageRangeAtMinLevel, damageRangeAtMaxLevel, base.Booster.GetValue());

        RaycastHit2D[]    array   = Physics2D.CircleCastAll(base.transform.position, radius, Vector2.zero, 0f, layerMask);
        HashSet <Vehicle> hashSet = new HashSet <Vehicle>();

        for (int j = 0; j < array.Length; j++)
        {
            Vehicle componentInParent = array[j].collider.GetComponentInParent <Vehicle>();
            if (componentInParent != null && !hashSet.Contains(componentInParent))
            {
                hashSet.Add(componentInParent);
                componentInParent.CurrentHealth -= Mathf.Lerp(damageAtMinLevel, damageAtMaxLevel, base.Booster.GetValue());
                componentInParent.rigidbodies[0].AddForce((componentInParent.transform.position - base.transform.position).normalized * Mathf.Lerp(forceAtMinLevel, forceAtMaxLevel, base.Booster.GetValue()), ForceMode2D.Impulse);
            }
        }
        particles.Play();
        Detonated = true;
        UnityEngine.Object.Destroy(base.gameObject, particles.main.duration);
    }
Ejemplo n.º 22
0
    private IEnumerator AnimateUnlock()
    {
        AudioMap.PlayClipAt(AudioMap.instance["levelUnlock"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        CanvasGroup buttonCanvasGroup = unlockButton.GetComponent <CanvasGroup>();
        float       time = 0.4f;

        for (float t2 = 0f; t2 <= time; t2 += Time.deltaTime)
        {
            buttonCanvasGroup.alpha = LeanTween.easeOutExpo(1f, 0f, t2 / time);
            yield return(null);
        }
        unlockButton.gameObject.SetActive(value: false);
        CanvasGroup scoreCanvasGroup = scoreText.GetComponent <CanvasGroup>();

        CanvasGroup[] componentsInChildren = scoreText.GetComponentsInChildren <CanvasGroup>();
        CanvasGroup   scoreBgCanvasGroup   = scoreCanvasGroup;

        CanvasGroup[] array = componentsInChildren;
        foreach (CanvasGroup canvasGroup in array)
        {
            if (canvasGroup != scoreCanvasGroup)
            {
                scoreBgCanvasGroup = canvasGroup;
            }
        }
        scoreCanvasGroup.alpha   = 0f;
        scoreBgCanvasGroup.alpha = 0f;
        scoreText.gameObject.SetActive(value: true);
        for (float t2 = 0f; t2 <= time; t2 += Time.deltaTime)
        {
            float val = t2 / time;
            scoreCanvasGroup.alpha   = LeanTween.easeInExpo(0f, 1f, val);
            scoreBgCanvasGroup.alpha = LeanTween.easeInExpo(0f, 1f, val);
            yield return(null);
        }
        scoreCanvasGroup.alpha   = 1f;
        scoreBgCanvasGroup.alpha = 1f;
    }
Ejemplo n.º 23
0
    private IEnumerator InitIAP()
    {
        while (!iapItem.IsInitialized)
        {
            yield return(null);
        }
        gemAmountText.GetComponent <LocalizationParamsManager>().SetParameterValue("AMOUNT", iapItem.product.definition.payout.quantity.ToString());
        bool someIAPbought = IAPManager.GetSomeIAPBought();

        iapItem.SetOnComplete(delegate
        {
            TankAnalytics.BoughtNoAdsOffer(!someIAPbought);
            LeanTween.delayedCall(1.25f, (Action) delegate
            {
                AnimatedCurrencyController.AnimateGems((int)iapItem.product.definition.payout.quantity, MenuController.UICamera.WorldToViewportPoint(iapItem.transform.position), MenuController.TotalGemsPositionViewport, 1, null, delegate(int tc)
                {
                    //MenuController.instance.topTotalGemsText.Tick(tc);
                });
                AudioMap.PlayClipAt(AudioMap.instance["gemCollect"], Vector3.zero, AudioMap.instance.uiMixerGroup);
                TankPrefs.SaveAndSendToCloud(forced: true);
                MenuController.HideMenu <NoAdsPopup>();
            });
        });
    }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     map = FindObjectOfType<AudioMap>();
     Invoke("SetHashID", 10);
 }
Ejemplo n.º 25
0
    private IEnumerator AddStars()
    {
        while (true)
        {
            int j;
            for (int i = 0; i < starsToAddPerGameMode.Length; i = j)
            {
                if (starsToAddPerGameMode[i] > 0)
                {
                    //yield return new WaitWhile(() => AdsManager.ShowingAd);
                    yield return(new WaitForSeconds(1.25f));

                    GameMode       mode   = (GameMode)i;
                    GameModeButton button = null;
                    Vector3        to     = default(Vector3);
                    switch (mode)
                    {
                    case GameMode.Arena:
                        to = MenuController.UICamera.WorldToViewportPoint(pvpChest.starAnimationTarget.position);
                        //	button = play1V1Button;
                        break;

                    case GameMode.Arena2v2:
                        to = MenuController.UICamera.WorldToViewportPoint(pvpChest.starAnimationTarget.position);
                        //button = play2V2Button;
                        break;

                    case GameMode.Adventure:
                        to     = MenuController.UICamera.WorldToViewportPoint(adventureChest.starAnimationTarget.position);
                        button = playAdventureButton;
                        break;
                    }
                    button.glow.enabled = true;
                    RectTransform glowRect       = button.glow.GetComponent <RectTransform>();
                    Vector2       startPosition  = new Vector2(0f, -300f);
                    Vector2       targetPosition = new Vector2(0f, 300f);
                    if (mode == GameMode.Adventure)
                    {
                        RectOpacityContainer[] adventureButtonElements = GetAdventureButtonElements(adventureLogoLevel);
                        StartCoroutine(FadeElementOut(adventureButtonElements[2], 0.15f, 0.1f));
                        StartCoroutine(FadeElementOut(adventureButtonElements[1], 0.22f, 0.1f));
                        StartCoroutine(FadeElementOut(adventureButtonElements[0], 0.26f, 0.14f));
                    }
                    for (float t = 0f; t < 0.5f; t += Time.deltaTime)
                    {
                        glowRect.anchoredPosition = Vector2.Lerp(startPosition, targetPosition, t / 0.5f);
                        yield return(null);
                    }
                    button.glow.enabled = false;
                    AnimateFlash[] componentsInChildren = button.GetComponentsInChildren <AnimateFlash>();
                    for (j = 0; j < componentsInChildren.Length; j++)
                    {
                        componentsInChildren[j].Play();
                    }
                    button.sparkleParticles.Play();
                    Vector3      fromViewportSpace = MenuController.UICamera.WorldToViewportPoint(button.starFlightStart.position);
                    int          startCount        = 0;
                    Action <int> onLeaveTick       = delegate
                    {
                    };
                    Action <int> action = (Action <int>) delegate
                    {
                    };
                    if (mode == GameMode.Adventure)
                    {
                        int num = starsToAddPerGameMode[i];
                        startCount = PlayerDataManager.GetChestProgress(ChestProgressionType.Adventure) - num;
                        Action <int> onArriveTick = delegate(int tickCount)
                        {
                            float progress2 = (float)(startCount + tickCount) / (float)Variables.instance.GetChestPointsNeeded(ChestProgressionType.Adventure);
                            adventureChest.SetProgress(progress2);
                            adventureChest.progressText.Tick(tickCount);
                            adventureChest.GetComponentInChildren <AnimateFlash>().Play();
                            AudioMap.PlayClipAt("progressBarTick", Vector3.zero, AudioMap.instance.uiMixerGroup);
                            MenuController.UpdateTopMenu();
                            StartCoroutine(AnimateFadeMapChange());
                        };
                        AnimatedCurrencyController.AnimateSilverStars(num, fromViewportSpace, to, 1, onLeaveTick, onArriveTick);
                    }
                    else
                    {
                        int num = starsToAddPerGameMode[i];
                        startCount = PlayerDataManager.GetChestProgress(ChestProgressionType.Pvp) - num;
                        Action <int> onArriveTick = delegate(int tickCount)
                        {
                            float progress = (float)(startCount + tickCount) / (float)Variables.instance.GetChestPointsNeeded(ChestProgressionType.Pvp);
                            pvpChest.SetProgress(progress);
                            pvpChest.progressText.Tick(tickCount);
                            pvpChest.GetComponentInChildren <AnimateFlash>().Play();
                            AudioMap.PlayClipAt("progressBarTick", Vector3.zero, AudioMap.instance.uiMixerGroup);
                            MenuController.UpdateTopMenu();
                        };
                        AnimatedCurrencyController.AnimateGoldenStars(num, fromViewportSpace, to, 1, onLeaveTick, onArriveTick);
                    }
                    starsToAddPerGameMode[i] = 0;
                }
                j = i + 1;
            }
            yield return(null);
        }
    }
Ejemplo n.º 26
0
    private IEnumerator OnGameEnd(TankGame game, GameMode mode)
    {
        if (game.playerTankContainer.CurrentHealth <= 0f)
        {
            GetComponent <CanvasGroup>().alpha = 0f;
            if (!TankGame.instance.ReviveTried)
            {
                RevivePopup revive = MenuController.ShowMenu <RevivePopup>();
                revive.reviveCoinsButton.onClick.RemoveAllListeners();
                revive.reviveCoinsButton.onClick.AddListener(delegate
                {
                    if (PlayerDataManager.TakeGems(Variables.instance.reviveCost))
                    {
                        TankGame.instance.ReviveTried = true;
                        TankGame.instance.ReviveUsed  = true;
                        MenuController.HideMenu <RevivePopup>();
                        TankAnalytics.BoughtWithPremiumCurrency("revive", "revive", Variables.instance.reviveCost);
                    }
                    else
                    {
                        MenuController.ShowMenu <OutOfCurrencyPopup>().SetCurrency(CurrencyType.Gems);
                    }
                });
                revive.reviveAdsButton.onClick.RemoveAllListeners();
                revive.reviveAdsButton.onClick.AddListener(delegate
                {
                    // SDKManager.Instance.MakeToast("ÔÝÎÞ¹ã¸æ!!!");
                    SDKManager.Instance.ShowAd(ShowAdType.Reward, 1, "µã»÷Ãâ·Ñ¸´»î", (bool IsComp) =>
                    {
                        if (IsComp)
                        {
                            FH();
                        }
                    });
                });
                bool  blink         = false;
                float blinkTime     = 0f;
                float blinkInterval = 0.1f;
                float time          = 0f;
                while (time <= Variables.instance.reviveTime && !TankGame.instance.ReviveTried)
                {
                    revive.reviveSecondsText.text = Mathf.FloorToInt(Variables.instance.reviveTime - time).ToString();
                    if (MenuController.GetMenu <ShopMenu>().gameObject.activeInHierarchy || MenuController.GetMenu <OutOfCurrencyPopup>().gameObject.activeInHierarchy)
                    {
                        time = 0f;
                        yield return(null);

                        continue;
                    }
                    AudioMap.PlayClipAt("countdown", Vector3.zero, AudioMap.instance.uiMixerGroup);
                    for (float secondTime = 0f; secondTime <= 1f; secondTime += Time.deltaTime)
                    {
                        if (Variables.instance.reviveTime - time < 4f)
                        {
                            if (blinkTime > Mathf.Max(0.1f, blinkInterval * (Variables.instance.reviveTime - time)))
                            {
                                revive.reviveSecondsText.enabled = blink;
                                blink     = !blink;
                                blinkTime = 0f;
                            }
                            blinkTime += Time.deltaTime;
                        }
                        time += Time.deltaTime;
                        yield return(null);
                    }
                }
                MenuController.HideMenu <RevivePopup>();
            }
            if (TankGame.instance.ReviveTried)
            {
                yield return(null); //new WaitWhile(() => AdsManager.ShowingAd);
            }
            if (TankGame.instance.AllLivesUsed)
            {
                yield return(new WaitForSecondsRealtime(1.5f));
            }
            GetComponent <CanvasGroup>().alpha = 1f;
        }
        else
        {
            MusicManager.SetToBossEndMusic();
        }
    }
Ejemplo n.º 27
0
    private IEnumerator AnimateFadeMapChange()
    {
        RectOpacityContainer[] elements = GetAdventureButtonElements();
        float[] audioDelays             = new float[3]
        {
            0.16f,
            0.2f,
            0.15f
        };
        float scale = 2f;

        for (int j = 0; j != elements.Length; j++)
        {
            RectOpacityContainer rectOpacityContainer = elements[j];
            rectOpacityContainer.rect.localScale = Vector3.one * scale;
            if (rectOpacityContainer.text != null)
            {
                rectOpacityContainer.text.color = new Color(1f, 1f, 1f, 0f);
                rectOpacityContainer.text.gameObject.SetActive(value: true);
            }
            if (rectOpacityContainer.images != null && rectOpacityContainer.images.Length != 0)
            {
                Image[] images = rectOpacityContainer.images;
                foreach (Image obj in images)
                {
                    obj.color = new Color(1f, 1f, 1f, 0f);
                    obj.gameObject.SetActive(value: true);
                }
            }
            rectOpacityContainer.rect.gameObject.SetActive(value: true);
        }
        int k;

        for (int i = 0; i != elements.Length; i = k)
        {
            RectOpacityContainer ele = elements[i];
            float time = 0f;
            AudioMap.PlayClipAt(AudioMap.instance.logoHit[i], Vector3.zero, AudioMap.instance.uiMixerGroup, audioDelays[i]);
            for (; time < 0.35f; time += Time.deltaTime)
            {
                float num = time / 0.35f;
                ele.rect.localScale = Vector3.Lerp(Vector3.one * scale, Vector3.one, LeanTween.easeInCubic(0f, 1f, num));
                if (ele.text != null)
                {
                    ele.text.color = new Color(1f, 1f, 1f, Mathf.Lerp(0f, 1f, num));
                }
                if (ele.images != null && ele.images.Length != 0)
                {
                    Image[] images = ele.images;
                    for (k = 0; k < images.Length; k++)
                    {
                        images[k].color = new Color(1f, 1f, 1f, Mathf.Lerp(0f, 1f, num));
                    }
                }
                yield return(null);
            }
            ele.rect.localScale = Vector3.one;
            cameraShake        += new Vector2(UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f) * 10f;
            yield return(new WaitForSeconds(0.1f));

            k = i + 1;
        }
    }
Ejemplo n.º 28
0
    private IEnumerator ChestOpenAnimationRoutine(Rarity chestRarity)
    {
        rewardingDone       = false;
        chestExploded       = false;
        currentChestRewards = Variables.instance.GenerateChestRewards(chestRarity);
        PlayerDataManager.AddChestRewards(currentChestRewards);
        contentGridLayoutGroup.enabled = true;
        for (int j = 0; j != currentChestRewards.cards.Count; j++)
        {
            CardElement       component = UnityEngine.Object.Instantiate(cardPrefab).GetComponent <CardElement>();
            Card              card      = currentChestRewards.cards[j];
            ShopMenu.ShopItem item      = new ShopMenu.ShopItem
            {
                rarity = card.rarity,
                count  = card.count,
                id     = card.id,
                type   = ((card.type == CardType.TankCard) ? ShopMenu.ShopItemType.TankCard : ShopMenu.ShopItemType.BoosterCard),
                isNew  = card.isNew
            };
            shopItems.Add(item);
            AddElement(component);
            if (card.type == CardType.TankCard)
            {
                Tank tank = Variables.instance.GetTank(card.id);
                if (card.isNew)
                {
                    newCards.Push(new KeyValuePair <Collectible, CardElement>(tank, component));
                }
            }
        }
        if (currentChestRewards.gems > 0)
        {
            CardElement       component2 = UnityEngine.Object.Instantiate(cardPrefab).GetComponent <CardElement>();
            ShopMenu.ShopItem item2      = new ShopMenu.ShopItem
            {
                rarity = Rarity.Epic,
                count  = currentChestRewards.gems,
                type   = ShopMenu.ShopItemType.Gem
            };
            shopItems.Add(item2);
            AddElement(component2);
        }
        CardElement component3 = UnityEngine.Object.Instantiate(cardPrefab).GetComponent <CardElement>();

        ShopMenu.ShopItem item3 = new ShopMenu.ShopItem
        {
            rarity = chestRarity,
            count  = currentChestRewards.coins,
            type   = ShopMenu.ShopItemType.Coin
        };
        shopItems.Add(item3);
        AddElement(component3);
        LayoutRebuilder.ForceRebuildLayoutImmediate(contentGridLayoutGroup.GetComponent <RectTransform>());
        contentGridLayoutGroup.enabled = false;
        foreach (CardElement element in elements)
        {
            element.gameObject.SetActive(value: false);
        }
        chest.gameObject.SetActive(value: true);
        Image  image = chest;
        object sprite;

        switch (chestRarity)
        {
        default:
            sprite = commonChestSprite;
            break;

        case Rarity.Rare:
            sprite = rareChestSprite;
            break;

        case Rarity.Epic:
            sprite = epicChestSprite;
            break;
        }
        image.sprite = (Sprite)sprite;
        chest.SetNativeSize();
        yield return(new WaitForSeconds(currentOptions.shakeTime));

        AudioMap.PlayClipAt(AudioMap.instance["chestShake"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        LeanTween.delayedCall(currentOptions.windupTime - 0.367f, (Action) delegate
        {
            AudioMap.PlayClipAt(AudioMap.instance["chestWindup"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        });
        for (float time = 0f; time <= currentOptions.windupTime; time += Time.deltaTime)
        {
            chest.transform.rotation = Quaternion.Euler(0f, 0f, 50f * (Mathf.PingPong(time / 0.2f, 0.3f) - 0.2f));
            glowImage.color          = new Color(1f, 1f, 1f, LeanTween.easeInExpo(0f, 1f, time / currentOptions.windupTime));
            yield return(null);
        }
        chest.gameObject.SetActive(value: false);
        chest.transform.rotation = Quaternion.identity;
        currentOptions.explosion.Play();
        AudioMap.PlayClipAt(AudioMap.instance["chestOpen"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        if (chestRarity == Rarity.Epic)
        {
            AudioMap.PlayClipAt(AudioMap.instance["chestOpenChime"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        }
        yield return(new WaitForSeconds(currentOptions.postExplosionWaitTime));

        doubleRewardsOfferButton.gameObject.SetActive(!isSubscribed);
        doubleRewardingDone = !isSubscribed;
        chestExploded       = true;
        MenuController.backButtonOverrideAction = FinishAnimation;
        int num;

        for (int i = 0; i < elements.Count; i = num)
        {
            if (!(elements[i] == null))
            {
                CardElement cardElement = elements[i];
                AudioMap.PlayClipAt(AudioMap.instance["cardReveal"], Vector3.zero, AudioMap.instance.uiMixerGroup);
                cardElement.gameObject.SetActive(value: true);
                cardElement.SetValues(shopItems[i], animateRoll: true, deductCount: true, isSubscribed);
                if (shopItems[i].type == ShopMenu.ShopItemType.TankCard && shopItems[i].isNew)
                {
                    SetNewCard(i);
                }
                if (shopItems[i].type == ShopMenu.ShopItemType.Coin)
                {
                    AnimatedCurrencyController.AnimateCoins(isSubscribed ? (shopItems[i].count / 2) : shopItems[i].count, MenuController.UICamera.WorldToViewportPoint(cardElement.transform.position), MenuController.TotalCoinsPositionViewport, 5, null, delegate(int ts)
                    {
                        MenuController.instance.topTotalCoinsText.Tick(ts);
                    });
                }
                else if (shopItems[i].type == ShopMenu.ShopItemType.Gem)
                {
                    AnimatedCurrencyController.AnimateGems(isSubscribed ? (shopItems[i].count / 2) : shopItems[i].count, MenuController.UICamera.WorldToViewportPoint(cardElement.transform.position), MenuController.TotalGemsPositionViewport, 1, null, delegate(int ts)
                    {
                        MenuController.instance.topTotalGemsText.Tick(ts);
                    });
                }
                yield return(new WaitForSeconds(0.25f));
            }
            num = i + 1;
        }
        if (isSubscribed)
        {
            doubleRewardRoutine = StartCoroutine(DoubleRewardsRoutine());
        }
        FinishAnimation();
    }
Ejemplo n.º 29
0
 private void Awake()
 {
     map = FindObjectOfType<AudioMap>();
     source = recordingButton.GetComponent<AudioSource>();
 }
Ejemplo n.º 30
0
 // Use this for initialization
 private void Start()
 {
     audio = GetComponent<AudioSource>();
     currentHashID = new ButtonHashID(Animator.StringToHash(gameObject.name));
     map = FindObjectOfType<AudioMap>();
 }
Ejemplo n.º 31
0
 private void OnEnable()
 {
     instance = this;
 }
Ejemplo n.º 32
0
    private IEnumerator ScoreRoll(int highscore, int score, int coins)
    {
        int        num             = 0;
        bool       waitedFirst     = false;
        float      maxTime         = 2f;
        float      minTick         = 0.1f;
        float      scoreRollTime   = Mathf.Min(minTick * (float)scoreGotten, maxTime);
        FillTarget imageFillTarget = gameOverXpBarFill.GetComponent <FillTarget>();

        imageFillTarget.smoothTime = 0.066f;
        for (float t2 = 0f; t2 < scoreRollTime; t2 += Time.deltaTime)
        {
            SetXpBar(ranks, oldXp + num, gameOverXpBarFill, gameOverXpIndicator, gameOverPrevRank, gameOverNextRank, gameOverXpContainer, gameOverLastRankImage);
            newScoreText.text = num.ToString();
            AudioMap.PlayClipAt("scoreroll", Vector3.zero, AudioMap.instance.uiMixerGroup);
            if (MenuBase <GameEndMenu> .instance.nextRank != null)
            {
                float num2       = oldXp + num;
                float fillAmount = gameOverXpBarFill.fillAmount;
                float num3       = (prevRank != null) ? (num2 - (float)prevRank.xp) : num2;
                float num4       = (prevRank != null) ? (nextRank.xp - prevRank.xp) : nextRank.xp;
                float num5       = num3 / num4;
                if (num5 < imageFillTarget.fillTarget)
                {
                    imageFillTarget.Reset(num5);
                }
                else
                {
                    imageFillTarget.fillTarget = num5;
                }
            }
            yield return(null);

            if (!waitedFirst)
            {
                yield return(new WaitForSeconds(1f));

                waitedFirst = true;
            }
            num = Mathf.RoundToInt(Mathf.Lerp(0f, scoreGotten, t2 / scoreRollTime));
        }
        num = scoreGotten;
        newScoreText.text = num.ToString();
        if (MenuBase <GameEndMenu> .instance.nextRank != null)
        {
            float num6        = oldXp + num;
            float fillAmount2 = gameOverXpBarFill.fillAmount;
            float num7        = (prevRank != null) ? (num6 - (float)prevRank.xp) : num6;
            float num8        = (prevRank != null) ? (nextRank.xp - prevRank.xp) : nextRank.xp;
            float num5        = imageFillTarget.fillTarget = num7 / num8;
        }
        int   currentCoins = 0;
        float coinRollTime = Mathf.Min((float)coinsGotten * minTick, maxTime);

        for (float t2 = 0f; t2 < coinRollTime; t2 += Time.deltaTime)
        {
            coinsText.text = currentCoins.ToString();
            AudioMap.PlayClipAt("coinroll", Vector3.zero, AudioMap.instance.uiMixerGroup);
            currentCoins = Mathf.RoundToInt(Mathf.Lerp(0f, coinsGotten, t2 / coinRollTime));
            yield return(null);
        }
        scoreRollRoutine = null;
        FinishScoreRoll();
    }
Ejemplo n.º 33
0
 public static AudioSource PlayClipAt(AudioMap audioMap, string name, Vector3 pos, AudioMixerGroup mixerGroup, float delay = 0f)
 {
     return(PlayClipAt(audioMap[name], pos, mixerGroup, delay));
 }