备份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,169 @@
using asap.core;
using DG.Tweening;
using GameCore;
using System;
using System.Threading;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class BPBanner : MonoBehaviour
{
#region Banner
[SerializeField]
TMP_Text txt_exp, txt_level;
[SerializeField]
Image img_expBar;
[SerializeField]
Animation anim_levelCoin;
[SerializeField]
RewardItemNew _tokenItem;
#endregion
BattlePassDataProvider _dataProvider;
public async void RefreshLevelBanner()
{
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
_tokenItem.SetData(new ItemData { id = _dataProvider.curPassMain.ExpItem, count = 0 });
_tokenItem.transform.Find("text_num").gameObject.SetActive(false);
var nextLevel = _dataProvider.GetBPNextLevel;
var maxLevel = _dataProvider.BPMaxLevel;
txt_level.text = nextLevel.ToString();
var curExp = _dataProvider.GetBPCurExp();
var levelUpExp = _dataProvider.GetTotalExpFromLevelRange(nextLevel - 1, nextLevel);
//满级了
if (_dataProvider.GetBPCurLevel == maxLevel)
{
txt_exp.text = LocalizationMgr.GetText("UI_FishingRodPanel_Advanced_18");
img_expBar.fillAmount = 1;
return;
}
txt_exp.text = $"{curExp}/{levelUpExp}";
img_expBar.fillAmount = (float)curExp / (float)levelUpExp;
if (_dataProvider.CheckIfPopBuyVipPanel())
{
await UIManager.Instance.ShowUI(UITypes.BattlePassBuyNoticePopupPanel);
_dataProvider.UpdateVipToastLevel();
}
}
public async void ResAnimation(CancellationToken token, float _fillTime, float _levelUpWaitTime)
{
var curNextLevel = int.Parse(txt_level.text);
var newNextLevel = _dataProvider.GetBPNextLevel;
var maxLevel = _dataProvider.BPMaxLevel;
if (curNextLevel == maxLevel)
{
return;
}
try
{
do
{
var levelUpExp = _dataProvider.GetTotalExpFromLevelRange(curNextLevel - 1, curNextLevel);
var addation = 0;
if (_dataProvider.GetBPCurLevel == maxLevel)
{
addation = 1;
}
var curExp = (addation + img_expBar.fillAmount) * levelUpExp + addation;
if (curNextLevel < newNextLevel)
{
img_expBar.DOFillAmount(1f, _fillTime).OnUpdate(
() =>
{
var curExp = img_expBar.fillAmount * levelUpExp;
txt_exp.text = $"{(int)curExp}/{levelUpExp}";
}
).OnComplete(() => anim_levelCoin.Play()).SetId("BPFill1");
await Task.Delay((int)((_fillTime + _levelUpWaitTime) * 1000), token);
if (this == null)
{
return;
}
curNextLevel++;
txt_level.text = (curNextLevel).ToString();
img_expBar.fillAmount = 0f;
curExp = 0;
levelUpExp = _dataProvider.GetTotalExpFromLevelRange(curNextLevel - 1, curNextLevel);
txt_exp.text = $"{(int)curExp}/{levelUpExp}";
}
else
{
var targetExp = _dataProvider.Data.BattlePassRecord.Exp;
//满级了
if (_dataProvider.GetBPCurLevel == maxLevel)
{
levelUpExp = _dataProvider.GetTotalExpFromLevelRange(_dataProvider.BPMaxLevel - 1, _dataProvider.BPMaxLevel);
targetExp += levelUpExp;
}
var curRate = 0f;
var txts = txt_exp.text.Split('/');
var curFillAmount = (float)int.Parse(txts[0]) / (float)int.Parse(txts[1]);
DOTween.To(
() => curFillAmount,
(value) => curRate = value,
(float)targetExp / (float)levelUpExp,
_fillTime
).OnUpdate(
() =>
{
img_expBar.fillAmount = curRate;
var curExp = curRate * levelUpExp;
txt_exp.text = $"{(int)curExp}/{levelUpExp}";
}
);
await Task.Delay((int)(_fillTime * 1000), token);
if (this == null)
{
return;
}
break;
}
} while (curNextLevel <= newNextLevel && curNextLevel <= maxLevel);
}
catch (OperationCanceledException)
{
DOTween.Kill("BPFill1");
DOTween.Kill("BPFill2");
return;
}
finally
{
}
txt_level.text = $"{newNextLevel}";
if (_dataProvider.GetBPCurLevel == maxLevel)
{
txt_exp.text = LocalizationMgr.GetText("UI_FishingRodPanel_Advanced_18");
return;
}
txt_exp.text = $"{(int)(_dataProvider.Data.BattlePassRecord.Exp + (_dataProvider.GetBPCurLevel == maxLevel ? 1000 : 0))}/{_dataProvider.GetTotalExpFromLevelRange(_dataProvider.GetBPNextLevel - 1, _dataProvider.GetBPNextLevel)}";
// txt_level.text = newLevel.ToString();
if (_dataProvider.CheckIfPopBuyVipPanel())
{
await UIManager.Instance.ShowUI(UITypes.BattlePassBuyNoticePopupPanel);
_dataProvider.UpdateVipToastLevel();
}
}
}

View File

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

View File

