Files
BingoGrassland/Assets/BingoBrain/ModuleUI/SaveingPot/SaveingPotUI.cs
T

1027 lines
40 KiB
C#
Raw Normal View History

2026-05-08 11:03:00 +08:00
using System;
2026-04-20 13:49:36 +08:00
using System.Collections.Generic;
2026-05-08 11:03:00 +08:00
using System.Linq;
2026-04-20 13:49:36 +08:00
using BingoBrain.Core;
2026-05-08 11:03:00 +08:00
using BingoBrain.HotFix;
using DG.Tweening;
2026-04-20 13:49:36 +08:00
using FairyGUI;
2026-05-08 11:03:00 +08:00
using FGUI.ACommon;
using FGUI.Common_01;
using FGUI.tixian;
2026-04-20 13:49:36 +08:00
using Spine.Unity;
2026-05-08 11:03:00 +08:00
using UnityEngine;
2026-04-20 13:49:36 +08:00
namespace BingoBrain
{
public class SaveingPotUI : BaseUI
{
private SaveingPotUICtrl ctrl;
private SaveingPotModel model;
2026-05-08 11:03:00 +08:00
private FGUI.tixian.com_saveingpot ui;
2026-04-20 13:49:36 +08:00
private SaveingPotClass makeupTaskData;
public int ad_cool_down = 120;
private int broadtime = 1;
public SaveingPotUI(SaveingPotUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SaveingPotUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
2026-05-08 11:03:00 +08:00
uiInfo.packageName = "tixian";
2026-04-20 13:49:36 +08:00
uiInfo.assetName = "com_saveingpot";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
2026-05-08 11:03:00 +08:00
//model = ModuleManager.Instance.GetModel(ModelConst.SaveingPotModel) as SaveingPotModel;
2026-04-20 13:49:36 +08:00
}
protected override void OnClose()
{
2026-05-08 11:03:00 +08:00
// AdRedeemManager.Instance.Destroy();
2026-04-20 13:49:36 +08:00
Hall.Instance.UpdateSecondEvent -= updateSpeedCD;
2026-05-08 11:03:00 +08:00
Hall.Instance.UpdateSecondEvent -= Update;
Hall.Instance.UpdateSecondEvent -= upTaskWatchAdsBtn;
2026-04-20 13:49:36 +08:00
closeCallback?.Invoke();
2026-05-08 11:03:00 +08:00
// WebviewManager.ShezhiACT(true);
GameDispatcher.Instance.Dispatch(BingoInfo.RefreshSaveingPot);
// if (SaveLocalData.GetSaveLocalObject().rankRewardData.Count > 0 && !Hall.Instance.isShowRankView)
// {
// Hall.Instance.isShowRankView = true;
// uiCtrlDispatcher.Dispatch(UICtrlMsg.RankRewardUI_Open);
// }
2026-04-20 13:49:36 +08:00
}
protected override void OnBind()
{
2026-05-08 11:03:00 +08:00
ui = baseUI as FGUI.tixian.com_saveingpot;
2026-04-20 13:49:36 +08:00
}
protected override void OnOpenBefore(object args)
{
if (Screen.safeArea.y != 0)
{//刘海屏
ui.group_.y += Screen.safeArea.y;
}
2026-05-08 11:03:00 +08:00
// WebviewManager.ShezhiACT(false);
2026-04-20 13:49:36 +08:00
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Close);
SaveingPotHelper.TestingClearTime();
makeupTaskData = SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1];
2026-05-08 11:03:00 +08:00
makeupTaskData.H5Time = 99999999;
// SaveData.GetSaveobject().saveingpot_ch = 999; //zhushi
// makeupTaskData.videoCount = 99999999;//zhushi
// makeupTaskData.inlineNum = 0;//zhushi
// ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_potparent, Fx_Type.fx_saving, ref closeCallback);
// ske_pot.state.SetAnimation(0, "edie", true);
FX.Instance.SetFx<SkeletonAnimation>(ui.ani_potparent, Fx_Type.fx_saving, ps =>
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
// ps.transform.localPosition = new Vector3(0, 195, 0);
ske_pot = ps;
NAAVsa.PlayAnim(ske_pot, "edie", true);
}, closeCallback);
ui.btn_close.SetClick(() =>
2026-04-20 13:49:36 +08:00
{
CtrlCloseUI();
});
InitView();
2026-05-08 11:03:00 +08:00
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1)
{
ui.btn_watch.GetChild("img_saveingpot").visible = true;
}
2026-04-20 13:49:36 +08:00
ui.btn_watch.SetClick(WatchBtnClick);
2026-05-08 11:03:00 +08:00
// AdRedeemManager.Instance.SetWatchAd(AdRedeemManager.SavingPotMakeupAd, ui.btn_task_watch as btn_watchAd, () => { });
// AdRedeemManager.Instance.Start();
ui.btn_task_watch.SetClick(taskWatchBtnClick);
ad_cool_down = ConfigSystem.GetConfig<CommonModel>().WwalaccelerationCD;
2026-04-20 13:49:36 +08:00
Hall.Instance.UpdateSecondEvent += updateSpeedCD;
2026-05-08 11:03:00 +08:00
Hall.Instance.UpdateSecondEvent += Update;
Hall.Instance.UpdateSecondEvent += upTaskWatchAdsBtn;
2026-04-20 13:49:36 +08:00
InitBroadCast();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
#endregion
2026-05-08 11:03:00 +08:00
void taskWatchBtnClick()
{
GameHelper.ShowVideoAd("taskWatchAd", (issuccess) =>
{
if (issuccess)
{
var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
SaveData.GetSaveobject()._watch_ad_cd = ad_times + GameHelper.GetCommonModel().exchangeCD;
btn_watchAd btn_task_watch = ui.btn_task_watch as btn_watchAd;
btn_task_watch.enabled = false;
btn_task_watch.can_buy.selectedIndex = 1;
btn_task_watch.btn_text.text = GameHelper.TimeFormat(SaveData.GetSaveobject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
Hall.Instance.UpdateSecondEvent += upTaskWatchAdsBtn;
OnTask();
}
});
}
public void upTaskWatchAdsBtn()
{
var lastTimes = SaveData.GetSaveobject()._watch_ad_cd;
btn_watchAd btn_task_watch = ui.btn_task_watch as btn_watchAd;
btn_task_watch.img_saveingpot.visible = false;
if (GameHelper.GetNowTime() < lastTimes)
{
btn_task_watch.enabled = false;
btn_task_watch.can_buy.selectedIndex = 1;
btn_task_watch.btn_text.text = GameHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
Hall.Instance.UpdateSecondEvent -= upTaskWatchAdsBtn;
btn_task_watch.enabled = true;
btn_task_watch.can_buy.selectedIndex = 0;
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) btn_task_watch.img_saveingpot.visible = true;
}
}
private void Update()
{
if (ui.type.selectedIndex == 4)
{
OnTask();
}
}
private SkeletonAnimation ske_pot;
2026-04-20 13:49:36 +08:00
private Action closeCallback;
//初始化页面逻辑
private void InitView()
{
2026-05-08 11:03:00 +08:00
// Debug.Log(DataMgr.ExchangeAccount);
2026-04-20 13:49:36 +08:00
makeup_2 makeupVo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(makeupTaskData.tableId);
2026-05-08 11:03:00 +08:00
ui.text_ad.text = string.Format(GameHelper.getDesByKey("saving_pot_5"), makeupVo.ADIncrease);
string str = string.Format(GameHelper.getDesByKey("saving_pot_2"), makeupVo.PayIncrease);
ui.text_pay.text = str;
2026-04-20 13:49:36 +08:00
initTop();
2026-05-08 11:03:00 +08:00
ske_pot.gameObject.SetActive(false);
2026-04-20 13:49:36 +08:00
2026-05-08 11:03:00 +08:00
string val = $"{SaveData.GetSaveobject().saveingpot_ch:N}";
ui.text_lose.SetVar("num", val).FlushVars();
// ui.text_lose.text = string.Format(ui.text_lose.text, SaveingPotHelper.getChString(SaveData.GetSaveobject().saveingpot_ch));
2026-04-20 13:49:36 +08:00
if (makeupTaskData.needShowAni)
{
ui.type.selectedIndex = 0;
2026-05-08 11:03:00 +08:00
ui.text_chprogress.text = SaveingPotHelper.getChNumber(SaveData.GetSaveobject().saveingpot_ch) + "/" + SaveingPotHelper.getChNumber(makeupTaskData.amount);
ui.progress_ch.value = (SaveData.GetSaveobject().saveingpot_ch / makeupTaskData.amount) * 100;
ske_pot.gameObject.SetActive(true);
Debug.Log("iiiiiiiiiiiiiiiiiiiii");
if (SaveData.GetSaveobject().saveingpot_ch < makeupTaskData.amount)
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
ui.btn_ch.title = "Go";
ui.btn_ch.SetClick(() =>
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
// if (UIManager.Instance.IsExistUI(UIConst.HallUI))
// {
// GameDispatcher.Instance.Dispatch(BingoInfo.MainTab, 1);
// }
// else
// {
// buygoldParam param = new buygoldParam()
// {
// isShow1 = false,
// is_in_game = true
// };
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open, param);
// }
2026-04-20 13:49:36 +08:00
CtrlCloseUI();
});
}
else
{
2026-05-08 11:03:00 +08:00
ui.btn_ch.SetClick(() =>
2026-04-20 13:49:36 +08:00
{
makeupTaskData.needShowAni = false;
SaveData.saveDataFunc();
InitView();
});
}
2026-05-08 11:03:00 +08:00
if (SaveData.GetSaveobject().saveingpot_ch > SaveData.GetSaveobject().last_saveingpot_ch)
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
DOVirtual.Float(SaveData.GetSaveobject().last_saveingpot_ch, SaveData.GetSaveobject().saveingpot_ch, 1,
value => { ui.text_nowch.text = GameHelper.Get102Str((decimal)value); });
ske_pot.state.SetAnimation(0, "getcash", false);
2026-04-20 13:49:36 +08:00
ske_pot.state.Complete += (a) =>
{
2026-05-08 11:03:00 +08:00
ske_pot.state.SetAnimation(0, "edie", true);
2026-04-20 13:49:36 +08:00
};
}
2026-05-08 11:03:00 +08:00
else ui.text_nowch.text = GameHelper.Get102Str((decimal)SaveData.GetSaveobject().saveingpot_ch);
SaveData.GetSaveobject().last_saveingpot_ch = SaveData.GetSaveobject().saveingpot_ch;
2026-04-20 13:49:36 +08:00
SaveData.saveDataFunc();
}
else if (makeupTaskData.status == SaveingPotTaskStatus.None)
{
if (PreferencesMgr.Instance.ExchangeAccount == null)
{
Debug.Log("enter");
OnEnter();
}
else
{
OnConfirm();
}
}
else if (makeupTaskData.status == SaveingPotTaskStatus.Task)
{
OnTask();
}
else if (makeupTaskData.status == SaveingPotTaskStatus.Inline)
{
2026-05-08 11:03:00 +08:00
// makeupTaskData.status = SaveingPotTaskStatus.ticket;
// PreferencesMgr.Instance.SaveMakeupTaskHistory();
// InitView();
// return;
2026-04-20 13:49:36 +08:00
OnInline();
Debug.Log("inline");
}
2026-05-08 11:03:00 +08:00
else if (makeupTaskData.status == SaveingPotTaskStatus.ticket)
{
onTicket();
}
else if (makeupTaskData.status == SaveingPotTaskStatus.code)
{
onCode();
}
upTaskWatchAdsBtn();
updateSpeedCD();
Update();
2026-04-20 13:49:36 +08:00
}
void WatchBtnClick()
{
if (GameHelper.GetNowTime() <= PlayerPrefs.GetInt($"speed_ad_cool_times_pot", 0) + ad_cool_down)
{
Debug.Log("not click");
return;
}
GameHelper.ShowVideoAd("reward_OpeningDollarBills", isSuccess =>
{
if (isSuccess)
{
ui.btn_watch.enabled = false;
// TimerHelper.mEasy.AddTimer(1.5f, () =>
// {
var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
PlayerPrefs.SetInt($"speed_ad_cool_times_pot", ad_times);
InitView();
// });
}
});
2026-05-08 11:03:00 +08:00
// var adNum = DataMgr.RealWatchVideo;
2026-04-20 13:49:36 +08:00
// Debug.Log($"adNum========: {adNum}");
}
void updateSpeedCD()
{
broadtime++;
BroadCast();
if (makeupTaskData.needShowAni)
{
2026-05-08 11:03:00 +08:00
ui.text_remaintime.text = GameHelper.TimeFormat((int)makeupTaskData.clear_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Day);
2026-04-20 13:49:36 +08:00
}
if (SaveingPotHelper.TestingClearTime())
{
InitView();
}
var lastTimes = PlayerPrefs.GetInt($"speed_ad_cool_times_pot", 0);
if (GameHelper.GetNowTime() < lastTimes + ad_cool_down)
{
ui.btn_watch.enabled = false;
ui.btn_watch.show_cd.selectedIndex = 1;
ui.btn_watch.text_cd.text = GameHelper.TimeFormat(
lastTimes + ad_cool_down - Convert.ToInt32(GameHelper.GetNowTime()),
CountDownType.Hour);
}
else
{
ui.btn_watch.enabled = true;
ui.btn_watch.show_cd.selectedIndex = 0;
}
}
private void OnInline()
{
CheckBtnWatchStatus();
ui.type.selectedIndex = 5;
CheckActive(makeupTaskData.tableId);
2026-05-08 11:03:00 +08:00
GameDispatcher.Instance.Dispatch(BingoInfo.RefreshMakeupData);
2026-04-20 13:49:36 +08:00
RefreshRecordData();
}
private void RefreshRecordData()
{
var data = makeupTaskData;
if (data.inlineNum <= 1)
{
2026-05-08 11:03:00 +08:00
if (GameHelper.isRDExchangeMode())
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
ui.cont_confirm.selectedIndex = 0;
ui.btn_inline_ok.SetClick(() =>
{
makeupTaskData.SetStatus(SaveingPotTaskStatus.ticket);
SaveData.saveDataFunc();
InitView();
});
}
else
{
ui.cont_confirm.selectedIndex = 0;
ui.type.selectedIndex = 6;
ui.text_payhint.text = "You will get the " + makeupTaskData.amountStr + " for 90 days";
ui.text_query.text = PreferencesMgr.Instance.ExchangeAccount;
ui.btn_confirm.SetClick(() =>
{
CtrlCloseUI();
});
}
2026-04-20 13:49:36 +08:00
}
2026-05-08 11:03:00 +08:00
else
{
ui.cont_confirm.selectedIndex = 1;
}
2026-04-20 13:49:36 +08:00
var com_rank = ui.com_newRecord.com_rank;
2026-05-08 11:03:00 +08:00
com_rank.lab_title_des.text = GameHelper.getDesByKey("saving_pot_3");
com_rank.lab_rank_tips.text = GameHelper.getDesByKey("saving_pot_4");
2026-04-20 13:49:36 +08:00
2026-05-08 11:03:00 +08:00
var rdVOModel = ConfigSystem.GetConfig<MakeupModel_2>().dataList
.FirstOrDefault(rd => rd.id == data.tableId);
if (rdVOModel == null) return;
2026-04-20 13:49:36 +08:00
2026-05-08 11:03:00 +08:00
if (rdVOModel.AD_Limit_times <= data.WatchVideoSpeedNum)
2026-04-20 13:49:36 +08:00
{
ui.btn_watch.enabled = false;
ui.btn_watch.visible = false;
com_rank.content1.selectedIndex = 1;
com_rank.text_rank1.SetVar("rank", data.WatchVideoSpeedNum.ToString()).FlushVars();
}
else
{
ui.btn_watch.enabled = true;
ui.btn_watch.visible = true;
com_rank.content1.selectedIndex = 0;
2026-05-08 11:03:00 +08:00
com_rank.text_rank1.SetVar("rank", rdVOModel.AD_Down.ToString()).FlushVars();
2026-04-20 13:49:36 +08:00
}
2026-05-08 11:03:00 +08:00
if (rdVOModel.Login_Limit_times <= data.loginSpeedNum)
2026-04-20 13:49:36 +08:00
{
com_rank.content2.selectedIndex = 1;
2026-05-08 11:03:00 +08:00
com_rank.text_rank2.SetVar("rank", rdVOModel.Login_Limit_times.ToString()).FlushVars();
2026-04-20 13:49:36 +08:00
}
else
{
com_rank.content2.selectedIndex = 0;
var loginRans = GameHelper.GetCommonModel().inlineLoginDown[0] + "-" + GameHelper.GetCommonModel().inlineLoginDown[1];
com_rank.text_rank2.SetVar("rank", loginRans).FlushVars();
}
2026-05-08 11:03:00 +08:00
if (rdVOModel.Active_Limit_times <= data.activeSpeedNum)
2026-04-20 13:49:36 +08:00
{
com_rank.content3.selectedIndex = 1;
2026-05-08 11:03:00 +08:00
com_rank.text_rank3.SetVar("rank", rdVOModel.Active_Limit_times.ToString()).FlushVars();
2026-04-20 13:49:36 +08:00
}
else
{
com_rank.content3.selectedIndex = 0;
2026-05-08 11:03:00 +08:00
com_rank.text_rank3.SetVar("time", rdVOModel.Active_time.ToString()).FlushVars();
com_rank.text_rank3.SetVar("rank", rdVOModel.Active_time_Down.ToString()).FlushVars();
2026-04-20 13:49:36 +08:00
if (GameHelper.activeTimes_saveingpot.TryGetValue(data.tableId, out int openTimes))
{
//Debug.Log($"openTimes ===== {openTimes}, data.tableId=== activeTimes_saveingpot_{data.tableId}");
if (openTimes > 1)
{
//活跃的分钟数
int min_num = ((int)Time.time - data.activeMinute) / 60;
//是配置的活跃时间的多少倍
2026-05-08 11:03:00 +08:00
int active_times = min_num / rdVOModel.Active_time;
2026-04-20 13:49:36 +08:00
//Debug.Log($"min_num=== {min_num} {active_times} ");
if (active_times > 0)
{
data.activeMinute = (int)Time.time;
// 可以加速多少排名
2026-05-08 11:03:00 +08:00
int rank_num = active_times * rdVOModel.Active_time_Down;
2026-04-20 13:49:36 +08:00
var last = data.activeSpeedNum;
data.activeSpeedNum += rank_num;
2026-05-08 11:03:00 +08:00
//Debug.Log($"rank_num=== {rank_num} {last} {data.activeSpeedNum} {rdVOModel.Active_Limit_times}");
if (data.activeSpeedNum > rdVOModel.Active_Limit_times)
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
rank_num = rdVOModel.Active_Limit_times - last;
data.activeSpeedNum = rdVOModel.Active_Limit_times;
2026-04-20 13:49:36 +08:00
}
data.inlineNum -= rank_num;
//Debug.Log($"订单为: {data.tableId} 通过活跃时间减少的排名为:{rank_num}");
if (data.inlineNum < GameHelper.GetCommonModel().inlineMin)
{
data.inlineNum = GameHelper.GetCommonModel().inlineMin;
}
}
}
else
{
data.activeMinute = (int)Time.time;
}
}
}
2026-05-08 11:03:00 +08:00
com_rank.text_ranks.text = data.inlineNum.ToString();
}
void onTicket()
{
var vo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(makeupTaskData.tableId);
ui.type.selectedIndex = 7;
if (makeupTaskData.rdData != null && makeupTaskData.rdData.Count > 0)
{
makeupTaskData.rdData.Sort((a, b) =>
{
if (a.isClaimed == b.isClaimed)
{
return b.coupon_mount.CompareTo(a.coupon_mount);
}
else
{
return a.isClaimed ? 1 : -1;
}
});
}
else
{
makeupTaskData.rdData = new List<SaveingPotRdData>();
int[] arr = ConfigSystem.GetConfig<CommonModel>().PotExchange;
Array.Sort(arr, (a, b) => b.CompareTo(a));
int remainValue = vo.item_need;
List<int> tickets = new List<int>();
for (int i = 0; i < arr.Length; i++)
{
tickets.Add(remainValue / arr[i]);
remainValue = remainValue % arr[i];
for (int j = 0; j < tickets[i]; j++)
{
SaveingPotRdData data = new SaveingPotRdData();
data.code = GameHelper.GenerateUniqueKey();
data.coupon_mount = arr[i];
data.isClaimed = false;
makeupTaskData.rdData.Add(data);
}
}
PreferencesMgr.Instance.SaveMakeupTaskHistory();
}
int value = 0;
for (int i = 0; i < makeupTaskData.rdData.Count; i++)
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
if (makeupTaskData.rdData[i].isClaimed)
{
value += makeupTaskData.rdData[i].coupon_mount;
}
2026-04-20 13:49:36 +08:00
}
2026-05-08 11:03:00 +08:00
ui.lab_mn.text = GameHelper.Get101Str(vo.item_need - value);
ui.list_kicket.itemRenderer = refreshItem;
ui.list_kicket.numItems = makeupTaskData.rdData.Count;
}
private void refreshItem(int index, GObject obj)
{
com_ticket_item item = (com_ticket_item)obj;
item.lab_num.text = GameHelper.getPrice(makeupTaskData.rdData[index].coupon_mount);
if (makeupTaskData.rdData[index].isClaimed)
{
item.btn_claim.state.selectedIndex = 1;
item.btn_claim.title = "Claimed";
}
else
{
item.btn_claim.state.selectedIndex = 0;
item.btn_claim.title = "Claim";
}
item.btn_claim.SetClick(() =>
{
makeupTaskData.SetStatus(SaveingPotTaskStatus.code);
makeupTaskData.rdData[index].isClaimed = true;
makeupTaskData.lastRdData = makeupTaskData.rdData[index];
onCode();
// DataMgr.ImmediateSendSave();
PreferencesMgr.Instance.SaveMakeupTaskHistory();
GameDispatcher.Instance.Dispatch(BingoInfo.RefreshSaveingPot);
SaveData.saveDataFunc();
});
}
void onCode()
{
if (makeupTaskData.lastRdData == null)
{
ui.type.selectedIndex = 7;
makeupTaskData.SetStatus(SaveingPotTaskStatus.ticket);
return;
}
ui.type.selectedIndex = 8;
int value = 0;
for (int i = 0; i < makeupTaskData.rdData.Count; i++)
{
if (makeupTaskData.rdData[i].isClaimed)
{
value += makeupTaskData.rdData[i].coupon_mount;
}
}
var vo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(makeupTaskData.tableId);
ui.lab_mn2.text = GameHelper.Get101Str(vo.item_need - value);
ui.lab_ticket.text = GameHelper.GetPriceInt(makeupTaskData.lastRdData.coupon_mount);
ui.lab_code.text = makeupTaskData.lastRdData.code;
ui.btn_back.SetClick(() =>
{
ui.type.selectedIndex = 7;
makeupTaskData.SetStatus(SaveingPotTaskStatus.ticket);
InitView();
});
ui.btn_copy.SetClick(() =>
{
GameHelper.CopyText(ui.lab_code.text);
});
ui.btn_contact_us.SetClick(() =>
{
GameHelper.OpenEmail();
});
2026-04-20 13:49:36 +08:00
}
2026-05-08 11:03:00 +08:00
2026-04-20 13:49:36 +08:00
private void CheckActive(int index)
{
if (GameHelper.activeTimes_saveingpot.TryGetValue(index, out int value))
{
value++;
// Debug.Log($"CheckActive2: {index} {value}");
GameHelper.activeTimes_saveingpot[index] = value;
}
else
{
GameHelper.activeTimes_saveingpot.Add(index, 1);
}
}
void CheckBtnWatchStatus()
{
var data = makeupTaskData;
if (data == null)
{
return;
}
2026-05-08 11:03:00 +08:00
var CardRdVOModel = ConfigSystem.GetConfig<MakeupModel_2>().dataList
.FirstOrDefault(rd => rd.id == data.tableId);
if (CardRdVOModel == null) return;
2026-04-20 13:49:36 +08:00
2026-05-08 11:03:00 +08:00
bool isShow = CardRdVOModel.AD_Limit_times > data.WatchVideoSpeedNum && data.inlineNum > GameHelper.GetCommonModel().inlineMin;
2026-04-20 13:49:36 +08:00
ui.btn_watch.enabled = isShow;
}
private void OnConfirm()
{
ui.type.selectedIndex = 3;
makeup_2 vo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(makeupTaskData.tableId);
if (vo == null)
{
return;
}
2026-05-08 11:03:00 +08:00
// ui.text_condi1.text = GameHelper.Get101Str(vo.item_need);
2026-04-20 13:49:36 +08:00
// ui.pb_condi1.max = vo.item_need;
2026-05-08 11:03:00 +08:00
// var curValue = Math.Min(SaveData.GetSaveobject().saveingpot_ch, vo.item_need);
2026-04-20 13:49:36 +08:00
// ui.pb_condi1.value = (double)curValue;
2026-05-08 11:03:00 +08:00
// var textTitle = ui.pb_condi1.GetChild("title");
2026-04-20 13:49:36 +08:00
// if (textTitle != null)
// {
2026-05-08 11:03:00 +08:00
// textTitle.text = GameHelper.Get102Str((decimal)curValue) + "/" + GameHelper.Get102Str(vo.item_need);
2026-04-20 13:49:36 +08:00
// }
var taskTime = (int)((float)vo.task_need / 60 * 100) * 0.01F;
2026-05-08 11:03:00 +08:00
// var completeTaskTime = (int)((float)makeupTaskData.H5Time / 60 * 100) * 0.01F;
// var completeTaskValue = Math.Min(completeTaskTime, taskTime);
// ui.text_condi2.text = taskTime.ToString();
// ui.pb_condi2.max = taskTime;
// ui.pb_condi2.value = completeTaskValue;
// ui.pb_condi2.title.text = $"{completeTaskValue}/{taskTime}";
// if (DataMgr.MakeupTaskH5Time < vo.task_need && AppConst.isPt())
2026-04-20 13:49:36 +08:00
// {
// ui.show_pay.selectedIndex = com_confirm.Show_pay_true;
// }
// else ui.show_pay.selectedIndex = com_confirm.Show_pay_false;
//ui.text_wallet.SetVar("Payer", "$").FlushVars();
// if (AppConst.isPt()) ui.text_wallet.text = "Pix";
2026-05-08 11:03:00 +08:00
ui.text_ch.text = GameHelper.Get102Str((decimal)makeupTaskData.amount);
if (!GameHelper.isRDExchangeMode()) ui.card_.visible = false;
2026-04-20 13:49:36 +08:00
ui.text_account.text = PreferencesMgr.Instance.ExchangeAccount;
2026-05-08 11:03:00 +08:00
if (SaveData.GetSaveobject().saveingpot_ch >= vo.item_need)
2026-04-20 13:49:36 +08:00
{
ui.cont_confirm.selectedIndex = 0;
ui.btn_confirm.SetClick(() =>
{
Audio.Instance.PlayDynamicEffect("makupdone");
makeupTaskData.SetStatus(SaveingPotTaskStatus.Task);
2026-05-08 11:03:00 +08:00
SaveData.saveDataFunc();
2026-04-20 13:49:36 +08:00
OnTask();
});
}
else
{
ui.cont_confirm.selectedIndex = 1;
ui.btn_confirm.SetClick(() =>
{
Audio.Instance.PlayDynamicEffect("makupdone");
2026-05-08 11:03:00 +08:00
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.H5UI_Open);
//GameDispatcher.Instance.Dispatch(BingoInfo.MainTab, 1);
2026-04-20 13:49:36 +08:00
CtrlCloseUI();
});
}
}
private void OnTask()
{
var vo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(makeupTaskData.tableId);
if (vo == null)
{
return;
}
ui.type.selectedIndex = 4;
2026-05-08 11:03:00 +08:00
ui.com_task.text_task.text = "get gift card";
ui.com_task.text_payer.text = "{amt=$0.5} directly to your gift card";
2026-04-20 13:49:36 +08:00
ui.com_task.text_orderid.text = makeupTaskData.orderID;
ui.com_task.text_task_title.SetVar("ad", vo.ad_need.ToString()).FlushVars();
ui.com_task.text_ads.text = $"{makeupTaskData.videoCount}/{vo.ad_need}";
ui.com_task.text_payer.SetVar("amt", makeupTaskData.GetAmountStr()).FlushVars();
2026-05-08 11:03:00 +08:00
2026-04-20 13:49:36 +08:00
if (makeupTaskData.videoCount >= vo.ad_need)
{
ui.com_task.cont_process.selectedIndex = 1;
2026-05-08 11:03:00 +08:00
ui.cont_confirm.selectedIndex = 0;
2026-04-20 13:49:36 +08:00
}
2026-05-08 11:03:00 +08:00
else
2026-04-20 13:49:36 +08:00
{
2026-05-08 11:03:00 +08:00
ui.com_task.cont_process.selectedIndex = 0;
ui.cont_confirm.selectedIndex = 1;
}
2026-04-20 13:49:36 +08:00
2026-05-08 11:03:00 +08:00
if (makeupTaskData.videoCount >= vo.ad_need)
{
ui.btn_confirm.state.selectedIndex = 0;
ui.btn_confirm.visible = true;
ui.btn_confirm.SetClick(() =>
{
if (makeupTaskData.videoCount >= vo.ad_need)
{
GameHelper.ShowLoading(1, 2, () =>
{
TuSystem.Consume(vo.item, vo.item_need, isSuccess =>
{
makeupTaskData.SetStatus(SaveingPotTaskStatus.Inline);
makeupTaskData.inlineInitNum =
UnityEngine.Random.Range(ConfigSystem.GetConfig<CommonModel>().inlineInitNum[0],
ConfigSystem.GetConfig<CommonModel>().inlineInitNum[1]);
makeupTaskData.inlineNum = UnityEngine.Random.Range(
ConfigSystem.GetConfig<CommonModel>().inlineInitNum[0],
makeupTaskData.inlineInitNum);
makeupTaskData.order_time = GameHelper.GetNowTime();
// PreferencesMgr.Instance.SaveMakeupTaskHistory();
//OnInline();
SaveData.GetSaveobject().saveingpot_ch -= vo.item_need;
SaveingPotHelper.CreatSaveingPotItem();
// Debug.Log(JsonConvert.SerializeObject(vo));
// if (vo.id == 1)
// {
// TrackKit.SendEvent(Property.withdraw_Event, Property.withdraw_cash1);
// }
// else if (vo.id == 2)
// {
// TrackKit.SendEvent(Property.withdraw_Event, Property.withdraw_cash2);
// }
// else if (vo.id == 3)
// {
// TrackKit.SendEvent(Property.withdraw_Event, Property.withdraw_cash3);
// }
if (vo.id != 3)
{
// ch_index++;
}
InitView();
if (vo.id == 3)
{
// PlayerPrefs.SetInt("ch_lv", 2);
makeupTaskData = SaveData.GetSaveobject().saveingpot_history.Last();
}
});
});
}
else
{
CtrlCloseUI();
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.H5UI_Open);
// MainTabUI.getIns().OnGameTab(1);
}
});
}
else
{
ui.btn_confirm.state.selectedIndex = 1;
ui.btn_confirm.visible = false;
}
2026-04-20 13:49:36 +08:00
}
private void OnEnter()
{
GTextInput enter_input = null;
enter_input = ui.com_info.enter_email;
ui.type.selectedIndex = 1;
ui.btn_confirm.SetClick(() =>
{
var account = enter_input.text.Replace(" ", "");
if (account == null || account == "")
{
GameHelper.ShowTips("Please enter the correct account information1", true);
return;
}
if (!GameHelper.CheckAccountValidly(account))
{
GameHelper.ShowTips("Please enter the correct account information2", true);
return;
}
var fname = ui.com_fname.enter_fname.text.Replace(" ", "");
if (!GameHelper.CheckNameValidly(fname))
{
GameHelper.ShowTips("Please enter the correct account information3", true);
return;
}
2026-05-08 11:03:00 +08:00
var lname = ui.com_lname.enter_lname.text.Replace(" ", "");
2026-04-20 13:49:36 +08:00
if (!GameHelper.CheckNameValidly(lname))
{
GameHelper.ShowTips("Please enter the correct account information4", true);
return;
}
PreferencesMgr.Instance.ExchangeAccount = account;
PreferencesMgr.Instance.ExchangeName = $"{fname} {lname}";
PreferencesMgr.Instance.short_name = fname;
PreferencesMgr.Instance.long_name = lname;
showPaypal();
//uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupStepUI_Open, makeupTaskData);
//CtrlCloseUI();
});
}
void showPaypal()
{
ui.type.selectedIndex = 2;
if (makeupTaskData == null)
{
return;
}
ui.com_pay.text_name.text = PreferencesMgr.Instance.ExchangeName;
ui.com_pay.text_email.text = PreferencesMgr.Instance.ExchangeAccount;
ui.com_pay.btn_change.SetClick(() =>
{
PreferencesMgr.Instance.ExchangeName = null;
PreferencesMgr.Instance.ExchangeAccount = null;
OnEnter();
});
2026-05-08 11:03:00 +08:00
var avatarId = PreferencesMgr.Instance.PlayerAvatarId;
// EyesHarmony.SetAvatarToLoader(avatarId, ui.com_pay.head.GetChild("load_avatar") as GLoader);
2026-04-20 13:49:36 +08:00
ui.btn_confirm.SetClick(() =>
2026-05-08 11:03:00 +08:00
{
// NetApi.PayOutUserInfo<OrderState>(DataMgr.ExchangeAccount.Value,
// DataMgr.short_name, DataMgr.long_name, (isSuccess, obj) =>
// {
// if (isSuccess)
// {
// }
// });
// TrackKit.SendEvent(Property.withdraw_Event, Property.WithdrawMessage);
InitView();
});
2026-04-20 13:49:36 +08:00
}
public int now_selectindex;
void initTop()
{
2026-05-08 11:03:00 +08:00
// Debug.Log(JsonConvert.SerializeObject(DataMgr.MakeupTaskHistory.Value));
2026-04-20 13:49:36 +08:00
List<btn_top> btn_list = new List<btn_top>() { ui.btn_level0, ui.btn_level1, ui.btn_level2 };
List<makeup_2> makeup_list = ConfigSystem.GetConfig<MakeupModel_2>().dataList;
now_selectindex = makeupTaskData.tableId - 1;
List<SaveingPotClass> saveingpot_history = SaveData.GetSaveobject().saveingpot_history;
for (int i = 0; i < btn_list.Count; i++)
{
2026-05-08 11:03:00 +08:00
btn_list[i].text_ch.text = "$" + (int)makeup_list[i].item_need;
2026-04-20 13:49:36 +08:00
Debug.Log(makeup_list[i].item_need);
btn_list[i].index.selectedIndex = i;
if (i >= saveingpot_history.Count)
{
btn_list[i].btn_state.selectedIndex = 2;
2026-05-08 11:03:00 +08:00
// btn_list[i].text_type.grayed = true;
btn_list[i].text_ch.grayed = true;
2026-04-20 13:49:36 +08:00
}
else if (saveingpot_history.Count > i + 1 || ((saveingpot_history.Count == 3) && (saveingpot_history[2].status == SaveingPotTaskStatus.Inline)))
{
btn_list[i].btn_state.selectedIndex = 0;
}
else
{
btn_list[i].btn_state.selectedIndex = 1;
}
if (i == now_selectindex)
{
btn_list[i].img_outline.visible = true;
}
else if (i >= saveingpot_history.Count)
{
btn_list[i].img_outline.visible = false;
btn_list[i].SetClick(() =>
{
GameHelper.ShowTips("To be unlocked");
});
}
else
{
btn_list[i].img_outline.visible = false;
int index = i;
btn_list[i].SetClick(() =>
{
for (int j = saveingpot_history.Count - 1; j >= 0; j--)
{
Debug.Log(saveingpot_history[j].tableId);
Debug.Log(index + 1);
Debug.Log(saveingpot_history[j].tableId == index + 1);
if (saveingpot_history[j].tableId == index + 1)
{
makeupTaskData = saveingpot_history[j];
now_selectindex = index;
break;
}
}
InitView();
});
}
}
}
private List<string> config_name_list = exBrPoolModel_2.config_name_list;
2026-05-08 11:03:00 +08:00
private List<string> config_money_list = exBrPoolModel_2.config_money_list;
2026-04-20 13:49:36 +08:00
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
ui.broad.t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
2026-05-08 11:03:00 +08:00
if (GameHelper.isRDExchangeMode())
{
text_list[i].text = "congratulations,[color=#ad4800][size=36] " + broad_list[i][0] + " [/size][/color]Successful exchange[color=#ad4800]<img src='ui://o9974uc5t9w7c3'/>" + broad_list[i][1] + "[/color]";
}
else
{
text_list[i].text = "congratulations,[color=#ad4800][size=36] " + broad_list[i][0] + " [/size][/color]Successful exchange[color=#ad4800]$" + broad_list[i][1] + "[/color]";
}
2026-04-20 13:49:36 +08:00
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
2026-05-08 11:03:00 +08:00
text_list.Add(ui.broad.rich_text0);
text_list.Add(ui.broad.rich_text1);
text_list.Add(ui.broad.rich_text2);
text_list.Add(ui.broad.rich_text3);
2026-04-20 13:49:36 +08:00
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
2026-05-08 11:03:00 +08:00
if (GameHelper.isRDExchangeMode())
{
text_list[i].text = "congratulations,[color=#ad4800][size=36] " + broad_list[i][0] + " [/size][/color]Successful exchange[color=#ad4800]<img src='ui://o9974uc5t9w7c3'/>" + broad_list[i][1] + "[/color]";
}
else
{
text_list[i].text = "congratulations,[color=#ad4800][size=36] " + broad_list[i][0] + " [/size][/color]Successful exchange[color=#ad4800]$" + broad_list[i][1] + "[/color]";
}
2026-04-20 13:49:36 +08:00
}
}
}
}