2026-05-21 10:56:37 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using FairyGUI;
|
|
|
|
|
using FGUI.ZM_store_17;
|
|
|
|
|
using System;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using FGUI.ZM_Common_01;
|
|
|
|
|
using SGModule.NetKit;
|
|
|
|
|
using Spine.Unity;
|
|
|
|
|
|
|
|
|
|
namespace RedHotRoast
|
|
|
|
|
{
|
|
|
|
|
public class BuygoldUI : BaseUI
|
|
|
|
|
{
|
|
|
|
|
private BuygoldUICtrl ctrl;
|
|
|
|
|
private BuygoldModel model;
|
|
|
|
|
private FGUI.ZM_store_17.com_buygold ui;
|
|
|
|
|
|
|
|
|
|
private List<Paidgift> _paidGiftList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BuygoldUI(BuygoldUICtrl ctrl) : base(ctrl)
|
|
|
|
|
{
|
|
|
|
|
uiName = UIConst.BuygoldUI;
|
|
|
|
|
this.ctrl = ctrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
|
|
|
{
|
|
|
|
|
uiInfo.packageName = "ZM_store_17";
|
|
|
|
|
uiInfo.assetName = "com_buygold";
|
|
|
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
|
|
|
uiInfo.isNeedOpenAnim = false;
|
|
|
|
|
uiInfo.isNeedCloseAnim = false;
|
|
|
|
|
uiInfo.isNeedUIMask = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生命周期
|
|
|
|
|
|
|
|
|
|
protected override void OnInit()
|
|
|
|
|
{
|
|
|
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.BuygoldModel) as BuygoldModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
{
|
|
|
|
|
GameHelper.showGameUI = true;
|
|
|
|
|
HallManager.Instance.UpdateSecondEvent -= initList;
|
|
|
|
|
HallManager.Instance.UpdateSecondEvent -= upWatchAdsBtn;
|
|
|
|
|
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
|
|
|
|
|
// if (Isbuysuccess)
|
|
|
|
|
// {
|
|
|
|
|
// GameHelper.ShowTurnOffReward();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// GameHelper.ShowPaidPack();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
private bool Isbuysuccess = false;
|
|
|
|
|
protected override void OnBind()
|
|
|
|
|
{
|
|
|
|
|
ui = baseUI as FGUI.ZM_store_17.com_buygold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
|
|
|
{
|
|
|
|
|
if (Screen.safeArea.y != 0)
|
|
|
|
|
{
|
|
|
|
|
//刘海屏
|
|
|
|
|
ui.top_gold.y += Screen.safeArea.y - 15;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
|
|
|
|
TrackKit.SendEvent(eventName, ADEventTrack.Property.shop_show);
|
|
|
|
|
|
|
|
|
|
_paidGiftList = ConfigSystem.GetConfig<Paidgift>();
|
|
|
|
|
|
|
|
|
|
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
|
|
|
|
|
ui.pay_type.selectedIndex = !GameHelper.IsAdModelOfPay() ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
InitView();
|
|
|
|
|
|
|
|
|
|
HallManager.Instance.UpdateSecondEvent += initList;
|
|
|
|
|
HallManager.Instance.UpdateSecondEvent += upWatchAdsBtn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var head = ui.com_head as btn_head;
|
|
|
|
|
var headId = DataMgr.PlayerAvatarId.Value;
|
|
|
|
|
GameHelper.SetSelfAvatar(head.head.load_avatar, headId);
|
|
|
|
|
}
|
|
|
|
|
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 GetAward(decimal gold, int index)
|
|
|
|
|
{
|
|
|
|
|
var item = ui.gold_list.GetChildAt(index);
|
|
|
|
|
var start = GameHelper.GetUICenterPosition(item);
|
|
|
|
|
var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("text_gold"));
|
|
|
|
|
|
|
|
|
|
var rewardData = new RewardData();
|
|
|
|
|
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
|
|
|
|
{
|
|
|
|
|
startPosition = start,
|
|
|
|
|
endPosition = new Vector2(end.x, end.y)
|
|
|
|
|
};
|
|
|
|
|
rewardData.AddReward(rewardSingleData);
|
|
|
|
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
|
|
|
|
rewardData.AddCompleted((isScu) =>
|
|
|
|
|
{
|
|
|
|
|
DOVirtual.DelayedCall(0.5f, () =>
|
|
|
|
|
{
|
|
|
|
|
var startNum = DataMgr.Coin.Value - gold;
|
|
|
|
|
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
|
|
|
|
value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pay_success(object str)
|
|
|
|
|
{
|
|
|
|
|
string type = (string)str;
|
|
|
|
|
string purch_number = "";
|
|
|
|
|
|
|
|
|
|
if (PurchasingManager.ShopProductMap.TryGetValue(type, out var idx))
|
|
|
|
|
{
|
|
|
|
|
int suffix_num = int.Parse(idx);
|
|
|
|
|
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
|
|
|
|
SaveData.SaveDataFunc();
|
|
|
|
|
GetAward(list[suffix_num].Actual_coins, suffix_num);
|
|
|
|
|
purch_number = list[suffix_num].Payment_amount.ToString();
|
|
|
|
|
Isbuysuccess = true;
|
|
|
|
|
}
|
|
|
|
|
InitView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化页面逻辑
|
|
|
|
|
private void InitView()
|
|
|
|
|
{
|
|
|
|
|
ui.top_gold.touchable = false;
|
|
|
|
|
ui.btn_close.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Close); });
|
|
|
|
|
|
|
|
|
|
initList();
|
|
|
|
|
upWatchAdsBtn();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.btn_watch.SetClick(() =>
|
|
|
|
|
{
|
|
|
|
|
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
|
|
|
|
TrackKit.SendEvent(eventName, ADEventTrack.Property.gold_click_ad);
|
|
|
|
|
|
|
|
|
|
GameHelper.ShowVideoAd("BuyGold", (issuccess) =>
|
|
|
|
|
{
|
|
|
|
|
if (issuccess)
|
|
|
|
|
{
|
|
|
|
|
var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
|
|
|
|
|
SaveData.GetSaveObject()._watch_ad_cd = ad_times + GameHelper.GetCommonModel().exchangeCD;
|
|
|
|
|
|
|
|
|
|
SaveData.SaveDataFunc();
|
|
|
|
|
initList();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
|
|
|
|
|
|
|
|
|
void initList()
|
|
|
|
|
{
|
|
|
|
|
ui.gold_list.itemRenderer = setRemaintime;
|
|
|
|
|
ui.gold_list.numItems = list.Count;
|
|
|
|
|
|
|
|
|
|
SetTextString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void upWatchAdsBtn()
|
|
|
|
|
{
|
|
|
|
|
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
|
|
|
|
|
|
|
|
|
|
if (GameHelper.GetNowTime() < lastTimes)
|
|
|
|
|
{
|
|
|
|
|
ui.btn_watch.enabled = false;
|
|
|
|
|
ui.btn_watch.can_buy.selectedIndex = 1;
|
|
|
|
|
ui.btn_watch.btn_text.text =
|
|
|
|
|
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui.btn_watch.enabled = true;
|
|
|
|
|
ui.btn_watch.can_buy.selectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetTextString()
|
|
|
|
|
{
|
|
|
|
|
var myAds = AdExchangeManager.Instance.GetLookRewardADNum();
|
|
|
|
|
ui.text_my_ads.SetVar("ads", myAds.ToString()).FlushVars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SkeletonAnimation pack_anims = null;
|
|
|
|
|
private SkeletonAnimation no_ad_anims = null;
|
|
|
|
|
private Action closeCallback = null;
|
|
|
|
|
|
|
|
|
|
void setRemaintime(int index, GObject obj)
|
|
|
|
|
{
|
|
|
|
|
buygold_item item = (buygold_item)obj;
|
|
|
|
|
|
|
|
|
|
int time = 0;
|
|
|
|
|
time = SaveData.GetSaveObject()._goldtime[index];
|
|
|
|
|
|
|
|
|
|
item.coin_text.text = GameHelper.Get101Str(list[index].Actual_coins);
|
|
|
|
|
item.index.selectedIndex = index > 6 ? 6 : index;
|
|
|
|
|
bool is_paid = list[index].is_paid;
|
|
|
|
|
item.btn_buy.index.selectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
// item.off_text.text = list[index].Discount_rate + "%";
|
|
|
|
|
// item.discount.visible = !GameHelper.IsAdModelOfPay() && list[index].Discount_rate > 0;
|
|
|
|
|
//
|
|
|
|
|
// if (list[index].Discount_rate != 0) item.off_text.text = list[index].Discount_rate + "%";
|
|
|
|
|
|
|
|
|
|
if (time + list[index].receive_CD < GameHelper.GetNowTime())
|
|
|
|
|
{
|
|
|
|
|
item.btn_buy.can_buy.selectedIndex = 0;
|
|
|
|
|
if (!GameHelper.IsAdModelOfPay()){
|
|
|
|
|
item.btn_buy.index.selectedIndex = 1;
|
|
|
|
|
item.text_ads.visible = false;
|
|
|
|
|
|
|
|
|
|
if (!is_paid)
|
|
|
|
|
{
|
|
|
|
|
item.btn_buy.btn_text.text = "Free";
|
|
|
|
|
// item.discount.visible = false;
|
|
|
|
|
item.index.selectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
decimal price = (decimal)list[index].Payment_amount2;
|
|
|
|
|
item.btn_buy.btn_text.text = GameHelper.getPrice(price);
|
|
|
|
|
}
|
|
|
|
|
item.btn_buy.SetClick(() =>
|
|
|
|
|
{
|
|
|
|
|
rm_Gold(index);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
|
|
|
|
|
int count = (int)list[index].Payment_amount;
|
|
|
|
|
if (is_paid)
|
|
|
|
|
{
|
|
|
|
|
item.text_ads.SetVar("num", count.ToString()).FlushVars();
|
|
|
|
|
}
|
|
|
|
|
if (myAds >= count)
|
|
|
|
|
{
|
|
|
|
|
item.btn_buy.index.selectedIndex = 1;
|
|
|
|
|
if (!is_paid)
|
|
|
|
|
{
|
|
|
|
|
item.btn_buy.btn_text.text = Language.GetContent("free");
|
|
|
|
|
// item.discount.visible = false;
|
|
|
|
|
item.index.selectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
item.btn_buy.btn_text.text = Language.GetContent("exchange");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.btn_buy.SetClick(() =>
|
|
|
|
|
{
|
|
|
|
|
rm_Gold(index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
|
|
|
|
|
// {
|
|
|
|
|
// item.btn_buy.can_buy.selectedIndex = 1;
|
|
|
|
|
// item.btn_buy.index.selectedIndex = 1;
|
|
|
|
|
// item.btn_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
|
|
|
|
// item.btn_buy.SetClick(() => { });
|
|
|
|
|
// }
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
item.btn_buy.can_buy.selectedIndex = 0;
|
|
|
|
|
item.btn_buy.index.selectedIndex = 0;
|
|
|
|
|
item.btn_buy.btn_text.text = count + " ADs";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!is_paid)
|
|
|
|
|
{
|
|
|
|
|
// item.discount.visible = false;
|
|
|
|
|
item.index.selectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!GameHelper.IsAdModelOfPay())
|
|
|
|
|
{
|
|
|
|
|
item.text_ads.visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (is_paid)
|
|
|
|
|
{
|
|
|
|
|
int count = (int)list[index].Payment_amount;
|
|
|
|
|
item.text_ads.SetVar("num", count.ToString()).FlushVars();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.btn_buy.can_buy.selectedIndex = 1;
|
|
|
|
|
item.btn_buy.index.selectedIndex = 1;
|
|
|
|
|
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
|
|
|
|
item.btn_buy.SetClick(() =>{});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rm_Gold(int index)
|
|
|
|
|
{
|
|
|
|
|
// string _type = "buy_gold" + index.ToString();
|
|
|
|
|
// if (GameHelper.IsAdModelOfPay())
|
|
|
|
|
// {
|
|
|
|
|
// AdExchangeData test = new AdExchangeData()
|
|
|
|
|
// {
|
|
|
|
|
// ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
|
|
|
|
|
// type = _type,
|
|
|
|
|
// };
|
|
|
|
|
// AdExchangeManager.Instance.Exchange(test);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// decimal price = (decimal)list[index].Payment_amount2;
|
|
|
|
|
// ApplePayClass maxPayData = new ApplePayClass()
|
|
|
|
|
// {
|
|
|
|
|
// amount = (int)Math.Round(price * 100),
|
|
|
|
|
// sku = _type,
|
|
|
|
|
// currency = "USD"
|
|
|
|
|
// };
|
|
|
|
|
// Debug.Log($"amount============={maxPayData.amount}");
|
|
|
|
|
// MaxPayManager.Instance.Buy(maxPayData);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
var isPaid = list[index].is_paid;
|
|
|
|
|
if (!isPaid)
|
|
|
|
|
{
|
|
|
|
|
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
|
|
|
|
|
SaveData.SaveDataFunc();
|
|
|
|
|
GetAward(list[index].Actual_coins, index);
|
|
|
|
|
|
|
|
|
|
InitView();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var skuType = GetShopName(index);
|
|
|
|
|
if (GameHelper.IsAdModelOfPay())
|
|
|
|
|
{
|
|
|
|
|
var test = new AdExchangeData()
|
|
|
|
|
{
|
|
|
|
|
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(skuType),
|
|
|
|
|
type = $"buy_gold{index}",
|
|
|
|
|
shopName = $"buy_gold{index}"
|
|
|
|
|
};
|
|
|
|
|
AdExchangeManager.Instance.Exchange(test);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var price = (decimal)list[index].Payment_amount2;
|
|
|
|
|
var maxPayData = new ApplePayClass()
|
|
|
|
|
{
|
|
|
|
|
amount = (int)Math.Round(price * 100),
|
|
|
|
|
sku = skuType,
|
|
|
|
|
currency = "USD",
|
|
|
|
|
shopName = $"buy_gold{index}"
|
|
|
|
|
};
|
|
|
|
|
MaxPayManager.Instance.Buy(maxPayData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string GetShopName(int index)
|
|
|
|
|
{
|
|
|
|
|
var name = list[index].SKU;
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|