@@ -0,0 +1,127 @@
using asap.core;
using GameCore;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class BPItemSlot : MonoBehaviour
{
#region Field
protected RewardItemNew RewardItem;
// protected Image
// img_bg;
protected GameObject
go_claim,
go_levelLock,
go_vipLock,
go_hasGot;
protected Button
btn_click;
protected bool _isNormal;
protected int _level;
protected CompositeDisposable _disposables = new();
protected BattlePassDataProvider _dataProvider;
#endregion
#region Func
private void Init()
{
RewardItem = transform.GetComponentInChildren<RewardItemNew>();
go_claim = transform.Find("position/claim").gameObject;
go_vipLock = transform.Find("position/lock")?.gameObject;
go_levelLock = transform.Find("position/unlock")?.gameObject;
go_hasGot = transform.Find("position/reward/received").gameObject;
// img_bg = RewardItem.transform.Find("bg").GetComponent<Image>();
btn_click = go_claim?.GetComponent<Button>();
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
}
protected virtual void Start()
{
}
public void SetData(bool isNomal, BPRewardSlot.ESlotState state, ItemData itemData)
{
Init();
if (itemData == null)
{
gameObject.SetActive(false);
return;
}
gameObject.SetActive(true);
_level = -1;
_isNormal = isNomal;
// GContext.container.Resolve<IUIService>().SetImageSprite(img_bg, isNomal ? "bg_shop_gift_hook" : "bg_batttlepass_reward");
RewardItem.SetData(itemData, abbr: true);
ChangeState(state);
}
public void SetData(bool isNomal, int level)
{
Init();
_level = level;
_isNormal = isNomal;
var itemData = _dataProvider.GetSlotDropItem(level, isNomal);
// GContext.container.Resolve<IUIService>().SetImageSprite(img_bg, isNomal ? "bg_shop_gift_hook" : "bg_batttlepass_reward");
RewardItem.SetData(itemData, abbr: true);
RefreshSlot();
}
public void RefreshSlot()
{
if (_level != -1)
ChangeState(GContext.container.Resolve<BattlePassDataProvider>().GetSlotState(_level, _isNormal));
else
ChangeState(BPRewardSlot.ESlotState.Normal);
}
public void SetInactive()
{
gameObject.SetActive(false);
}
public virtual void ChangeState(BPRewardSlot.ESlotState state)
{
go_claim.SetActive(false);
go_levelLock?.SetActive(state == BPRewardSlot.ESlotState.LevelLock);
go_hasGot?.SetActive(state == BPRewardSlot.ESlotState.HasGotReward);
switch (state)
{
case BPRewardSlot.ESlotState.CanGetReward:
if (!_isNormal && !_dataProvider.IsUnlockVip)
break;
if (btn_click)
btn_click.enabled = true;
go_claim.SetActive(true);
break;
default:
break;
}
go_vipLock?.SetActive(!_isNormal && !_dataProvider.IsUnlockVip);
}
private void OnDestroy()
{
_disposables?.Dispose();
}
#endregion
}

View File

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

View File

@@ -0,0 +1,95 @@
using asap.core;
using GameCore;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class BPRewardBar : PanelItemBase<int>
{
#region Field
private BPRewardSlot NormalSlot;
private BPRewardSlot VipSlot;
private GameObject
go_claim,
go_unlock,
go_normal;
private TMP_Text
txt_level;
Transform
btn_buyLevel;
Transform btn_buygrade;
BattlePassDataProvider
_dataProvider;
#endregion
bool isShowBuy;
#region Func
private void Awake()
{
txt_level = transform.Find("grade/text_num").GetComponent<TMP_Text>();
NormalSlot = transform.Find("gift1").GetComponent<BPRewardSlot>();
VipSlot = transform.Find("gift2").GetComponent<BPRewardSlot>();
btn_buyLevel = transform.Find("btn_buygrade").GetComponent<Transform>();
btn_buygrade = transform.parent.parent.Find("buygrade").GetComponent<Transform>();
go_claim = transform.Find("grade/position/claim").gameObject;
go_unlock = transform.Find("grade/position/unlock").gameObject;
go_normal = transform.Find("grade/position/bg").gameObject;
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
GContext.OnEvent<BpGetExp>().Subscribe(x =>
{
ChangeState();
}).AddTo(this);
}
public override void OnInit()
{
gameObject.SetActive(true);
txt_level.text = data.ToString();
ChangeState();
NormalSlot.SetData(true, data);
VipSlot.SetData(false, data);
}
private void ChangeState()
{
go_claim.SetActive(false);
go_normal.SetActive(false);
go_unlock.SetActive(false);
if (isShowBuy)
{
btn_buygrade?.gameObject.SetActive(false);
}
isShowBuy = data == _dataProvider.GetBPCurLevel && data != _dataProvider.BPMaxLevel;
if (data == _dataProvider.GetBPCurLevel)
{
go_claim.SetActive(true);
}
else if (data > _dataProvider.GetBPCurLevel)
{
go_unlock.SetActive(true);
}
else
{
go_normal.SetActive(true);
}
}
private void LateUpdate()
{
if (isShowBuy)
{
btn_buygrade?.gameObject.SetActive(true);
btn_buygrade.position = btn_buyLevel.position;
}
}
#endregion
}

View File

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

View File

@@ -0,0 +1,98 @@
using asap.core;
using System;
using System.Threading.Tasks;
using UniRx;
using UnityEngine;
public class BPRewardSlot : BPItemSlot
{
public enum ESlotState
{
LevelLock,
Normal,
CanGetReward,
HasGotReward
}
#region Field
[SerializeField]
private GameObject
go_light;
#endregion
#region Func
protected override void Start()
{
base.Start();
btn_click?.OnClickAsObservable().Subscribe(_ => OnClickSlotToGetReward()).AddTo(_disposables);
GContext.OnEvent<GetAllBPRewards>().Subscribe(_ => OnGetAllRewards()).AddTo(_disposables);
GContext.OnEvent<BpGetExp>().Subscribe(_ => OnBuyBpLevel()).AddTo(_disposables);
GContext.OnEvent<BpVipUnlock>().Subscribe(_ => OnUnlockBpVip()).AddTo(_disposables);
}
public void OnBuyBpLevel()
{
RefreshSlot();
}
public void OnGetAllRewards()
{
RefreshSlot();
}
public void OnClickSlotToGetReward()
{
if (btn_click)
btn_click.enabled = false;
var eventData = new GetBattlePassRewardEvent();
if (_isNormal)
eventData.NormalLevels.Add(_level);
else
eventData.VipLevels.Add(_level);
GContext.Publish(eventData);
// await RewardItem.ParticleAttractor();
ChangeState(ESlotState.HasGotReward);
}
public override void ChangeState(ESlotState state)
{
base.ChangeState(state);
go_light.SetActive(false);
switch (state)
{
case ESlotState.CanGetReward:
go_light.SetActive(true);
break;
}
}
private async void OnUnlockBpVip()
{
if (!_isNormal)
{
var particle = transform.Find("position/particle");
go_vipLock?.SetActive(!_dataProvider.IsUnlockVip);
particle.gameObject.SetActive(true);
await new WaitForSeconds(2);
if (this != null)
{
particle.gameObject.SetActive(false);
RefreshSlot();
}
}
}
private void OnDestroy()
{
_disposables?.Dispose();
}
#endregion
}

