备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
using asap.core;
using game;
using System;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using TMPro;
using GameCore;
public class AdvertButton : MonoBehaviour
{
public Button advBtn;
public Button adticketBtn;
public TMP_Text adticket_text;
public Button advBtnGray;
public Button adticketBtnGray;
public TMP_Text adticket_text_gray;
private IDisposable ads;
private AdvertPopupType curOpenAdType = AdvertPopupType.None;
private Action OnBuySuccess;
private IDisposable disposable;
int quantityRequired = 1;
bool isGray = false;
//private void Awake()
//{
// advBtn = transform.Find("btn_green1").GetComponent<Button>();
// adticketBtn = transform.Find("btn_green2").GetComponent<Button>();
//}
private void Start()
{
advBtn.onClick.AddListener(OnClickAds);
adticketBtn.onClick.AddListener(OnClickCoupon);
}
public void SetData(Action onBuySuccess, AdvertPopupType openAdType)
{
this.OnBuySuccess = onBuySuccess;
this.curOpenAdType = openAdType;
}
private void OnEnable()
{
disposable?.Dispose();
OnAdticketChangeEvent();
disposable = GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1006).Subscribe(x =>
{
OnAdticketChangeEvent();
});
}
void OnAdticketChangeEvent()
{
if (isGray) { return; }
int count = GContext.container.Resolve<PlayerShopData>().GetAdticketCount();
advBtn.gameObject.SetActive(count < quantityRequired);
adticketBtn.gameObject.SetActive(count >= quantityRequired);
adticket_text.text = $"{count}/{quantityRequired}";
}
public void SetGray()
{
int count = GContext.container.Resolve<PlayerShopData>().GetAdticketCount();
advBtn.gameObject.SetActive(false);
adticketBtn.gameObject.SetActive(false);
if (advBtnGray != null)
{
advBtnGray.gameObject.SetActive(count < quantityRequired);
}
if (adticketBtnGray != null)
{
adticketBtnGray.gameObject.SetActive(count >= quantityRequired);
adticket_text_gray.text = $"{count}/{quantityRequired}";
}
}
void OnClickCoupon()
{
if (OnBuySuccess == null)
{
return;
}
//消耗广告券 quantityRequired
GContext.container.Resolve<PlayerShopData>().AddAdticket(-quantityRequired);
OnBuySuccess?.Invoke();
}
void OnClickAds()
{
if (OnBuySuccess == null)
{
return;
}
advBtn.enabled = false;
//拉起广告
AdsDispose();
ads = GContext.OnEvent<AdsResult>().Subscribe(SetResult);
GContext.container.Resolve<IAdsService>().ShowRewarded(curOpenAdType);
}
void SetResult(AdsResult adsResult)
{
AdsDispose();
advBtn.enabled = true;
if (adsResult.Result == 0 && adsResult.Type == curOpenAdType)
{
//广告成功
OnBuySuccess?.Invoke();
}
}
void AdsDispose()
{
ads?.Dispose();
ads = null;
}
private void OnDisable()
{
disposable?.Dispose();
disposable = null;
AdsDispose();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f75cfe94920e1754fbb346025ac3ea2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using cfg;
using UnityEngine;
using UnityEngine.UI;
public class AdvertGiftItem : MonoBehaviour
{
public bool vipFree;
public AdConfig adConfig;
public RewardItemNew rewardItem1;
public RewardItemNew rewardItem2;
public GameObject done;
public GameObject current;
public AdvertButton btn_watch;
public Button btn_free;
public GameObject unlock;
public GameObject unlock2;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 800e6b282fd800e419c5b040fd385fc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,147 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UniRx;
public class AdvertGiftPanel : MonoBehaviour
{
Tables _tables;
PlayerShopData shopData;
TMP_Text text_time;
AdvertGiftItem[] advertGiftItems;
Timer timer;
private IDisposable ads;
AdConfig curAdConfig;
AdvertGiftItem advertGiftItem;
private AdvertPopupType _curOpenAdType = AdvertPopupType.None;
private void Awake()
{
_tables = GContext.container.Resolve<Tables>();
shopData = GContext.container.Resolve<PlayerShopData>();
text_time = transform.Find("title2/bg_time/text_info").GetComponent<TMP_Text>();
advertGiftItems = transform.GetComponentsInChildren<AdvertGiftItem>();
}
protected void Start()
{
Init();
StartTimer();
}
void Init()
{
var DataList = _tables.TbAdConfig.DataList;
int viplv = GContext.container.Resolve<PlayerData>().vip;
for (int i = 0; i < advertGiftItems.Length; i++)
{
AdConfig adConfig = DataList[i];
var drop = _tables.TbDrop.GetOrDefault(adConfig.Reward);
var itemDropPackage = _tables.TbItemDropPackage.GetOrDefault(adConfig.Reward);
advertGiftItems[i].adConfig = adConfig;
advertGiftItems[i].vipFree = viplv >= adConfig.VipFree;
advertGiftItems[i].btn_watch.SetData(() =>
{
shopData.AddAdvertCount(curAdConfig.Reward);
//广告成功
OnBuySuccess();
}, AdvertPopupType.Shop);
advertGiftItems[i].btn_free.onClick.AddListener(OnBuySuccess);
if (itemDropPackage.ItemDisplay.Count > 0)
{
List<string> CountDisplay = GContext.container.Resolve<PlayerItemData>().ShowItemDropPackage(itemDropPackage);
advertGiftItems[i].rewardItem1.SetData(itemDropPackage.ItemDisplay[0], CountDisplay[0], true);
advertGiftItems[i].rewardItem2.SetData(itemDropPackage.ItemDisplay[1], CountDisplay[1], true);
}
}
}
async void ReStart()
{
await Awaiters.Seconds(0.5f);
StartTimer();
}
void SetState()
{
shopData.ClearAdvertCount();
int adCount = shopData.VIPAdPackData.index;
for (int i = 0; i < advertGiftItems.Length; i++)
{
advertGiftItems[i].current.SetActive(i == adCount);
advertGiftItems[i].done.SetActive(i < adCount);
advertGiftItems[i].unlock.SetActive(i > adCount);
advertGiftItems[i].unlock2.SetActive(i > adCount);
if (i == adCount)
{
advertGiftItem = advertGiftItems[i];
advertGiftItem.btn_free.gameObject.SetActive(advertGiftItem.vipFree);
advertGiftItem.btn_watch.gameObject.SetActive(!advertGiftItem.vipFree);
curAdConfig = advertGiftItems[i].adConfig;
}
}
}
void StartTimer()
{
if (timer != null)
{
timer.Cancel();
timer = null;
}
var newTime = ZZTimeHelper.UtcNow().UtcNowOffset().Date.AddDays(1);
TimeSpan timeSpan = newTime - ZZTimeHelper.UtcNow().UtcNowOffset();
SetState();
timer = this.AttachTimer((float)timeSpan.TotalSeconds, ReStart, (elapsed) =>
{
TimeSpan now = newTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_refresh", $"<size=40>{ConvertTools.ConvertTime2(now)}</size>");
}, useRealTime: true);
}
void OnClickGet()
{
advertGiftItem.btn_watch.enabled = false;
//拉起广告
AdsDispose();
ads = GContext.OnEvent<AdsResult>().Subscribe(SetResult);
_curOpenAdType = AdvertPopupType.Shop;
GContext.container.Resolve<IAdsService>().ShowRewarded(_curOpenAdType);
}
void SetResult(AdsResult adsResult)
{
AdsDispose();
advertGiftItem.btn_watch.enabled = true;
if (adsResult.Result == 0 && adsResult.Type == AdvertPopupType.Shop)
{
shopData.AddAdvertCount(curAdConfig.Reward);
//广告成功
OnBuySuccess();
}
}
void AdsDispose()
{
if (ads != null)
{
_curOpenAdType = AdvertPopupType.None;
ads.Dispose();
ads = null;
}
}
private void OnBuySuccess()
{
GContext.container.Resolve<PlayerItemData>().AddItemByDrop(curAdConfig.Reward);
shopData.SetVIPPackNext();
GContext.Publish(new ShowData());
SetState();
shopData.SetAdvRedPoint();
}
protected void OnDestroy()
{
if (timer != null)
{
timer.Cancel();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1178540a5347431488207b304d81371c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,108 @@
using asap.core;
using DG.Tweening;
using GameCore;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class AdvertData
{
public int ID;
public int index;
public int day;
public string cdTime;
public bool isOpen;
}
public class AdvertPanel : MonoBehaviour
{
Button btn_close;
TMP_Text txt_energy, txt_money, txt_ticket;
ulong _curGold;
int _curEnergy;
int _curTicket;
protected CompositeDisposable disposables = new CompositeDisposable();
private void Awake()
{
txt_ticket = transform.Find("top_area/resource/icon_ticket/text_num").GetComponent<TMP_Text>();
txt_energy = transform.Find("top_area/resource/icon_energy/text_num").GetComponent<TMP_Text>();
txt_money = transform.Find("top_area/resource/icon_money/text_num").GetComponent<TMP_Text>();
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
}
private void Start()
{
var playerData = GContext.container.Resolve<PlayerData>();
_curGold = playerData.gold;
_curEnergy = playerData.Energy;
_curTicket = GContext.container.Resolve<PlayerShopData>().GetAdticketCount();
txt_money.text = ConvertTools.GetNumberString2(_curGold);
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
txt_ticket.text = ConvertTools.GetNumberString2(_curTicket);
btn_close.onClick.AddListener(() =>
{
GContext.Publish(new RestartShowHomeUIEvent());
UIManager.Instance.DestroyUI(UITypes.AdvertPanel);
});
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1002).Subscribe(x =>
{
GoldAddAnim();
}).AddTo(disposables);
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1001).Subscribe(x =>
{
EnergyAddAnim();
}).AddTo(disposables);
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1006).Subscribe(x =>
{
TicketAddAnim();
}).AddTo(disposables);
}
//private async System.Threading.Tasks.Task WaitForRewardPanel()
//{
// await new WaitForSeconds(0.5f);
// var rewardPanelTask = new RewardPopupData();
// GContext.Publish(rewardPanelTask);
// if (rewardPanelTask.tcs != null)
// {
// await rewardPanelTask.tcs.Task;
// }
//}
void GoldAddAnim()
{
//await WaitForRewardPanel();
DOTween.Kill("txt_money");
txt_money.text = ConvertTools.GetNumberString2(_curGold);
var EndDiamond = GContext.container.Resolve<PlayerData>().gold;
DOTween.To(() => _curGold, x => _curGold = x, EndDiamond, 1f).OnUpdate(() =>
{
txt_money.text = ConvertTools.GetNumberString2(_curGold);
}).SetId("txt_money");
}
void EnergyAddAnim()
{
//await WaitForRewardPanel();
DOTween.Kill("advert_text_energy");
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
var EndEnergy = GContext.container.Resolve<PlayerData>().Energy;
DOTween.To(() => _curEnergy, x => _curEnergy = x, EndEnergy, 1f).OnUpdate(() =>
{
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
}).SetId("advert_text_energy");
}
void TicketAddAnim()
{
//await WaitForRewardPanel();
DOTween.Kill("text_ticket");
txt_ticket.text = ConvertTools.GetNumberString2(_curTicket);
var Ticket = GContext.container.Resolve<PlayerShopData>().GetAdticketCount();
DOTween.To(() => _curTicket, x => _curTicket = x, Ticket, 1f).OnUpdate(() =>
{
txt_ticket.text = ConvertTools.GetNumberString2(_curTicket);
}).SetId("text_ticket");
}
private void OnDestroy()
{
disposables.Dispose();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cb21725ac23e8d64ca20b1d66146f141
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AdvertRewardPanel : MonoBehaviour
{
Tables _tables;
ShopPackManager packM;
Pack pack;
int num;
RewardItemNew[] rewardItems;
//倒计时
GameObject cd;
TMP_Text text_time;
//购买按钮
Button btn_buy;
AdvertButton btn_advert;
PlayerShopData shopData;
Timer timer;
List<ItemData> itemDataGift;
Daily daily;
private void Awake()
{
shopData = GContext.container.Resolve<PlayerShopData>();
_tables = GContext.container.Resolve<Tables>();
rewardItems = transform.Find("reward_panel").GetComponentsInChildren<RewardItemNew>();
cd = transform.Find("reward_panel/cd").gameObject;
text_time = transform.Find("reward_panel/cd/text_time").GetComponent<TMP_Text>();
btn_buy = transform.Find("reward_panel/btn_free/btn_green").GetComponent<Button>();
btn_advert = transform.Find("reward_panel/AdvertBtn").GetComponent<AdvertButton>();
}
private void Start()
{
btn_buy.onClick.AddListener(OnBuySuccess);
btn_advert.SetData(() =>
{
shopData.AddAdvertCount(packM.ID);
//广告成功
OnBuySuccess();
}, AdvertPopupType.Chest);
var id = GContext.container.Resolve<PlayerData>().priceLevel.DailyGiftPackList[0];
packM = shopData.TbPackManagerGetOrDefault(id);
pack = _tables.TbPack.GetOrDefault(packM.PackID[0]);
num = shopData.GetShopPackBuyCount(packM.ID);
SetTimer();
SetRewardItems();
SetBuy();
}
void OnBuySuccess()
{
num += 1;
shopData.AddShopPackDailyBuyCount("DailyGiftDisplay");
shopData.AddShopPackDailyBuyCount(packM.ID, 1);
GContext.Publish(new ShowData(itemDataGift));
GContext.container.Resolve<PlayerItemData>().AddItem(itemDataGift);
//ShowGiftNoticePanel();
GContext.Publish(new ShowData());
SetBuy();
shopData.SetAdvRedPoint();
#if AGG
using (var e = GEvent.GameEvent("item_change", gaSend: false))
{
e.AddContent("item_id", GContext.container.Resolve<PlayerData>().priceLevel.DailyGiftDisplay)
.AddContent("state_info", "get")
.AddContent("get_times", shopData.GetShopPackBuyCount("DailyGiftDisplay"))
.AddContent("change_num", 1);
}
#endif
}
void SetTimer()
{
DateTime now = ZZTimeHelper.UtcNow().UtcNowOffset();
daily = packM.TimeDefinition as Daily;
var DailyGiftPackList = GContext.container.Resolve<PlayerData>().priceLevel.DailyGiftPackList;
int id;
for (int i = 0; i < DailyGiftPackList.Count; i++)
{
id = DailyGiftPackList[i];
ShopPackManager localPackM = shopData.TbPackManagerGetOrDefault(id);
if (localPackM == null) break;
daily = localPackM.TimeDefinition as Daily;
if (TimeSpan.FromSeconds(daily.StartTime) <= now.TimeOfDay && TimeSpan.FromSeconds(daily.EndTime) > now.TimeOfDay)
{
packM = localPackM;
num = shopData.GetShopPackBuyCount(localPackM.ID);
break;
}
}
TimeSpan ts = TimeSpan.FromSeconds(daily.EndTime) - now.TimeOfDay;
text_time.text = ConvertTools.ConvertTime2(0, ts.Hours, ts.Minutes, ts.Seconds);
if (timer == null)
{
timer = this.AttachTimer((float)ts.TotalSeconds, ReStart,
(elapsed) =>
{
now = ZZTimeHelper.UtcNow().UtcNowOffset();
ts = TimeSpan.FromSeconds(daily.EndTime) - now.TimeOfDay;
text_time.text = ConvertTools.ConvertTime2(0, ts.Hours, ts.Minutes, ts.Seconds);
}, useRealTime: true);
}
}
//void ShowGiftNoticePanel()
//{
// int showGiftNoticePanel = PlayerPrefs.GetInt("GiftNoticePanel", 0);
// ISettingService settingService = GContext.container.Resolve<ISettingService>();
// if (showGiftNoticePanel == 0 && !settingService.Notice)
// {
// _ = UIManager.Instance.ShowUI(UITypes.GiftNoticePanel);
// }
//}
void SetRewardItems()
{
itemDataGift = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(pack.DropID);
for (int i = 0; i < rewardItems.Length; i++)
{
if (i < itemDataGift.Count)
{
rewardItems[i].SetData(itemDataGift[i], isCanClick: true);
}
else
{
rewardItems[i].gameObject.SetActive(false);
}
}
}
void SetBuy()
{
var adConfig = _tables.TbAdConfig.DataList[0];
bool vipFree = adConfig.VipFree <= GContext.container.Resolve<PlayerData>().vip;
if (vipFree)
{
btn_buy.gameObject.SetActive(num <= 1);
btn_advert.gameObject.SetActive(false);
}
else
{
btn_buy.gameObject.SetActive(num == 0);
btn_advert.gameObject.SetActive(num == 1);
}
cd.gameObject.SetActive(num > 1);
}
void ReStart()
{
timer.Cancel();
timer = null;
shopData.InitShopPackData();
num = 0;
SetBuy();
SetTimer();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bb198a31a0972a74ca90d5e4fe01268c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AdvertShopSlot : MonoBehaviour
{
Button btn_buy;
Image bg;
TMP_Text text_num;
TMP_Text text_price;
Button btn_showItem;
ShopToken shopToken;
IAPItemList iAPItemList;
private void Awake()
{
btn_buy = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
btn_showItem = transform.Find("position/reward").GetComponent<Button>();
bg = transform.Find("position/bg").GetComponent<Image>();
text_num = transform.Find("position/text_num").GetComponent<TMP_Text>();
text_price = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
btn_buy.onClick.AddListener(OnBuy);
btn_showItem.onClick.AddListener(OnShowItemInfo);
}
public void SetData(cfg.ShopToken shopToken)
{
this.shopToken = shopToken;
text_num.text = shopToken.Number.ToString();
iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(shopToken.IAPID);
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
GContext.Publish(sKUDetailDataEvent);
text_price.text = sKUDetailDataEvent.price;
}
async void OnBuy()
{
List<ItemData> itemData = new List<ItemData>
{
new ItemData { count = shopToken.Number, id = shopToken.TokenID }
};
btn_buy.enabled = false;
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
shopBuyTypeData.type = ShopBuyType.ShopToken;
shopBuyTypeData.ID = shopToken.ID;
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(shopToken.TokenID,shopBuyTypeData, iAPItemList, itemData);
btn_buy.enabled = true;
}
void OnShowItemInfo()
{
GContext.container.Resolve<PlayerItemData>().ShowItemTips(1006, btn_showItem.transform);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be486304b4d024e489d25b09e2fdbf81
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using asap.core;
using cfg;
using System.Linq;
using UnityEngine;
public class AdvertTicketPanel : MonoBehaviour
{
AdvertShopSlot[] advertShopSlot;
private void Awake()
{
advertShopSlot = GetComponentsInChildren<AdvertShopSlot>();
}
private void Start()
{
var shopTokens = GContext.container.Resolve<Tables>().TbShopToken.DataList;
var advertShopTokens = shopTokens.Where(x => x.Type == 6).ToArray();
for (int i = 0; i < advertShopTokens.Length; i++)
{
if (i == advertShopSlot.Length)
{
break;
}
advertShopSlot[i].SetData(advertShopTokens[i]);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 05f35e8c7c8bd7842b75ddb0ffaf32a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: