备份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,77 @@
using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class BenefitUpgrade : MonoBehaviour
{
public Button btnClose;
public ItemData itemData;
public Image icon;
TMP_Text text_name;
TMP_Text text_num_before;
TMP_Text text_num_after;
private void Awake()
{
text_name = transform.Find("bg_info/text_name").GetComponent<TMP_Text>();
btnClose = transform.Find("reward/btn_receive/btn_green").GetComponent<Button>();
icon = transform.Find("icon").GetComponent<Image>();
text_num_before = transform.Find("bg_info/change/text_num_before").GetComponent<TMP_Text>();
text_num_after = transform.Find("bg_info/change/text_num_after").GetComponent<TMP_Text>();
}
private void Start()
{
btnClose.onClick.AddListener(OnClickClose);
}
private void OnEnable()
{
ShowPanel();
}
void ShowPanel()
{
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(itemData.id);
if (item.Type == 12)
{
int level = itemData.count;
var benefits = GContext.container.Resolve<Tables>().TBBenefits.GetOrDefault(item.SubType);
if (level >= benefits.BenefitsValue.Count)
{
level = benefits.BenefitsValue.Count - 1;
}
var curValue = benefits.BenefitsValue[level];
var preValue = benefits.BenefitsValue[level - 1];
if (item.SubType == 3 || item.SubType == 4 || item.SubType == 7)
{
text_num_before.text = preValue.ToString("F0");
text_num_after.text = curValue.ToString("F0");
}
else
{
text_num_before.text = preValue.ToPercentageString();
text_num_after.text = curValue.ToPercentageString();
}
}
else
{
int curCount = (int)GContext.container.Resolve<PlayerItemData>().GetItemCount(itemData.id);
text_num_before.text = $"{curCount - itemData.count}%";
text_num_after.text = $"{curCount}%";
}
if (item != null)
{
text_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
}
else
{
OnClickClose();
}
}
void OnClickClose()
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
}

View File

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

View File

@@ -0,0 +1,68 @@
using asap.core;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventConvertedPopupPanel : MonoBehaviour
{
Button btn_close;
Button btn_confrim;
Button mask;
TMP_Text text_activity;
FishingEventData curFishingEventData;
TransitionData curTransitionData;
RewardItemNew reward1;
RewardItemNew reward2;
ItemData itemData1;
ItemData itemData2;
private void Awake()
{
curFishingEventData = GContext.container.Resolve<FishingEventData>();
if (curFishingEventData.curTransitionData.Count == 0)
{
UIManager.Instance.DestroyUI(UITypes.EventConvertedPopupPanel);
return;
}
foreach (var item in curFishingEventData.curTransitionData)
{
curTransitionData = item.Value;
break;
}
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_confrim = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
mask = transform.Find("mask").GetComponent<Button>();
text_activity = transform.Find("root/text_activity").GetComponent<TMP_Text>();
reward1 = transform.Find("root/reward1").GetComponent<RewardItemNew>();
reward2 = transform.Find("root/reward2").GetComponent<RewardItemNew>();
text_activity.text = LocalizationMgr.GetText(curTransitionData.eventName);
if (curTransitionData.eventID == 0)
{
Close();
}
}
private void Start()
{
btn_close.onClick.AddListener(OnClickClose);
btn_confrim.onClick.AddListener(OnClickClose);
mask.onClick.AddListener(OnClickClose);
itemData1 = new ItemData(curTransitionData.sourceItemID, curTransitionData.sourceCount);
itemData2 = new ItemData(curTransitionData.targetItemID, curTransitionData.targetCount);
reward1.SetData(itemData1);
reward2.SetData(itemData2);
}
async void OnClickClose()
{
btn_close.enabled = false;
btn_confrim.enabled = false;
mask.enabled = false;
GContext.container.Resolve<PlayerItemData>().AddItem(itemData2);
await reward2.ParticleAttractor();
Close();
}
void Close()
{
UIManager.Instance.DestroyUI(UITypes.EventConvertedPopupPanel);
curFishingEventData.ClearTransitionData(curTransitionData);
}
}

View File

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

View File