View File

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

View File

@@ -0,0 +1,279 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TMPro;
using tysdk;
using UnityEngine;
using UnityEngine.UI;
public class BPTaskSlot : MonoBehaviour, IComparable<BPTaskSlot>
{
Button btn_go, btn_finish;
GameObject
go_doneBtn,
go_normalBg,
go_finishBg,
go_doneBg;
// TMP_Text text_task_finish_notice;
TMP_Text
txt_expGet,
txt_progress,
text_task;
// TMP_Text text_task_finish;
Image bar;
RewardItemNew
_tokenReward,
_itemReward;
// Image p_icon_item;
// public Transform icon_done;
List<ItemData> itemDatas = new();
bool _isDailyTask;
public int TaskID;
int requiredCount;
string type;
public int State;
private void Init()
{
btn_go = transform.Find("finish_notice/btn_go/btn_green_c").GetComponent<Button>();
btn_finish = transform.Find("finish_notice/btn_finish/btn_green_c").GetComponent<Button>();
go_doneBtn = transform.Find("finish_notice/done").gameObject;
go_normalBg = transform.Find("finish_notice/bg").gameObject;
go_finishBg = transform.Find("finish_notice/bg_finish").gameObject;
go_doneBg = transform.Find("finish_notice/bg_done").gameObject;
txt_progress = transform.Find("finish_notice/btn_go/text_progress").GetComponent<TMP_Text>();
text_task = transform.Find("finish_notice/text_task").GetComponent<TMP_Text>();
bar = transform.Find("finish_notice/bg_bar/bar").GetComponent<Image>();
_tokenReward = transform.Find("finish_notice/icon_exp").GetComponent<RewardItemNew>();
_itemReward = transform.Find("reward").GetComponent<RewardItemNew>();
btn_finish.onClick.AddListener(OnClickFinish);
btn_go.onClick.AddListener(OnClickGo);
gameObject.SetActive(true);
}
public void Start()
{
//but_go.onClick.AddListener(OnClickGo);
}
public void SetData(int taskID, bool isDailyTask)
{
Init();
this.TaskID = taskID;
var tables = GContext.container.Resolve<Tables>();
var task = tables.TbBattlePassTask.Get(taskID);
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(task.Reward);
_tokenReward.SetData(itemDatas[0]);
_itemReward.SetData(itemDatas[1], isCanClick: true, abbr: true);
_isDailyTask = isDailyTask;
requiredCount = int.Parse(task.Param[0]);
text_task.text = LocalizationMgr.GetFormatTextValue(task.Desc_l10n_key, requiredCount);
type = task.Type.ToString();
RefreshView();
}
public async System.Threading.Tasks.Task ShowReward()
{
await _itemReward.PlayClose();
OnGetReward();
await _itemReward.ParticleAttractor();
}
void RefreshView()
{
var tasks = _isDailyTask ? GContext.container.Resolve<BattlePassDataProvider>().Data.BattleTask.dic_dailyTasks : GContext.container.Resolve<BattlePassDataProvider>().Data.BattleTask.dic_weeklyTasks;
tasks.TryGetValue(TaskID, out var state);
var done = state == -1;
var normal = state < requiredCount && !done;
var finish = state >= requiredCount;
State = finish ? 0 : normal ? 1 : 2;
btn_go.transform.parent.gameObject.SetActive(normal);
btn_finish.transform.parent.gameObject.SetActive(finish);
go_doneBtn.SetActive(done);
go_normalBg.SetActive(normal);
go_finishBg.SetActive(finish);
go_doneBg.SetActive(done);
//Done
if (done)
{
_itemReward.SetReceived(true);
txt_progress.text = requiredCount + "/" + requiredCount;
bar.fillAmount = 1;
}
//Normal
else if (normal)
{
_itemReward.SetReceived(false);
txt_progress.text = state + "/" + requiredCount;
bar.fillAmount = (float)state / requiredCount;
}
//Finish
else if (finish)
{
_itemReward.SetReceived(false);
txt_progress.text = requiredCount + "/" + requiredCount;
bar.fillAmount = 1;
}
}
void OnGetReward()
{
RefreshView();
}
async void OnClickFinish()
{
var task = GContext.container.Resolve<Tables>().TbBattlePassTask.Get(TaskID);
var playerData = GContext.container.Resolve<PlayerItemData>();
var startLevel = GContext.container.Resolve<BattlePassDataProvider>().GetBPCurLevel;
itemDatas = playerData.AddItemByDrop(task.Reward, false);
#if AGG
using (var e = GEvent.GameEvent("bp_task_reward"))
{
e.AddContent("bp_level", startLevel)
.AddContent("task_type", task.Type.ToString())
.AddContent("task_id", task.TaskID)
.AddContent("item_id", itemDatas[1].id)
.AddContent("item_num", itemDatas[1].count)
.AddContent("exp", itemDatas[0].count);
if (itemDatas != null && itemDatas.Count > 0)
{
for (int i = 0; i < itemDatas.Count; i++)
{
if (itemDatas[i].id == 1001)
{
e.AddContent("reward_hook", itemDatas[i].count);
}
else if (itemDatas[i].id == 1002)
{
e.AddContent("reward_cash", itemDatas[i].count);
}
}
}
}
#endif
GContext.container.Resolve<BattlePassDataProvider>().SetTaskDone(TaskID, _isDailyTask);
RefreshView();
_ = _itemReward.ParticleAttractor();
await _tokenReward.ParticleAttractor();
GContext.Publish(new ShowData());
GContext.Publish(new BpGetExp());
}
async void OnClickGo()
{
await Awaiters.NextFrame;
var task = GContext.container.Resolve<Tables>().TbBattlePassTask.Get(TaskID);
switch (task.Type)
{
case ConditionType.ConstructionCount:
OpenConstruction();
return;
case ConditionType.Complete1v1Count:
case ConditionType.ConsumeEnergy:
case ConditionType.OpenFishBoxCount:
GContext.Publish(new RestartShowHomeUIEvent());
break;
case ConditionType.LoginDays:
return;
//case ConditionType.OpenFishBoxCount:
//await UIManager.Instance.ShowUI(UITypes.FishingBoxPanel);
//break;
case ConditionType.ConusumeTicketCount:
await UIManager.Instance.ShowUI(UITypes.FishingTurntablePanel);
break;
case ConditionType.CollectFishCardCount:
case ConditionType.ConsumeDiamondCount:
await UIManager.Instance.ShowUI(UITypes.FishingShopPanel);
GContext.Publish(new LackOfResourceConfirmEvent() { state = 0 });
break;
case ConditionType.CompleteChallengeCount:
//GContext.Publish(new RestartShowHomeUIEvent());
// var FCC = GContext.container.Resolve<FishingChallengeCenter>();
var fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
// int curCount = fishingChallengeManager.number;
// int allCount = fishingChallengeManager.challengeMatchConfig.DailyTimes;
//TODO:LF 结束的状态
var challengeState = fishingChallengeManager.ChallengeState();
if (!fishingChallengeManager.ShouldOpen() && challengeState == 0)
{
var curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
var timer = curTime.AddDays(1).Date - curTime;
ToastPanel.Show( LocalizationMgr.GetFormatTextValue("UI_EventChallangePanel_24", ConvertTools.ConvertTime2(timer)));
return;
}
GContext.Publish(new RestartShowHomeUIEvent());
if (challengeState == 0)
{
//未开始比赛
// await UIManager.Instance.ShowUI(UITypes.EventChallengeFacePopupPanel);
}
else
{
fishingChallengeManager.InChallenge();
return;
}
break;
case ConditionType.UpgradeRodTimes:
await UIManager.Instance.ShowUI(UITypes.FishingRodBagPanel);
break;
default:
GContext.Publish(new RestartShowHomeUIEvent());
break;
}
CloseBPPanel();
}
void CloseBPPanel()
{
UIManager.Instance.DestroyUI(UITypes.BattlePassPanel);
}
async void OpenConstruction()
{
var campData = GContext.container.Resolve<CampDataMM>();
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
bool isCanEnter = await loadResourceService.Loads(campData.AllPrefabs);
if (isCanEnter)
{
//取消自动钓鱼
//ExitAutoFishing();
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
//Building.Enter();
GContext.Publish(new UnloadActToNextAct("BuildAct"));
}
else
{
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct("BuildAct")));
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, () => GContext.Publish(new UnloadActToNextAct("BuildAct")));
}
}
public int CompareTo(BPTaskSlot slot)
{
int result = this.State.CompareTo(slot.State);
if (result == 0)
{
result = this.State.CompareTo(slot.TaskID);
}
return result;
}
}

