502 lines
19 KiB
C#
502 lines
19 KiB
C#
using System.Collections.Generic;
|
|
using FGUI.ZM_Common_01;
|
|
using UnityEngine;
|
|
using FairyGUI;
|
|
using FGUI.LG_Vip;
|
|
using SGModule.Common.Helper;
|
|
using SGModule.NetKit;
|
|
using SGModule.MarkdownKit;
|
|
using Newtonsoft.Json;
|
|
using SGModule.Net;
|
|
|
|
public enum VipDay
|
|
{
|
|
Week = 7,
|
|
Month = 30,
|
|
Year = 365
|
|
}
|
|
|
|
namespace BallKingdomCrush
|
|
{
|
|
public class VipClubViewUI : BaseUI
|
|
{
|
|
private VipClubViewUICtrl ctrl;
|
|
private VipClubViewModel model;
|
|
private FGUI.LG_Vip.com_vip ui;
|
|
|
|
public VipClubViewUI(VipClubViewUICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.VipClubViewUI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "LG_Vip";
|
|
uiInfo.assetName = "com_vip";
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
uiInfo.isNeedOpenAnim = false;
|
|
uiInfo.isNeedCloseAnim = false;
|
|
uiInfo.isNeedUIMask = true;
|
|
}
|
|
|
|
#region 生命周期
|
|
|
|
protected override void OnInit()
|
|
{
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.VipClubViewModel) as VipClubViewModel;
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
|
|
{
|
|
_loader.texture = null;
|
|
}
|
|
_loader = null;
|
|
}
|
|
|
|
protected override void OnBind()
|
|
{
|
|
ui = baseUI as FGUI.LG_Vip.com_vip;
|
|
}
|
|
|
|
private List<VipClub> vip_list = new List<VipClub>();
|
|
//这个要做下标,或者控制器的索引,所以从0开始(Vip是1,2,3)
|
|
private int _level = 2;
|
|
|
|
private GLoader _loader = new GLoader();
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
_loader = ui.bg_loader;
|
|
setList();
|
|
if (GameHelper.IsGiftSwitch())
|
|
{
|
|
var fileName = GameHelper.GetBackgroundName(des_key.VIP.ToString());
|
|
TextureHelper.SetImgLoader(ui.bg_loader, fileName, null, "Background/", FolderNames.BackgroundName);
|
|
}
|
|
|
|
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_page);
|
|
|
|
// 检查VIP是否过期
|
|
GameHelper.CheckVipExpiration();
|
|
|
|
_level = GameHelper.GetVipLevel() > 0 ? GameHelper.GetVipLevel() - 1 : 2;
|
|
if (args != null) _level = (int)args;
|
|
|
|
vip_list = ConfigSystem.GetConfig<VipClub>();
|
|
InitView();
|
|
// ui.text_terms.text=
|
|
// Debug.Log(MarkdownDataMgr.TryGetValue("user", out MarkdownData data));
|
|
// Debug.Log(JsonConvert.SerializeObject(data));
|
|
ui.btn_terns.SetClick(() =>
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
|
|
});
|
|
ui.btn_pri.SetClick(() =>
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
|
|
});
|
|
|
|
if (GameHelper.IsGiftSwitch())
|
|
{
|
|
int random_ = Random.Range(0, 100);
|
|
bool need_open = false;
|
|
if (random_ < GameHelper.GetCommonModel().VIPGuideRate)
|
|
{
|
|
if (GameHelper.GetVipLevel() > 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
|
|
{
|
|
|
|
|
|
// List<int> unlocklist = new List<int>();
|
|
if ((GameHelper.GetCommonModel().Live == 1) &&
|
|
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview) &&
|
|
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1]))
|
|
{
|
|
// if (DataMgr.IsUnlockLive.Value < 0) //未解锁。
|
|
// {
|
|
// unlocklist.Add(0);
|
|
need_open = true;
|
|
// }
|
|
}
|
|
|
|
if ((GameHelper.GetCommonModel().Secret == 1) &&
|
|
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview) &&
|
|
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1]))
|
|
{
|
|
// if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
|
|
// {
|
|
// unlocklist.Add(1);
|
|
need_open = true;
|
|
// }
|
|
}
|
|
// if ((GameHelper.GetCommonModel().Assitant == 1) &&
|
|
// (GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview))
|
|
// {
|
|
// // if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
|
|
// // {
|
|
// // unlocklist.Add(1);
|
|
// need_open = true;
|
|
// // }
|
|
// }
|
|
}
|
|
|
|
if (need_open) uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
|
|
else if (GameHelper.GetVipLevel() < 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
|
|
{
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
protected override void OnOpen(object args)
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
}
|
|
|
|
protected override void OnDisplay(object args)
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 消息
|
|
|
|
protected override void AddListener()
|
|
{
|
|
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
|
}
|
|
|
|
protected override void RemoveListener()
|
|
{
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
|
}
|
|
|
|
#endregion
|
|
|
|
void pay_success(object str)
|
|
{
|
|
string type = (string)str;
|
|
string purch_number = "";
|
|
|
|
if (PurchasingManager._vipProductMap.ContainsKey(type))
|
|
{
|
|
InitView();
|
|
}
|
|
}
|
|
|
|
//初始化页面逻辑
|
|
private void InitView()
|
|
{
|
|
ui.viplevel.selectedIndex = GameHelper.GetVipLevel();
|
|
|
|
ui.btn_week.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
|
|
ui.btn_month.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
|
|
ui.btn_year.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
|
|
ui.btn_week.text_price_old.text = GameHelper.getPrice((decimal)vip_list[0].Price);
|
|
ui.btn_month.text_price_old.text = GameHelper.getPrice((decimal)vip_list[1].Price);
|
|
ui.btn_year.text_price_old.text = GameHelper.getPrice((decimal)vip_list[2].Price);
|
|
|
|
ui.btn_close.SetClick(CtrlCloseUI);
|
|
// ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
|
|
// ui.btn_restore.SetClick(() =>
|
|
// {
|
|
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
|
// {
|
|
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
|
|
// if (success)
|
|
// {
|
|
// Debug.Log("[barry] restore success: " + success);
|
|
// GameHelper.ShowTips("Restore Purchases Success!");
|
|
// SaveData.GetSaveObject().have_slot = success;
|
|
// DataMgr.VipLevel.Value = 3;
|
|
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
|
|
//
|
|
// InitView();
|
|
// }
|
|
// else
|
|
// {
|
|
// GameHelper.ShowTips("There are no recoverable transactions");
|
|
// }
|
|
// });
|
|
// });
|
|
|
|
SetSubBtnState(_level, (int)VipDay.Year);
|
|
|
|
ui.btn_week.SetClick(() => { SetSubBtnState(0, (int)VipDay.Week); });
|
|
|
|
ui.btn_month.SetClick(() => { SetSubBtnState(1, (int)VipDay.Month); });
|
|
|
|
ui.btn_year.SetClick(() => { SetSubBtnState(2, (int)VipDay.Year); });
|
|
|
|
|
|
ui.btn_sub.SetClick(() =>
|
|
{
|
|
if (ui.btn_sub.is_buy.selectedIndex == 1) return;
|
|
|
|
string _type = "vip_club" + _level;
|
|
ApplePayClass maxPayData = new ApplePayClass
|
|
{
|
|
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
|
|
sku = GetTypeByIndex(_level),
|
|
currency = "USD",
|
|
shopName = _type
|
|
};
|
|
MaxPayManager.Instance.Buy(maxPayData);
|
|
});
|
|
|
|
|
|
}
|
|
|
|
private string GetTypeByIndex(int index)
|
|
{
|
|
return index switch
|
|
{
|
|
0 => IAPPayManager.PRODUCT_VIP_WEEK,
|
|
1 => IAPPayManager.PRODUCT_VIP_MONTH,
|
|
2 => IAPPayManager.PRODUCT_VIP_YEAR,
|
|
_ => IAPPayManager.PRODUCT_VIP_WEEK
|
|
};
|
|
}
|
|
|
|
private void SetSubBtnState(int index, int day)
|
|
{
|
|
Debug.Log($"lvele============{index}");
|
|
|
|
_level = index;
|
|
ui.btn_sub.title = Language.GetContentParams("vip_buy", new[] {GameHelper.getPrice((decimal)vip_list[index].DiscountPrice), day.ToString()});
|
|
|
|
ui.btn_week.img_select.visible = index == 0;
|
|
ui.btn_month.img_select.visible = index == 1;
|
|
ui.btn_year.img_select.visible = index == 2;
|
|
|
|
ui.list.itemRenderer = ItemRenderer;
|
|
if (GameHelper.IsGiftSwitch())
|
|
{
|
|
ui.list.numItems = _vipEquity.Count;
|
|
|
|
}
|
|
else
|
|
{
|
|
ui.list.numItems = _vipEquity1.Count;
|
|
}
|
|
|
|
//vip等级(1:7天 2:30天 3:365天)
|
|
var selectIndex = 0;
|
|
if (_level <= GameHelper.GetVipLevel() - 1) //比如:如果订阅了30天,则30天和7天的订阅按钮隐藏,显示已订阅
|
|
{
|
|
selectIndex = 1;
|
|
}
|
|
|
|
ui.btn_sub.is_buy.selectedIndex = selectIndex;
|
|
|
|
}
|
|
|
|
private void ItemRenderer(int index, GObject obj)
|
|
{
|
|
var item = (item_viplist)obj;
|
|
|
|
if (GameHelper.IsGiftSwitch())
|
|
{
|
|
item.title.text = _vipEquity[index];
|
|
|
|
var state = 0;
|
|
if (_level == 0)
|
|
{
|
|
state = index > 1 ? 0 : 1;
|
|
}
|
|
else if (_level == 1)
|
|
{
|
|
state = index > 0 ? 0 : 1;
|
|
}
|
|
|
|
item.have.selectedIndex = state;
|
|
}
|
|
else
|
|
{
|
|
item.title.text = _vipEquity1[index];
|
|
}
|
|
|
|
|
|
|
|
}
|
|
private void setList()
|
|
{
|
|
var lang = PlayerPrefsKit.ReadString("LangIdKey");
|
|
if (lang.IsNullOrWhiteSpace())
|
|
{
|
|
lang = "en";
|
|
}
|
|
if (lang == "en")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"Free access to VIP levels",
|
|
"Free access to Special levels",
|
|
"Double Chest Coins Reward",
|
|
"Image downloads ad-Free",
|
|
"Double level rewards",
|
|
"Remove the interstitial ads",
|
|
"Unlock the Secret Album and Enjoy some resources",
|
|
"Unlock the live and Enjoy some resources"
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"Double chest rewards",
|
|
"Double level rewards",
|
|
"Remove interstitial ads",
|
|
"Remove banner ads",
|
|
};
|
|
}
|
|
else if (lang == "fr")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"Accès gratuit aux niveaux VIP",
|
|
"Accès gratuit aux niveaux Spéciaux",
|
|
"Récompenses double de pièces du coffre",
|
|
"Téléchargements d'images sans publicité",
|
|
"Récompenses double des niveaux",
|
|
"Supprimer les publicités interstitielles",
|
|
"Déverrouiller l'album secret et profiter de ressources exclusives",
|
|
"Déverrouiller le direct et profiter de ressources exclusives",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"Récompenses double du coffre",
|
|
"Récompenses double des niveaux",
|
|
"Supprimer les publicités interstitielles",
|
|
"Supprimer les bannières publicitaires",
|
|
};
|
|
}
|
|
else if (lang == "de")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"Kostenlosen Zugang zu VIP-Leveln",
|
|
"Kostenlosen Zugang zu Spezial-Leveln",
|
|
"Doppelte Schatzkisten-Münzenbelohnungen",
|
|
"Werbefreie Bilddownloads",
|
|
"Doppelte Levelbelohnungen",
|
|
"Zwischenanzeigen entfernen",
|
|
"Das geheime Album freischalten und exklusive Ressourcen genießen",
|
|
"Den Livestream freischalten und exklusive Ressourcen genießen",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"Doppelte Schatzkistenbelohnungen",
|
|
"Doppelte Levelbelohnungen",
|
|
"Zwischenanzeigen entfernen",
|
|
"Banneranzeigen entfernen",
|
|
};
|
|
}
|
|
else if (lang == "es")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"Acceso gratuito a los niveles VIP",
|
|
"Acceso gratuito a los niveles Especiales",
|
|
"Recompensas dobles de monedas del cofre",
|
|
"Descargas de imágenes sin anuncios",
|
|
"Recompensas dobles de niveles",
|
|
"Eliminar los anuncios intersticiales",
|
|
"Desbloquear el álbum secreto y disfrutar de recursos exclusivos",
|
|
"Desbloquear la transmisión en directo y disfrutar de recursos exclusivos",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"Recompensas dobles del cofre",
|
|
"Recompensas dobles de niveles",
|
|
"Eliminar los anuncios intersticiales",
|
|
"Eliminar los banners publicitarios",
|
|
};
|
|
}
|
|
else if (lang == "pt")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"Acesso gratuito aos níveis VIP",
|
|
"Acesso gratuito aos níveis Especiais",
|
|
"Recompensas em moedas do baú em dobro",
|
|
"Baixar imagens sem anúncios",
|
|
"Recompensas de nível em dobro",
|
|
"Remover anúncios intersticiais",
|
|
"Desbloquear o álbum secreto e aproveitar recursos exclusivos",
|
|
"Desbloquear a transmissão ao vivo e aproveitar recursos exclusivos",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"Recompensas do baú em dobro",
|
|
"Recompensas de nível em dobro",
|
|
"Remover anúncios intersticiais",
|
|
"Remover banners publicitários",
|
|
};
|
|
}
|
|
else if (lang == "ja")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"VIP レベルへの無料アクセス",
|
|
"スペシャルレベルへの無料アクセス",
|
|
"チェストコインのダブル報酬",
|
|
"広告なしの画像ダウンロード",
|
|
"レベル報酬のダブル",
|
|
"インタースティシャル広告を削除",
|
|
"シークレットアルバムをアンロックし、専用リソースを享受",
|
|
"ライブ配信をアンロックし、専用リ소스を享受",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"チェスト報酬のダブル",
|
|
"レベル報酬のダブル",
|
|
"インタースティシャル広告を削除",
|
|
"バナー広告を削除",
|
|
};
|
|
}
|
|
else if (lang == "ko")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"VIP 레벨 무료 접근",
|
|
"스페셜 레벨 무료 접근",
|
|
"상자 동전 더블 보상",
|
|
"광고 없는 이미지 다운로드",
|
|
"레벨 보상 더블",
|
|
"인터스티셜 광고 제거",
|
|
"비밀 앨범을 잠금 해제하고 전용 리소스 즐기기",
|
|
"라이브 스트림을 잠금 해제하고 전용 리소스 즐기기",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"상자 보상 더블",
|
|
"레벨 보상 더블",
|
|
"인터스티셜 광고 제거",
|
|
"배너 광고 제거",
|
|
};
|
|
}
|
|
else if (lang == "ru")
|
|
{
|
|
_vipEquity = new List<string>{
|
|
"Бесплатный доступ к VIP-уровням",
|
|
"Бесплатный доступ к специальным уровням",
|
|
"Двойные награды монет из сундука",
|
|
"Скачивание изображений без рекламы",
|
|
"Двойные награды уровней",
|
|
"Удалить межстраничную рекламу",
|
|
"Разблокировать секретный альбом и наслаждаться эксклюзивными ресурсами",
|
|
"Разблокировать прямой эфир и наслаждаться эксклюзивными ресурсами",
|
|
};
|
|
_vipEquity1 = new List<string>
|
|
{
|
|
"Двойные награды из сундука",
|
|
"Двойные награды уровней",
|
|
"Удалить межстраничную рекламу",
|
|
"Удалить баннерную рекламу",
|
|
};
|
|
}
|
|
}
|
|
|
|
//Vip权益内容列表
|
|
private List<string> _vipEquity;
|
|
|
|
private List<string> _vipEquity1;
|
|
}
|
|
} |