예제 #1
0
        // Buys the product, if the product exists and the funds allow for it
        public bool BuyProduct(int _id, UIProduct.BuyType buyType)
        {
            Debug.Log("BuyProduct(id) " + _id);
            ProductInfo product   = GetProductInfo(_id);
            UIProduct   uiProduct = GetUIProductById(_id);

            if (product != null && uiProduct != null)
            {
                if (((!IsOwned(_id) && buyType == UIProduct.BuyType.nonConsumable) || buyType == UIProduct.BuyType.consumable) && uiProduct.price <= ProgressManager.GetProgress().starsOwned)
                {
                    ProgressManager.GetProgress().AddStarsToWallet(-uiProduct.price);

                    productInfos.Find(x => x.id == _id).owned = true;
                    EquipProduct(_id);

                    // Khajiit has Wares
                    Social.ReportProgress("CgkIqIqqjZYFEAIQBg", 100.0f, (bool success) =>
                    {
                        //if (success)
                        //Main.onAchievementUnlock.Invoke();
                    });

                    bool everythingBought = true;

                    // check if all 15 pruducts are bought to unlock the shoplifter achievement
                    foreach (ProductInfo p in productInfos)
                    {
                        if (p.owned == false)
                        {
                            everythingBought = false;
                            break;
                        }
                    }

                    if (everythingBought)
                    {
                        // Shoplifter
                        Social.ReportProgress("CgkIqIqqjZYFEAIQEA", 100.0f, (bool _success) =>
                        {
                            if (_success)
                            {
                                Main.onAchievementUnlock.Invoke();
                            }
                        });
                    }
                    ProgressManager.SaveProgressData();
                    return(true);
                }
                return(false);
            }
            return(false);
        }
예제 #2
0
        //Updates existing highscores (if the score is better) or creates a new one if it doesnt exist already
        public Highscore EnterHighscore(int id, double time)
        {
            Highscore hs;

            //doesnt exist
            if (!highscores.Any(x => x.levelId == id))
            {
                hs = new Highscore(id, time);
                ProgressManager.GetProgress().AddStarsToWallet(hs.starCount);
                highscores.Add(hs);
                Debug.Log("[ProgresssData]: Creating new Highscore of level " + id);
            }
            //exists, thus try to edit this one
            else
            {
                hs = highscores.Find(x => x.levelId == id);
                int oldStars;
                oldStars = hs.starCount;
                if (oldStars < 0)
                {
                    oldStars = 0;
                }
                hs.PlaceTime(time);
                int newStars = hs.starCount;
                ProgressManager.GetProgress().AddStarsToWallet(newStars - oldStars);
                Debug.Log("[ProgresssData]: Updating existing Highscore of level " + id);
            }

            // enter score to leaderboard
            string leaderboard = UILevelselectionManager.leaderboards[id];

            Social.ReportScore((long)(time * 1000), leaderboard, (bool success) =>
            {
            });

            if (time >= 45F)
            {
                // slow but steady achievement
                Social.ReportProgress("CgkIqIqqjZYFEAIQCA ", 100.0f, (bool success) =>
                {
                    if (success)
                    {
                        Main.onAchievementUnlock.Invoke();
                    }
                });
            }
            ProgressManager.SaveProgressData();
            return(hs);
        }
예제 #3
0
        public void ReportUpdateUIProduct(int _id, bool _owned, bool _equiped, UIProduct.BuyType _buyType)
        {
            ProductInfo info = GetProductInfo(_id);

            if (info == null)
            {
                productInfos.Add(new ProductInfo(_id, _owned, _equiped, _buyType));
            }
            else
            {
                GetProductInfo(_id).owned = _owned;
                if (_equiped)
                {
                    EquipProduct(_id);
                }
            }
            ProgressManager.SaveProgressData();
            //onProductInfoChange.Invoke();
        }
예제 #4
0
        /// <param name="id">Current level, used for comparison if next level can be unlocked</param>
        public bool TryUnlockNextLevel(int id)
        {
            if (lastUnlockedLevel <= id && lastUnlockedLevel + 1 <= LevelManager.GetLastStoryLevel())
            {
                // First Steps
                if (lastUnlockedLevel == 0)
                {
                    Social.ReportProgress("CgkIqIqqjZYFEAIQBw", 100.0f, (bool success) =>
                    {
                        if (success)
                        {
                            Main.onAchievementUnlock.Invoke();
                        }
                    });
                }

                lastUnlockedLevel++;
                UILevelselectionManager.unlockNextLevel = true;
                ProgressManager.SaveProgressData();
                return(true);
            }
            return(false);
        }
예제 #5
0
 public static void SetProgress(ProgressData pd)
 {
     progress = pd;
     onProgressChange.Invoke(progress);
     ProgressManager.SaveProgressData();
 }