View File

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

View File

@@ -0,0 +1,139 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using TMPro;
using asap.core;
using cfg;
public class BattlePassActivePopupPanel : BasePanel
{
#region Field
[SerializeField]
private Button
btn_buyNormal,
btn_buySpecial,
btn_close;
[SerializeField]
private TMP_Text
txt_title,
txt_normalValue,
txt_specialValue,
txt_spcialUpLevel,
txt_normalCost,
txt_specialCost;
[SerializeField]
RewardItemNew
rewardItem;
[SerializeField]
Transform
tran_vipBar,
tran_nomralBar;
BattlePassDataProvider _dataProvider;
#endregion
#region Func
private void Awake()
{
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
}
protected override void Start()
{
base.Start();
var dic_iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.DataMap;
var curPassMain = _dataProvider.curPassMain;
// txt_normalValue.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", curPassMain.PrimeValue);
// txt_specialValue.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", curPassMain.DeluxeValue);
// txt_spcialUpLevel.text = LocalizationMgr.GetFormatTextValue("UI_BattlePassPanel_18", _dataProvider.GetUpLevelByExp((int) GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(curPassMain.DeluxeReward).FirstOrDefault(x => x.id == 3003).count));
SKUDetailDataEvent ssde = new SKUDetailDataEvent(dic_iAPItemList[_dataProvider.curPassMain.PrimeIAPID]);
GContext.Publish(ssde);
txt_normalCost.text = ssde.price;
ssde = new SKUDetailDataEvent(dic_iAPItemList[_dataProvider.curPassMain.DeluxeIAPID]);
GContext.Publish(ssde);
txt_specialCost.text = ssde.price;
txt_title.text = LocalizationMgr.GetText("UI_BattlePassPanel_6");
rewardItem.gameObject.SetActive(false);
var dropID = _dataProvider.curPassMain.PrimeReward;
var itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
for (int i = 1; i < itemDatas.Count; i++)
{
Instantiate(rewardItem, tran_nomralBar).SetData(itemDatas[i]);
}
dropID = _dataProvider.curPassMain.DeluxeReward;
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
for (int i = 1; i < itemDatas.Count; i++)
{
Instantiate(rewardItem, tran_vipBar).SetData(itemDatas[i]);
}
btn_close.OnClickAsObservable().Subscribe(_ => Close()).AddTo(disposables);
btn_buyNormal.OnClickAsObservable().Subscribe(_ => OnBuy(0)).AddTo(disposables);
btn_buySpecial.OnClickAsObservable().Subscribe(_ => OnBuy(1)).AddTo(disposables);
}
protected void Close()
{
UIManager.Instance.DestroyUI(UITypes.BattlePassActivePopupPanel);
}
/// <summary>
///
/// </summary>
/// <param name="scope">0:Normal 1:Special</param>
async void OnBuy(int scope)
{
var iAPItemID = scope == 0 ? _dataProvider.curPassMain.PrimeIAPID : scope == 1 ? _dataProvider.curPassMain.DeluxeIAPID : -1;
var iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(iAPItemID);
var dropID = scope == 0 ? _dataProvider.curPassMain.PrimeReward : scope == 1 ? _dataProvider.curPassMain.DeluxeReward : -1;
var itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
var startLevel = _dataProvider.GetBPCurLevel;
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
shopBuyTypeData.type = ShopBuyType.None;
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(dropID, shopBuyTypeData, iAPItemList, itemDatas);
if (Result)
{
#if AGG
using ( var e = GEvent.GameEvent("bp_active") )
{
e.AddContent("bp_level", startLevel)
.AddContent("active_type", scope+1);
}
#endif
OnBuySuccess(scope);
}
}
/*async*/ void OnBuySuccess(int scope)
{
GContext.Publish(new BpVipUnlock());
if (scope == 1)
GContext.Publish(new BpGetExp());
Close();
//await WaitForRewardPanel();
}
private async System.Threading.Tasks.Task WaitForRewardPanel()
{
var count = 0;
var rewardInfo = new RewardPopupData();
while (count++ < 5)
{
GContext.Publish(rewardInfo);
if (rewardInfo.isShow)
{
await rewardInfo.tcs.Task;
break;
}
await new WaitForSeconds(0.2f);
}
}
#endregion
}

