public void ReloadUsingGold() { UserStockData data = UserStockData.Load(); if (!data.PlusMinGold(-40)) { messagePopup.Show("You dont have enough coin, let buy more!"); } else { ReloadView.SetActive(true); ReloadPopUp.SetActive(false); //Statistik string command = "{"; command += "action:PlAY_LEVEL"; command += ",place:" + dataStaticLevel.Place; command += ",level:" + dataStaticLevel.Level; command += ",status:2_COMFIRM_RELOAD_USING_COINS"; command += "}"; ServerStatistic.DoRequest(command); } if (!PlayerPrefs.HasKey("hadwatch")) { tutorialPora.SetTrigger("define"); closeForDefine.SetActive(true); tutorialAnimator.SetTrigger("Show"); PlayerPrefs.SetString("hadwatch", ""); PlayerPrefs.Save(); } }
public void Show(StaticLevel dataStaticLevel, CallbackYes callbackYes, CallbackNo callbackNo) { UserStockData.Load(); this.dataStaticLevel = dataStaticLevel; WhiteBubbleStock = UserStockData.WhiteBubbleStock; RedBubbleStock = UserStockData.RedBubbleStock; OrangeBubbleStock = UserStockData.OrangeBubbleStock; TextWhiteBubble.text = WhiteBubbleStock.ToString(); TextRedBubble.text = RedBubbleStock.ToString(); TextOrangeBubble.text = OrangeBubbleStock.ToString(); this.callbackYes = callbackYes; this.callbackNo = callbackNo; GetComponent <Animator>().SetTrigger("Show"); isShowing = true; MaksBubble = dataStaticLevel.Bubbles.Count; for (int i = 0; i < MaksBubble; i++) { GameObject objek = (GameObject)Instantiate(UndefineBubble); objek.transform.SetParent(PanelPreview.transform); objek.transform.localScale = new Vector3(1, 1, 1); objek.transform.localPosition = new Vector3(objek.transform.localPosition.x, objek.transform.localPosition.y, 0); objek.GetComponent <DropBubbleHandler>().reloadPopupController = this; objek.GetComponent <ItemGelembungController>().Define = false; } WhiteBubbleButton.SetActive(!(WhiteBubbleStock == 0)); RedBubbleButton.SetActive(!(RedBubbleStock == 0)); OrangeBubbleButton.SetActive(!(OrangeBubbleStock == 0)); }
public void WatchClue() { GetComponent <Animator>().SetTrigger("Show"); string url = "http://nedstudio.net/ned/api/web/v1/clues/watch-clue"; WWWForm form = new WWWForm(); form.AddField("facebook_id", FB.UserId); form.AddField("app_token", UserDataManager.APP_TOKEN); form.AddField("level_id", clueLevel); WWW www = new WWW(url, form); UserStockData Transaction = UserStockData.Load(); for (int i = 1; i < ParentScrenshot.transform.childCount; i++) { Destroy(ParentScrenshot.transform.GetChild(i).gameObject); } if (Transaction.Gold >= 500) { StartCoroutine(WaitForRequest(www)); } else { messagePopupController.Show("You need " + (500 - Transaction.Gold) + " more coins!"); } }
private void YesToBuy() { UserStockData userStock = UserStockData.Load(); if (userStock.PlusMinGem(-Price)) { if (userStock.PlusMinGold(Gold)) { messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_COIN"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } else { userStock.PlusMinGem(Price); } } else { messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!"); } }
private void YesToBuy() { UserStockData userStock = UserStockData.Load(); if (Payment == PaymentType.Gold) { if (userStock.PlusMinGold(-Price)) { if (userStock.PlusMinBubble(WhiteBubble, RedBubble, OrangeBubble)) { messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_BUBBLE"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); if (reloadPopup) { reloadPopup.NewBuy(WhiteBubble, RedBubble, OrangeBubble); } } else { userStock.PlusMinGold(Price); } } else { messagePopup.Show("You need " + (Price - userStock.Gold) + " more coins!"); } } else if (Payment == PaymentType.Gem) { if (userStock.PlusMinGem(-Price)) { if (userStock.PlusMinBubble(WhiteBubble, RedBubble, OrangeBubble)) { messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_BUBBLE"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); if (reloadPopup) { reloadPopup.NewBuy(WhiteBubble, RedBubble, OrangeBubble); } } else { userStock.PlusMinGem(Price); } } else { messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!"); } } }
public void Show(StaticLevel dataLevel) { leaderboard.Show(dataLevel); UserStockData.Load(); this.dataLevel = dataLevel; RefreshLevel(dataLevel); animator.SetTrigger("Show"); //GetComponent<LeaderboardManager>().Show(dataLevel); MyPublicHightScore.text = dataLevel.HighScore.ToString("#,0"); MyFriendHightScore.text = dataLevel.HighScore.ToString("#,0"); LevelName.text = "Level " + dataLevel.Level; }
private void FinishWatching() { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); messagePopUp.Show("You have got 1 Pearl!"); string command = "{"; command += "action:BUY_PEARL"; command += ",item:1_SUCCESS_PEARLD_ADS"; command += "}"; ServerStatistic.DoRequest(command); }
private void OnQueryInventorySucceeded(Inventory inventory) { SkuDetails skusDetail = inventory.GetSkuDetails(ItemPurchaseStore.AndroidStore); priceText.text = skusDetail.CurrencyCode + " " + skusDetail.PriceValue; #if UNITY_ANDROID if (inventory.HasPurchase(ItemPurchaseStore.AndroidStore)) { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.AndroidStore)); MessagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_PEARL"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } #elif UNITY_IOS if (inventory.HasPurchase(ItemPurchaseStore.IosStore)) { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.IosStore)); MessagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_PEARL"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } #elif UNITY_WP8 if (inventory.HasPurchase(ItemPurchaseStore.WpStore)) { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.WpStore)); MessagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_PEARL"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } #endif }
public void Show(string season, string place, int level) { UserStockData.Load(); this.dataLevel = new StaticLevel(season, place, level); leaderboard.Show(dataLevel); RefreshLevel(dataLevel); animator.SetTrigger("Show"); //GetComponent<LeaderboardManager>().Show((StaticLevel)dataLevel); MyPublicHightScore.text = dataLevel.HighScore.ToString("#,0"); MyFriendHightScore.text = dataLevel.HighScore.ToString("#,0"); LevelName.text = "Level " + dataLevel.Level; }
private void OnPurchaseSucceded(Purchase purchase) //to VerifyDeveloperPayload to our own server { #if UNITY_ANDROID if (purchase.Sku == ItemPurchaseStore.AndroidStore) { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); OpenIAB.consumeProduct(purchase); MessagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_PEARL"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } #elif UNITY_IOS if (purchase.Sku == ItemPurchaseStore.IosStore) { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); OpenIAB.consumeProduct(purchase); MessagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_PEARL"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } #elif UNITY_WP8 if (purchase.Sku == ItemPurchaseStore.WpStore) { UserStockData userStock = UserStockData.Load(); userStock.PlusMinGem(Gems); OpenIAB.consumeProduct(purchase); MessagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_PEARL"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); } #endif }
IEnumerator WaitForRequest(WWW www) { yield return(www); //string data = www.text; var dict = Json.Deserialize(www.text) as Dictionary <string, object>; Debug.Log(www.text); if (www.error == null) { UserStockData Transaction = UserStockData.Load(); if (Transaction.PlusMinGold(-500)) { var data = dict["data"] as List <object>; Dictionary <string, object> clue_data = data[0] as Dictionary <string, object>; string[] separator = new string[1]; separator[0] = "#"; string[] sc = (clue_data["clue_data"]).ToString().Split(separator, System.StringSplitOptions.RemoveEmptyEntries); Debug.Log(sc.Length); List <ScreenShot> ListOFClue = new List <ScreenShot>(); for (int i = 0; i < sc.Length; i++) { ListOFClue.Add(ScreenShot.Deserialize(sc[i])); } RefreshClue(ListOFClue); } else { messagePopupController.Show("You need " + (500 - Transaction.Gold) + " more coins!"); } } else { messagePopupController.Show("Failed to connect to server!"); } }
public static UserStockData Load() { BinaryFormatter formater = new BinaryFormatter(); UserStockData data; FileStream fileStream; if (!File.Exists(Application.persistentDataPath + "/userStock.dat")) { fileStream = File.Create(Application.persistentDataPath + "/userStock.dat"); data = new UserStockData(); data.Gems = InitialGems; data.Gold = InitialGold; data.WhiteBubble = InitialWhiteBubble; data.RedBubble = InitialOrangeBubble; data.OrangeBubble = InitialOrangeBubble; formater.Serialize(fileStream, data); fileStream.Close(); } else { fileStream = File.Open(Application.persistentDataPath + "/userStock.dat", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); data = (UserStockData)formater.Deserialize(fileStream); fileStream.Close(); if (data.DeviceId != SystemInfo.deviceUniqueIdentifier) { formater = new BinaryFormatter(); fileStream = File.Create(Application.persistentDataPath + "/userStock.dat"); data = new UserStockData(); formater.Serialize(fileStream, data); fileStream.Close(); } } GemsStock = data.Gems; GoldStock = data.Gold; WhiteBubbleStock = data.WhiteBubble; RedBubbleStock = data.RedBubble; OrangeBubbleStock = data.OrangeBubble; return(data); }
private void UseBubble(List <Gelembung> daftarGelembung) { int WhiteBubble = 0; int RedBubble = 0; int OrangeBubble = 0; foreach (Gelembung gel in daftarGelembung) { if (gel.Type == BubbleType.White) { WhiteBubble++; } else if (gel.Type == BubbleType.Red) { RedBubble++; } else if (gel.Type == BubbleType.Orange) { OrangeBubble++; } } UserStockData data = UserStockData.Load(); data.PlusMinBubble(-WhiteBubble, -RedBubble, -OrangeBubble); //Statistik string command = "{"; command += "action:PlAY_LEVEL"; command += ",place:" + dataStaticLevel.Place; command += ",level:" + dataStaticLevel.Level; command += ",status:3_RELOAD"; command += ",WhiteBubble:" + WhiteBubble; command += ",RedBubble:" + RedBubble; command += ",OrangeBubble:" + OrangeBubble; command += "}"; ServerStatistic.DoRequest(command); }
IEnumerator WaitForRequest(WWW www) { yield return(www); // check for errors if (www.error == null) { messagePopupController.Show("Success Share Clue and You Earned 250 Coins!"); UserStockData RewardShare = UserStockData.Load(); RewardShare.PlusMinGold(250); Debug.Log("WWW Ok!: " + www.text); StatusShareClue = "OK"; LoadingData.SetTrigger("Hide"); BtnSharedClue.SetActive(false); } else { Debug.Log("WWW Error: " + www.error); LoadingData.SetTrigger("Hide"); messagePopupController.Show("Failed To Share Clue. Check your Internet Connection!"); BtnSharedClue.SetActive(true); } }
// Use this for initialization void Start() { UserStockData.Load(); }
public void Success() { if (State != GameplayState.Success) { PlayManager.ScoreTime = (int)(1200 - (float.Parse(TimePlaying.ToString("F1")) * 10)); PlayManager.Score += PlayManager.ScoreTime; if (Score < 0) { Score = 0; } State = GameplayState.Success; if (Mode == GameplayMode.StaticLevel) { UserScoreData userScore = UserScoreData.Load(); int BintangSebelumnya = userScore.GetStar(dataStaticLevel.Place, dataStaticLevel.Level); dataStaticLevel.HighScore = Score; if (Score >= dataStaticLevel.ScoreFor3Star) { Bintang = 3; } else if (Score >= dataStaticLevel.ScoreFor2Star) { Bintang = 2; } else { Bintang = 1; } UserStockData userStockDagta = UserStockData.Load(); List <BubbleType> bubblesGet = new List <BubbleType>(); int maksGold = 0;; int goldGet = 0; if (Bintang == 3 && BintangSebelumnya == 3) { maksGold = (int)(Score / 100f); goldGet = maksGold; } else if (Bintang == 3 && BintangSebelumnya == 2) { maksGold = (int)((Score / 100f) * 10); goldGet = (int)(maksGold * ((11 / 11f) - (5 / 11f))); } else if (Bintang == 3 && BintangSebelumnya == 1) { maksGold = (int)((Score / 100f) * 10); goldGet = (int)(maksGold * ((11 / 11f) - (2 / 11f))); } else if (Bintang == 3 && BintangSebelumnya == 0) { maksGold = (int)((Score / 100f) * 10); goldGet = (int)(maksGold * (11 / 11f)); } else if (Bintang == 2 && BintangSebelumnya >= 2) { maksGold = (int)(Score / 100f); goldGet = maksGold; } else if (Bintang == 2 && BintangSebelumnya == 1) { maksGold = (int)((Score / 100f) * 10); goldGet = (int)(maksGold * ((5 / 11f) - (2 / 11f))); } else if (Bintang == 2 && BintangSebelumnya == 0) { maksGold = (int)((Score / 100f) * 10); goldGet = (int)(maksGold * (5 / 11f)); } else if (Bintang == 1 && BintangSebelumnya >= 1) { maksGold = (int)(Score / 100f); goldGet = maksGold; } else if (Bintang == 1 && BintangSebelumnya == 0) { maksGold = (int)((Score / 100f) * 10); goldGet = (int)(maksGold * (2 / 11f)); } if (Bintang == 3) { int indicator = Random.Range(1, 282); if (indicator >= 1 && indicator <= 94) { bubblesGet.Add(BubbleType.White); } else if (indicator >= 95 && indicator <= 188) { bubblesGet.Add(BubbleType.Red); } else if (indicator >= 189 && indicator <= 282) { bubblesGet.Add(BubbleType.Orange); } indicator = Random.Range(1, 282); if (indicator >= 1 && indicator <= 94) { bubblesGet.Add(BubbleType.White); } else if (indicator >= 95 && indicator <= 188) { bubblesGet.Add(BubbleType.Red); } else if (indicator >= 189 && indicator <= 282) { bubblesGet.Add(BubbleType.Orange); } } else if (Bintang == 2) { int indicator = Random.Range(1, 282); if (indicator >= 1 && indicator <= 94) { bubblesGet.Add(BubbleType.White); } else if (indicator >= 95 && indicator <= 188) { bubblesGet.Add(BubbleType.Red); } else if (indicator >= 189 && indicator <= 282) { bubblesGet.Add(BubbleType.Orange); } } dataStaticLevel.Save(); userStockDagta.PlusMinGold(goldGet); int bubbleWhiteGet = 0; int bubbleRedGet = 0; int bubbleOrangeGet = 0; foreach (BubbleType typeGet in bubblesGet) { if (typeGet == BubbleType.White) { userStockDagta.PlusMinBubble(1, 0, 0); bubbleWhiteGet++; } else if (typeGet == BubbleType.Red) { userStockDagta.PlusMinBubble(0, 1, 0); bubbleRedGet++; } else if (typeGet == BubbleType.Orange) { userStockDagta.PlusMinBubble(0, 0, 1); bubbleOrangeGet++; } } //Statistik string command = "{"; command += "action:PlAY_LEVEL"; command += ",place:" + dataStaticLevel.Place; command += ",level:" + dataStaticLevel.Level; command += ",status:4_SUCCESS"; command += ",timePlaying:" + TimePlaying.ToString(); if (FB.IsLoggedIn) { command += ",facebook_id:" + FB.UserId; } command += ",score:" + Score; command += ",goldGet:" + goldGet; command += ",bubbleGetWhite:" + bubbleWhiteGet; command += ",bubbleGetRed:" + bubbleRedGet; command += ",bubbleGetOrange:" + bubbleOrangeGet; command += "}"; ServerStatistic.DoRequest(command); successPopupController.ShowForPlayingStaticLevel(Score, Bintang, goldGet, bubblesGet, SuccessCallback); } else if (Mode == GameplayMode.Edited) { if (Score > dataLevel.ScoreFor3Star) { Bintang = 3; } else if (Score > dataLevel.ScoreFor2Star) { Bintang = 2; } else { Bintang = 1; } successPopupController.ShowForPlayingEditedLevel(Score, Bintang, SuccessCallback); Debug.Log("Edited"); } else if (Mode == GameplayMode.ValidateLevel) { if (Score > dataLevel.ScoreFor3Star) { Bintang = 3; } else if (Score > dataLevel.ScoreFor2Star) { Bintang = 2; } else { Bintang = 1; } successPopupController.ShowForValidateLevel(Score, Bintang, SuccessCallback); Debug.Log("ValidateLevel"); } } Debug.Log("Score Time :" + PlayManager.ScoreTime); Debug.Log("Time Playing :" + TimePlaying); Debug.Log("Time Playing dengan 1 Decimal:" + float.Parse(TimePlaying.ToString("F1")) * 10); }
private void YesToBuy() { UserStockData userStock = UserStockData.Load(); UserItemStock userItems = new UserItemStock(); userItems.Load(); if (Payment == PaymentType.Gem) { if (userStock.PlusMinGem(-Price)) { for (int i = 0; i < ItemAlias.Length; i++) { userItems.Add(ItemAlias); } messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_ITEM"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); if (UserItemStock.Items.Contains(ItemAlias[0])) { textPrice.text = "Bought"; EffectedItem.SetActive(true); } } else { messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!"); } } else if (Payment == PaymentType.Gold) { if (userStock.PlusMinGold(-Price)) { for (int i = 0; i < ItemAlias.Length; i++) { userItems.Add(ItemAlias[i]); } messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_ITEM"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); if (UserItemStock.Items.Contains(ItemAlias[0])) { textPrice.text = "Bought"; EffectedItem.SetActive(true); } //gameObject.SetActive(!UserItemStock.Items.Contains(ItemAlias[0])); } else { messagePopup.Show("You need " + (Price - userStock.Gold) + " more coins!"); } } }