Ejemplo n.º 1
0
 public void OnSlotPressed()
 {
     if (Singleton <TimeManager> .Instance.CurrentEpochTime == 0)
     {
         return;
     }
     UnityEngine.Debug.LogWarning(string.Concat(new string[]
     {
         "[OnSlotPressed] ",
         this.index.ToString(),
         ": state(",
         this.state.ToString(),
         ")"
     }));
     if (this.state == LootCrateSlot.State.Inactive)
     {
         if (LootCrateSlots.IsUnlockingInProgress())
         {
             this.ShowPurchasePopup(UnlockLootCrateSlotDialog.UnlockType.PurchaseInactiveCrate);
         }
         else
         {
             this.ShowPurchasePopup(UnlockLootCrateSlotDialog.UnlockType.StartUnlocking);
         }
     }
     else if (this.state == LootCrateSlot.State.Locked)
     {
         this.ShowPurchasePopup(UnlockLootCrateSlotDialog.UnlockType.PurchaseLockedCrate);
     }
     else if (this.state == LootCrateSlot.State.Unlocked)
     {
         this.OpenCrate();
     }
 }
Ejemplo n.º 2
0
 public static void InformCrateOpened(string identifier, LootCrateType crateType)
 {
     if (LootCrateSlots.instance != null)
     {
         LootCrateSlots.instance.ShowFullBubble(LootCrateSlots.AreSlotsFull());
     }
 }
Ejemplo n.º 3
0
 private void OnCrateUnlocked(int secondsSinceDone)
 {
     if (GameProgress.HasKey(this.identifier, GameProgress.Location.Local, null))
     {
         GameProgress.SetString(this.identifier, string.Format("{0},{1}", LootCrateSlot.State.Unlocked.ToString(), this.crateType.ToString()), GameProgress.Location.Local);
         this.ChangeState(LootCrateSlot.State.Unlocked);
     }
     LootCrateSlots.InformCrateUnlocked(this.identifier, this.crateType, this.unlockPrice);
 }
Ejemplo n.º 4
0
 public void OpenCrate()
 {
     if (Singleton <TimeManager> .Instance.HasTimer(this.identifier))
     {
         Singleton <TimeManager> .Instance.RemoveTimer(this.identifier);
     }
     GameProgress.DeleteKey(this.identifier, GameProgress.Location.Local);
     LootCrate.SpawnLootCrateOpeningDialog(this.crateType, 1, WPFMonoBehaviour.s_hudCamera, null, new LootCrate.AnalyticData("Slot", this.unlockPrice.ToString(), LootCrate.AdWatched.NotApplicaple));
     this.ChangeState(LootCrateSlot.State.Empty);
     LootCrateSlots.InformCrateOpened(this.identifier, this.crateType);
 }
Ejemplo n.º 5
0
 public static bool AreSlotsFull()
 {
     for (int i = 0; i < LootCrateSlots.SlotsAvailable; i++)
     {
         if (!LootCrateSlots.IsSlotOccupied(i))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 6
0
 private float TimeLeftInSeconds()
 {
     if (!string.IsNullOrEmpty(this.identifier) && Singleton <TimeManager> .Instance.HasTimer(this.identifier))
     {
         return(Mathf.Clamp(Singleton <TimeManager> .Instance.TimeLeft(this.identifier), 0f, float.MaxValue));
     }
     if (this.state == LootCrateSlot.State.Inactive)
     {
         return((float)LootCrateSlots.GetOpenTimeForCrate(this.crateType));
     }
     return(0f);
 }
Ejemplo n.º 7
0
    private void ChangeState(State newState)
    {
        this.state = newState;
        if (this.state == LootCrateSlot.State.Empty)
        {
            this.crateType = LootCrateType.None;
        }
        this.activeTf.gameObject.SetActive(this.state != LootCrateSlot.State.Empty);
        this.emptyTf.gameObject.SetActive(this.state == LootCrateSlot.State.Empty);
        this.unlockedTf.gameObject.SetActive(this.state == LootCrateSlot.State.Unlocked);
        this.priceTf.gameObject.SetActive(this.state == LootCrateSlot.State.Locked);
        this.timeTf.gameObject.SetActive(this.state != LootCrateSlot.State.Unlocked);
        this.lockIcon.enabled  = (this.state == LootCrateSlot.State.Inactive);
        this.clockIcon.enabled = (this.state == LootCrateSlot.State.Locked);
        bool flag = this.state == LootCrateSlot.State.Unlocked || this.state == LootCrateSlot.State.Inactive;

        this.crateHolder.transform.localScale    = Vector3.one * ((!flag) ? 1f : 1.2f);
        this.crateHolder.transform.localPosition = Vector3.up * ((!flag) ? 0.1f : 0f);
        if (this.crateType != LootCrateType.None && this.crateHolder.childCount == 0 && this.state != LootCrateSlot.State.Empty)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(LootCrateSlots.GetCratePrefab(this.crateType));
            gameObject.transform.parent        = this.crateHolder;
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.localRotation = Quaternion.identity;
        }
        else if (this.crateHolder.childCount > 0 && this.state == LootCrateSlot.State.Empty)
        {
            for (int i = 0; i < this.crateHolder.childCount; i++)
            {
                Transform child = this.crateHolder.GetChild(i);
                if (child)
                {
                    UnityEngine.Object.Destroy(child.gameObject);
                }
            }
        }
        if (this.state == LootCrateSlot.State.Locked)
        {
            Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.openNowLocalization, null);

            TextMeshHelper.UpdateTextMeshes(this.activeInfoLabel, localeParameters.translation, false);
            TextMeshHelper.Wrap(this.activeInfoLabel, (!TextMeshHelper.UsesKanjiCharacters()) ? 8 : 4);
        }
        else
        {
            TextMeshHelper.UpdateTextMeshes(this.activeInfoLabel, string.Empty, false);
        }
        this.UpdateLabels();
    }
