Exemple #1
0
        public static MissionBoosterHelper CreateMissionBooster(RectTransform parent, MissionBoosterHelper prefab, Booster b, Action GotoShopHandler)
        {
            if (prefab)
            {
                prefab.boosterImage.sprite = b.bData.GuiImage;         // unity 2019 fix
            }
            MissionBoosterHelper missionBooster = Instantiate(prefab);

            missionBooster.transform.localScale = parent.transform.lossyScale;
            missionBooster.transform.SetParent(parent);
            missionBooster.boosterImage.sprite = b.bData.GuiImage;
            missionBooster.boosterCounter.text = b.Count.ToString();

            // add footer click handlers
            missionBooster.boosterButton.onClick.AddListener(() => { if (b.Count > 0)
                                                                     {
                                                                         b.ChangeUse();
                                                                     }
                                                                     else
                                                                     {
                                                                         GotoShopHandler?.Invoke();
                                                                     } });
            missionBooster.shopButton.onClick.AddListener(GotoShopHandler.Invoke);
            missionBooster.booster = b;
            missionBooster.InitStart();
            return(missionBooster);
        }
Exemple #2
0
        private void CreateBoostersPanel()
        {
            MissionBoosterHelper[] ms = BoostersParent.GetComponentsInChildren <MissionBoosterHelper>();
            foreach (MissionBoosterHelper item in ms)
            {
                DestroyImmediate(item.gameObject);
            }
            List <Booster> bList = new List <Booster>();

            foreach (var b in MPlayer.BoostHolder.Boosters)
            {
                if (b.Count > 0)
                {
                    bList.Add(b);
                }
            }

            bList.Shuffle();
            for (int i = 0; i < bList.Count; i++)
            {
                Booster b  = bList[i];
                string  id = b.bData.ID.ToString();
                MissionBoosterHelper bM = MissionBoosterHelper.CreateProfileBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id); });
            }
        }
        private void CreateBoostersPanel()
        {
            MissionBoosterHelper[] ms = BoostersParent.GetComponentsInChildren <MissionBoosterHelper>();
            foreach (MissionBoosterHelper item in ms)
            {
                DestroyImmediate(item.gameObject);
            }
            List <Booster> bList       = new List <Booster>();
            List <Booster> bListToShop = new List <Booster>();

            bool selectFromAll = true;

            if (!selectFromAll)
            {
                foreach (var b in MPlayer.BoostHolder.Boosters)
                {
                    if (b.Count > 0)
                    {
                        bList.Add(b);
                    }
                    else
                    {
                        bListToShop.Add(b);
                    }
                }

                bList.Shuffle();
                int bCount = Mathf.Min(bList.Count, boostersCount);
                for (int i = 0; i < bCount; i++)
                {
                    Booster b  = bList[i];
                    string  id = b.bData.ID.ToString();
                    MissionBoosterHelper bM = MissionBoosterHelper.CreateMissionBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id); });
                }

                int shopCount = boostersCount - bList.Count;
                if (shopCount > 0)
                {
                    shopCount = Mathf.Min(shopCount, bListToShop.Count);
                    bListToShop.Shuffle();

                    for (int i = 0; i < shopCount; i++)
                    {
                        Booster b  = bListToShop[i];
                        string  id = b.bData.ID.ToString();
                        MissionBoosterHelper bM = MissionBoosterHelper.CreateMissionBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id); });
                    }
                }
            }
            else
            {
                foreach (var b in MPlayer.BoostHolder.Boosters)
                {
                    bList.Add(b);
                }

                bList.Shuffle();
                int bCount = Mathf.Min(bList.Count, boostersCount);
                for (int i = 0; i < bCount; i++)
                {
                    Booster b  = bList[i];
                    string  id = b.bData.ID.ToString();
                    MissionBoosterHelper bM = MissionBoosterHelper.CreateMissionBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id); });
                }
            }
        }