@@ -0,0 +1,44 @@
using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class FeaturesUnlock : MonoBehaviour
{
public Button btnClose;
public int id;
public Image icon;
TMP_Text text_name;
private void Awake()
{
text_name = transform.Find("bg_info/text_info").GetComponent<TMP_Text>();
btnClose = transform.Find("reward/btn_receive/btn_green").GetComponent<Button>();
icon = transform.Find("icon").GetComponent<Image>();
}
private void Start()
{
btnClose.onClick.AddListener(OnClickClose);
ShowPanel();
}
void ShowPanel()
{
var account = GContext.container.Resolve<Tables>().TBAccount.GetOrDefault(id);
if (account != null)
{
text_name.text = LocalizationMgr.GetText(account.Title_l10n_key);
GContext.container.Resolve<IUIService>().SetImageSprite(icon, account.Img, BasePanel.PanelName);
}
else
{
OnClickClose();
}
}
void OnClickClose()
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using asap.core;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RewardAlbumAllComplete : MonoBehaviour
{
public Transform reward_group;
public Button btnClose;
public TMP_Text text_name;
List<RewardItemNew> items;
public List<ItemData> itemDatas = new List<ItemData>();
private void Awake()
{
reward_group = transform.Find("reward_group");
text_name = transform.Find("album/text_name").GetComponent<TMP_Text>();
btnClose = transform.Find("btn_close").GetComponent<Button>();
}
private void Start()
{
btnClose.onClick.AddListener(OnClickClose);
}
void OnClickClose()
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
public void Show(List<RewardItemNew> rewardItems)
{
items = rewardItems;
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
var theme = GContext.container.Resolve<AlbumData>().theme;
if (theme != null)
{
text_name.text = LocalizationMgr.GetText(theme.Title_l10n_key);
}
int itemCount = items.Count;
for (int i = 0; i < itemCount; i++)
{
items[i].gameObject.SetActive(false);
}
for (int i = 0; i < itemDatas.Count; i++)
{
items[i].transform.SetParent(reward_group);
items[i].SetRewardPopupData(itemDatas[i], false);
items[i].PlayOpen();
}
ShowReward();
}
async void ShowReward()
{
await Awaiters.Seconds(2f);
for (int i = 0; i < itemDatas.Count; i++)
{
await items[i].PlayClose();
await items[i].ParticleAttractor();
}
await Awaiters.Seconds(0.4f);
OnClickClose();
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RewardAlbumComplete : MonoBehaviour
{
public Button btnClose;
public Transform reward_group;
public AlbumAttribute albumAttribute;
List<RewardItemNew> items;
public List<ItemData> itemDatas = new List<ItemData>();
private void Awake()
{
btnClose = transform.Find("btn_close").GetComponent<Button>();
reward_group = transform.Find("reward_group");
albumAttribute = transform.Find("album").GetComponent<AlbumAttribute>();
}
private void Start()
{
btnClose.onClick.AddListener(OnClickClose);
}
void OnClickClose()
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
public void Show(int id, List<RewardItemNew> rewardItems)
{
items = rewardItems;
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
Album album = GContext.container.Resolve<Tables>().TbAlbum.GetOrDefault(id);
if (album != null)
{
albumAttribute.Init(album);
}
int itemCount = items.Count;
for (int i = 0; i < itemCount; i++)
{
items[i].gameObject.SetActive(false);
}
for (int i = 0; i < itemDatas.Count; i++)
{
items[i].transform.SetParent(reward_group);
items[i].SetRewardPopupData(itemDatas[i], false);
items[i].PlayOpen();
}
ShowReward();
}
async void ShowReward()
{
await Awaiters.Seconds(2f);
for (int i = 0; i < itemDatas.Count; i++)
{
await items[i].PlayClose();
await items[i].ParticleAttractor();
}
await Awaiters.Seconds(0.4f);
OnClickClose();
}
}

View File

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

View File

@@ -0,0 +1,422 @@
using asap.core;
using cfg;
using DG.Tweening;
using game;
using GameCore;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RewardBox : RewardPopupBase
{
[Range(0f, 3.5f)]
public float CannotClickTimer;
Tables _tables;
public Animation anim;
public Animation[] boxGo;
public Button btn_click;
public Button btn_close;
public Button btn_next;
public Button btn_all;
public FishCardUI[] fishCardAttributes;
public Animation[] gameObjects;
List<ItemData> itemDataCards = new List<ItemData>();
public List<DropFishCardData> itemDataGifts = new List<DropFishCardData>();
GameObject reward_layout;
List<Transform> trans = new List<Transform>();
[SerializeField]
private Transform tran_rewardParent;
[SerializeField]
private GameObject go_row;
[SerializeField] private PanelScroll ps;
public float RewardPopSpeed = 0.075f;
private List<GameObject> rows = new();
public bool IsShow;
int childCount;
int Quality;
private void Awake()
{
anim = GetComponent<Animation>();
btn_click = GetComponent<Button>();
btn_close = transform.Find("reward/btn_receive/btn_green").GetComponent<Button>();
btn_next = transform.Find("reward/btn_next/btn_green").GetComponent<Button>();
btn_all = transform.Find("reward/btn_open_all/btn_green").GetComponent<Button>();
boxGo = new Animation[5];
for (int i = 0; i < 5; i++)
{
boxGo[i] = transform.Find($"icon_box/icon_box_{i + 1}").GetComponent<Animation>();
}
fishCardAttributes = new FishCardUI[2];
fishCardAttributes[0] = transform.Find("card").GetComponent<FishCardUI>();
fishCardAttributes[1] = transform.Find("cardNext").GetComponent<FishCardUI>();
gameObjects = new Animation[2];
gameObjects[0] = transform.Find("card").GetComponent<Animation>();
gameObjects[1] = transform.Find("cardNext").GetComponent<Animation>();
Transform tran;
reward_layout = transform.Find("reward_layout").gameObject;
for (int i = 1; i < 4; i++)
{
for (int j = 1; j < 4; j++)
{
tran = transform.Find($"reward_layout/reward_group{i}/reward{j}");
trans.Add(tran);
}
}
_tables = GContext.container.Resolve<Tables>();
go_row.SetActive(false);
childCount = go_row.transform.childCount;
}
private void Start()
{
receive.SetActive(true);
GContext.Publish(new VibrationData(HapticTypes.Success));
btn_close.onClick.AddListener(OnClickClose);
btn_all.onClick.AddListener(ShowAll);
btn_next.onClick.AddListener(OnClickClose);
}
void OnClickClose()
{
if (itemDataGifts.Count > 0)
{
gameObject.SetActive(false);
Show();
}
else
{
OnClose();
}
}
//双击跳过
void DoubleClickSkip()
{
OnClickSkip();
}
void OnClickSkip()
{
StopAllCoroutines();
anim.Play("RewardPopupPanel_reward_box_end");
StartCoroutine(SetShowPicture());
btn_click.onClick.RemoveAllListeners();
gameObjects[0].gameObject.SetActive(false);
gameObjects[1].gameObject.SetActive(false);
}
IEnumerator SetShowPicture()
{
reward_layout.SetActive(true);
FishCardUI pictureAttribute;
GameObject go;
int allCount = 0;
List<GameObject> cards = new List<GameObject>();
foreach (var itemData in itemDataCards)
{
Item item = _tables.TbItem[itemData.id];
var fishCard = _tables.TbFishCard.GetOrDefault(item.RedirectID);
var picture = _tables.TbFishData[fishCard.FishID];
if (picture != null)
{
int addCount = Mathf.RoundToInt(itemData.count);
go = trans[allCount].gameObject;
go.SetActive(true);
pictureAttribute = go.transform.Find("card").GetComponent<FishCardUI>();
pictureAttribute.data = picture;
pictureAttribute.curShowNum = (int)itemData.curCount + addCount;
pictureAttribute.Init();
pictureAttribute.SetNum(addCount);
pictureAttribute.transfer.gameObject.SetActive(false);
pictureAttribute.gameObject.SetActive(false);
if (itemData.exchangeItemData != null)
{
ExchangeItemData exchangeItemData = itemData.exchangeItemData;
if (exchangeItemData.exchangeCount > 0)
{
pictureAttribute.transfer.SetData(exchangeItemData.exchangeId, $"x{exchangeItemData.exchangeCount}");
pictureAttribute.transfer.gameObject.SetActive(true);
var flyItem = _tables.TbItem.GetOrDefault(exchangeItemData.exchangeId);
var showCount = exchangeItemData.exchangeCount;
ResAddEvent resAddEvent = new ResAddEvent(flyItem.ID, flyItem.Type, flyItem.SubType);
resAddEvent.addCount = showCount;
GContext.Publish(resAddEvent);
}
}
cards.Add(pictureAttribute.gameObject);
allCount++;
if (allCount >= trans.Count)
{
break;
}
}
}
for (int i = 0; i < cards.Count; i++)
{
cards[i].SetActive(true);
yield return new WaitForSeconds(RewardPopSpeed);
}
AutoClose();
}
void ShowAll()
{
StopAllCoroutines();
gameObject.SetActive(false);
for (int i = 0; i < boxGo.Length; i++)
{
boxGo[i].gameObject.SetActive(false);
}
for (int i = 0; i < trans.Count; i++)
{
trans[i].gameObject.SetActive(false);
}
reward_layout.SetActive(false);
btn_click.onClick.RemoveAllListeners();
btn_click.onClick.AddListener(OnClick);
gameObjects[0].gameObject.SetActive(false);
gameObjects[1].gameObject.SetActive(false);
List<ItemData> dropItems = new List<ItemData>();
for (int i = 0; itemDataGifts.Count > 0; i++)
{
DropFishCardData dropFishCardData = itemDataGifts[0];
itemDataCards = dropFishCardData.FishCardItemList;
dropItems.AddRange(itemDataCards);
itemDataGifts.Remove(dropFishCardData);
}
receive.SetActive(true);
gameObject.SetActive(true);
ps.gameObject.SetActive(true);
StartCoroutine(InitAsync(dropItems));
btn_close.gameObject.SetActive(false);
btn_next.gameObject.SetActive(false);
btn_all.gameObject.SetActive(false);
anim.Play("RewardPopupPanel_reward_box_end");
}
public ItemData exchangeItemData;
public void Show()
{
receive.SetActive(true);
gameObject.SetActive(true);
ps.gameObject.SetActive(false);
gameObjects[0].gameObject.SetActive(false);
gameObjects[1].gameObject.SetActive(false);
for (int i = 0; i < trans.Count; i++)
{
trans[i].gameObject.SetActive(false);
}
btn_click.onClick.RemoveAllListeners();
DropFishCardData dropFishCardData = itemDataGifts[0];
itemDataCards = dropFishCardData.FishCardItemList;
itemDataGifts.Remove(dropFishCardData);
if (exchangeItemData == null && dropFishCardData.exchangeItemData != null)
{
exchangeItemData = dropFishCardData.exchangeItemData;
InitResource(new List<ItemData>() { exchangeItemData });
}
Show(dropFishCardData.ItemID);
StartCoroutine(ShowItem());
btn_close.gameObject.SetActive(itemDataGifts.Count == 0);
btn_next.gameObject.SetActive(itemDataGifts.Count > 0);
btn_all.gameObject.SetActive(itemDataGifts.Count > 1);
}
public void Show(int id)
{
for (int i = 0; i < boxGo.Length; i++)
{
boxGo[i].gameObject.SetActive(false);
}
Quality = 0;
Item item = _tables.TbItem.GetOrDefault(id);
if (item != null)
{
Quality = item.Quality - 1;
if (Quality > 4)
{
Quality = 4;
}
}
GameObject box = boxGo[Quality].gameObject;
Image logo = box.transform.Find("box/logo").GetComponent<Image>();
Image num = box.transform.Find("box/num").GetComponent<Image>();
IUIService uiService = GContext.container.Resolve<IUIService>();
List<string> BgNameList;
if (item.SubType == 1)
{
var fishCard = GContext.container.Resolve<Tables>().TbFishCardDrop.GetOrDefault(item.RedirectID);
BgNameList = fishCard.BgNameList;
}
else
{
var fishCard = GContext.container.Resolve<Tables>().TbGeneralCardWeight.GetOrDefault(item.RedirectID);
BgNameList = fishCard.BgNameList;
}
uiService.SetImageSprite(logo, BgNameList[1], BasePanel.PanelName);
uiService.SetImageSprite(num, BgNameList[2], BasePanel.PanelName);
box.gameObject.SetActive(true);
boxGo[Quality].Play("box_open");
boxGo[Quality].Sample();
}
IEnumerator ShowItem()
{
yield return new WaitForSeconds(CannotClickTimer);
btn_click.onClick.AddListener(DoubleClickSkip);
yield return new WaitForSeconds(3.5f - CannotClickTimer);
int curIndex = 0;
FishCardUI pictureAttribute;
foreach (var itemData in itemDataCards)
{
Item item = _tables.TbItem[itemData.id];
var fishCard = _tables.TbFishCard.GetOrDefault(item.RedirectID);
var picture = _tables.TbFishData[fishCard.FishID];
if (picture != null)
{
int addCount = Mathf.RoundToInt(itemData.count);
gameObjects[curIndex].gameObject.SetActive(true);
gameObjects[curIndex].Play("card_show");
pictureAttribute = fishCardAttributes[curIndex];
pictureAttribute.curShowNum = (int)itemData.curCount + addCount;
pictureAttribute.data = picture;
pictureAttribute.Init();
pictureAttribute.SetNum(addCount);
curIndex++;
if (curIndex >= fishCardAttributes.Length)
{
curIndex = 0;
}
yield return new WaitForSeconds(0.7f);
}
}
yield return new WaitForSeconds(0.2f);
OnClickSkip();
}
IEnumerator AutoCloseCoroutine()
{
yield return new WaitForSeconds(3f);
if (isAutoClose)
{
if (itemDataGifts.Count > 1)
{
ShowAll();
}
else if (itemDataGifts.Count > 0)
{
gameObject.SetActive(false);
Show();
}
else
{
OnClose();
}
}
}
public IEnumerator InitAsync(List<ItemData> dropItems)
{
clickCount = 0;
jump = false;
IsShow = true;
GameObject curParent;
btn_close.gameObject.SetActive(false);
for (int i = 0; i < dropItems.Count; i += childCount)
{
curParent = Instantiate(go_row, tran_rewardParent);
curParent.SetActive(true);
rows.Add(curParent.gameObject);
var count = dropItems.Count - i;
for (int j = 0; j < childCount; j++)
{
curParent.transform.GetChild(j).gameObject.SetActive(j < count);
curParent.transform.GetChild(j).GetChild(0).gameObject.SetActive(false);
}
yield return Awaiters.NextFrame;
ps.DONormalizedPos(Vector2.zero, RewardPopSpeed);
for (int j = 0; j < childCount; j++)
{
if (j < count)
{
var itemData = dropItems[i + j];
Item item = _tables.TbItem[itemData.id];
curParent.transform.GetChild(j).gameObject.SetActive(true);
var pictureAttribute = curParent.transform.GetChild(j).GetChild(0).GetComponent<FishCardUI>();
var fishCard = _tables.TbFishCard.GetOrDefault(item.RedirectID);
var picture = _tables.TbFishData[fishCard.FishID];
if (picture != null)
{
int addCount = Mathf.RoundToInt(itemData.count);
pictureAttribute.gameObject.SetActive(true);
pictureAttribute.data = picture;
pictureAttribute.curShowNum = (int)itemData.curCount + addCount;
pictureAttribute.Init();
pictureAttribute.SetNum(addCount);
pictureAttribute.transfer.gameObject.SetActive(false);
if (itemData.exchangeItemData != null)
{
ExchangeItemData exchangeItemData = itemData.exchangeItemData;
if (exchangeItemData.exchangeCount > 0)
{
pictureAttribute.transfer.SetData(exchangeItemData.exchangeId, $"x{exchangeItemData.exchangeCount}");
pictureAttribute.transfer.gameObject.SetActive(true);
var flyItem = _tables.TbItem.GetOrDefault(exchangeItemData.exchangeId);
var showCount = exchangeItemData.exchangeCount;
ResAddEvent resAddEvent = new ResAddEvent(flyItem.ID, flyItem.Type, flyItem.SubType);
resAddEvent.addCount = showCount;
GContext.Publish(resAddEvent);
}
}
}
if (jump)
{
}
else
{
yield return new WaitForSeconds(RewardPopSpeed);
}
}
}
}
yield return Awaiters.NextFrame;
ps.DONormalizedPos(Vector2.zero, RewardPopSpeed);
btn_close.gameObject.SetActive(true);
AutoClose();
}
private int clickCount;
private bool jump;
private void OnClick()
{
if (IsShow)
{
clickCount++;
if (clickCount == 2)
{
jump = true;
}
}
}
private void OnClose()
{
receive.SetActive(false);
StopCoroutine("AutoCloseCoroutine");
rows.ForEach(x => Destroy(x.gameObject));
rows.Clear();
IsShow = false;
GContext.Publish(new ShowData(RewardType.Destroy));
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 672e61fcc5ae3d14faa1aa60b3929ac3
timeCreated: 1691640177

View File

@@ -0,0 +1,270 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RewardFishBox : RewardPopupBar
{
public Button btn_skip;
public Button btn_close;
public Button btn_next;
public Button btn_all;
public RewardNormal rewardBoxShow;
public TMP_Text text_title, txt_rewardInfo;
public bool isFly = false;
List<ItemData> dropItemsFly = new List<ItemData>();
bool isAllOpen;
[SerializeField]
private RewardItemNew rewardItem;
[SerializeField]
private Transform tran_rewardParent;
[SerializeField]
private GameObject go_row;
[SerializeField] private PanelScroll ps;
private List<RewardItemNew> rewards = new();
private List<GameObject> rows = new();
bool IsShow;
public Action<bool> OnClickClose;
private void Awake()
{
btn_close.onClick.AddListener(OnClose);
btn_next.onClick.AddListener(OnClose);
btn_all.onClick.AddListener(() =>
{
isAllOpen = true;
OnClose();
});
btn_skip.onClick.AddListener(OnClick);
}
public void Init(List<ItemData> dropItems, string rewardInfo, string title)
{
OnClickClose = (_) =>
{
GContext.Publish(new ShowData(RewardType.Destroy));
};
btn_close.gameObject.SetActive(true);
btn_next.gameObject.SetActive(false);
btn_all.gameObject.SetActive(false);
InitAsync(dropItems);
txt_rewardInfo.gameObject.SetActive(!string.IsNullOrEmpty(rewardInfo));
txt_rewardInfo.text = rewardInfo;
if (!string.IsNullOrEmpty(title))
{
text_title.text = title;
}
}
public async void InitAsync(List<ItemData> dropItems)
{
txt_rewardInfo.text = "";
text_title.text = LocalizationMgr.GetText("UI_FishingRewardPanel_101002");
dropItemsFly.Clear();
if (isFly)
{
ExchangeItem(dropItems);
}
receive.SetActive(true);
var x = 3;
var curParent = tran_rewardParent;
btn_close.gameObject.SetActive(false);
btn_skip.gameObject.SetActive(true);
int parentCount = 0;
int rewardCount = 0;
IsShow = true;
clickCount = 0;
jump = false;
for (int i = 0; i < dropItems.Count; i++)
{
var index = i % 3;
if (index == 0)
{
if (rows.Count > parentCount)
{
curParent = rows[parentCount].transform;
}
else
{
curParent = Instantiate(go_row, tran_rewardParent).transform;
rows.Add(curParent.gameObject);
}
parentCount++;
curParent.gameObject.SetActive(true);
var count = dropItems.Count - i;
for (int j = 0; j < x; j++)
{
curParent.GetChild(j).gameObject.SetActive(j < count);
}
}
var item = dropItems[i];
RewardItemNew reward;
if (rewards.Count > rewardCount)
{
reward = rewards[rewardCount];
}
else
{
reward = Instantiate(rewardItem.gameObject, curParent.GetChild(index)).GetComponent<RewardItemNew>();
rewards.Add(reward);
}
rewardCount++;
reward.SetData(item, isCanClick: true);
reward.gameObject.SetActive(true);
reward.PlayOpen();
if (jump)
{
}
else
{
await Awaiters.NextFrame;
ps.verticalNormalizedPosition = 0f;
await new WaitForSeconds(0.1f);
}
}
AutoClose();
await Awaiters.NextFrame;
ps.verticalNormalizedPosition = 0f;
btn_skip.gameObject.SetActive(false);
btn_close.gameObject.SetActive(true);
}
void ExchangeItem(List<ItemData> dropItems)
{
var map = new Dictionary<int, int>();
var mapCurCount = new Dictionary<int, ulong>();
//itemDataList重复合并
for (int i = dropItems.Count - 1; i >= 0; i--)
{
ItemData itemData = dropItems[i];
if (itemData.exchangeItemData != null)
{
continue;
}
if (map.ContainsKey(itemData.id))
{
map[itemData.id] += itemData.count;
}
else
{
map[itemData.id] = itemData.count;
}
mapCurCount[itemData.id] = itemData.curCount;
}
var newData = new List<ItemData>();
Tables tables = GContext.container.Resolve<Tables>();
foreach (var item in map)
{
ItemData itemData1 = new ItemData()
{
id = item.Key,
count = item.Value
};
itemData1.curCount = mapCurCount[itemData1.id];
newData.Add(itemData1);
Item itemTable = tables.TbItem.GetOrDefault(itemData1.id);
if (itemTable.Type != 5 && itemTable.Type != 9 && !(itemTable.Type == 3 && itemTable.SubType == 1))
{
dropItemsFly.Add(itemData1);
}
}
if (dropItems != null)
{
//转换物品链处理
dropItems = new List<ItemData>(dropItems);
for (int i = 0; i < dropItems.Count; i++)
{
ItemData itemData = dropItems[i];
ExchangeItemData nextExchangeItemData = GetExchangeItemData(itemData.exchangeItemData);
itemData.exchangeItemData = nextExchangeItemData;
if (nextExchangeItemData != null)
{
dropItemsFly.Add(itemData);
ExchangeItemData exchangeItemData = GetExchangeItemData(nextExchangeItemData.nextExchangeItemData);
nextExchangeItemData.nextExchangeItemData = null;
if (exchangeItemData != null)
{
ItemData itemData1 = new ItemData();
itemData1.id = itemData.id;
itemData1.curCount = itemData.curCount;
itemData1.count = itemData.count;
itemData1.exchangeItemData = exchangeItemData;
dropItems.Insert(i + 1, itemData1);
dropItemsFly.Add(itemData1);
}
}
}
}
}
ExchangeItemData GetExchangeItemData(ExchangeItemData exchangeItemData)
{
if (exchangeItemData == null)
{
return null;
}
if (exchangeItemData.exchangeCount > 0)
{
return exchangeItemData;
}
else
{
return GetExchangeItemData(exchangeItemData.nextExchangeItemData);
}
}
private int clickCount;
private bool jump;
private void OnClick()
{
if (IsShow)
{
clickCount++;
if (clickCount == 2)
{
jump = true;
}
}
}
IEnumerator AutoCloseCoroutine()
{
yield return new WaitForSeconds(3f);
if (isAutoClose)
{
isAllOpen = true;
OnClose();
}
}
private async void OnClose()
{
receive.SetActive(false);
StopCoroutine("AutoCloseCoroutine");
rewards.ForEach(x => x.gameObject.SetActive(false));
rows.ForEach(x => x.gameObject.SetActive(false));
IsShow = false;
gameObject.SetActive(false);
if (dropItemsFly.Count > 0)
{
var list = dropItemsFly.Take(9).ToList();
rewardBoxShow.InitHide(list);
await Awaiters.NextFrame;
await rewardBoxShow.AllClose();
rewardBoxShow.gameObject.SetActive(false);
}
OnClickClose.Invoke(isAllOpen);
}
}

View File

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

View File

@@ -0,0 +1,233 @@
using asap.core;
using cfg;
using game;
using Game;
using GameCore;
using Spine.Unity;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
public class FishingBoxOpenData
{
public int id;
public int count;
public List<ItemData> itemDatas;
}
public class RewardFishBoxOpen : MonoBehaviour
{
public RewardFishBox rewardFishBox;
private SkeletonGraphic curAnimation;
Tables tables;
[SerializeField]
private List<SkeletonGraphic> boxAnimations = new();
[SerializeField] float _fxDelay, _fxDisappearDelay;
List<FishingBoxOpenData> fishingBoxOpenDatas = new List<FishingBoxOpenData>();
FishingBoxDataProvier _dataProvider;
PlayerItemData playerItemData;
ItemData openData;
public void Init(List<ItemData> openDatas)
{
if (openDatas == null || openDatas.Count == 0)
{
openData = null;
}
else
{
this.openData = openDatas[0];
}
//开箱获得新鱼杆
//GContext.container.Resolve<PlayerData>().StartAddNewRod();
for (int i = 0; i < boxAnimations.Count; i++)
{
boxAnimations[i].gameObject.SetActive(false);
}
tables = GContext.container.Resolve<Tables>();
playerItemData = GContext.container.Resolve<PlayerItemData>();
_dataProvider = GContext.container.Resolve<FishingBoxDataProvier>();
AddItem();
OnClickClose(false);
}
void AddItem()
{
Dictionary<int, int> FishingBoxs = new Dictionary<int, int>();
if (openData != null)
{
int count = _dataProvider.Data.GetFishingBoxCount(openData.id);
if (count < openData.count)
{
openData.count = count;
}
FishingBoxs[openData.id] = (int)openData.count;
}
else
{
FishingBoxs = _dataProvider.Data.FishingNewBoxs;
}
int allCount = 0;
var localFishingBoxCount = new Dictionary<int, int>();
foreach (var box in FishingBoxs)
{
var boxCount = box.Value;
if (boxCount > 0)
{
var boxID = box.Key;
localFishingBoxCount[boxID] = boxCount;
allCount += boxCount;
}
}
if (allCount == 0)
{
GContext.Publish(new ShowData(RewardType.Destroy));
return;
}
var dropItems = new List<ItemData>();
var items = tables.TbItem.DataMap;
foreach (var box in localFishingBoxCount)
{
var boxCount = box.Value;
var boxID = box.Key;
_dataProvider.Data.SetFishingBoxCount(boxID, -boxCount);
//_dataProvider.SetBoxRewardScore(boxID, openCount);
//List<int> dropIds = new List<int>();
List<ItemData> localDropItems = new List<ItemData>();
for (int i = 0; i < boxCount; i++)
{
List<int> dropId = _dataProvider.GetFishingBoxDropID(boxID);
//dropIds.AddRange(dropId);
//List<ItemData> localDropItems = playerItemData.GetItemDataByDropList(dropIds);
localDropItems.AddRange(playerItemData.GetItemDataByDropList(dropId));
}
int count = localDropItems.Count;
//Convert Random Rod To A Rod
for (int i = 0; i < count; i++)
{
var item = items[localDropItems[i].id];
if (item.Type == 9 && (item.SubType == 4 || item.SubType == 1 || item.SubType == 3 || item.SubType == 7))
{
var newItem = playerItemData.GetItemDropPackageItemList(item.RedirectID, localDropItems[i].count)[0];
localDropItems[i] = newItem;
}
}
dropItems.AddRange(localDropItems);
FishingBoxOpenData data = new FishingBoxOpenData();
fishingBoxOpenDatas.Add(data);
data.id = boxID;
data.count = boxCount;
data.itemDatas = localDropItems;
//Add To ItemData
playerItemData.AddItem(localDropItems);
#if AGG
using (var e = GEvent.GameEvent("item_change", gaSend: false))
{
e.AddContent("item_id", boxID)
.AddContent("state_info", "cost")
.AddContent("change_num", boxCount);
}
#endif
}
}
void ShowAll()
{
var dropItems = new List<ItemData>();
for (int i = 0; i < fishingBoxOpenDatas.Count; i++)
{
dropItems.AddRange(fishingBoxOpenDatas[i].itemDatas);
}
fishingBoxOpenDatas.Clear();
rewardFishBox.btn_close.gameObject.SetActive(true);
rewardFishBox.btn_next.gameObject.SetActive(false);
rewardFishBox.btn_all.gameObject.SetActive(false);
InitAsync(dropItems);
}
void NextShow(bool isAllOpen)
{
OnClickClose(isAllOpen);
}
void OnClickClose(bool isAllOpen)
{
if (fishingBoxOpenDatas.Count == 0)
{
//获得新鱼杆展示
//GContext.container.Resolve<PlayerData>().ShowNewRod();
GContext.Publish(new ShowData(RewardType.Destroy));
GContext.Publish(new ResAddEvent(1002));
return;
}
if (isAllOpen)
{
ShowAll();
return;
}
rewardFishBox.btn_close.gameObject.SetActive(fishingBoxOpenDatas.Count == 1);
rewardFishBox.btn_next.gameObject.SetActive(fishingBoxOpenDatas.Count > 1);
rewardFishBox.btn_all.gameObject.SetActive(fishingBoxOpenDatas.Count > 2);
StartCoroutine(PlayOpenOn());
}
IEnumerator PlayOpenOn()
{
//打开全部开启按钮
//隐藏下一个按钮
if (curAnimation != null)
{
curAnimation.gameObject.SetActive(false);
}
FishingBoxOpenData data = fishingBoxOpenDatas[0];
Item boxItem = tables.TbItem.GetOrDefault(data.id);
curAnimation = boxAnimations[boxItem.Quality];
Transform bg_num = curAnimation.transform.Find("bg_num");
bg_num.gameObject.SetActive(data.count > 1);
if (data.count > 1)
{
bg_num.Find("text_num").GetComponent<TMP_Text>().text = $"x{data.count}";
}
curAnimation.gameObject.SetActive(true);
curAnimation.AnimationState.SetAnimation(0, "Show01", false);
yield return new WaitForSeconds(0.333f);
fishingBoxOpenDatas.RemoveAt(0);
curAnimation.AnimationState.SetAnimation(0, boxItem.Quality > 2 ? "Open01" : "Open02", false);
GContext.Publish(new EventUISound("audio_ui_box_open"));
//Debug.Log($"Animation Open Played! Idx: {curAnimationIdx}");
yield return new WaitForSeconds(_fxDelay);
GameObject fx = curAnimation.transform.GetChild(0).gameObject;
fx.SetActive(false);
fx.SetActive(true);
yield return new WaitForSeconds(_fxDisappearDelay - _fxDelay);
fx.SetActive(false);
if (curAnimation != null)
{
curAnimation.gameObject.SetActive(false);
}
//下一个按钮打开
InitAsync(data.itemDatas);
}
void InitAsync(List<ItemData> dropItems)
{
rewardFishBox.isFly = true;
rewardFishBox.gameObject.SetActive(true);
rewardFishBox.OnClickClose = NextShow;
rewardFishBox.InitAsync(dropItems);
}
}

View File

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

View File

@@ -0,0 +1,196 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using game;
using DG.Tweening;
using UniRx;
public class RewardFishCardUpgrade : MonoBehaviour
{
class FishCard
{
public Transform root;
public FishCardUI FishCardUI;
public MapFishAttribute attribute;
public float startAttribute1;
public float startAttribute2;
public FishCard(FishData data, Transform root, float startAttribute1, float startAttribute2)
{
this.root = root;
FishCardUI = root.Find("card").GetComponent<FishCardUI>();
attribute = root.Find("card/bg_attribute").GetComponent<MapFishAttribute>();
FishCardUI.gameObject.SetActive(false);
attribute.gameObject.SetActive(false);
FishCardUI.data = data;
this.startAttribute1 = startAttribute1;
this.startAttribute2 = startAttribute2;
}
public void Init()
{
FishCardUI.Init();
FishCardUI.gameObject.SetActive(true);
attribute.gameObject.SetActive(true);
attribute.SetRewardShowData(FishCardUI.data, startAttribute1, startAttribute2);
}
}
[SerializeField]
Transform tran_rewardParent;
List<FishCard> fishCards = new();
[SerializeField]
private GameObject go_row;
[SerializeField] private PanelScroll ps;
public float RewardPopSpeed = 0.1f;
[SerializeField]
private Button
btn_close,
btn_skip;
private List<GameObject> rows = new();
public bool IsShow;
int childCount;
void Init()
{
tran_rewardParent = transform.Find("ScrollView/Viewport/Content").GetComponent<Transform>();
go_row = transform.Find("ScrollView/Viewport/Content/reward_group1").gameObject;
ps = transform.Find("ScrollView").GetComponent<PanelScroll>();
btn_close = transform.Find("reward/btn_play/btn_green").GetComponent<Button>();
btn_skip = transform.Find("btn_skip").GetComponent<Button>();
gameObject.SetActive(true);
}
private void Awake()
{
btn_close.onClick.AddListener(OnClose);
btn_skip.onClick.AddListener(OnClick);
go_row.SetActive(false);
childCount = go_row.transform.childCount;
}
private int clickCount;
private bool jump;
private void OnClick()
{
if (IsShow)
{
clickCount++;
if (clickCount == 2)
{
jump = true;
}
}
}
private void OnClose()
{
rows.ForEach(x => Destroy(x.gameObject));
rows.Clear();
IsShow = false;
GContext.Publish(new SRefreshFishCardEvent());
GContext.Publish(new ShowData(RewardType.Destroy));
}
#region Func
public async void InitAsync(int mapID)
{
Init();
clickCount = 0;
jump = false;
IsShow = true;
gameObject.SetActive(true);
GameObject curParent;
btn_skip.gameObject.SetActive(true);
btn_close.gameObject.SetActive(false);
var playerFishData = GContext.container.Resolve<PlayerFishData>();
var fishCardIds = playerFishData.GetFishCardIdsCanLevelUpAll();
//var fishCardIds = playerFishData.GetFishCardIdsCanLevelUp(mapID);
var fishCardInfos = GContext.container.Resolve<Tables>().TbFishCard;
var fishInfos = GContext.container.Resolve<Tables>().TbFishData;
for (int i = 0; i < fishCardIds.Count; i += childCount)
{
curParent = Instantiate(go_row, tran_rewardParent);
// curParent.SetActive(true);
rows.Add(curParent.gameObject);
var count = fishCardIds.Count - i;
for (int j = 0; j < childCount; j++)
{
curParent.transform.GetChild(j).gameObject.SetActive(j < count);
curParent.transform.GetChild(j).GetChild(0).gameObject.SetActive(false);
}
await Awaiters.NextFrame;
// ps.verticalNormalizedPosition = 0f;
for (int j = 0; j < childCount; j++)
{
if (j < count)
{
var fishCardId = fishCardIds[i + j];
var fishData = fishInfos.Get(fishCardInfos.Get(fishCardId).FishID);
var slot = curParent.transform.GetChild(j);
// slot.gameObject.SetActive(true);
(var startAtrribute1, var startAtrribute2) = GetFishCardAtrributes(fishData);
fishCards.Add(new FishCard
(
fishData, slot.transform, startAtrribute1, startAtrribute2
));
}
}
}
playerFishData.AutoUpgradeFishCardAll();
foreach (var fishCard in fishCards)
{
fishCard.Init();
fishCard.root.parent.gameObject.SetActive(true);
if (jump)
{
}
else
{
await Awaiters.NextFrame;
ps.DONormalizedPos(Vector2.zero, RewardPopSpeed);
await new WaitForSeconds(RewardPopSpeed);
}
}
await Awaiters.NextFrame;
ps.DONormalizedPos(Vector2.zero, RewardPopSpeed);
btn_skip.gameObject.SetActive(false);
btn_close.gameObject.SetActive(true);
}
private (float, float) GetFishCardAtrributes(FishData fishData)
{
int level = GContext.container.Resolve<PlayerFishData>().GetDataLevel(fishData.ID);
cfg.FishCard fishCard = GContext.container.Resolve<Tables>().TbFishCard[fishData.FishCardID];
if (level >= fishCard.MaxLevel)
{
return (fishCard.WeightMagList[fishCard.MaxLevel - 1], fishCard.DamageMagList[fishCard.MaxLevel - 1]);
}
else
{
return level == 0 ? (0f, 0f) : (fishCard.WeightMagList[level - 1], fishCard.DamageMagList[level - 1]);
}
}
#endregion
}

View File

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

View File

@@ -0,0 +1,230 @@
using asap.core;
using game;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RewardNormal : RewardPopupBase
{
[SerializeField]
private Transform tran_rewardParent;
[SerializeField]
private GameObject go_row;
[SerializeField] private PanelScroll ps;
[SerializeField] TMP_Text text_title, txt_rewardInfo;
[SerializeField]
private Button
btn_close,
btn_skip;
private List<GameObject> rows = new();
public bool IsShow;
List<RewardItemNew> rewardItemNews = new();
int childCount;
//间隔时间
public float intervalTime = 0.166f;
float maxWaitTime = 2.3f;
private void Awake()
{
btn_close.onClick.AddListener(OnClose);
btn_skip.onClick.AddListener(OnClick);
go_row.SetActive(false);
childCount = go_row.transform.childCount;
}
public void InitRestore(List<ItemData> dropItems)
{
text_title.text = LocalizationMgr.GetText("Server_1003");
Init(dropItems);
ShowRewardInfo(LocalizationMgr.GetText("Server_1004"));
}
public void InitAsync(List<ItemData> dropItems, string rewardInfo)
{
text_title.text = LocalizationMgr.GetText("UI_FishingRewardPanel_101002");
Init(dropItems);
ShowRewardInfo(rewardInfo);
}
void ShowRewardInfo(string rewardInfo)
{
if (!string.IsNullOrEmpty(rewardInfo))
{
txt_rewardInfo.gameObject.SetActive(true);
txt_rewardInfo.text = rewardInfo;
}
else
{
txt_rewardInfo.gameObject.SetActive(false);
}
}
async void Init(List<ItemData> dropItems)
{
receive.SetActive(true);
text_title.gameObject.SetActive(true);
InitResource(dropItems);
clickCount = 0;
jump = false;
IsShow = true;
gameObject.SetActive(true);
GameObject curParent;
btn_skip.gameObject.SetActive(true);
btn_close.gameObject.SetActive(false);
for (int i = 0; i < dropItems.Count; i += childCount)
{
curParent = Instantiate(go_row, tran_rewardParent);
curParent.SetActive(true);
rows.Add(curParent.gameObject);
var count = dropItems.Count - i;
for (int j = 0; j < childCount; j++)
{
curParent.transform.GetChild(j).gameObject.SetActive(j < count);
curParent.transform.GetChild(j).GetChild(0).gameObject.SetActive(false);
}
await Awaiters.NextFrame;
ps.verticalNormalizedPosition = 0f;
for (int j = 0; j < childCount; j++)
{
if (j < count)
{
var item = dropItems[i + j];
curParent.transform.GetChild(j).gameObject.SetActive(true);
var reward = curParent.transform.GetChild(j).GetChild(0).GetComponent<RewardItemNew>();
reward.SetRewardPopupData(item);
reward.gameObject.SetActive(true);
reward.PlayOpen();
rewardItemNews.Add(reward);
cfg.Item itemCfg = GContext.container.Resolve<cfg.Tables>().TbItem.GetOrDefault(item.id);
//GContext.Publish(new ResAddEvent(itemCfg.ID, itemCfg.Type, itemCfg.SubType));
if (jump)
{
}
else
{
await new WaitForSeconds(0.1f);
}
}
}
}
await Awaiters.NextFrame;
ps.verticalNormalizedPosition = 0f;
btn_skip.gameObject.SetActive(false);
btn_close.gameObject.SetActive(true);
AutoClose();
}
IEnumerator AutoCloseCoroutine()
{
yield return new WaitForSeconds(3f);
if (isAutoClose)
{
OnClose();
}
}
private int clickCount;
private bool jump;
private void OnClick()
{
if (IsShow)
{
clickCount++;
if (clickCount == 2)
{
jump = true;
}
}
}
private async void OnClose()
{
StopCoroutine("AutoCloseCoroutine");
btn_close.gameObject.SetActive(false);
CurRewardQCount curRewardQCount = new CurRewardQCount();
GContext.Publish(curRewardQCount);
if (curRewardQCount.count <= 1)
{
GContext.Publish(new MaskFadeAlpha());
text_title.text = "";
txt_rewardInfo.gameObject.SetActive(false);
}
receive.SetActive(false);
bool isfly = false;
float waitTime = 0f;
for (int i = 0; i < rewardItemNews.Count; i++)
{
isfly = rewardItemNews[i].ParticleAttractorCheck();
await Awaiters.Seconds(intervalTime);
if (isfly)
{
waitTime = maxWaitTime;
}
else
{
waitTime -= intervalTime;
}
}
if (!isShowTop)
waitTime -= 0.8f;
if (waitTime > 0)
await Awaiters.Seconds(waitTime);
rows.ForEach(x => Destroy(x.gameObject));
rows.Clear();
rewardItemNews.Clear();
IsShow = false;
GContext.Publish(new ShowData(RewardType.Destroy));
}
public void InitHide(List<ItemData> dropItems)
{
text_title.gameObject.SetActive(false);
ShowRewardInfo("");
InitResource(dropItems);
receive.SetActive(false);
btn_skip.gameObject.SetActive(false);
btn_close.gameObject.SetActive(false);
gameObject.SetActive(true);
GameObject curParent;
for (int i = 0; i < dropItems.Count; i += childCount)
{
curParent = Instantiate(go_row, tran_rewardParent);
curParent.SetActive(true);
rows.Add(curParent.gameObject);
var count = dropItems.Count - i;
for (int j = 0; j < childCount; j++)
{
curParent.transform.GetChild(j).gameObject.SetActive(j < count);
curParent.transform.GetChild(j).GetChild(0).gameObject.SetActive(false);
}
for (int j = 0; j < childCount; j++)
{
if (j < count)
{
var item = dropItems[i + j];
curParent.transform.GetChild(j).gameObject.SetActive(true);
var reward = curParent.transform.GetChild(j).GetChild(0).GetComponent<RewardItemNew>();
reward.SetRewardPopupData(item, false);
reward.canvasGroup.alpha = 0f;
reward.gameObject.SetActive(true);
rewardItemNews.Add(reward);
}
}
}
}
public async Task AllClose()
{
for (int i = 0; i < rewardItemNews.Count; i++)
{
rewardItemNews[i].ParticleAttractor();
}
await Awaiters.Seconds(maxWaitTime);
rows.ForEach(x => Destroy(x.gameObject));
rows.Clear();
rewardItemNews.Clear();
}
}

View File

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

View File

@@ -0,0 +1,151 @@
using asap.core;
using cfg;
using game;
using Game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RewardNormal1 : RewardPopupBase
{
public RewardNormal reward;
public Button btn_next;
public Button btn_all;
public RewardItemNew rewardNew;
public RewardItemNew rewardNewShow;
public TMP_Text text_title;
public GameObject[] _lights;
public float showTime = 0.3f;
int curIndex;
int allCount;
List<ItemData> itemDatas;
ItemData curItemData;
bool isClose;
bool isClickClose;
bool text_title_restore = false;
private void Start()
{
btn_next.onClick.AddListener(OnClickNext);
btn_all.onClick.AddListener(OnClickAll);
}
public void InitRestore(List<ItemData> dropItems)
{
text_title_restore = true;
text_title.text = LocalizationMgr.GetText("UI_RewardPopupPanel_9");
Init(dropItems);
}
public void InitAsync(List<ItemData> itemDatas)
{
text_title_restore = false;
text_title.text = LocalizationMgr.GetText("UI_FishingRewardPanel_101002");
Init(itemDatas);
}
public void Init(List<ItemData> itemDatas)
{
this.itemDatas = itemDatas;
InitResource(itemDatas);
allCount = itemDatas.Count;
curIndex = 0;
SetData();
}
async void SetData()
{
int audioName = curIndex % 4 + 1;
GContext.Publish(new EventUISound($"audio_ui_getreward_{audioName}"));
isClickClose = false;
isClose = false;
curItemData = itemDatas[curIndex];
rewardNew.SetData(curItemData);
rewardNew.PlayOpen("reward_common1_open");
float showCount = curItemData.count;
ItemShow itemShow = GContext.container.Resolve<Tables>().TbItemShow.GetOrDefault(curItemData.id);
int light_index = 1;
if (itemShow != null)
{
light_index = 0;
if (itemShow.Id == 1002)
{
showCount = (showCount / GContext.container.Resolve<PlayerItemData>().ExtraCoinMag());
}
for (int i = itemShow.Count.Count - 1; i >= 0; i--)
{
if (showCount > itemShow.Count[i])
{
light_index = i + 1;
break;
}
}
}
if (light_index >= _lights.Length)
{
light_index = _lights.Length - 1;
}
for (int i = 0; i < _lights.Length; i++)
{
_lights[i].SetActive(i == light_index);
}
receive.SetActive(false);
receive.SetActive(true);
curIndex++;
if (curIndex >= allCount)
{
btn_all.gameObject.SetActive(false);
}
//if (curItemData.id == 1001 || curItemData.id == 1002 || curItemData.id == 1005)
//{
await Awaiters.Seconds(showTime);
rewardNewShow.SetData(curItemData, false);
await rewardNewShow.ParticleAttractor(true);
if (isClickClose)
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
//}
isClose = true;
}
void OnClickNext()
{
if (curIndex >= allCount)
{
receive.SetActive(false);
if (isClose)
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
else
{
isClickClose = true;
}
return;
}
SetData();
}
void OnClickAll()
{
gameObject.SetActive(false);
reward.gameObject.SetActive(true);
var allItemDatas = new List<ItemData>();
for (int i = curIndex; i < allCount; i++)
{
allItemDatas.Add(itemDatas[i]);
}
if (text_title_restore)
{
reward.InitRestore(allItemDatas);
}
else
{
reward.InitAsync(allItemDatas, null);
}
}
}

View File

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

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEngine.UI;
public class RewardPopupBar : MonoBehaviour
{
public Image bar;
public GameObject receive;
public float barTime = 3f;
public bool isAutoClose = false;
protected void AutoClose()
{
ShowBar();
if (isAutoClose)
{
StartCoroutine("AutoCloseCoroutine");
}
}
void ShowBar()
{
bar.gameObject.SetActive(isAutoClose);
}
protected virtual void OnDisable()
{
StopAllCoroutines();
}
}

View File

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

View File

@@ -0,0 +1,168 @@
using asap.core;
using DG.Tweening;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
public class ShowRewardPopupTop
{
public bool isHide;
public bool isShow;
}
public class RewardPopupBase : RewardPopupBar
{
public GameObject top_area;
public TMP_Text text_gold;
public TMP_Text text_energy;
public TMP_Text txt_diamond;
int Energy;
int curDiamond;
ulong Gold;
IDisposable disposable;
protected bool isShowTop = false;
private void OnEnable()
{
disposable = GContext.OnEvent<ResAddEvent>().Subscribe(x =>
{
NumPlay(x.id, x.addCount);
});
}
public void InitResource(List<ItemData> itemDatas)
{
ShowRewardPopupTop showRewardPopupTop = new ShowRewardPopupTop();
GContext.Publish(showRewardPopupTop);
top_area.SetActive(false);
if (showRewardPopupTop.isHide && !showRewardPopupTop.isShow)
{
return;
}
Energy = GContext.container.Resolve<PlayerData>().Energy;
Gold = GContext.container.Resolve<PlayerData>().gold;
curDiamond = GContext.container.Resolve<PlayerData>().diamond;
bool isShow = ShowItemCount(itemDatas);
if (isShow)
{
isShowTop = true;
top_area.SetActive(true);
text_energy.text = ConvertTools.GetNumberString2(Energy);
text_gold.text = ConvertTools.GetNumberString2(Gold);
txt_diamond.text = ConvertTools.GetNumberString2(curDiamond);
}
}
void NumPlay(int id, int addCount)
{
if (id == 1002)
{
GoldAddAnim(addCount);
}
else if (id == 1001)
{
EnergyAddAnim(addCount);
}
else if (id == 1005)
{
DiamondAddAnim(addCount);
}
}
void GoldAddAnim(float add)
{
DOTween.Kill("popup_text_gold");
text_gold.text = ConvertTools.GetNumberString2(Gold);
ulong playerGold = GContext.container.Resolve<PlayerData>().gold;
ulong endGold = playerGold;
if (add > 0)
{
var _endGold = Gold + (ulong)add;
if (_endGold < playerGold)
{
endGold = _endGold;
}
}
float progress = 0;
ulong cur_glod = Gold;
Gold = endGold;
if (endGold < cur_glod)
{
ulong addGold = cur_glod - endGold;
DOTween.To(() => progress, x => progress = x, 1, 1f).OnUpdate(() =>
{
ulong gold = (ulong)(addGold * progress);
if (gold > cur_glod)
{
gold = cur_glod;
}
text_gold.text = ConvertTools.GetNumberString2(cur_glod - gold);
}).SetId("popup_text_gold");
}
else if (endGold > cur_glod)
{
ulong addGold = endGold - cur_glod;
DOTween.To(() => progress, x => progress = x, 1, 1f).OnUpdate(() =>
{
text_gold.text = ConvertTools.GetNumberString2(cur_glod + (ulong)(addGold * progress));
}).SetId("popup_text_gold");
}
}
void EnergyAddAnim(float add)
{
DOTween.Kill("popup_text_energy");
text_energy.text = ConvertTools.GetNumberString2(Energy);
int EndEnergy = Energy + (int)add;
int curEnergy = Energy;
Energy = EndEnergy;
DOTween.To(() => curEnergy, x => curEnergy = x, EndEnergy, 1f).OnUpdate(() =>
{
text_energy.text = ConvertTools.GetNumberString2(curEnergy);
}).SetId("popup_text_energy");
}
void DiamondAddAnim(float add)
{
DOTween.Kill("popup_text_diamond");
txt_diamond.text = ConvertTools.GetNumberString2(curDiamond);
var EndDiamond = curDiamond + (int)add;
DOTween.To(() => curDiamond, x => curDiamond = x, EndDiamond, 1f).OnUpdate(() =>
{
txt_diamond.text = ConvertTools.GetNumberString2(curDiamond);
}).SetId("popup_text_diamond").OnComplete(() => txt_diamond.text = ConvertTools.GetNumberString2(EndDiamond));
}
bool ShowItemCount(List<ItemData> itemDatas)
{
bool isShow = false;
if (itemDatas != null)
{
for (int i = itemDatas.Count - 1; i >= 0; i--)
{
if (itemDatas[i].id == 1001)
{
Energy = (int)itemDatas[i].curCount;
isShow = true;
}
else if (itemDatas[i].id == 1002)
{
Gold = (ulong)itemDatas[i].curCount;
isShow = true;
}
else if (itemDatas[i].id == 1005)
{
curDiamond = (int)itemDatas[i].curCount;
isShow = true;
}
}
}
return isShow;
}
protected override void OnDisable()
{
base.OnDisable();
disposable?.Dispose();
disposable = null;
}
}

View File

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

View File

@@ -0,0 +1,271 @@
using asap.core;
using game;
using System.Threading.Tasks;
using UnityEngine;
using UniRx;
using System;
using System.Collections.Generic;
using GameCore;
using TMPro;
public class RewardPopupData
{
public string panelName;
public bool isShow;
public TaskCompletionSource<bool> tcs;
}
public struct MaskFadeAlpha
{
}
public class RewardPopupPanel : MonoBehaviour
{
CanvasGroup canvasGroup;
public float maskAlpha = 0.3f; //遮罩透明度
public CanvasGroup maskCanvasGroup;
public RewardNormal reward;
public RewardNormal1 reward1;
public RewardFishBox rewardFishBox;
public RewardFishBoxOpen rewardFishBoxOpen;
public RewardBox rewardBox1;
public RewardAlbumComplete rewardAlbumComplete;
public RewardAlbumAllComplete rewardAlbumAllComplete;
public FeaturesUnlock featuresUnlock;
public BenefitUpgrade benefitUpgrade;
public RewardFishCardUpgrade rewardFishCardUpgrade;
List<RewardItemNew> rewardItems;
Transform reward_group;
RewardPopupData rewardPopupData;
IDisposable disposable;
IDisposable disposable1;
RewardType rewardType;
private void Awake()
{
reward_group = transform.Find("reward_group");
rewardItems = new List<RewardItemNew>();
for (int i = 0; i < 9; i++)
{
rewardItems.Add(reward_group.GetChild(i).GetComponent<RewardItemNew>());
}
rewardPopupData = new RewardPopupData();
rewardPopupData.tcs = new TaskCompletionSource<bool>();
canvasGroup = GetComponent<CanvasGroup>();
reward = transform.Find("reward").GetComponent<RewardNormal>();
reward1 = transform.Find("reward_1").GetComponent<RewardNormal1>();
rewardBox1 = transform.Find("reward_box1").GetComponent<RewardBox>();
rewardFishBox = transform.Find("reward_show_1").GetComponent<RewardFishBox>();
rewardFishBoxOpen = transform.Find("reward_box_open").GetComponent<RewardFishBoxOpen>();
rewardAlbumComplete = transform.Find("album_complete").GetComponent<RewardAlbumComplete>();
rewardAlbumAllComplete = transform.Find("album_all_complete").GetComponent<RewardAlbumAllComplete>();
featuresUnlock = transform.Find("features_unlock").GetComponent<FeaturesUnlock>();
benefitUpgrade = transform.Find("Benefit_upgrade").GetComponent<BenefitUpgrade>();
rewardFishCardUpgrade = transform.Find("reward_fishcard_upgrade").GetComponent<RewardFishCardUpgrade>();
disposable = GContext.OnEvent<RewardPopupData>().Subscribe(OnRewardPopupData);
disposable1 = GContext.OnEvent<MaskFadeAlpha>().Subscribe(x =>
{
CheckMaskFadeAlpha();
});
}
void OnRewardPopupData(RewardPopupData data)
{
data.isShow = enabled;
data.tcs = rewardPopupData.tcs;
}
private void OnEnable()
{
Init();
}
public void Init()
{
bool isAutoClose = rewardType == RewardType.AutoOpen;
canvasGroup.alpha = DeBugPanel.isShow ? 1 : 0;
canvasGroup.blocksRaycasts = true;
reward.gameObject.SetActive(false);
reward1.gameObject.SetActive(false);
SetAutoClose(isAutoClose);
rewardFishBox.gameObject.SetActive(false);
rewardFishBoxOpen.gameObject.SetActive(false);
rewardBox1.gameObject.SetActive(false);
rewardAlbumComplete.gameObject.SetActive(false);
rewardAlbumAllComplete.gameObject.SetActive(false);
featuresUnlock.gameObject.SetActive(false);
benefitUpgrade.gameObject.SetActive(false);
rewardFishCardUpgrade.gameObject.SetActive(false);
}
void SetAutoClose(bool isAutoClose)
{
reward.isAutoClose = isAutoClose;
reward1.isAutoClose = isAutoClose;
rewardFishBox.isAutoClose = isAutoClose;
rewardBox1.isAutoClose = isAutoClose;
}
ExchangeItemData GetExchangeItemData(ExchangeItemData exchangeItemData)
{
if (exchangeItemData == null)
{
return null;
}
if (exchangeItemData.exchangeCount > 0)
{
return exchangeItemData;
}
else
{
return GetExchangeItemData(exchangeItemData.nextExchangeItemData);
}
}
public void ShowPanel(ShowData showData, string textValue, RewardType rewardType)
{
this.rewardType = rewardType;
Init();
List<ItemData> itemDatas = null;
//有些弹窗需要展示物品 itemDatas 有些不需要 比如 FeaturesUnlock itemDatas可为空
if (showData.itemDatas != null)
{
//转换物品链处理
itemDatas = new List<ItemData>(showData.itemDatas);
for (int i = 0; i < itemDatas.Count; i++)
{
ItemData itemData = itemDatas[i];
ExchangeItemData nextExchangeItemData = GetExchangeItemData(itemData.exchangeItemData);
itemData.exchangeItemData = nextExchangeItemData;
if (nextExchangeItemData != null)
{
ExchangeItemData exchangeItemData = GetExchangeItemData(nextExchangeItemData.nextExchangeItemData);
nextExchangeItemData.nextExchangeItemData = null;
if (exchangeItemData != null)
{
ItemData itemData1 = new ItemData();
itemData1.id = itemData.id;
itemData1.curCount = itemData.curCount;
itemData1.count = itemData.count;
itemData1.exchangeItemData = exchangeItemData;
itemDatas.Insert(i + 1, itemData1);
}
}
}
}
bool guide = GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("RewardPopupPanel");
//if (guide)
//{
// SetAutoClose(false);
//}
switch (showData.rewardType)
{
//case RewardType.NormalOneRestore:
// reward1.gameObject.SetActive(true);
// reward1.InitRestore(itemDatas);
// break;
case RewardType.NormalOne:
reward1.gameObject.SetActive(true);
reward1.InitAsync(itemDatas);
break;
case RewardType.NormalOneRestore:
case RewardType.NormalRestore:
reward.gameObject.SetActive(true);
reward.InitRestore(itemDatas);
break;
case RewardType.Normal:
reward.gameObject.SetActive(true);
reward.InitAsync(itemDatas, textValue);
break;
case RewardType.FishBox:
rewardFishBox.isFly = false;
rewardFishBox.gameObject.SetActive(true);
rewardFishBox.Init(itemDatas, showData.textValue, "");
break;
case RewardType.FishBoxFly:
rewardFishBox.isFly = true;
rewardFishBox.gameObject.SetActive(true);
rewardFishBox.Init(itemDatas, showData.textValue, "");
break;
case RewardType.FishBoxFlyRestore:
rewardFishBox.isFly = true;
rewardFishBox.gameObject.SetActive(true);
rewardFishBox.Init(itemDatas, showData.textValue, LocalizationMgr.GetText("UI_FishingRewardPanel_101041"));
break;
case RewardType.FishBoxOpen:
rewardFishBoxOpen.gameObject.SetActive(true);
rewardFishBoxOpen.Init(itemDatas);
break;
case RewardType.CardHolder:
rewardBox1.itemDataGifts = showData.itemDataGifts;
rewardBox1.exchangeItemData = null;
rewardBox1.Show();
break;
case RewardType.CollectionAlbum:
if (showData.id == 0)
{
rewardAlbumAllComplete.gameObject.SetActive(true);
rewardAlbumAllComplete.itemDatas = itemDatas;
rewardAlbumAllComplete.Show(rewardItems);
}
else
{
rewardAlbumComplete.gameObject.SetActive(true);
rewardAlbumComplete.itemDatas = itemDatas;
rewardAlbumComplete.Show(showData.id, rewardItems);
}
break;
case RewardType.FeaturesUnlock:
featuresUnlock.id = showData.id;
featuresUnlock.gameObject.SetActive(true);
break;
case RewardType.BenefitUpgrade:
benefitUpgrade.itemData = showData.itemDatas[0];
benefitUpgrade.gameObject.SetActive(true);
break;
case RewardType.FishCardUpgrade:
rewardFishCardUpgrade.InitAsync(showData.id);
break;
case RewardType.NewRod:
ShowFishingAppearancePanel(itemDatas);
break;
}
}
async void ShowFishingAppearancePanel(List<ItemData> itemDatas)
{
GameObject go = await UIManager.Instance.ShowUILoad(UITypes.FishingAppearancePanel);
FishingAppearancePanel fishingAppearance = go.GetComponent<FishingAppearancePanel>();
fishingAppearance.ShowNewRod(itemDatas);
}
public void CheckMaskFadeAlpha()
{
maskCanvasGroup.DOFadeAlpha(maskAlpha, 1);
}
private void OnDestroy()
{
// Debug.Log($"[turntable] Current thread ID @ OnRewardPopupPanelDestroy: {System.Threading.Thread.CurrentThread.ManagedThreadId}");
GContext.Publish(new FishingTurnTableContinueMultiDraw());
GContext.Publish(new FishingChallengeContinueEvent());
disposable?.Dispose();
disposable = null;
disposable1?.Dispose();
disposable1 = null;
rewardPopupData.tcs.SetResult(true);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b9b733709d2d4d5bb8957281fba768c2
timeCreated: 1691640005

View File

@@ -0,0 +1,66 @@
using asap.core;
using cfg;
using GameCore;
using MoreMountains.NiceVibrations;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UnlockNewMapPopupPanel : MonoBehaviour
{
public Button btn_close;
TMP_Text text_name;
buff_tips buff_Tips;
Animation anim;
private void Awake()
{
anim = GetComponent<Animation>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
text_name = transform.Find("map_unlock/text_name").GetComponent<TMP_Text>();
buff_Tips = transform.Find("map_unlock/buff").GetComponent<buff_tips>();
}
private void Start()
{
btn_close.onClick.AddListener(OnGoto);
Show();
}
public void Show()
{
int mapId = GContext.container.Resolve<FishingData>().MapId;
MapData data = GContext.container.Resolve<Tables>().TbMapData.GetOrDefault(mapId);
if (data != null)
{
text_name.text = LocalizationMgr.GetText(data.Name_l10n_key);
}
BuffDataCenter buffDataCenter = GContext.container.Resolve<BuffDataCenter>();
var buffTimeData = buffDataCenter.GetMapBuffTimeData(mapId);
var buff = GContext.container.Resolve<Tables>().TbFishBuff.GetOrDefault(buffTimeData.buffID);
buff_Tips.InitPanel(buff);
var buffTime = buffTimeData.buffEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
double seconds = buffTime.TotalSeconds;
Timer map_buff_timer = this.AttachTimer((float)seconds,
null,
(elapsed) =>
{
TimeSpan now = buffTimeData.buffEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
if (now.TotalSeconds <= 0)
{
map_buff_timer = null;
return;
}
buff_Tips.SetBuffTime(ConvertTools.ConvertTime2(now));
}, useRealTime: true);
}
async void OnGoto()
{
btn_close.enabled = false;
GContext.Publish(new VibrationData(HapticTypes.Success));
anim.Play("UnlockNewMap_out");
GContext.Publish(new CameraAnimatorSpeedEvent());
await Awaiters.Seconds(2f);
GContext.Publish(new RestartShowHomeUIEvent());
UIManager.Instance.DestroyUI(UITypes.UnlockNewMapPopupPanel);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2f68d48bf1b8495e86d4f7e87ca6d0f3
timeCreated: 1691647587