备份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,70 @@
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AlbumAttribute : MonoBehaviour
{
public static string[] AlbumBg =
{
"bg_album_album_white",
"bg_album_album_blue",
"bg_album_album_purple",
"bg_album_album_yellow",
};
public static string[] sp_album_card_title =
{
"sp_album_card_title_white",
"sp_album_card_title_blue",
"sp_album_card_title_purple",
"sp_album_card_title_yellow",
"sp_album_card_title_yellow",
};
public Image bg_album;
public Image icon;
public Image bg_title;
public TMP_Text[] text_names;
public Image bar;
public TMP_Text text_progress;
public Album data;
#if UNITY_EDITOR
private void Reset()
{
if (icon == null)
{
bg_album = transform.Find("bg_album").GetComponent<Image>();
icon = transform.Find("icon_album").GetComponent<Image>();
bg_title = transform.Find("bg_title").GetComponent<Image>();
// text_name = transform.Find("text_name_yellow").GetComponent<TMP_Text>();
bar = transform.Find("bg_bar/bar").GetComponent<Image>();
text_progress = transform.Find("bg_bar/bar/text_progress").GetComponent<TMP_Text>();
}
}
#endif
public void Init(Album _data)
{
data = _data;
GContext.container.Resolve<IUIService>().SetImageSprite(bg_album, AlbumBg[data.Quality - 1], BasePanel.PanelName);
GContext.container.Resolve<IUIService>().SetImageSprite(icon, data.Image, BasePanel.PanelName);
GContext.container.Resolve<IUIService>().SetImageSprite(bg_title, sp_album_card_title[data.Quality - 1], BasePanel.PanelName);
for (int i = 0; i < text_names.Length; i++)
{
text_names[i].gameObject.SetActive(i == data.Quality - 1);
if (data.Quality - 1 == i)
{
text_names[i].text = LocalizationMgr.GetText(data.Title_l10n_key);
}
}
if (data.Quality > text_names.Length)
{
text_names[^1].text = LocalizationMgr.GetText(data.Title_l10n_key);
text_names[^1].gameObject.SetActive(true);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 244716d9642d432aba62f54a1a0613a2
timeCreated: 1691735046

View File

@@ -0,0 +1,196 @@
using System;
using System.Collections.Generic;
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AlbumExchangePopupPanel : MonoBehaviour
{
public Button btn_close;
public Button btn_mask;
public TMP_Text text_repetitive_card;
List<AlbumExchange> exhangeList = new List<AlbumExchange>();
List<BntState> bntStates = new List<BntState>();
public SelectPicturePopupPanel selectPicturePopupPanel;
List<RewardItem> rewards = new List<RewardItem>();
private List<Timer> timers = new List<Timer>();
#if UNITY_EDITOR
private void Reset()
{
Awake();
}
#endif
private void Awake()
{
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
text_repetitive_card = transform.Find("root/cost/text_repetitive_card").GetComponent<TMP_Text>();
selectPicturePopupPanel = transform.Find("SelectPicturePopupPanel").GetComponent<SelectPicturePopupPanel>();
selectPicturePopupPanel.gameObject.SetActive(false);
selectPicturePopupPanel.albumExchangePopupPanel = this;
for (int i = 1; i <= 3; i++)
{
GameObject go = transform.Find($"root/list_exchange/Item{i}").gameObject;
rewards.Add(transform.Find($"root/list_exchange/Item{i}/reward").GetComponent<RewardItem>());
BntState bntState = new BntState
{
index = i,
openExchangePopupPanel = OpenExchangePopupPanel,
text_num = go.transform.Find("btn_exchange/btn_green_c/Ani_Container/content_cost/cost/p_text_num").GetComponent<TMP_Text>(),
text_num1 = go.transform.Find("exchange_cd/btn_exchange/btn_green_c/Ani_Container/content_cost/cost/p_text_num").GetComponent<TMP_Text>(),
btn_exchange = go.transform.Find("btn_exchange/btn_green_c").GetComponent<Button>(),
btn_exchange_cd = go.transform.Find("exchange_cd/btn_exchange/btn_green_c").GetComponent<Button>(),
text_time = go.transform.Find("exchange_cd/text_time").GetComponent<TMP_Text>(),
exchange_cd = go.transform.Find("exchange_cd").gameObject,
};
bntState.SetButtonClick();
bntStates.Add(bntState);
}
}
private void Start()
{
List<int> exchangeIdList = GContext.container.Resolve<AlbumData>().theme.ExchangeList;
for (int i = 0; i < rewards.Count; i++)
{
AlbumExchange albumExchange = GContext.container.Resolve<Tables>().GetAlbumExchange(exchangeIdList[i]);
exhangeList.Add(albumExchange);
bntStates[i].SetData(exhangeList[i]);
rewards[i].SetData(albumExchange.ItemID);
}
btn_close.onClick.AddListener(OnClickClose);
btn_mask.onClick.AddListener(OnClickClose);
}
void OnClickClose()
{
UIManager.Instance.HideUI(UITypes.AlbumExchangePopupPanel);
}
private void OnEnable()
{
int count = GContext.container.Resolve<AlbumData>().GetPictureRepeatCount();
text_repetitive_card.text = LocalizationMgr.GetFormatTextValue("UI_AlbumExchangePopupPanel_101002", count);
for (int i = 0; i < bntStates.Count; i++)
{
int index = i;
float endTimer = GContext.container.Resolve<AlbumData>().GetExchangeCd(index);
if (endTimer > 0.001f)
{
SetTimer(index, endTimer);
}
else
{
bntStates[index].SetTimeShow(0);
}
}
}
private void OnDisable()
{
foreach (var t in timers)
{
t.Cancel();
}
timers.Clear();
}
//打开兑换弹窗
public void OpenExchangePopupPanel(int index)
{
selectPicturePopupPanel.OpenExchangePopupPanel(index);
}
public void SetTimer(int index, float cd)
{
bntStates[index].SetTimeShow(cd);
Timer timer = this.AttachTimer(cd, () =>
{
GContext.container.Resolve<AlbumData>().RemoveExchangeCd(index);
bntStates[index].SetTimeShow(0);
},
(elapsed) => { bntStates[index].SetTimeText(cd - elapsed); }, useRealTime: true);
timers.Add(timer);
}
class BntState
{
//是否可以兑换
private bool isCanExchange;
public int index;
public TMP_Text text_time;
public Button btn_exchange;
public Button btn_exchange_cd;
public GameObject exchange_cd;
public TMP_Text text_num;
public TMP_Text text_num1;
public Action<int> openExchangePopupPanel;
private float exchangeTime;
public void SetButtonClick()
{
btn_exchange.onClick.AddListener(() =>
{
//打开兑换弹窗
openExchangePopupPanel?.Invoke(index - 1);
});
btn_exchange_cd.onClick.AddListener(() =>
{
if (exchangeTime > 0.001)
{
ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_6",text_time.text));
}
else
{
//打开兑换弹窗
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_7"));
}
});
}
public void SetData(AlbumExchange albumExchange)
{
isCanExchange = albumExchange.PictureRequired <= GContext.container.Resolve<AlbumData>().GetPictureRepeatCount();
text_num.text = albumExchange.PictureRequired.ToString();
text_num1.text = albumExchange.PictureRequired.ToString();
SetBtnShow();
}
public void SetTimeShow(float _exchangeTime)
{
exchangeTime = _exchangeTime;
if (exchangeTime > 0.001f)
{
text_time.gameObject.SetActive(true);
SetTimeText(exchangeTime);
}
else
{
text_time.gameObject.SetActive(false);
}
SetBtnShow();
}
void SetBtnShow()
{
btn_exchange.gameObject.SetActive(isCanExchange && exchangeTime < 0.001);
exchange_cd.gameObject.SetActive(!isCanExchange || exchangeTime > 0.001);
}
public void SetTimeText(float _exchangeTime)
{
exchangeTime = _exchangeTime;
TimeSpan now = TimeSpan.FromSeconds(exchangeTime);
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
//text_time.text = ConvertTools.ConvertTime((int)exchangeTime);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3c230b686774457d906456bbbc3a7550
timeCreated: 1691562884

View File

@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AlbumPictureReviewPopupPanel : MonoBehaviour
{
public Button btn_close;
public Button btn_mask;
// public GameObject mask_empty;
public TMP_Text text_left_time;
public TMP_Text text_tips;
public TMP_Text text_disable;
public Button btn_askforfriend;
public Button btn_join;
public PictureItem pictureItem;
int count = 0;
ClubService _socialData;
Picture data;
private void Awake()
{
_socialData = GContext.container.Resolve<ClubService>();
pictureItem = transform.Find("root/album_photo").GetComponent<PictureItem>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
text_left_time = transform.Find("root/text_left_time").GetComponent<TMP_Text>();
text_tips = transform.Find("root/text_tips").GetComponent<TMP_Text>();
text_disable = transform.Find("root/text_disable").GetComponent<TMP_Text>();
btn_askforfriend = transform.Find("root/btn_askforfriend/btn_green").GetComponent<Button>();
btn_join = transform.Find("root/btn_join/btn_green").GetComponent<Button>();
}
private void Start()
{
btn_close.onClick.AddListener(OnClickClose);
btn_mask.onClick.AddListener(OnClickClose);
btn_askforfriend.onClick.AddListener(OnClickDown);
btn_join.onClick.AddListener(OnClickJoin);
}
void OnClickClose()
{
UIManager.Instance.HideUI(UITypes.AlbumPictureReviewPopupPanel);
}
async void OnClickJoin()
{
if (GContext.container.Resolve<ClubService>().IsOpenClubJoined)
{
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
btn_join.enabled = false;
//打开俱乐部界面
await UIManager.Instance.ShowUI(UITypes.FishingSocialPanel);
btn_join.enabled = true;
OnClickClose();
}
else
{
GContext.Publish(new VibrationData(HapticTypes.Failure));
ToastPanel.Show(GContext.container.Resolve<FishingEventData>().GetTipforUnlocked(GContext.container.Resolve<ClubService>().socialTipforUnlocked));
}
}
async void OnClickDown()
{
if (GContext.container.Resolve<AlbumData>().GetPhotoRequestCountByDay() < GContext.container.Resolve<Tables>().TbGlobalConfig.PictureGiftedLimitDaily)
{
btn_askforfriend.enabled = false;
//社交求助帖
bool resut = await _socialData.SendGetPhoto(data.ID);
if (resut)
{
int giftToFriendsDay = GContext.container.Resolve<AlbumData>().SetPhotoRequestCountByDay();
int PictureGiftedLimitDaily = GContext.container.Resolve<Tables>().TbGlobalConfig.PictureGiftedLimitDaily;
text_left_time.text = LocalizationMgr.GetFormatTextValue("UI_AlbumPictureReviewPopupPanel_101001",
PictureGiftedLimitDaily - giftToFriendsDay,
PictureGiftedLimitDaily);
//ToastPanel求助成功
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_37"));
GContext.container.Resolve<AlbumData>().UpdatePlayerStatistics();
}
btn_askforfriend.enabled = true;
}
else
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_8"));
}
}
public void SetData(Picture _data)
{
data = _data;
gameObject.SetActive(true);
pictureItem.SetData(_data, null);
//pictureAttribute.Init(_data);
SetState();
}
void SetState()
{
count = GContext.container.Resolve<AlbumData>().GetPictureProgress(data.ID);
// mask_empty.SetActive(count <= 0);
// img_card.gameObject.SetActive(count > 0);
//pictureAttribute.text_num.transform.parent.gameObject.SetActive(count > 1);
bool isJoin = _socialData.IsClubJoined();
text_left_time.gameObject.SetActive(false);
text_tips.gameObject.SetActive(false);
btn_askforfriend.gameObject.SetActive(false);
btn_join.gameObject.SetActive(false);
if (!data.IsTradable)
{
text_disable.gameObject.SetActive(true);
return;
}
else
{
text_disable.gameObject.SetActive(false);
}
if (count <= 0)
{
if (isJoin)
{
text_left_time.gameObject.SetActive(true);
int giftToFriendsDay = GContext.container.Resolve<AlbumData>().GetPhotoRequestCountByDay();
int PictureGiftedLimitDaily = GContext.container.Resolve<Tables>().TbGlobalConfig.PictureGiftedLimitDaily;
text_left_time.text = LocalizationMgr.GetFormatTextValue("UI_AlbumPictureReviewPopupPanel_101001",
PictureGiftedLimitDaily - giftToFriendsDay,
PictureGiftedLimitDaily);
btn_askforfriend.gameObject.SetActive(true);
}
else
{
text_tips.gameObject.SetActive(true);
btn_join.gameObject.SetActive(true);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0af57c6d0e554a2681c1a4fb669843ab
timeCreated: 1691492551

View File

@@ -0,0 +1,68 @@
using cfg;
using System;
using UnityEngine;
using UnityEngine.UI;
public class ExchangePictureItem : MonoBehaviour
{
public GameObject selected;
public Button btn_click;
public Action<ExchangePictureItem> action;
public PictureAttribute pictureAttribute;
public int index;
bool isShow;
public ExchangePictureItemData itemData;
public void Awake()
{
pictureAttribute = transform.Find("Item").GetComponent<PictureAttribute>();
btn_click = transform.Find("Item").GetComponent<Button>();
selected = transform.Find("Item/selected").gameObject;
if (isShow)
{
Show();
}
isShow = true;
}
private void Start()
{
btn_click.onClick.AddListener(OnClick);
}
public void SetData(ExchangePictureItemData _data, Action<ExchangePictureItem> _action)
{
itemData = _data;
index = _data.index;
action = _action;
if (isShow)
{
Show();
}
isShow = true;
}
void Show()
{
pictureAttribute.Init(itemData.data);
SetSelected(itemData.isSelect);
}
public void SetSelected(bool isSelect)
{
selected.SetActive(isSelect);
}
public void OnClick()
{
action?.Invoke(this);
}
}
public class ExchangePictureItemData
{
public Picture data;
public int index;
public bool isSelect;
public ExchangePictureItemData(int index, Picture data)
{
this.index = index;
this.data = data;
}
}

View File

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

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class ExchangePictureItemGroup : PanelItemBase<ExchangePictureItemGroupData>
{
List<ExchangePictureItem> pictureItems = new List<ExchangePictureItem>();
private void Awake()
{
for (int i = 0; i < 3; i++)
{
GameObject go = transform.Find($"album_photo{i}").gameObject;
pictureItems.Add(go.AddComponent<ExchangePictureItem>());
}
}
public override void OnInit()
{
int count = data.exchangePictureItemDatas.Count;
for (int i = 0; i < 3; i++)
{
if (i < count)
{
pictureItems[i].gameObject.SetActive(true);
pictureItems[i].SetData(data.exchangePictureItemDatas[i], data.action);
}
else
{
pictureItems[i].gameObject.SetActive(false);
}
}
}
}
public class ExchangePictureItemGroupData
{
public List<ExchangePictureItemData> exchangePictureItemDatas = new List<ExchangePictureItemData>();
public Action<ExchangePictureItem> action;
}

View File

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

View File

@@ -0,0 +1,273 @@
using System;
using System.Collections.Generic;
using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class FishingAlbumPanel : BasePanel
{
//赛季名称
public TMP_Text text_season_name;
public Button btn_questionmark;
public Button btn_bottom;
public Button btn_close;
//兑换按钮
public Button btn_exchange;
//赛季背景
public Image bg_season;
//赛季图标
public Image icon_season;
//收集进度Text
public TMP_Text text_progress;
public Image bar;
//剩余时间Text
public TMP_Text text_time;
//奖励数组
public RewardItem[] rewards;
public GameObject albumItem;
List<AlbumItem> albumItems = new List<AlbumItem>();
public Transform content;
private Theme theme;
List<Album> albumList = new List<Album>();
private FishingAlbumPopupPanel fishingAlbumPopupPanel;
List<ItemData> dropPackageList;
public GameObject AlbumInfoPopupPanel;
public Button btn_close_inif;
public Button btn_close_inif_mask;
#if UNITY_EDITOR
private void Reset()
{
Awake();
}
#endif
private void Awake()
{
text_season_name = transform.Find("root/title/text_title").GetComponent<TMP_Text>();
btn_questionmark = transform.Find("root/title/btn_questionmark").GetComponent<Button>();
btn_bottom = transform.Find("root/btn_close/bg_bottom").GetComponent<Button>();
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
btn_exchange = transform.Find("root/btn_reward").GetComponent<Button>();
bg_season = transform.Find("root/bg_title").GetComponent<Image>();
icon_season = transform.Find("root/bg_title/icon_integral").GetComponent<Image>();
text_progress = transform.Find("root/bg_title/bg_bar/text_progress").GetComponent<TMP_Text>();
bar = transform.Find("root/bg_title/bg_bar/bar").GetComponent<Image>();
text_time = transform.Find("root/bg_title/time/text_time").GetComponent<TMP_Text>();
rewards = new RewardItem[3];
rewards[0] = transform.Find("root/bg_title/reward_panel/reward1").GetComponent<RewardItem>();
rewards[1] = transform.Find("root/bg_title/reward_panel/reward2").GetComponent<RewardItem>();
rewards[2] = transform.Find("root/bg_title/reward_panel/reward3").GetComponent<RewardItem>();
content = transform.Find("root/panel_card/ScrollView/Viewport/Content").GetComponent<Transform>();
AlbumInfoPopupPanel = transform.Find("AlbumInfoPopupPanel").gameObject;
btn_close_inif = transform.Find("AlbumInfoPopupPanel/btn_close").GetComponent<Button>();
btn_close_inif_mask = transform.Find("AlbumInfoPopupPanel/mask").GetComponent<Button>();
albumItem = transform.Find("root/panel_card/ScrollView/Viewport/Content/album").gameObject;
theme = GContext.container.Resolve<AlbumData>().theme ?? GContext.container.Resolve<Tables>().TbTheme.DataList[0];
for (int i = 0; i < theme.AlbumList.Count; i++)
{
albumList.Add(GContext.container.Resolve<Tables>().TbAlbum[theme.AlbumList[i]]);
}
dropPackageList = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(theme.CollectionReward);
}
protected override void Start()
{
base.Start();
GContext.OnEvent<RewardPanelClose>().Subscribe(_ => SetProgress()).AddTo(disposables);
AlbumInfoPopupPanel.SetActive(false);
albumItem.SetActive(false);
btn_questionmark.onClick.AddListener(() => AlbumInfoPopupPanel.SetActive(true));
btn_close.onClick.AddListener(OnClickClose);
btn_bottom.onClick.AddListener(OnClickClose);
btn_exchange.onClick.AddListener(OnClickExchange);
btn_close_inif.onClick.AddListener(() => AlbumInfoPopupPanel.SetActive(false));
btn_close_inif_mask.onClick.AddListener(() => AlbumInfoPopupPanel.SetActive(false));
text_season_name.text = LocalizationMgr.GetText(theme.Title_l10n_key);
// bg_season.sprite = ResourceManager.Instance.GetSprite(theme.Season_bg);
// icon_season.sprite = ResourceManager.Instance.GetSprite(theme.Season_icon);
for (int i = 0; i < albumList.Count; i++)
{
var go = Instantiate(albumItem, content);
go.SetActive(true);
go.name = i.ToString();
go.AddComponent<AlbumItem>();
albumItems.Add(go.GetComponent<AlbumItem>());
}
for (int i = 0; i < rewards.Length; i++)
{
if (dropPackageList.Count > i)
{
rewards[i].SetData(dropPackageList[i]);
}
else
{
rewards[i].gameObject.SetActive(false);
}
}
SetTime();
SetProgress();
GContext.Publish(new OnEventTriggerGuide(GetType().Name));
}
void SetAlbumItem()
{
for (int i = 0; i < albumItems.Count; i++)
{
albumItems[i].SetData(i, albumList[i], OnClickAlbumItem);
}
}
bool isShowing = false;
async void OnClickAlbumItem(AlbumItem item)
{
if (isShowing)
{
return;
}
if (fishingAlbumPopupPanel == null)
{
isShowing = true;
GameObject panel = await UIManager.Instance.GetUIAsync(UITypes.FishingAlbumPopupPanel);
fishingAlbumPopupPanel = panel.GetComponent<FishingAlbumPopupPanel>();
fishingAlbumPopupPanel.albumList = albumList;
isShowing = false;
}
fishingAlbumPopupPanel.SetData(item.index);
}
void OnClickClose()
{
UIManager.Instance.DestroyUI(UITypes.FishingAlbumPanel);
}
async void OnClickExchange()
{
btn_exchange.enabled = false;
await UIManager.Instance.ShowUI(UITypes.AlbumExchangePopupPanel);
btn_exchange.enabled = true;
}
//设置赛季倒计时
void SetTime()
{
DateTime endTime = GContext.container.Resolve<AlbumData>().GetAlbumEndTime();
TimeSpan data = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_FishingAlbumPanel_101002",
data.TotalDays.ToString("00") + "d" + data.Hours.ToString("00") + "h");
// $"剩余时间{data.TotalDays:00}天{data.Hours:00}小时";
}
//设置收集进度
void SetProgress()
{
SetAlbumItem();
int count = albumList.Count;
int fishAlbumProgress = 0;
int allAlbumProgress = 0;
for (int i = 0; i < count; i++)
{
//if ( Instance.Album.GetAlbumProgress(albumList[i].PictureList) >= albumList[i].PictureList.Count)
//{
// fishAlbumProgress++;
//}
fishAlbumProgress += GContext.container.Resolve<AlbumData>().GetAlbumProgress(albumList[i].PictureList);
allAlbumProgress += albumList[i].PictureList.Count;
}
if (fishAlbumProgress >= allAlbumProgress)
{
for (int i = 0; i < rewards.Length; i++)
{
rewards[i].SetReceived(true);
}
}
text_progress.text = $"{fishAlbumProgress}/{allAlbumProgress}";
if (bar)
bar.fillAmount = (float)fishAlbumProgress / allAlbumProgress;
}
private void OnDisable()
{
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
GContext.Publish(restartShowHomeUIEvent);
}
protected override void OnDestroy()
{
UIManager.Instance.DestroyUI(UITypes.FishingAlbumPopupPanel);
UIManager.Instance.DestroyUI(UITypes.AlbumExchangePopupPanel);
base.OnDestroy();
}
}
public class AlbumItem : MonoBehaviour
{
public Button btn_click;
Action<AlbumItem> action;
public int index;
public AlbumAttribute albumAttribute;
public GameObject done;
public UIRedPoint red;
private void Awake()
{
albumAttribute = transform.GetComponent<AlbumAttribute>();
btn_click = transform.GetComponent<Button>();
done = albumAttribute.bar.transform.Find("done").gameObject;
red = transform.Find("redpoint").GetComponent<UIRedPoint>();
}
private void Start()
{
btn_click.onClick.AddListener(OnClick);
GContext.container.Resolve<AlbumData>().SetAlubmRed(RedPointName.Home_Album_ID, false);
}
public void SetData(int _index, Album _data, Action<AlbumItem> _action)
{
red.SetKey("Album" + _index);
index = _index;
action = _action;
albumAttribute.Init(_data);
int count = GContext.container.Resolve<AlbumData>().GetAlbumProgress(albumAttribute.data.PictureList);
for (int i = 0; i < albumAttribute.data.PictureList.Count; i++)
{
if (GContext.container.Resolve<AlbumData>().IsNewPicture(albumAttribute.data.PictureList[i]))
{
RedPointManager.Instance.SetRedPointState("Album" + index, true);
break;
}
}
if (count >= albumAttribute.data.PictureList.Count)
{
albumAttribute.bar.fillAmount = 1;
albumAttribute.text_progress.text = "";
done.SetActive(true);
}
else
{
done.SetActive(false);
albumAttribute.bar.fillAmount = (float)count / albumAttribute.data.PictureList.Count;
albumAttribute.text_progress.text =
$"{GContext.container.Resolve<AlbumData>().GetAlbumProgress(albumAttribute.data.PictureList)}/{albumAttribute.data.PictureList.Count}";
}
}
public void OnClick()
{
action?.Invoke(this);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2170d55c59b445f3a07516cf101031eb
timeCreated: 1691466784

View File

@@ -0,0 +1,239 @@
using System;
using System.Collections.Generic;
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class FishingAlbumPopupPanel : MonoBehaviour
{
public static string[] AlbumBg =
{
"bg_album_album_white",
"bg_album_album_blue",
"bg_album_album_purple",
"bg_album_album_yellow",
};
public Button btn_close;
public Button btn_mask;
public AlbumAttribute albumAttribute;
public TMP_Text text_progress;
public RewardItem[] rewards;
public GameObject pictureItem;
public Transform content;
public ScrollRect scrollRect;
List<Picture> pictureList = new List<Picture>();
private List<ItemData> dropPackageList;
List<PictureItem> pictureItems = new List<PictureItem>();
public List<Album> albumList = new List<Album>();
public TMP_Text text_page;
public Button btn_left;
public Button btn_right;
public GameObject btn_left_icon;
public GameObject btn_left_icon_gray;
public GameObject btn_right_icon;
public GameObject btn_right_icon_gray;
int currentAlbumIndex = 0;
private void Awake()
{
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
albumAttribute = transform.Find("root/album").GetComponent<AlbumAttribute>();
text_progress = transform.Find("root/reward_panel/text_reward").GetComponent<TMP_Text>();
rewards = new RewardItem[3];
rewards[0] = transform.Find("root/reward_panel/reward1").GetComponent<RewardItem>();
rewards[1] = transform.Find("root/reward_panel/reward2").GetComponent<RewardItem>();
rewards[2] = transform.Find("root/reward_panel/reward3").GetComponent<RewardItem>();
pictureItem = transform.Find("root/panel_card/ScrollView/Viewport/Content/album_photo").gameObject;
content = transform.Find("root/panel_card/ScrollView/Viewport/Content").GetComponent<Transform>();
scrollRect = transform.Find("root/panel_card/ScrollView").GetComponent<ScrollRect>();
text_page = transform.Find("root/text_page").GetComponent<TMP_Text>();
btn_left = transform.Find("btn_close/btn_arrow_left").GetComponent<Button>();
btn_right = transform.Find("btn_close/btn_arrow_right").GetComponent<Button>();
btn_left_icon = transform.Find("btn_close/btn_arrow_left/icon").gameObject;
btn_left_icon_gray = transform.Find("btn_close/btn_arrow_left/icon_gray").gameObject;
btn_right_icon = transform.Find("btn_close/btn_arrow_right/icon").gameObject;
btn_right_icon_gray = transform.Find("btn_close/btn_arrow_right/icon_gray").gameObject;
}
private void Start()
{
pictureItem.SetActive(false);
btn_close.onClick.AddListener(OnClickClose);
btn_mask.onClick.AddListener(OnClickClose);
btn_left.onClick.AddListener(OnLeftClick);
btn_right.onClick.AddListener(OnRightClick);
}
private void OnEnable()
{
GContext.Publish(new OnEventTriggerGuide(GetType().Name));
}
private void OnDisable()
{
GContext.Publish(new OnEventTriggerGuide(GetType().Name));
}
private void Update()
{
//左右滑动屏幕一半距离触发OnLeftClick或OnRightClick
if (Input.GetMouseButtonDown(0))
{
OnBeginDrag();
}
if (Input.GetMouseButtonUp(0))
{
OnEndDrag();
}
}
float beginDragPosX = 0;
void OnBeginDrag()
{
beginDragPosX = Input.mousePosition.x;
}
void OnEndDrag()
{
//滑动屏幕一半距离触发OnLeftClick或OnRightClick
if (Mathf.Abs(Input.mousePosition.x - beginDragPosX) > Screen.width / 4)
{
if (Input.mousePosition.x > beginDragPosX)
{
OnLeftClick();
}
else
{
OnRightClick();
}
}
}
void OnClickClose()
{
UIManager.Instance.HideUI(UITypes.FishingAlbumPopupPanel);
}
public void OnLeftClick()
{
if (currentAlbumIndex > 0)
{
SetData(currentAlbumIndex - 1);
}
}
public void OnRightClick()
{
if (currentAlbumIndex < albumList.Count - 1)
{
SetData(currentAlbumIndex + 1);
}
}
public void SetData(int index)
{
currentAlbumIndex = index;
btn_left_icon.SetActive(index > 0);
btn_left_icon_gray.SetActive(index <= 0);
btn_right_icon.SetActive(index < albumList.Count - 1);
btn_right_icon_gray.SetActive(index >= albumList.Count - 1);
text_page.text = $"{index + 1}/{albumList.Count}";
Album album = albumList[index];
albumAttribute.Init(album);
pictureList.Clear();
foreach (var t in album.PictureList)
{
pictureList.Add(GContext.container.Resolve<Tables>().TbPicture[t]);
}
dropPackageList = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(album.CollectionReward);
gameObject.SetActive(true);
SetItem();
SetReward();
}
void SetItem()
{
int count = pictureItems.Count;
for (int i = 0; i < count; i++)
{
pictureItems[i].gameObject.SetActive(false);
}
for (int i = 0; i < pictureList.Count; i++)
{
if (count <= i)
{
var go = Instantiate(pictureItem, content);
go.SetActive(true);
go.name = i.ToString();
go.AddComponent<PictureItem>().SetData(pictureList[i], OnClickPictureItem);
pictureItems.Add(go.GetComponent<PictureItem>());
}
else
{
pictureItems[i].gameObject.SetActive(true);
pictureItems[i].SetData(pictureList[i], OnClickPictureItem);
}
}
RedPointManager.Instance.SetRedPointState("Album" + currentAlbumIndex, false);
}
void SetReward()
{
for (int i = 0; i < rewards.Length; i++)
{
if (dropPackageList.Count > i)
{
rewards[i].SetData(dropPackageList[i]);
// rewards[i].btn_click.onClick.AddListener(() =>
// {
// //TODO
// });
}
else
{
rewards[i].gameObject.SetActive(false);
}
}
int count = pictureList.Count;
int fishPictureProgress = 0;
for (int i = 0; i < count; i++)
{
if (GContext.container.Resolve<AlbumData>().GetPictureProgress(pictureList[i].ID) > 0)
{
fishPictureProgress++;
}
}
if (fishPictureProgress >= count)
{
for (int i = 0; i < rewards.Length; i++)
{
rewards[i].SetReceived(true);
}
}
text_progress.text = fishPictureProgress >= count
? LocalizationMgr.GetFormatTextValue("UI_FishingAlbumPanel_101003", count, count)
: LocalizationMgr.GetFormatTextValue("UI_FishingAlbumPanel_101003", fishPictureProgress, count);
}
bool isClick = false;
async void OnClickPictureItem(PictureItem item)
{
if (isClick)
{
return;
}
isClick = true;
(await UIManager.Instance.ShowUI(UITypes.AlbumPictureReviewPopupPanel)).GetComponent<AlbumPictureReviewPopupPanel>().SetData(item.pictureAttribute.data);
isClick = false;
}
private void OnDestroy()
{
UIManager.Instance.DestroyUI(UITypes.AlbumPictureReviewPopupPanel);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9f8fb4f6053f4b3d9ded779ea69c9c82
timeCreated: 1691486363

View File

@@ -0,0 +1,108 @@
using System.Collections.Generic;
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PictureAttribute : MonoBehaviour
{
string[] sp_bg_card_string =
{
"sp_album_card_bg_white",
"sp_album_card_bg_blue",
"sp_album_card_bg_purple",
"sp_album_card_bg_yellow",
"sp_album_card_bg_yellow"
};
[HideInInspector]
public Image img_card;
Image sp_bg_card;
Image bg_title;
public TMP_Text[] text_names;
List<GameObject> starList = new List<GameObject>();
[HideInInspector]
public TMP_Text text_num;
public Picture data;
[HideInInspector]
public GameObject newTag;
bool isShow;
bool newState;
private void Awake()
{
InitPanel();
if (isShow)
{
Show();
}
isShow = true;
}
void InitPanel()
{
img_card = transform.Find("img_card").GetComponent<Image>();
sp_bg_card = transform.Find("sp_bg_card").GetComponent<Image>();
bg_title = transform.Find("bg_title").GetComponent<Image>();
newTag = transform.Find("new")?.gameObject;
text_num = transform.Find("extra_card/text_extra_card").GetComponent<TMP_Text>();
Transform star = transform.Find("star");
int count = star.childCount;
for (int i = 0; i < count; i++)
{
starList.Add(star.GetChild(i).gameObject);
}
}
public void Init(Picture _data)
{
data = _data;
if (isShow)
{
Show();
}
isShow = true;
}
public void SetNewState(bool newState)
{
this.newState = newState;
if (newTag != null)
{
newTag.SetActive(newState);
}
}
void Show()
{
if (newTag != null)
{
newTag.SetActive(newState);
}
GContext.container.Resolve<IUIService>().SetImageSprite(sp_bg_card, sp_bg_card_string[data.Quality - 1], BasePanel.PanelName);
GContext.container.Resolve<IUIService>().SetImageSprite(bg_title, AlbumAttribute.sp_album_card_title[data.Quality - 1], BasePanel.PanelName);
GContext.container.Resolve<IUIService>().SetImageSprite(img_card, data.Image, BasePanel.PanelName);
for (int i = 0; i < text_names.Length; i++)
{
text_names[i].gameObject.SetActive(i == data.Quality - 1);
if (data.Quality - 1 == i)
{
text_names[i].text = LocalizationMgr.GetText(data.Title_l10n_key);
}
}
if (data.Quality > text_names.Length)
{
text_names[^1].text = LocalizationMgr.GetText(data.Title_l10n_key);
text_names[^1].gameObject.SetActive(true);
}
for (int i = 0; i < starList.Count; i++)
{
starList[i].SetActive(i == data.Quality - 1);
}
if (data.Quality > starList.Count)
{
starList[^1].gameObject.SetActive(true);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a2c6dc6e648549899eed3287e3846e2b
timeCreated: 1691652601

View File

@@ -0,0 +1,61 @@
using asap.core;
using cfg;
using GameCore;
using System;
using UnityEngine;
using UnityEngine.UI;
public class PictureItem : MonoBehaviour
{
public Button btn_click;
public GameObject mask_empty;
Action<PictureItem> action;
public PictureAttribute pictureAttribute;
public GameObject effect_kapai_loop;
public GameObject effect_tuowei;
private void Awake()
{
pictureAttribute = transform.Find("Item").GetComponent<PictureAttribute>();
mask_empty = transform.Find("Item/mask_empty").gameObject;
btn_click = transform.Find("Item").GetComponent<Button>();
//Transform star = transform.Find("Item/star");
effect_kapai_loop = transform.Find("effect_kapai_loop").gameObject;
effect_tuowei = transform.Find("effect_tuowei").gameObject;
}
private void Start()
{
btn_click.onClick.AddListener(OnClick);
}
public void SetData(Picture _data, Action<PictureItem> _action, bool isChat = false)
{
effect_kapai_loop.SetActive(!_data.IsTradable);
effect_tuowei.SetActive(!_data.IsTradable);
action = _action;
pictureAttribute.Init(_data);
int count = GContext.container.Resolve<AlbumData>().GetPictureProgress(pictureAttribute.data.ID);
mask_empty.SetActive(count <= 0);
pictureAttribute.img_card.gameObject.SetActive(count > 0);
if (isChat)
{
return;
}
pictureAttribute.text_num.transform.parent.gameObject.SetActive(count > 1);
if (count > 1)
{
pictureAttribute.text_num.text = $"+{count - 1}";
}
bool isNew = GContext.container.Resolve<AlbumData>().IsNewPicture(pictureAttribute.data.ID);
pictureAttribute.SetNewState(isNew);
if (isNew)
{
GContext.container.Resolve<AlbumData>().RemoveNewPicture(pictureAttribute.data.ID);
}
}
public void OnClick()
{
action?.Invoke(this);
}
}

View File

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

View File

@@ -0,0 +1,176 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class SelectPicturePopupPanel : MonoBehaviour
{
List<AlbumExchange> exhangeList = new List<AlbumExchange>();
public AlbumExchangePopupPanel albumExchangePopupPanel;
public Button btn_close_sub;
public Button btn_close_sub1;
public TMP_Text text_title;//UI_SelectPicturePopupPanel_1
PanelScroll scrollRect;
float itemHigh;
public GameObject pictureItem;
public Toggle toggle_all;
public TMP_Text text_check;
public Button btn_exchange;
List<ExchangePictureItemData> exchangePictureItemDatas = new List<ExchangePictureItemData>();
List<ExchangePictureItemGroupData> exchangePictureItemGroupDatas = new List<ExchangePictureItemGroupData>();
List<Picture> pictureList;
//选中卡牌
Dictionary<int, int> selectPicture = new Dictionary<int, int>();
private int selectIndex = -1;
private float _CD = 3600;
private void Awake()
{
btn_close_sub = transform.Find("mask").GetComponent<Button>();
btn_close_sub1 = transform.Find("btn_close").GetComponent<Button>();
text_title = transform.Find("root/text_title").GetComponent<TMP_Text>();
scrollRect = transform.Find("root/panel_card/ScrollView").GetComponent<PanelScroll>();
pictureItem = transform.Find("root/panel_card/ScrollView/Viewport/Content/Item").gameObject;
toggle_all = transform.Find("root/autoselect/checkpoint").GetComponent<Toggle>();
text_check = transform.Find("root/autoselect/text_check").GetComponent<TMP_Text>();
btn_exchange = transform.Find("root/btn_sure/btn_green").GetComponent<Button>();
pictureItem.SetActive(false);
List<int> exchangeIdList = GContext.container.Resolve<AlbumData>().theme.ExchangeList;
for (int i = 0; i < 3; i++)
{
AlbumExchange albumExchange = GContext.container.Resolve<Tables>().GetAlbumExchange(exchangeIdList[i]);
exhangeList.Add(albumExchange);
}
itemHigh = pictureItem.GetComponent<RectTransform>().sizeDelta.y;
}
private void Start()
{
btn_close_sub.onClick.AddListener(() => { gameObject.SetActive(false); });
btn_close_sub1.onClick.AddListener(() => { gameObject.SetActive(false); });
toggle_all.onValueChanged.AddListener(OnToggleChange);
btn_exchange.onClick.AddListener(OnClickExchange);
}
public void OpenExchangePopupPanel(int index)
{
gameObject.SetActive(true);
selectIndex = index;
//设置兑换弹窗数据
SetExchangeItem();
text_check.text = LocalizationMgr.GetFormatTextValue("UI_SelectPicturePopupPanel_2", exhangeList[selectIndex].PictureRequired);
//按钮不置灰
// btn_exchange.interactable = true;
}
void OnToggleChange(bool isOn)
{
selectPicture.Clear();
int count = exchangePictureItemDatas.Count;
//设置兑换弹窗数据
for (int i = 0; i < count; i++)
{
if (i < exhangeList[selectIndex].PictureRequired && isOn)
{
selectPicture[i] = exchangePictureItemDatas[i].data.ID;
}
exchangePictureItemDatas[i].isSelect = i < exhangeList[selectIndex].PictureRequired && isOn;
}
//刷新列表
SetTitle();
scrollRect.Refresh();
}
void SetTitle()
{
text_title.text = $"{LocalizationMgr.GetText("UI_SelectPicturePopupPanel_1")}({selectPicture.Count}/{exhangeList[selectIndex].PictureRequired})";
}
void SetExchangeItem()
{
selectPicture.Clear();
pictureList = new List<Picture>();
exchangePictureItemDatas.Clear();
exchangePictureItemGroupDatas.Clear();
ShowList();
}
void ShowList()
{
pictureList = GContext.container.Resolve<AlbumData>().GetPictureRepeatList();
//Quality从小到大排序
pictureList.Sort((a, b) => { return a.Quality.CompareTo(b.Quality); });
int total = 0;
for (int i = 0; i < pictureList.Count; i++)
{
var curPictureCount = GContext.container.Resolve<AlbumData>().GetPictureProgress(pictureList[i].ID);
for (int j = 1; j < curPictureCount; j++)
{
exchangePictureItemDatas.Add(new ExchangePictureItemData(total, pictureList[i]));
if (total < exhangeList[selectIndex].PictureRequired)
{
exchangePictureItemDatas[total].isSelect = true;
selectPicture[total] = pictureList[i].ID;
}
total++;
}
}
for (int i = 0; i < total; i += 3)
{
ExchangePictureItemGroupData exchangePictureItemGroupData = new ExchangePictureItemGroupData();
for (int j = 0; j < 3; j++)
{
if (i + j < total)
{
exchangePictureItemGroupData.exchangePictureItemDatas.Add(exchangePictureItemDatas[i + j]);
}
}
exchangePictureItemGroupData.action = OnClickPictureItem;
exchangePictureItemGroupDatas.Add(exchangePictureItemGroupData);
}
//滑动列表
scrollRect.Init<ExchangePictureItemGroup, ExchangePictureItemGroupData>(itemHigh, pictureItem, null, exchangePictureItemGroupDatas);
SetTitle();
}
void OnClickPictureItem(ExchangePictureItem item)
{
item.SetSelected(!item.selected.activeSelf);
if (item.selected.activeSelf)
{
exchangePictureItemDatas[item.index].isSelect = true;
selectPicture[item.index] = item.pictureAttribute.data.ID;
}
else
{
exchangePictureItemDatas[item.index].isSelect = false;
selectPicture.Remove(item.index);
}
SetTitle();
}
void OnClickExchange()
{
if (selectPicture.Count == exhangeList[selectIndex].PictureRequired)
{
//减卡牌数
GContext.container.Resolve<AlbumData>().RemovePictureProgress(selectPicture);
gameObject.SetActive(false);
//获得奖励
GContext.container.Resolve<PlayerItemData>().AddItemCount(exhangeList[selectIndex].ItemID, 1);
GContext.Publish(new game.ShowData());
//更新兑换按钮状态
GContext.container.Resolve<AlbumData>().SetExchangeCd(selectIndex, _CD);
albumExchangePopupPanel.SetTimer(selectIndex, _CD);
int count = GContext.container.Resolve<AlbumData>().GetPictureRepeatCount();
albumExchangePopupPanel.text_repetitive_card.text = LocalizationMgr.GetFormatTextValue("UI_AlbumExchangePopupPanel_101002", count);
}
else
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_9"));
}
}
}

View File

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