先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
150 lines
5.0 KiB
C#
150 lines
5.0 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using System;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GiftPopupPanel_3 : GiftPopupPanel
|
|
{
|
|
string Type = "WheelPack";
|
|
GameObject Advert;
|
|
Button btn_advert;
|
|
GameObject soldout;
|
|
|
|
WheelPack wheelPack;
|
|
FishingEventData _fishingEventData;
|
|
IDisposable ads;
|
|
|
|
private AdvertPopupType _curOpenAdType = AdvertPopupType.None;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
soldout = transform.Find("root/soldout").gameObject;
|
|
Advert = transform.Find("root/advert").gameObject;
|
|
btn_advert = transform.Find("root/advert/btn_advert").GetComponent<Button>();
|
|
}
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
wheelPack = _tables.TbWheelPack[1];
|
|
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
|
SetAdvertState();
|
|
btn_advert.onClick.AddListener(OnWatchClick);
|
|
|
|
btn_close.onClick.AddListener(OnClickClose);
|
|
SetData();
|
|
}
|
|
|
|
public void SetData()
|
|
{
|
|
int vipLevel = GContext.container.Resolve<TriggerPackData>().GetVIPLevel(Type);
|
|
int buyCount = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(Type);
|
|
var PackList = wheelPack.PackList[vipLevel];
|
|
if (buyCount >= PackList.Count)
|
|
{
|
|
buyCount = PackList.Count - 1;
|
|
}
|
|
pack = _tables.TbPack.GetOrDefault(wheelPack.PackList[vipLevel][buyCount]);
|
|
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
|
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(pack.DropID);
|
|
SetShowData();
|
|
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
|
GContext.Publish(sKUDetailDataEvent);
|
|
text_buy.text = sKUDetailDataEvent.price;
|
|
tag_more.SetActive(pack.Rebate > 0.0001);
|
|
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", pack.Rebate * 100);
|
|
SetState();
|
|
}
|
|
|
|
protected override ShopBuyTypeData GetShopBuyTypeData()
|
|
{
|
|
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
|
shopBuyTypeData.type = ShopBuyType.ShopPackDailyBuy;
|
|
shopBuyTypeData.key = Type;
|
|
shopBuyTypeData.endDay = ZZTimeHelper.UtcNow().UtcNowOffset().Day;
|
|
return shopBuyTypeData;
|
|
}
|
|
protected override void OnSuccess()
|
|
{
|
|
GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(Type);
|
|
//GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(pack.ID, 1);
|
|
GContext.container.Resolve<TriggerPackData>().SetVIPLevel(Type, wheelPack.VIPBonusForNextType);
|
|
//SetState();
|
|
OnClickClose();
|
|
}
|
|
protected override void OnBuySuccess()
|
|
{
|
|
//GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(Type);
|
|
//GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(pack.ID, 1);
|
|
GContext.container.Resolve<TriggerPackData>().SetVIPLevel(Type, wheelPack.VIPBonusForNextType);
|
|
//SetState();
|
|
OnClickClose();
|
|
}
|
|
void SetState()
|
|
{
|
|
int remainder = wheelPack.MaxPurchaseCount - GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(Type);
|
|
if (remainder <= 0)
|
|
{
|
|
remainder = 0;
|
|
}
|
|
Remaining.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", remainder, wheelPack.MaxPurchaseCount);
|
|
soldout.SetActive(remainder <= 0);
|
|
btn_buy.gameObject.SetActive(remainder > 0);
|
|
}
|
|
protected void OnClickClose()
|
|
{
|
|
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_3);
|
|
}
|
|
|
|
private void OnWatchClick()
|
|
{
|
|
btn_advert.enabled = false;
|
|
AdsDispose();
|
|
ads = GContext.OnEvent<AdsResult>().Subscribe(SetResult);
|
|
// [REMOVED] Turntable deleted
|
|
// _curOpenAdType = AdvertPopupType.Turntable;
|
|
// GContext.container.Resolve<IAdsService>().ShowRewarded(AdvertPopupType.Turntable);
|
|
return;
|
|
}
|
|
void SetResult(AdsResult adsResult)
|
|
{
|
|
if (adsResult.Result == 0 && adsResult.Type == _curOpenAdType)
|
|
{
|
|
OnSucceed();
|
|
}
|
|
AdsDispose();
|
|
btn_advert.enabled = true;
|
|
}
|
|
void AdsDispose()
|
|
{
|
|
if (ads != null)
|
|
{
|
|
_curOpenAdType = AdvertPopupType.None;
|
|
ads.Dispose();
|
|
ads = null;
|
|
}
|
|
}
|
|
|
|
void OnSucceed()
|
|
{
|
|
GContext.container.Resolve<PlayerShopData>().AddAdvertCount(_fishingEventData.wheelInit.ID);
|
|
GContext.container.Resolve<PlayerItemData>().AddItemByDrop(1000001, null);
|
|
GContext.Publish(new ShowData());
|
|
SetAdvertState();
|
|
}
|
|
void SetAdvertState()
|
|
{
|
|
int count = GContext.container.Resolve<PlayerShopData>().GetAdvertCount(_fishingEventData.wheelInit.ID);
|
|
int WheelIAADailyCount = _tables.TbGlobalConfig.WheelIAADailyCount;
|
|
Advert.SetActive(count < WheelIAADailyCount);
|
|
}
|
|
protected void OnDestroy()
|
|
{
|
|
AdsDispose();
|
|
}
|
|
}
|