203 lines
7.9 KiB
C#
203 lines
7.9 KiB
C#
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace ZooMatch
|
||
|
|
{
|
||
|
|
public class RainPlayUICtrl : BaseUICtrl
|
||
|
|
{
|
||
|
|
private RainPlayUI ui;
|
||
|
|
private RainPlayModel model;
|
||
|
|
|
||
|
|
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
|
||
|
|
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
|
||
|
|
|
||
|
|
#region 生命周期
|
||
|
|
protected override void OnInit()
|
||
|
|
{
|
||
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnDispose()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void OpenUI(object args = null)
|
||
|
|
{
|
||
|
|
if (ui == null)
|
||
|
|
{
|
||
|
|
ui = new RainPlayUI(this);
|
||
|
|
ui.Open(args);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void CloseUI(object args = null)
|
||
|
|
{
|
||
|
|
if (ui != null && !ui.isClose)
|
||
|
|
{
|
||
|
|
ui.Close();
|
||
|
|
}
|
||
|
|
ui = null;
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 消息
|
||
|
|
public override uint GetOpenUIMsg(string uiName)
|
||
|
|
{
|
||
|
|
return openUIMsg;
|
||
|
|
}
|
||
|
|
public override uint GetCloseUIMsg(string uiName)
|
||
|
|
{
|
||
|
|
return closeUIMsg;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void AddListener()
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||
|
|
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||
|
|
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||
|
|
|
||
|
|
}
|
||
|
|
protected override void RemoveListener()
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||
|
|
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void AddServerListener()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
protected override void RemoveServerListener()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
private void GetPayReward(decimal goldNum)
|
||
|
|
{
|
||
|
|
if (goldNum == 0) return;
|
||
|
|
|
||
|
|
var start = new Vector2(540, 960);
|
||
|
|
var end = new Vector2(236, 62);
|
||
|
|
var rewardData = new RewardData();
|
||
|
|
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask){
|
||
|
|
startPosition = start,
|
||
|
|
};
|
||
|
|
rewardData.AddReward(rewardSingleData);
|
||
|
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||
|
|
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||
|
|
}
|
||
|
|
|
||
|
|
void pay_success(object str)
|
||
|
|
{
|
||
|
|
string type = (string)str;
|
||
|
|
string purch_number = "";
|
||
|
|
if (type.Contains("buy_gold"))
|
||
|
|
{
|
||
|
|
if (type.StartsWith("buy_gold"))
|
||
|
|
{
|
||
|
|
int startIndex = "buy_gold".Length;
|
||
|
|
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||
|
|
int suffix_num = int.Parse(suffix);
|
||
|
|
|
||
|
|
purch_number = ConfigSystem.GetConfig<PaidcoinsModel>().dataList[suffix_num].Payment_amount2.ToString();
|
||
|
|
|
||
|
|
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
||
|
|
{
|
||
|
|
List<Paidcoins> list = ConfigSystem.GetConfig<PaidcoinsModel>().dataList;
|
||
|
|
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
||
|
|
int gold_num = list[suffix_num].Actual_coins;
|
||
|
|
GetPayReward(gold_num);
|
||
|
|
SaveData.GetSaveobject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||
|
|
SaveData.saveDataFunc();
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
else if (type == AdRedeemManager.battle_pass)
|
||
|
|
{
|
||
|
|
var purch = ConfigSystem.GetConfig<CommonModel>().Passportgift2;
|
||
|
|
purch_number = purch.ToString();
|
||
|
|
}
|
||
|
|
else if (type == AdRedeemManager.buy_one)
|
||
|
|
{
|
||
|
|
SaveData.GetSaveobject().have_slot = true;
|
||
|
|
SaveData.saveDataFunc();
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
|
||
|
|
GameHelper.ShowTips("Purchase successful");
|
||
|
|
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
|
||
|
|
}
|
||
|
|
else if (type == AdRedeemManager.remove_ad)
|
||
|
|
{
|
||
|
|
SaveData.GetSaveobject().is_get_removead = true;
|
||
|
|
SaveData.saveDataFunc();
|
||
|
|
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<PaidgiftModel>().dataList[1].coins_quantity);
|
||
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||
|
|
ui?.setBtnAds();
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
|
||
|
|
GameHelper.ShowTips("Purchase successful");
|
||
|
|
purch_number = ConfigSystem.GetConfig<PaidgiftModel>().dataList[1].Paid_price2.ToString();
|
||
|
|
}
|
||
|
|
else if (type == AdRedeemManager.pack_reward)
|
||
|
|
{
|
||
|
|
List<Paidgift> list = ConfigSystem.GetConfig<PaidgiftModel>().dataList;
|
||
|
|
int gold_num = list[0].coins_quantity;
|
||
|
|
int back_num = list[0].props_quantity[1];
|
||
|
|
int out_num = list[0].props_quantity[0];
|
||
|
|
int refresh_num = list[0].props_quantity[2];
|
||
|
|
|
||
|
|
// GameHelper.AddGoldNumber(gold_num);
|
||
|
|
GameHelper.AddItemNumber(0, out_num);
|
||
|
|
GameHelper.AddItemNumber(1, back_num);
|
||
|
|
GameHelper.AddItemNumber(2, refresh_num);
|
||
|
|
SaveData.GetSaveobject().is_get_packreward = true;
|
||
|
|
SaveData.saveDataFunc();
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||
|
|
ui?.setBtnAds();
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
|
||
|
|
GameHelper.ShowTips("Purchase successful");
|
||
|
|
purch_number = ConfigSystem.GetConfig<PaidgiftModel>().dataList[0].Paid_price2.ToString();
|
||
|
|
}
|
||
|
|
else if (type == AdRedeemManager.fail_pack)
|
||
|
|
{
|
||
|
|
List<Paidgift> list = ConfigSystem.GetConfig<PaidgiftModel>().dataList;
|
||
|
|
purch_number = ConfigSystem.GetConfig<PaidgiftModel>().dataList[2].Paid_price2.ToString();
|
||
|
|
//ui?.setBtnAds();
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||
|
|
|
||
|
|
// PreferencesMgr.Instance.Currency101 += ConfigSystem.GetConfig<PaidgiftModel>().dataList[1].coins_quantity;
|
||
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||
|
|
int back_num = list[2].props_quantity[1];
|
||
|
|
int out_num = list[2].props_quantity[0];
|
||
|
|
int refresh_num = list[2].props_quantity[2];
|
||
|
|
//GameHelper.addGoldNumber(gold_num);
|
||
|
|
int gold_num = list[2].coins_quantity;
|
||
|
|
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) PreferencesMgr.Instance.Currency101 += gold_num;
|
||
|
|
GameHelper.AddItemNumber(0, out_num);
|
||
|
|
GameHelper.AddItemNumber(1, back_num);
|
||
|
|
GameHelper.AddItemNumber(2, refresh_num);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||
|
|
SaveData.saveDataFunc();
|
||
|
|
|
||
|
|
}
|
||
|
|
else if (type == AdRedeemManager.three_days_gift)
|
||
|
|
{
|
||
|
|
SaveData.GetSaveobject().is_get_ThreeDaysGift = true;
|
||
|
|
SaveData.saveDataFunc();
|
||
|
|
purch_number = ConfigSystem.GetConfig<MultigiftModel>().dataList[0].Paid_price2.ToString();
|
||
|
|
}
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||
|
|
|
||
|
|
if (purch_number != "")
|
||
|
|
{
|
||
|
|
GameHelper.SendRevenueToAF(purch_number);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
}
|
||
|
|
}
|