Ejemplo n.º 8
0
    public UnlockLootCrateSlotDialog ShowNoFreeSlotsDialog(LootCrateType crateType, TextDialog.OnConfirm onConfirm)
    {
        if (WPFMonoBehaviour.gameData.m_noFreeCrateSlotsPopup == null)
        {
            return(null);
        }
        UnlockLootCrateSlotDialog component = UnityEngine.Object.Instantiate <GameObject>(WPFMonoBehaviour.gameData.m_noFreeCrateSlotsPopup).GetComponent <UnlockLootCrateSlotDialog>();

        component.Open();
        component.SetOnConfirm(onConfirm);
        int openTimeForCrate = LootCrateSlots.GetOpenTimeForCrate(crateType);

        component.InitPopup(LootCrateSlot.GetSnoutCoinPrice(crateType, (float)openTimeForCrate), openTimeForCrate, LootCrateSlots.GetCratePrefab(crateType), crateType);
        return(component);
    }
Ejemplo n.º 9
0
 public void Initialize(bool isNew, int index, LootCrateType crateType)
 {
     this.FindComponents();
     this.index      = index;
     this.crateType  = crateType;
     this.identifier = LootCrateSlot.GetSlotIdentifier(index);
     this.hasTimer   = false;
     if (isNew)
     {
         LootCrateSlots.AddLootCrateToSlot(index, crateType);
         this.ChangeState(LootCrateSlot.State.Inactive);
     }
     else
     {
         this.TryRecover();
     }
 }
Ejemplo n.º 10
0
 public static void AddLootCrateToFreeSlot(LootCrateType crateType)
 {
     for (int i = 0; i < LootCrateSlots.SlotsAvailable; i++)
     {
         if (!LootCrateSlots.IsSlotOccupied(i))
         {
             LootCrateSlots.AddLootCrateToSlot(i, crateType);
             int num = GameProgress.GetInt("loot_crates_added_to_slots", 0, GameProgress.Location.Local, null);
             GameProgress.SetInt("loot_crates_added_to_slots", ++num, GameProgress.Location.Local);
             if (LootCrateSlots.instance != null)
             {
                 LootCrateSlots.instance.ShowFullBubble(LootCrateSlots.AreSlotsFull());
             }
             return;
         }
     }
     LootCrateSlots.overflowCrateType = crateType;
 }
Ejemplo n.º 11
0
    private void ActivateLootCrateSlot()
    {
        int num = LootCrateSlots.TryToActivateLootCrateAtSlot(this.index, this.crateType, new OnTimedOut(this.OnCrateUnlocked));

        if (num != -1)
        {
            if (num != 0)
            {
                if (num == 1)
                {
                    this.UpdateTimer();
                }
            }
            else
            {
                this.ChangeState(LootCrateSlot.State.Locked);
            }
        }
    }
Ejemplo n.º 12
0
 public void ShowUnlockDialog(LootCrateType crateType, int price, int timeLeft, TextDialog.OnConfirm onConfirm, UnlockLootCrateSlotDialog.UnlockType unlockType)
 {
     if (Singleton <BuildCustomizationLoader> .Instance.IsOdyssey)
     {
         return;
     }
     if (this.unlockCrateSlotDialogPrefab == null)
     {
         return;
     }
     if (this.unlockCrateSlotDialog == null)
     {
         this.unlockCrateSlotDialog = UnityEngine.Object.Instantiate <GameObject>(this.unlockCrateSlotDialogPrefab).GetComponent <UnlockLootCrateSlotDialog>();
     }
     this.unlockCrateSlotDialog.Open();
     this.unlockCrateSlotDialog.SetInfoLabel(unlockType);
     this.unlockCrateSlotDialog.SetOnConfirm(onConfirm);
     this.unlockCrateSlotDialog.InitPopup(price, timeLeft, LootCrateSlots.GetCratePrefab(crateType), crateType);
 }