View File

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

View File

@@ -0,0 +1,185 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using System.Collections.Generic;
using asap.core;
using TMPro;
using game;
using tysdk;
public class BattlePassBuyGradePopupPanel : BasePanel
{
#region Field
[SerializeField]
private Button
btn_close;
[SerializeField]
Transform
tran_slotParent;
[SerializeField]
Slider
sld_changeLevel;
[SerializeField]
Button
btn_buy,
btn_downLevel,
btn_upLevel;
[SerializeField]
GameObject
go_vipSlot,
go_normalSlot;
[SerializeField]
TMP_Text
txt_targetLevel,
txt_diamondCost,
txt_upLevel;
//Data
List<BPItemSlot> normalSlot = new();
List<BPItemSlot> vipSlot = new();
int curUpLevel;
int maxUpLevel;
int expGet;
int diamondCost;
float levelUpDelta;
BattlePassDataProvider _dataProvider;
#endregion
#region Func
private void Awake()
{
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
}
protected override void Start()
{
base.Start();
ResfreshPanel();
btn_close.OnClickAsObservable().Subscribe(_=>Close()).AddTo(disposables);
btn_downLevel.OnClickAsObservable().Subscribe(_=>OnChangeUpLevel(curUpLevel-1,true)).AddTo(disposables);
btn_upLevel.OnClickAsObservable().Subscribe(_=>OnChangeUpLevel(curUpLevel+1,true)).AddTo(disposables);
sld_changeLevel.OnValueChangedAsObservable().Subscribe(OnSliderMove).AddTo(disposables);
btn_buy.OnClickAsObservable().Subscribe(_=>OnBuy()).AddTo(disposables);
}
protected void Close()
{
UIManager.Instance.DestroyUI(UITypes.BattlePassBuyGradePopupPanel);
}
private void ResfreshPanel()
{
go_normalSlot.gameObject.SetActive(false);
go_vipSlot.gameObject.SetActive(false);
maxUpLevel=_dataProvider.BPMaxLevel-_dataProvider.GetBPCurLevel;
levelUpDelta=(float)1/(float)(maxUpLevel-curUpLevel);
for (int i = 2; i < tran_slotParent.childCount; i++)
{
Destroy(tran_slotParent.GetChild(i).gameObject);
}
for (int i = 0; i < 20; i++)
{
vipSlot.Add( Instantiate(go_vipSlot, tran_slotParent).GetComponent<BPItemSlot>());
}
for (int i = 0; i < 20; i++)
{
normalSlot.Add( Instantiate(go_normalSlot, tran_slotParent).GetComponent<BPItemSlot>());
}
OnChangeUpLevel(_dataProvider.DefaultBuyLevel,true);
}
private void OnChangeUpLevel(int upLevel,bool sliderMove=false)
{
if( upLevel < 1 )
upLevel = 1;
if(upLevel>maxUpLevel)
upLevel = maxUpLevel;
curUpLevel = upLevel;
txt_upLevel.text = LocalizationMgr.GetFormatTextValue("UI_BattlePassPanel_13", curUpLevel);
txt_targetLevel.text = LocalizationMgr.GetFormatTextValue("UI_BattlePassPanel_12", _dataProvider.GetBPCurLevel + curUpLevel);
diamondCost = _dataProvider.GetDiamondCostByUpLevel(upLevel);
var normalItemDatas = _dataProvider.GetRewardsByUpLevel(upLevel,true);
var vipItemDatas = _dataProvider.GetRewardsByUpLevel(upLevel,false);
expGet = diamondCost/_dataProvider.curPassMain.ExpPrice*100;
txt_diamondCost.text = diamondCost.ToString();
if ( sliderMove )
{
sld_changeLevel.value = curUpLevel * levelUpDelta-levelUpDelta/2f;
}
var isVipUnlock = _dataProvider.IsUnlockVip;
for (int i = 0; i<vipSlot.Count; i++)
{
if(i<vipItemDatas.Count)
{
vipSlot[i].SetData(false,BPRewardSlot.ESlotState.Normal,vipItemDatas[i]);
}
else
{
vipSlot[i].SetInactive();
}
}
for ( int i = 0; i < normalSlot.Count; i++ )
{
if ( i < normalItemDatas.Count )
{
normalSlot[i].SetData(true, BPRewardSlot.ESlotState.Normal, normalItemDatas[i]);
}
else
{
normalSlot[i].SetInactive();
}
}
// _dataProvider.DefaultBuyLevel = upLevel;
}
private void OnSliderMove(float value)
{
var upLevel = (int)(value*1000000f)/ (int)(levelUpDelta*1000000f) +1;
if(curUpLevel!=upLevel)
{
OnChangeUpLevel(upLevel);
}
}
private void OnBuy()
{
var curDiamond = GContext.container.Resolve<PlayerData>().diamond;
if ( curDiamond >= diamondCost)
{
GContext.container.Resolve<PlayerData>().AddDiamond(-diamondCost);
#if AGG
using ( var e = GEvent.GameEvent("bp_purchase_level") )
{
e.AddContent("bp_level", _dataProvider.GetBPCurLevel)
.AddContent("purchase_level", curUpLevel)
.AddContent(AFInAppEvents.PRICE, diamondCost);
}
#endif
_dataProvider.SetBPExp(expGet);
GContext.Publish(new BpGetExp());
GContext.Publish(new ResAddEvent(_dataProvider.curPassMain.ExpItem));
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_3"));
Close();
}
else
{
_ = UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_59"));
}
}
#endregion
}

