public void ShowItemPopup(string id, string title, string message, string btn, BoosterType type, int itemCount, int cost, Action actConfirm = null) { PopupConfirm temp = PopupConfirm.Open("Prefabs/Popup/ItemPopup", id, title, message, btn, false); PopupItem popupItem = temp.GetComponent <PopupItem>(); if (popupItem != null) { popupItem.ItemSetting(type, itemCount, cost); } temp.onConfirm += () => { if (actConfirm != null) { actConfirm(); actConfirm = null; } temp.SetMessage("Purchase completed!"); if (popupItem != null) { popupItem.UpdateData(false); } temp.onConfirm += () => { temp.Close(); }; }; }
public void ShowAdsPopup(string title, string message, string btn, Action actConfirm = null, Action actEixt = null) { PopupConfirm temp = PopupConfirm.Open("Prefabs/Popup/ADPopup", "AD", title, message + "\n" + "(After 10 ads, 200 coins will be paid.)", btn); temp.GetComponent <PopupAD>().SetInfo(); temp.onConfirm += () => { if (actConfirm != null) { actConfirm(); actConfirm = null; } temp.Close(); AdsMgr.G.ShowRewardedAd(); }; temp.onExit += () => { if (actEixt != null) { actEixt(); actEixt = null; } temp.Close(); }; }
public void OnPressed() { SoundMgr.G.EffectPlay(EffectSound.btn_ok); if (UserDataMgr.G.life <= 0) { int count = 1; if (UserDataMgr.G.IsItemCoins(count)) { PopupMgr.G.ShowItemPopup("Life Item Popup", "LIFE", "You can play the game with life!", "BUY", "life_icon", count, GameDataMgr.G.itemCost, () => { UserDataMgr.G.CoinsUsed(GameDataMgr.G.itemCost * count); UserDataMgr.G.life += count; UserDataMgr.G.SetTimeToNextLife(); if (LobbyMgr.G != null && LobbyMgr.G.levelNumber != null) { LobbyMgr.G.levelNumber.UpdateLifeLabel(); LobbyMgr.G.levelNumber.UpdateCoin(); } }); } else { PopupMgr.G.ShowAdsPopup(null, "Not enough coins and life." + "\n" + "Watch ads and get rewarded.", "OK"); } return; } string level = string.Format("LEVEL {0}", GameDataMgr.G.endLevel.ToString()); PopupConfirm temp = PopupConfirm.Open("Prefabs/Popup/GamePopup", "StartPopup", level, null, "PLAY"); temp.GetComponent <GamePopup>().OnPopup(GamePopupState.start); GamePopupItemGroup item = temp.GetComponentInChildren <GamePopupItemGroup>(); if (item != null) { item.BoosterItemSetting(); item.gameObject.GetComponent <UIWidget>().bottomAnchor.absolute = 50; } temp.onConfirm += () => { SceneFadeInOut fade = gameObject.GetComponentInParent <SceneFadeInOut>(); fade.delayTime = 0.15f; fade.fadeTime = 0.3f; fade.OnPressed(); }; }
public void OnPressed() { if (isLock) { return; } if (itemCount > 0) { int idx = (int)(type - 1); if (!GameDataMgr.G.isUseStartItem[idx]) { GameDataMgr.G.isUseStartItem[idx] = true; --UserDataMgr.G.availableStartItemCount[idx]; uiBtnImg.normalSprite = "BlueSquareButton"; CheckImg.SetActive(true); uiItemCnt.gameObject.SetActive(false); } else { GameDataMgr.G.isUseStartItem[idx] = false; ++UserDataMgr.G.availableStartItemCount[idx]; uiBtnImg.normalSprite = "green_square_button"; CheckImg.SetActive(false); uiItemCnt.gameObject.SetActive(true); } } else { TextInfo myTI = new CultureInfo("en-US", false).TextInfo; string boosterName = myTI.ToTitleCase(type.ToString()); string msg = string.Format("Start the level with a {0}!", boosterName); PopupConfirm temp = PopupConfirm.Open("Prefabs/Popup/ItemPopup", "Booster Item Popup", boosterName, msg, "Buy"); temp.GetComponent <PopupItem>().ItemSetting(type, 150); temp.onConfirm += () => { }; } }
public void OnPressed() { string level = string.Format("Level {0}", GameDataMgr.G.endLevel.ToString()); PopupConfirm temp = PopupConfirm.Open("Prefabs/Popup/GamePopup", "StartPopup", level, null, "Play"); temp.GetComponent <GamePopup>().OnPopup(GamePopupState.start); GamePopupItemGroup item = temp.GetComponentInChildren <GamePopupItemGroup>(); if (item != null) { item.BoosterItemSetting(); item.gameObject.GetComponent <UIWidget>().bottomAnchor.absolute = 50; } temp.onConfirm += () => { SceneFadeInOut fade = gameObject.GetComponentInParent <SceneFadeInOut>(); fade.delayTime = 0.15f; fade.fadeTime = 0.3f; fade.OnPressed(); }; }