Ejemplo n.º 13
0
    private void Awake()
    {
        LootCrateSlots.instance = this;
        List <LootCrateSlot> list = new List <LootCrateSlot>();

        for (int i = 0; i < this.slotCount; i++)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.lootCrateSlotPrefab);
            if (gameObject != null)
            {
                gameObject.name             = string.Format("Slot{0}", i + 1);
                gameObject.transform.parent = base.transform;
                LootCrateSlot component = gameObject.GetComponent <LootCrateSlot>();
                component.Initialize(false, i, LootCrateType.None);
                list.Add(component);
            }
        }
        this.slots = list.ToArray();
        LootCrateSlots.SlotsAvailable = this.slots.Length;
        GridLayout component2 = base.GetComponent <GridLayout>();

        component2.UpdateLayout();
        if (this.slotsFullBubble != null)
        {
            this.slotsFullBubble.transform.position = this.slots[this.slotCount - 1].transform.position;
        }
        this.ShowFullBubble(LootCrateSlots.AreSlotsFull());
        if (LootCrateSlots.overflowCrateType != LootCrateType.None)
        {
            LootCrateType crateType = LootCrateSlots.overflowCrateType;
            this.unlockCrateSlotDialog = this.ShowNoFreeSlotsDialog(crateType, delegate
            {
                if (this.unlockCrateSlotDialog != null && GameProgress.UseSnoutCoins(this.unlockCrateSlotDialog.SnoutCoinPrice))
                {
                    Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.snoutCoinUse);
                    LootCrate.SpawnLootCrateOpeningDialog(crateType, 1, WPFMonoBehaviour.hudCamera, null, new LootCrate.AnalyticData("CakeRaceOverflowUnlock", this.unlockCrateSlotDialog.SnoutCoinPrice.ToString(), LootCrate.AdWatched.NotApplicaple));
                    this.SendLootCrateUnlockedFlurryEvent(crateType, this.unlockCrateSlotDialog.SnoutCoinPrice, "overflow");
                }
            });
            LootCrateSlots.overflowCrateType = LootCrateType.None;
        }
    }
Ejemplo n.º 14
0
    public static int GetOpenTimeForCrate(LootCrateType crateType)
    {
        string valueKey = crateType.ToString();

        if (Singleton <GameConfigurationManager> .Instance.HasValue("lootcrate_open_times", valueKey))
        {
            int value = Singleton <GameConfigurationManager> .Instance.GetValue <int>("lootcrate_open_times", valueKey);

            if (value > 0)
            {
                return(value);
            }
        }
        switch (crateType)
        {
        case LootCrateType.Wood:
            return(LootCrateSlots.HoursToSeconds(8f));

        case LootCrateType.Metal:
            return(LootCrateSlots.HoursToSeconds(24f));

        case LootCrateType.Gold:
            return(LootCrateSlots.HoursToSeconds(48f));

        case LootCrateType.Cardboard:
            return(LootCrateSlots.HoursToSeconds(2f));

        case LootCrateType.Glass:
            return(LootCrateSlots.HoursToSeconds(4f));

        case LootCrateType.Bronze:
            return(LootCrateSlots.HoursToSeconds(16f));

        case LootCrateType.Marble:
            return(LootCrateSlots.HoursToSeconds(28f));

        default:
            return(LootCrateSlots.HoursToSeconds(72f));
        }
    }
Ejemplo n.º 15
0
    private void RewardCrate(int rewardIndex)
    {
        LootCrateType lootCrateType = LootCrateType.Cardboard;

        if (Singleton <GameConfigurationManager> .Instance.HasValue("cake_race", "loot_crates"))
        {
            string[] array = Singleton <GameConfigurationManager> .Instance.GetValue <string>("cake_race", "loot_crates").Split(new char[]
            {
                ','
            });

            int num = rewardIndex % array.Length;
            int num2;
            if (array != null && array.Length > 0 && num >= 0 && int.TryParse(array[num], out num2))
            {
                lootCrateType = (LootCrateType)num2;
            }
        }
        CakeRaceMode.CurrentRewardCrate = lootCrateType;
        if (lootCrateType != LootCrateType.None)
        {
            LootCrateSlots.AddLootCrateToFreeSlot(lootCrateType);
        }
    }
Ejemplo n.º 16
0
    public static int TryToActivateLootCrateAtSlot(int index, LootCrateType crateType, OnTimedOut onCrateUnlocked)
    {
        if (LootCrateSlots.IsUnlockingInProgress())
        {
            return(-1);
        }
        string slotIdentifier = LootCrateSlot.GetSlotIdentifier(index);

        GameProgress.SetString(slotIdentifier, string.Format("{0},{1}", LootCrateSlot.State.Locked.ToString(), crateType.ToString()), GameProgress.Location.Local);
        if (!Singleton <TimeManager> .Instance.HasTimer(slotIdentifier))
        {
            DateTime time = Singleton <TimeManager> .Instance.CurrentTime.AddSeconds((double)LootCrateSlots.GetOpenTimeForCrate(crateType));

            Singleton <TimeManager> .Instance.CreateTimer(slotIdentifier, time, onCrateUnlocked);

            GameProgress.SetString("LootCrateSlotOpening", slotIdentifier, GameProgress.Location.Local);
            if (LootCrateSlots.instance != null)
            {
                LootCrateSlots.instance.ShowFullBubble(LootCrateSlots.AreSlotsFull());
            }
            return(0);
        }
        return(1);
    }