View File

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

View File

@@ -0,0 +1,73 @@
using asap.core;
using GameCore;
using System.Threading.Tasks;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class BattlePassBuyNoticePopupPanel : BasePanel
{
#region Field
[SerializeField]
private Button
btn_activate,
btn_close;
[SerializeField]
private Transform
tran_slotParent;
[SerializeField]
GameObject
go_slot;
[SerializeField]
TMP_Text
txt_info,
txt_title;
BattlePassDataProvider _dataProvider;
#endregion
#region Func
private void Awake()
{
}
protected override async void Start()
{
base.Start();
btn_close.OnClickAsObservable().Subscribe(_=>Close()).AddTo(disposables);
btn_activate.OnClickAsObservable().Subscribe(_=>ActivateBP()).AddTo(disposables);
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
var curLevel = _dataProvider.Data.BattlePassRecord.Level;
txt_title.text = LocalizationMgr.GetFormatTextValue("UI_BattlePassPanel_14", curLevel);
txt_info.text=LocalizationMgr.GetFormatTextValue("UI_BattlePassPanel_15", curLevel);
go_slot.SetActive(false);
var slotDatas = _dataProvider.GetRewardsByLevelRange(1, curLevel, false);
await Task.Yield();
foreach (var data in slotDatas)
{
Instantiate(go_slot, tran_slotParent).GetComponent<BPItemSlot>().SetData(false,BPRewardSlot.ESlotState.Normal,data);
}
}
protected void Close()
{
UIManager.Instance.DestroyUI(UITypes.BattlePassBuyNoticePopupPanel);
}
async void ActivateBP()
{
UIManager.Instance.DestroyUI(UITypes.BattlePassBuyNoticePopupPanel);
await UIManager.Instance.ShowUI(UITypes.BattlePassActivePopupPanel);
}
#endregion
}

View File

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

View File

@@ -0,0 +1,172 @@
using asap.core;
using DG.Tweening;
using GameCore;
using System;
using System.Threading;
using System.Threading.Tasks;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class BattlePassPanel : BasePanel
{
[SerializeField, Range(0f, 2f)]
private float
_fillTime,
_levelUpWaitTime
;
BattlePassDataProvider _dataProvider;
PlayerItemData _playerItemData;
CancellationTokenSource _tokenSource;
[SerializeField, Header("===========")]
Button btn_close;
[SerializeField]
Toggle
tog_battlePass,
tog_task;
[SerializeField]
GameObject
go_taskBtn,
go_battlePassBtn;
[SerializeField]
BattlePassRecordPanel recordPanel;
[SerializeField]
BattleTaskPanel taskPanel;
[SerializeField]
TMP_Text txt_timer;
[SerializeField]
Button btn_activateBattlePass;
[SerializeField]
BPBanner bPBanner, bPBanner_bought;
BPBanner curBanner;
protected override async void Start()
{
base.Start();
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
_playerItemData = GContext.container.Resolve<PlayerItemData>();
GContext.OnEvent<BpVipUnlock>().Subscribe(_ =>
{
RefreshVipBtn();
recordPanel.BpVipUnlock();
}).AddTo(disposables);
btn_close.OnClickAsObservable().Subscribe(x => Close()).AddTo(disposables);
btn_activateBattlePass.OnClickAsObservable().Subscribe(x => OnActivateBP()).AddTo(disposables);
tog_task.onValueChanged.AddListener(x => SwitchPanel(1));
tog_battlePass.onValueChanged.AddListener(x => SwitchPanel(0));
GContext.OnEvent<ResAddEvent>().Subscribe(x => OnResAnimation(x)).AddTo(disposables);
Refresh();
await Awaiters.NextFrame;
SwitchPanel(0);
_dataProvider.CheckIfGetLastBpRewards();
}
private async void OnActivateBP()
{
if (_dataProvider.IsUnlockVip)
return;
btn_activateBattlePass.enabled = false;
await UIManager.Instance.ShowUI(UITypes.BattlePassActivePopupPanel);
btn_activateBattlePass.enabled = true;
bPBanner_bought.RefreshLevelBanner();
}
private void Close()
{
GContext.Publish(new RestartShowHomeUIEvent());
UIManager.Instance.DestroyUI(UITypes.BattlePassPanel);
}
private void SwitchPanel(int type)
{
if (type == 0)
{
tog_task.enabled = true;
tog_battlePass.enabled = false;
go_battlePassBtn.SetActive(true);
go_taskBtn.SetActive(false);
recordPanel.Open();
taskPanel.Close();
}
else if (type == 1)
{
tog_battlePass.enabled = true;
tog_task.enabled = false;
go_battlePassBtn.SetActive(false);
go_taskBtn.SetActive(true);
recordPanel.Close();
taskPanel.Open();
}
}
public void Refresh()
{
RefreshTimer();
RefreshVipBtn();
curBanner.RefreshLevelBanner();
}
private void RefreshTimer()
{
DateTime curTimer = ZZTimeHelper.UtcNow().UtcNowOffset();
DateTime endTime = GContext.container.Resolve<FishingEventData>().GetEventEndTime(_dataProvider.Data.BattlePassRecord.ID);
SetTimer(endTime - curTimer);
}
private void SetTimer(TimeSpan duration)
{
txt_timer.text = ConvertTools.ConvertTime2(duration);
var timer = Observable.Interval(TimeSpan.FromSeconds(1))
.TakeWhile(seconds => seconds <= duration.TotalSeconds)
.Subscribe(seconds =>
txt_timer.text = ConvertTools.ConvertTime2(duration.Subtract(TimeSpan.FromSeconds(seconds)))
, () => Close())
.AddTo(disposables)
;
}
void RefreshVipBtn()
{
bool isVip = _dataProvider.Data.BattlePassRecord.IsUnlockVip != 0;
bPBanner_bought.gameObject.SetActive(isVip);
bPBanner.gameObject.SetActive(!isVip);
if (isVip)
{
curBanner = bPBanner_bought;
}
else
{
curBanner = bPBanner;
}
}
private void OnResAnimation(ResAddEvent addEvent)
{
if (addEvent.Type == 0)
{
cfg.Item item = GContext.container.Resolve<cfg.Tables>().TbItem.GetOrDefault(addEvent.id);
if (item != null)
{
addEvent.Type = item.Type;
addEvent.SubType = item.SubType;
}
}
if (addEvent.Type == 7 && addEvent.SubType == 3)
{
if (_tokenSource != null)
{
_tokenSource.Cancel();
_tokenSource.Dispose();
}
_tokenSource = new CancellationTokenSource();
curBanner.ResAnimation(_tokenSource.Token, _fillTime, _levelUpWaitTime);
}
}
}

