258 lines
9.6 KiB
C#
258 lines
9.6 KiB
C#
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using FutureCore;
|
||
|
|
using FairyGUI;
|
||
|
|
using FGUI.failpack;
|
||
|
|
using System;
|
||
|
|
using FGUI.ZM_Common_01;
|
||
|
|
using DG.Tweening;
|
||
|
|
|
||
|
|
namespace ZooMatch
|
||
|
|
{
|
||
|
|
public class ResurgenceUI : BaseUI
|
||
|
|
{
|
||
|
|
private ResurgenceUICtrl ctrl;
|
||
|
|
private ResurgenceModel model;
|
||
|
|
private FGUI.failpack.com_resurgence ui;
|
||
|
|
|
||
|
|
public ResurgenceUI(ResurgenceUICtrl ctrl) : base(ctrl)
|
||
|
|
{
|
||
|
|
uiName = UIConst.ResurgenceUI;
|
||
|
|
this.ctrl = ctrl;
|
||
|
|
}
|
||
|
|
private float progress_value;
|
||
|
|
|
||
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||
|
|
{
|
||
|
|
uiInfo.packageName = "failpack";
|
||
|
|
uiInfo.assetName = "com_resurgence";
|
||
|
|
uiInfo.layerType = UILayerType.Popup;
|
||
|
|
uiInfo.isNeedOpenAnim = false;
|
||
|
|
uiInfo.isNeedCloseAnim = false;
|
||
|
|
uiInfo.isNeedUIMask = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 生命周期
|
||
|
|
protected override void OnInit()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnClose()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnBind()
|
||
|
|
{
|
||
|
|
ui = baseUI as FGUI.failpack.com_resurgence;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnOpenBefore(object args)
|
||
|
|
{
|
||
|
|
|
||
|
|
Debug.Log(args);
|
||
|
|
progress_value = (float)args * 100;
|
||
|
|
InitView();
|
||
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_show, 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnOpen(object args)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnHide()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnDisplay(object args)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 消息
|
||
|
|
protected override void AddListener()
|
||
|
|
{
|
||
|
|
if (GameHelper.IsAdModelOfPay())
|
||
|
|
{
|
||
|
|
HallManager.Instance.UpdateSecondEvent += InitView;
|
||
|
|
}
|
||
|
|
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||
|
|
HallManager.Instance.UpdateSecondEvent += updatEevent;
|
||
|
|
}
|
||
|
|
protected override void RemoveListener()
|
||
|
|
{
|
||
|
|
if (GameHelper.IsAdModelOfPay())
|
||
|
|
{
|
||
|
|
HallManager.Instance.UpdateSecondEvent -= InitView;
|
||
|
|
}
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||
|
|
HallManager.Instance.UpdateSecondEvent -= updatEevent;
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
private void updatEevent()
|
||
|
|
{
|
||
|
|
|
||
|
|
// ui.text_remain.text=CommonHelper.TimeFormat((int)(SaveData.GetSaveobject().failed_pack_time - Convert.ToInt32(GameHelper.GetNowTime())), CountDownType.Hour);
|
||
|
|
|
||
|
|
}
|
||
|
|
void pay_success(object str)
|
||
|
|
{
|
||
|
|
string type = (string)str;
|
||
|
|
Debug.Log("77777777777777777777777777" + type);
|
||
|
|
if (type == AdRedeemManager.fail_pack)
|
||
|
|
{
|
||
|
|
|
||
|
|
var start = GameHelper.GetUICenterPosition(ui.bg);
|
||
|
|
//var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("text_gold"));
|
||
|
|
|
||
|
|
// reward_data temp = new reward_data() { start = start, end = end, change = list[1].coins_quantity, type = 101 };
|
||
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.CoinWnd_newUI_Open, temp);
|
||
|
|
|
||
|
|
|
||
|
|
// DOVirtual.DelayedCall(1, () =>
|
||
|
|
// {
|
||
|
|
// DOVirtual.Float(0, (float)PreferencesMgr.Instance.Currency101, 1,
|
||
|
|
// value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||
|
|
// });
|
||
|
|
|
||
|
|
var rewardData = new RewardData();
|
||
|
|
var end = GameHelper.GetUICenterPosition(ui.end_point);
|
||
|
|
|
||
|
|
var rewardSingleData = new RewardSingleData(101, list[2].coins_quantity, RewardOrigin.AdTask)
|
||
|
|
{
|
||
|
|
startPosition = start,
|
||
|
|
endPosition = end
|
||
|
|
};
|
||
|
|
|
||
|
|
rewardData.AddReward(rewardSingleData);
|
||
|
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||
|
|
rewardData.AddCompleted(success =>
|
||
|
|
{
|
||
|
|
// if (success)
|
||
|
|
// {
|
||
|
|
// RefreshGold(awardNum);
|
||
|
|
// }
|
||
|
|
});
|
||
|
|
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||
|
|
// PreferencesMgr.Instance.Currency101 -= list[1].coins_quantity;
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ResurgenceUI_Close);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
private List<Paidgift> list;
|
||
|
|
//初始化页面逻辑
|
||
|
|
private void InitView()
|
||
|
|
{
|
||
|
|
if (SaveData.GetSaveobject().failed_pack_time < GameHelper.GetNowTime())
|
||
|
|
{
|
||
|
|
SaveData.GetSaveobject().failed_pack_time = GameHelper.GetNowTime() + GameHelper.GetCommonModel().FailedGiftCD;
|
||
|
|
}
|
||
|
|
Debug.Log("?????????");
|
||
|
|
ui.btn_back.SetClick(() =>
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ResurgenceUI_Close);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
|
||
|
|
});
|
||
|
|
list = ConfigSystem.GetConfig<PaidgiftModel>().dataList;
|
||
|
|
int gold_num = list[2].coins_quantity;
|
||
|
|
int back_num = list[2].props_quantity[1];
|
||
|
|
int out_num = list[2].props_quantity[0];
|
||
|
|
int refresh_num = list[2].props_quantity[2];
|
||
|
|
ui.text_outnum.text = "x" + out_num;
|
||
|
|
ui.text_backnum.text = "x" + back_num;
|
||
|
|
ui.text_refreshnum.text = "x" + refresh_num;
|
||
|
|
ui.text_goldnum.text = "x" + gold_num;
|
||
|
|
ui.text_progress.text = "Completion:" + Math.Round(progress_value) + "%";
|
||
|
|
ui.progress_1.value = progress_value;
|
||
|
|
if (!GameHelper.IsAdModelOfPay())
|
||
|
|
{
|
||
|
|
ui.pay_type.selectedIndex = 1;
|
||
|
|
|
||
|
|
decimal price = (decimal)list[2].Paid_price2;
|
||
|
|
ui.btn_max_pay.title = GameHelper.Get102Str(price);
|
||
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) (ui.btn_max_pay.GetChild("img_saveingpot") as GImage).visible = true;
|
||
|
|
ui.btn_max_pay.SetClick(() =>
|
||
|
|
{
|
||
|
|
MaxPayClass maxPayData = new()
|
||
|
|
{
|
||
|
|
amount = (int)Math.Round(price * 100),
|
||
|
|
sku = MaxPayManager.fail_pack,
|
||
|
|
currency = "USD"
|
||
|
|
};
|
||
|
|
MaxPayManager.Instance.Buy(maxPayData);
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
btn_watchAd btn_ad_buy = ui.btn_buy as btn_watchAd;
|
||
|
|
ui.text_have.text = "Owner ADs:" + AdRedeemManager.Instance.GetLookRewardADNum();
|
||
|
|
ui.need_text.text = "need " + list[2].Paid_price + " ADs";
|
||
|
|
btn_ad_buy.img_saveingpot.visible = false;
|
||
|
|
// btn_ad_buy.SetClick(() =>
|
||
|
|
// {
|
||
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ResurgenceUI_Close);
|
||
|
|
// });
|
||
|
|
|
||
|
|
|
||
|
|
int nums = PlayerPrefs.GetInt("get_look_reward_ad_num", 0);
|
||
|
|
if (nums >= list[2].Paid_price)
|
||
|
|
{
|
||
|
|
btn_ad_buy.buy_state.selectedIndex = 1;
|
||
|
|
btn_ad_buy.can_buy.selectedIndex = 0;
|
||
|
|
btn_ad_buy.SetClick(() =>
|
||
|
|
{
|
||
|
|
// ApplePayClass test = new ApplePayClass()
|
||
|
|
// {
|
||
|
|
// sku = PurchasingManager.fail_pack,
|
||
|
|
// };
|
||
|
|
// PurchasingManager.Instance.Purchase(PurchasingManager.fail_pack, test);
|
||
|
|
AdRedeemData adRedeemData = new AdRedeemData()
|
||
|
|
{
|
||
|
|
type = AdRedeemManager.fail_pack,
|
||
|
|
ad_count = (int)list[2].Paid_price
|
||
|
|
};
|
||
|
|
AdRedeemManager.Instance.Redeem(adRedeemData);
|
||
|
|
|
||
|
|
// nums -= (int)list[2].Paid_price;
|
||
|
|
//PlayerPrefs.SetInt("get_look_reward_ad_num", nums);
|
||
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_buy_success, 1);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
else if (SaveData.GetSaveobject()._watch_ad_cd > GameHelper.GetNowTime())
|
||
|
|
{
|
||
|
|
btn_ad_buy.buy_state.selectedIndex = 0;
|
||
|
|
btn_ad_buy.can_buy.selectedIndex = 1;
|
||
|
|
btn_ad_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveobject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||
|
|
btn_ad_buy.SetClick(() =>
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
});
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
btn_ad_buy.buy_state.selectedIndex = 0;
|
||
|
|
btn_ad_buy.can_buy.selectedIndex = 0;
|
||
|
|
//btn_ad_buy.text = "Watch AD";
|
||
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) btn_ad_buy.img_saveingpot.visible = true;
|
||
|
|
btn_ad_buy.SetClick(() =>
|
||
|
|
{
|
||
|
|
GameHelper.ShowVideoAd("Pass", (issuccess) =>
|
||
|
|
{
|
||
|
|
if (issuccess)
|
||
|
|
{
|
||
|
|
SaveData.GetSaveobject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
|
||
|
|
InitView();
|
||
|
|
|
||
|
|
}
|
||
|
|
});
|
||
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_click, 1);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|