先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
263 lines
8.6 KiB
C#
263 lines
8.6 KiB
C#
using asap.core;
|
|
using DG.Tweening;
|
|
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();
|
|
public GameObject btn_mask;
|
|
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()
|
|
{
|
|
PlayVipUnlock();
|
|
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);
|
|
}
|
|
async void PlayVipUnlock()
|
|
{
|
|
btn_mask.SetActive(true);
|
|
_dataProvider.UILockVip = true;
|
|
float time = 1f - sr_bars.verticalNormalizedPosition;
|
|
sr_bars.DOVerticalNormalizedPos(1f, time).SetEase(Ease.OutCubic);
|
|
await new WaitForSeconds(time);
|
|
var items = sr_bars.Init<BPRewardBar, int>(pfb_bar.rectTransform.rect.height, pfb_bar.gameObject, null, rewardBarDatas);
|
|
int index = -1;
|
|
int allitems = items.Count;
|
|
time = 0.2f;
|
|
//items[0].OnUnlockBpVip();
|
|
//await new WaitForSeconds(time * 2);
|
|
int all = rewardBarDatas.Count;
|
|
float totalTime = all * time;
|
|
sr_bars.DOVerticalNormalizedPos(0, totalTime)
|
|
.SetEase(Ease.InOutCubic)
|
|
.OnUpdate(() =>
|
|
{
|
|
int curIndex = Mathf.FloorToInt((1 - sr_bars.verticalNormalizedPosition) * all);
|
|
if (curIndex > index && curIndex < all)
|
|
{
|
|
index = curIndex;
|
|
items[index % allitems].OnUnlockBpVip();
|
|
Debug.Log("PlayVipUnlock " + all + " " + index + " " + curIndex);
|
|
}
|
|
});
|
|
await new WaitForSeconds(totalTime);
|
|
_dataProvider.UILockVip = false;
|
|
sr_bars.DOVerticalNormalizedPos(1f, 1).SetEase(Ease.OutCubic);
|
|
await new WaitForSeconds(1);
|
|
btn_mask.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)
|
|
{
|
|
int dropID = 0;
|
|
ChangeSource changeSource = new ChangeSource(_dataProvider.Data.BattlePassRecord.ID, "BattlePass", "BattlePass_Normal28Day", "FreeLevelReward");
|
|
if (data.NormalLevel > 0)
|
|
{
|
|
dropID = _dataProvider.GetSlotDropID(data.NormalLevel, true);
|
|
_dataProvider.SetLevelRewardGet(data.NormalLevel, true);
|
|
}
|
|
if (data.VipLevel > 0)
|
|
{
|
|
changeSource.Source_Module = "PrimeLevelReward";
|
|
dropID = _dataProvider.GetSlotDropID(data.VipLevel, false);
|
|
_dataProvider.SetLevelRewardGet(data.VipLevel, false);
|
|
}
|
|
|
|
var itemDatas = _playerItemData.AddItemByDropLureInflation(null, dropID, changeSource);
|
|
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", dropID);
|
|
if (itemDatas != null && itemDatas.Count > 0)
|
|
{
|
|
int reward_hook = 0;
|
|
int hook_origin = 0;
|
|
int reward_cash = 0;
|
|
for (int i = 0; i < itemDatas.Count; i++)
|
|
{
|
|
if (itemDatas[i].id == 1001)
|
|
{
|
|
reward_hook += itemDatas[i].count;
|
|
hook_origin += itemDatas[i].origin;
|
|
}
|
|
else if (itemDatas[i].id == 1002)
|
|
{
|
|
reward_cash += itemDatas[i].count;
|
|
}
|
|
}
|
|
e.AddContent("reward_hook", reward_hook)
|
|
.AddContent("hook_origin", hook_origin)
|
|
.AddContent("reward_cash", reward_cash);
|
|
}
|
|
}
|
|
#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();
|
|
}
|
|
|
|
}
|