View File

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

View File

@@ -0,0 +1,218 @@
using asap.core;
using game;
using GameCore;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class BattlePassRecordPanel : MonoBehaviour
{
[Range(0f, 2f), SerializeField]
private float waveWaitTimer = 1.2f;
[SerializeField]
BPRewardBar pfb_bar;
[SerializeField]
Button btn_buyLevel;
//[SerializeField]
//GameObject buyGO;
[SerializeField]
GameObject
go_cashBox_mask,
go_cashBox;
[SerializeField]
Transform
tran_barParent,
bottom,
mask_content;
[SerializeField]
Button
btn_GetAllReward;
[SerializeField]
PanelScroll
sr_bars;
[SerializeField]
TMP_Text
txt_bpRedeemCount,
txt_cashBox,
text_num_icon_money;
List<int> rewardBarDatas = new();
Dictionary<int, BPRewardBar> dic_bars = new();
BattlePassDataProvider _dataProvider;
PlayerItemData _playerItemData;
CompositeDisposable disposables = new();
private int _curSpeicalIndex;
public void Awake()
{
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
_playerItemData = GContext.container.Resolve<PlayerItemData>();
for (int j = 0; j < _dataProvider.BPMaxLevel; j++)
{
rewardBarDatas.Add(j + 1);
}
}
public void Start()
{
btn_buyLevel?.onClick.AddListener(async () => await UIManager.Instance.ShowUI(UITypes.BattlePassBuyGradePopupPanel));
RefreshView();
GContext.OnEvent<GetBattlePassRewardEvent>().Subscribe(OnGetBPReward).AddTo(disposables);
GContext.OnEvent<BpGetExp>().Subscribe(_ => RefreshGetAllBtn()).AddTo(disposables);
txt_bpRedeemCount.text = "100";
text_num_icon_money.text = (_playerItemData.GetExtraCoinMag(_dataProvider.curPassMain.ExpToCash)).ToString();
btn_GetAllReward.OnClickAsObservable().Subscribe(x => OnGetAllReward()).AddTo(disposables);
}
public async void BpVipUnlock()
{
await new WaitForSeconds(waveWaitTimer);
if (this == null)
return;
var go = sr_bars.transform.Find("particle_jiesuo").gameObject;
go.SetActive(true);
await new WaitForSeconds(2f);
if (this != null)
go.SetActive(false);
}
public void Open()
{
gameObject.SetActive(true);
}
public void Close()
{
gameObject.SetActive(false);
}
public void RefreshView()
{
_dataProvider.CheckIfRefreshBattblePass();
pfb_bar.gameObject.SetActive(false);
dic_bars.Clear();
for (int i = tran_barParent.childCount - 1; i >= 2; i--)
{
Destroy(tran_barParent.GetChild(i).gameObject);
}
var pos = _dataProvider.GetBarsDefaultPos() + 1;
if (_dataProvider.GetBPCurLevel == _dataProvider.BPMaxLevel)
{
sr_bars.Init<BPRewardBar, int>(pfb_bar.rectTransform.rect.height, pfb_bar.gameObject, null, rewardBarDatas, _currentIndex: _dataProvider.BPMaxLevel);
sr_bars.verticalNormalizedPosition = 0f;
// sr_bars.JumpToTarget(_dataProvider.BPMaxLevel,maxLevelOffsetY);
}
else
{
sr_bars.Init<BPRewardBar, int>(pfb_bar.rectTransform.rect.height, pfb_bar.gameObject, null, rewardBarDatas, _currentIndex: _dataProvider.GetBarsDefaultPos() - 1);
if (pos <= 3)
{
sr_bars.verticalNormalizedPosition = 1f;
}
else
{
sr_bars.JumpToTarget(pos);
}
}
RefreshGetAllBtn();
sr_bars.onValueChanged.AddListener(OnValueChanged);
bottom.GetComponent<RectTransform>().sizeDelta = tran_barParent.GetComponent<RectTransform>().sizeDelta;
}
private void RefreshGetAllBtn()
{
txt_cashBox.text = ConvertTools.GetNumberString(_playerItemData.GetExtraCoinMag(_dataProvider.GetCashBoxCount()));
go_cashBox_mask.SetActive(_dataProvider.GetBPCurLevel < _dataProvider.BPMaxLevel);
//btn_buyLevel.transform.parent.gameObject.SetActive(_dataProvider.GetBPCurLevel < _dataProvider.BPMaxLevel);
//go_cashBox_mask.SetActive(_dataProvider.GetCashBoxCount() <= 0);
btn_GetAllReward.transform.parent.gameObject.SetActive(_dataProvider.GetAllToGetRewardCount() >= 1);
bottom.localPosition = new Vector3(0, -_dataProvider.GetBPCurLevel * pfb_bar.rectTransform.rect.height, 0);
}
void OnValueChanged(Vector2 pos)
{
mask_content.position = tran_barParent.position;
}
private void OnGetBPReward(GetBattlePassRewardEvent data)
{
List<int> dropIDs = new List<int>();
for (int i = 0; i < data.NormalLevels.Count; i++)
{
dropIDs.Add(_dataProvider.GetSlotDropID(data.NormalLevels[i], true));
_dataProvider.SetLevelRewardGet(data.NormalLevels[i], true);
}
for (int i = 0; i < data.VipLevels.Count; i++)
{
dropIDs.Add(_dataProvider.GetSlotDropID(data.VipLevels[i], false));
_dataProvider.SetLevelRewardGet(data.VipLevels[i], false);
}
var itemDatas = _playerItemData.AddItemByDropList(dropIDs);
GContext.Publish(new ShowData());
_dataProvider.Data.SaveBattlePassRecord();
#if AGG
using (var e = GEvent.GameEvent("bp_level_reward"))
{
e.AddContent("bp_level", _dataProvider.GetBPCurLevel)
.AddContent("drop_id_list", JsonConvert.SerializeObject(dropIDs));
if (itemDatas != null && itemDatas.Count > 0)
{
for (int i = 0; i < itemDatas.Count; i++)
{
if (itemDatas[i].id == 1001)
{
e.AddContent("reward_hook", itemDatas[i].count);
}
else if (itemDatas[i].id == 1002)
{
e.AddContent("reward_cash", itemDatas[i].count);
}
}
}
}
#endif
RefreshGetAllBtn();
}
private async void OnGetAllReward()
{
_dataProvider.GetAllBpRewards();
RefreshGetAllBtn();
GContext.Publish(new ShowData());
GContext.Publish(new GetAllBPRewards());
await new WaitForSeconds(0.2f);
var rewardPanelTask = new RewardPopupData();
GContext.Publish(rewardPanelTask);
if (rewardPanelTask.tcs != null)
{
await rewardPanelTask.tcs.Task;
}
sr_bars.JumpToTarget(_dataProvider.GetBarsDefaultPos() + 1, pfb_bar.rectTransform.rect.height / 3);
// _dataProvider
}
private void OnDestroy()
{
disposables.Dispose();
}
}

View File

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

View File

@@ -0,0 +1,125 @@
using asap.core;
using System;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UniRx;
using UnityEngine;
public class BattleTaskPanel : BasePanel
{
#region Fields
[SerializeField]
TMP_Text
txt_weeklyTaskTiemr,
txt_dailyTaskTimer;
[SerializeField]
GameObject
go_WTslot,
go_DTslot;
[SerializeField]
Transform
tran_WTbanner,
tran_slotParent;
#endregion
BattlePassDataProvider _dataProviver;
#region Func
private void Awake()
{
_dataProviver = GContext.container.Resolve<BattlePassDataProvider>();
}
protected override void Start()
{
go_DTslot.SetActive(false);
go_WTslot.SetActive(false);
_dataProviver.CheckIfRefreshDailyTask();
_dataProviver.CheckIfRefreshWeekTask();
RefreshView();
}
private void SetDTTimer(TimeSpan duration)
{
txt_dailyTaskTimer.text = ConvertTools.ConvertTime2(duration);
var timer = Observable.Interval(TimeSpan.FromSeconds(1))
.TakeWhile(seconds => seconds <= duration.TotalSeconds)
.Subscribe(seconds =>
txt_dailyTaskTimer.text = ConvertTools.ConvertTime2(duration.Subtract(TimeSpan.FromSeconds(seconds)))
, () => { _dataProviver.Data.RefreshDaiyTask(); RefreshView(); })
.AddTo(disposables)
;
}
private void SetWTTimer(TimeSpan duration)
{
txt_weeklyTaskTiemr.text = ConvertTools.ConvertTime2(duration);
var timer = Observable.Interval(TimeSpan.FromSeconds(1))
.TakeWhile(seconds => seconds <= duration.TotalSeconds)
.Subscribe(seconds =>
txt_weeklyTaskTiemr.text = ConvertTools.ConvertTime2(duration.Subtract(TimeSpan.FromSeconds(seconds)))
, () => { _dataProviver.Data.RefreshWeeklyTask(); RefreshView(); })
.AddTo(disposables)
;
}
private void RefreshView()
{
SetDTTimer(_dataProviver.GetDailyTaskDuration());
SetWTTimer(_dataProviver.GetWeeklyTaskDuration());
var taskSlot = tran_slotParent.GetComponentsInChildren<BPTaskSlot>();
foreach (var slot in taskSlot)
{
if (slot.gameObject != go_DTslot && slot.gameObject != go_WTslot)
{
Destroy(slot.gameObject);
}
}
var dailyTasks = _dataProviver.Data.BattleTask.dic_dailyTasks;
var weeklyTasks = _dataProviver.Data.BattleTask.dic_weeklyTasks;
var slotP = new List<BPTaskSlot>();
foreach (var task in dailyTasks)
{
var slot = Instantiate(go_DTslot, tran_slotParent).GetComponent<BPTaskSlot>();
slot.SetData(task.Key, true);
slotP.Add(slot);
}
slotP.Sort();
foreach (var slot in slotP)
{
slot.transform.SetAsLastSibling();
}
tran_WTbanner.SetAsLastSibling();
slotP.Clear();
foreach (var task in weeklyTasks)
{
var slot = Instantiate(go_WTslot, tran_slotParent).GetComponent<BPTaskSlot>();
slot.SetData(task.Key, false);
slotP.Add(slot);
}
slotP.Sort();
foreach (var slot in slotP)
{
slot.transform.SetAsLastSibling();
}
}
public void Open()
{
gameObject.SetActive(true);
}
public void Close()
{
gameObject.SetActive(false);
}
#endregion
}

View File

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