备份CatanBuilding瘦身独立工程
This commit is contained in:
30
Assets/Scripts/UI/Appearance/AppearanceBtn.cs
Normal file
30
Assets/Scripts/UI/Appearance/AppearanceBtn.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public enum AppearanceOpenType
|
||||
{
|
||||
HomePanel,
|
||||
FishingRodPanel,
|
||||
//AppearancePanel
|
||||
}
|
||||
|
||||
public class AppearanceBtn : MonoBehaviour
|
||||
{
|
||||
Button btn_appearance;
|
||||
private void Awake()
|
||||
{
|
||||
btn_appearance = GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_appearance.onClick.AddListener(async () =>
|
||||
{
|
||||
var go = await UIManager.Instance.ShowUI(UITypes.AppearancePanel);
|
||||
AppearancePanel appearancePanel = go.GetComponent<AppearancePanel>();
|
||||
appearancePanel.appearanceOpenType = AppearanceOpenType.HomePanel;
|
||||
GContext.Publish(new HideHomePanelEvent() { IsHideMap = false });
|
||||
GContext.Publish(new MapShowEvent() { isShow = true });
|
||||
});
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Appearance/AppearanceBtn.cs.meta
Normal file
11
Assets/Scripts/UI/Appearance/AppearanceBtn.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9ee3d331c340d645a7671756a64c9a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/UI/Appearance/AppearanceItem.cs
Normal file
25
Assets/Scripts/UI/Appearance/AppearanceItem.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AppearanceItem : MonoBehaviour
|
||||
{
|
||||
public Button btn_item;
|
||||
public Image icon;
|
||||
public RewardItemNew reward;
|
||||
public GameObject equipped;
|
||||
public GameObject newGo;
|
||||
public GameObject unlock;
|
||||
public GameObject selected;
|
||||
public int index;
|
||||
public Action<int> action;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btn_item.onClick.AddListener(OnClickItem);
|
||||
}
|
||||
void OnClickItem()
|
||||
{
|
||||
action?.Invoke(index);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Appearance/AppearanceItem.cs.meta
Normal file
11
Assets/Scripts/UI/Appearance/AppearanceItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982fc4db6bdd4cd4d86814e3039d8e54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
564
Assets/Scripts/UI/Appearance/AppearancePanel.cs
Normal file
564
Assets/Scripts/UI/Appearance/AppearancePanel.cs
Normal file
@@ -0,0 +1,564 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AppearancePanel : BasePanel
|
||||
{
|
||||
[HideInInspector]
|
||||
public AppearanceOpenType appearanceOpenType;
|
||||
List<Toggle> toggles = new List<Toggle>();
|
||||
List<GameObject> selected_tab = new List<GameObject>();
|
||||
List<GameObject> redpoint = new List<GameObject>();
|
||||
TMP_Text text_name;
|
||||
TMP_Text text_title;
|
||||
Button btn_close;
|
||||
Button btn_equip;
|
||||
Button btn_unequip;
|
||||
GameObject equipped;
|
||||
GameObject waytoget;
|
||||
TMP_Text text_waytoget;
|
||||
Transform content;
|
||||
GameObject item;
|
||||
List<AppearanceItem> appearanceItems = new List<AppearanceItem>();
|
||||
|
||||
List<RodAccessoriesData> rodAccessoriesDatas;
|
||||
List<GloveData> gloveDatas;
|
||||
List<RodSkinData> rodSkinDatas;
|
||||
int curDataCount;
|
||||
|
||||
int curEqIndex;
|
||||
|
||||
int skinCount;
|
||||
int gloveCount;
|
||||
int accessoriesCount;
|
||||
|
||||
int curMainIndex = 0;
|
||||
int curSubIndex = -1;
|
||||
|
||||
Tables tables;
|
||||
IUIService uiService;
|
||||
FishingBehaviorB fishingBehavior;
|
||||
PlayerFishData playerFishData;
|
||||
GameObject fishingSkinTool;
|
||||
int rodID;
|
||||
bool unlockRod;
|
||||
Button btn_yugan;
|
||||
Button btn_view;
|
||||
Image bg_hud_god_image;
|
||||
Image rawImage;
|
||||
TMP_Text text_grade_rod;
|
||||
TMP_Text text_star_rod;
|
||||
string[] bg_hud_gods = { "bg_hud_god_blue", "bg_hud_god_blue", "bg_hud_god_purple", "bg_hud_god_yellow" };
|
||||
|
||||
CanvasGroup root;
|
||||
Button btn_close_view;
|
||||
|
||||
AppearanceRodChangePanel rodChangePanel;
|
||||
private void Awake()
|
||||
{
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
GetFishingBehaviorB getFishingBehavior = new GetFishingBehaviorB();
|
||||
GContext.Publish(getFishingBehavior);
|
||||
fishingBehavior = getFishingBehavior.fishingBehavior;
|
||||
fishingBehavior.gameObject.SetActive(false);
|
||||
|
||||
uiService = GContext.container.Resolve<IUIService>();
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
gloveDatas = tables.TbGloveData.DataList;
|
||||
gloveCount = playerFishData.rodAccessoriesData.GloveIds.Count;
|
||||
|
||||
rodAccessoriesDatas = tables.TbRodAccessoriesData.DataList;
|
||||
|
||||
root = transform.Find("root").GetComponent<CanvasGroup>();
|
||||
btn_close_view = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_view = transform.Find("root/btn_view").GetComponent<Button>();
|
||||
text_name = transform.Find("root/name/text_name").GetComponent<TMP_Text>();
|
||||
text_title = transform.Find("root/bg_title/text_title").GetComponent<TMP_Text>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
btn_equip = transform.Find("root/btn_equip/btn_green").GetComponent<Button>();
|
||||
btn_unequip = transform.Find("root/btn_unequip/btn_green").GetComponent<Button>();
|
||||
equipped = transform.Find("root/equipped").gameObject;
|
||||
waytoget = transform.Find("root/waytoget").gameObject;
|
||||
text_waytoget = transform.Find("root/waytoget/text_waytoget").GetComponent<TMP_Text>();
|
||||
content = transform.Find("root/layout_item");
|
||||
item = transform.Find("root/layout_item/item").gameObject;
|
||||
item.SetActive(false);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
redpoint.Add(transform.Find($"root/tab/redpoint_tab{i + 1}").gameObject);
|
||||
selected_tab.Add(transform.Find($"root/tab/selected_tab{i + 1}").gameObject);
|
||||
toggles.Add(transform.Find($"root/tab/normal_tab{i + 1}").GetComponent<Toggle>());
|
||||
Toggle toggle = toggles[i];
|
||||
int index = i;
|
||||
toggle.onValueChanged.AddListener((isOn) =>
|
||||
{
|
||||
selected_tab[index].SetActive(isOn);
|
||||
if (isOn)
|
||||
{
|
||||
OnToggleChange(index);
|
||||
}
|
||||
});
|
||||
selected_tab[i].SetActive(i == curMainIndex);
|
||||
toggle.isOn = i == curMainIndex;
|
||||
}
|
||||
btn_yugan = transform.Find("root/btn_yugan").GetComponent<Button>();
|
||||
bg_hud_god_image = transform.Find("root/btn_yugan/bg").GetComponent<Image>();
|
||||
rawImage = transform.Find("root/btn_yugan/mask/icon").GetComponent<Image>();
|
||||
text_grade_rod = transform.Find("root/btn_yugan/text_grade").GetComponent<TMP_Text>();
|
||||
text_star_rod = transform.Find("root/btn_yugan/bg_star/text_star").GetComponent<TMP_Text>();
|
||||
|
||||
OnChangeRod(GContext.container.Resolve<PlayerData>().equipRodID);
|
||||
rodChangePanel = transform.Find("AppearanceRodChangePanel").GetComponent<AppearanceRodChangePanel>();
|
||||
rodChangePanel.gameObject.SetActive(false);
|
||||
rodChangePanel.OnChangeRod = OnChangeRod;
|
||||
rodChangePanel.rodId = rodID;
|
||||
LoadFishingSkinTool();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
redpoint[1].SetActive(playerFishData.rodAccessoriesData.GloveNewIds.Count > 0);
|
||||
base.Start();
|
||||
btn_yugan.onClick.AddListener(() => rodChangePanel.gameObject.SetActive(true));
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_equip.onClick.AddListener(OnClickEquip);
|
||||
btn_unequip.onClick.AddListener(OnClickUnequip);
|
||||
btn_view.onClick.AddListener(ClickView);
|
||||
btn_close_view.onClick.AddListener(CloseView);
|
||||
}
|
||||
void ClickView()
|
||||
{
|
||||
root.alpha = 0;
|
||||
root.blocksRaycasts = false;
|
||||
btn_close_view.gameObject.SetActive(true);
|
||||
}
|
||||
void CloseView()
|
||||
{
|
||||
root.alpha = 1;
|
||||
root.blocksRaycasts = true;
|
||||
btn_close_view.gameObject.SetActive(false);
|
||||
}
|
||||
async void LoadFishingSkinTool()
|
||||
{
|
||||
fishingSkinTool = await Addressables.InstantiateAsync("FishingSkinTool").Task;
|
||||
}
|
||||
#region 装备、卸下
|
||||
void OnClickEquip()
|
||||
{
|
||||
switch (curMainIndex)
|
||||
{
|
||||
case (int)RodSkinType.skin:
|
||||
EquipSkin(true);
|
||||
break;
|
||||
case (int)RodSkinType.glove:
|
||||
EquipGlove(true);
|
||||
break;
|
||||
//case (int)RodSkinType.accessories:
|
||||
// EquipAccessories(true);
|
||||
// break;
|
||||
}
|
||||
OnEquip();
|
||||
}
|
||||
void OnClickUnequip()
|
||||
{
|
||||
switch (curMainIndex)
|
||||
{
|
||||
case (int)RodSkinType.skin:
|
||||
EquipSkin(false);
|
||||
break;
|
||||
case (int)RodSkinType.glove:
|
||||
EquipGlove(false);
|
||||
break;
|
||||
//case (int)RodSkinType.accessories:
|
||||
// EquipAccessories(false);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
void EquipSkin(bool iseq)
|
||||
{
|
||||
if (iseq)
|
||||
{
|
||||
playerFishData.SetRodSkin(rodID, rodSkinDatas[curSubIndex].ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerFishData.SetRodSkin(rodID, 0);
|
||||
}
|
||||
OnSelectSkin();
|
||||
GContext.Publish(new ChangeSkinEvent(RodSkinType.skin));
|
||||
}
|
||||
|
||||
void EquipGlove(bool iseq)
|
||||
{
|
||||
if (iseq)
|
||||
{
|
||||
if (playerFishData.rodAccessoriesData.GloveID != gloveDatas[curSubIndex].ID)
|
||||
{
|
||||
playerFishData.rodAccessoriesData.GloveID = gloveDatas[curSubIndex].ID;
|
||||
playerFishData.SaveInitRodAccessoriesData();
|
||||
OnSelectGlove();
|
||||
GContext.Publish(new ChangeSkinEvent(RodSkinType.glove));
|
||||
}
|
||||
}
|
||||
}
|
||||
//void EquipAccessories(bool iseq)
|
||||
//{
|
||||
// OnSelectAccessories();
|
||||
//}
|
||||
void OnEquip()
|
||||
{
|
||||
appearanceItems[curEqIndex].equipped.SetActive(false);
|
||||
curEqIndex = curSubIndex;
|
||||
appearanceItems[curEqIndex].equipped.SetActive(true);
|
||||
}
|
||||
#endregion 装备、卸下
|
||||
#region 切换鱼杆
|
||||
void OnChangeRod(int rodId)
|
||||
{
|
||||
rodID = rodId;
|
||||
unlockRod = !playerFishData.NotRod(rodID);
|
||||
RodData rodData = tables.TbRodData[rodID];
|
||||
List<int> SkinList = rodData.SkinList;
|
||||
rodSkinDatas = new List<RodSkinData>();
|
||||
skinCount = 0;
|
||||
int id;
|
||||
for (int i = 0; i < SkinList.Count; i++)
|
||||
{
|
||||
id = SkinList[i];
|
||||
RodSkinData rodSkinData = tables.TbRodSkinData.GetOrDefault(id);
|
||||
if (rodSkinData != null)
|
||||
{
|
||||
rodSkinDatas.Add(rodSkinData);
|
||||
if (unlockRod)
|
||||
{
|
||||
if (id == rodID || playerFishData.IsSkinUnlocked(id))
|
||||
{
|
||||
skinCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (curMainIndex == (int)RodSkinType.skin)
|
||||
{
|
||||
ChangeMainIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeRodNotSkin();
|
||||
}
|
||||
InitRodData();
|
||||
}
|
||||
void ChangeRodNotSkin()
|
||||
{
|
||||
int curRodSkinId = playerFishData.GetRodSkin(rodID);
|
||||
GContext.Publish(new SelectSkinEvent(curRodSkinId));
|
||||
}
|
||||
#endregion
|
||||
#region 选中杆皮肤、手
|
||||
void OnToggleChange(int index)
|
||||
{
|
||||
if (curMainIndex != index)
|
||||
{
|
||||
curMainIndex = index;
|
||||
ChangeMainIndex();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中页签
|
||||
/// </summary>
|
||||
void ChangeMainIndex()
|
||||
{
|
||||
curSubIndex = -1;
|
||||
switch (curMainIndex)
|
||||
{
|
||||
case (int)RodSkinType.skin:
|
||||
curDataCount = rodSkinDatas.Count;
|
||||
break;
|
||||
case (int)RodSkinType.glove:
|
||||
curDataCount = gloveDatas.Count;
|
||||
break;
|
||||
//case (int)RodSkinType.accessories:
|
||||
// curDataCount = rodAccessoriesDatas.Count;
|
||||
// break;
|
||||
}
|
||||
|
||||
int length = appearanceItems.Count;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
appearanceItems[i].gameObject.SetActive(false);
|
||||
}
|
||||
if (curDataCount > length)
|
||||
{
|
||||
for (int i = length; i < curDataCount; i++)
|
||||
{
|
||||
GameObject go = Instantiate(item, content);
|
||||
AppearanceItem appearanceItem = go.GetComponent<AppearanceItem>();
|
||||
appearanceItems.Add(appearanceItem);
|
||||
appearanceItem.index = i;
|
||||
appearanceItem.action = OnClickItem;
|
||||
}
|
||||
}
|
||||
|
||||
btn_equip.gameObject.SetActive(false);
|
||||
btn_unequip.gameObject.SetActive(false);
|
||||
equipped.gameObject.SetActive(false);
|
||||
waytoget.gameObject.SetActive(false);
|
||||
|
||||
//设置列表
|
||||
switch (curMainIndex)
|
||||
{
|
||||
case (int)RodSkinType.skin:
|
||||
SetSkin();
|
||||
break;
|
||||
case (int)RodSkinType.glove:
|
||||
SetGlove();
|
||||
break;
|
||||
//case (int)RodSkinType.accessories:
|
||||
// SetAccessories();
|
||||
// break;
|
||||
}
|
||||
redpoint[curMainIndex].SetActive(false);
|
||||
}
|
||||
|
||||
void SetGlove()
|
||||
{
|
||||
int index = 0;
|
||||
bool isUnlock;
|
||||
bool isEq;
|
||||
bool isNew;
|
||||
int gloveID;
|
||||
int curID = playerFishData.rodAccessoriesData.GloveID;
|
||||
text_title.text = $"Outfit({gloveCount}/{curDataCount})";
|
||||
for (int i = 0; i < curDataCount; i++)
|
||||
{
|
||||
gloveID = gloveDatas[i].ID;
|
||||
appearanceItems[i].gameObject.SetActive(true);
|
||||
appearanceItems[i].reward.icon.gameObject.SetActive(true);
|
||||
appearanceItems[i].reward.icon_rod.gameObject.SetActive(false);
|
||||
uiService.SetImageSprite(appearanceItems[i].reward.icon, gloveDatas[i].Icon);
|
||||
isUnlock = gloveID == tables.TbGlobalConfig.InitGloveID || playerFishData.IsGloveUnlocked(gloveID);
|
||||
appearanceItems[i].unlock.SetActive(!isUnlock);
|
||||
isNew = playerFishData.IsNewGlove(gloveID);
|
||||
appearanceItems[i].newGo.SetActive(isNew);
|
||||
isEq = curID == gloveID;
|
||||
appearanceItems[i].equipped.SetActive(isEq);
|
||||
if (isEq)
|
||||
{
|
||||
curEqIndex = i;
|
||||
index = i;
|
||||
}
|
||||
appearanceItems[i].selected.SetActive(false);
|
||||
}
|
||||
OnClickItem(index);
|
||||
playerFishData.RemoveGloveNewId();
|
||||
}
|
||||
void SetSkin()
|
||||
{
|
||||
text_title.text = $"Outfit({skinCount}/{curDataCount})";
|
||||
int index = 0;
|
||||
bool isUnlock;
|
||||
bool isEq;
|
||||
int skinId;
|
||||
bool isNew;
|
||||
int curRodSkinId = playerFishData.GetRodSkin(rodID);
|
||||
for (int i = 0; i < curDataCount; i++)
|
||||
{
|
||||
appearanceItems[i].gameObject.SetActive(true);
|
||||
appearanceItems[i].reward.icon.gameObject.SetActive(false);
|
||||
appearanceItems[i].reward.icon_rod.gameObject.SetActive(true);
|
||||
uiService.SetImageSprite(appearanceItems[i].reward.icon_rod, rodSkinDatas[i].Avatar);
|
||||
skinId = rodSkinDatas[i].ID;
|
||||
appearanceItems[i].selected.SetActive(false);
|
||||
if (unlockRod)
|
||||
{
|
||||
isEq = curRodSkinId == rodSkinDatas[i].ID;
|
||||
if (isEq)
|
||||
{
|
||||
curEqIndex = i;
|
||||
index = i;
|
||||
}
|
||||
isUnlock = skinId == rodID || playerFishData.IsSkinUnlocked(skinId);
|
||||
appearanceItems[i].unlock.SetActive(!isUnlock);
|
||||
isNew = playerFishData.IsNewSkin(skinId);
|
||||
appearanceItems[i].newGo.SetActive(isNew);
|
||||
appearanceItems[i].equipped.SetActive(isEq);
|
||||
}
|
||||
else
|
||||
{
|
||||
appearanceItems[i].newGo.SetActive(false);
|
||||
appearanceItems[i].unlock.SetActive(true);
|
||||
appearanceItems[i].equipped.SetActive(false);
|
||||
}
|
||||
}
|
||||
OnClickItem(index);
|
||||
}
|
||||
//void SetAccessories()
|
||||
//{
|
||||
// text_title.text = $"Outfit({accessoriesCount}/{curDataCount})";
|
||||
// for (int i = 0; i < curDataCount; i++)
|
||||
// {
|
||||
// appearanceItems[i].gameObject.SetActive(true);
|
||||
// uiService.SetImageSprite(appearanceItems[i].icon, rodAccessoriesDatas[i].Icon);
|
||||
// }
|
||||
// OnClickItem(0);
|
||||
//}
|
||||
#endregion 选中杆皮肤、手
|
||||
|
||||
#region 选中Item
|
||||
/// <summary>
|
||||
/// 选中列表中某个元素
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
void OnClickItem(int index)
|
||||
{
|
||||
if (curSubIndex == index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (curSubIndex >= 0)
|
||||
{
|
||||
appearanceItems[curSubIndex].selected.SetActive(false);
|
||||
}
|
||||
curSubIndex = index;
|
||||
appearanceItems[curSubIndex].selected.SetActive(true);
|
||||
appearanceItems[curSubIndex].newGo.SetActive(false);
|
||||
if (curDataCount > 0)
|
||||
{
|
||||
switch (curMainIndex)
|
||||
{
|
||||
case (int)RodSkinType.skin:
|
||||
OnSelectSkin();
|
||||
break;
|
||||
case (int)RodSkinType.glove:
|
||||
OnSelectGlove();
|
||||
break;
|
||||
//case (int)RodSkinType.accessories:
|
||||
// OnSelectAccessories();
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中某个皮肤
|
||||
/// </summary>
|
||||
void OnSelectSkin()
|
||||
{
|
||||
RodSkinData rodSkinData = rodSkinDatas[curSubIndex];
|
||||
text_name.text = LocalizationMgr.GetText(rodSkinData.Name_l10n_key);
|
||||
if (rodSkinData.ID == rodID)
|
||||
{
|
||||
text_waytoget.text = LocalizationMgr.GetText("UI_AppearancePanel_2");
|
||||
}
|
||||
else
|
||||
{
|
||||
text_waytoget.text = LocalizationMgr.GetText("UI_AppearancePanel_1");
|
||||
}
|
||||
if (unlockRod)
|
||||
{
|
||||
bool idHas = rodSkinData.ID == rodID || playerFishData.IsSkinUnlocked(rodSkinData.ID);
|
||||
if (!idHas)
|
||||
{
|
||||
ShowPack();
|
||||
}
|
||||
else
|
||||
{
|
||||
int curId = playerFishData.GetRodSkin(rodID);
|
||||
btn_equip.gameObject.SetActive(curId != rodSkinData.ID);
|
||||
equipped.gameObject.SetActive(curId == rodSkinData.ID);
|
||||
waytoget.SetActive(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowPack();
|
||||
}
|
||||
GContext.Publish(new SelectSkinEvent(rodSkinData.ID));
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中某个手
|
||||
/// </summary>
|
||||
void OnSelectGlove()
|
||||
{
|
||||
GloveData gloveData = gloveDatas[curSubIndex];
|
||||
text_name.text = LocalizationMgr.GetText(gloveData.Name_l10n_key);
|
||||
bool idHas = gloveData.ID == tables.TbGlobalConfig.InitGloveID || playerFishData.IsGloveUnlocked(gloveData.ID);
|
||||
if (!idHas)
|
||||
{
|
||||
text_waytoget.text = LocalizationMgr.GetText("UI_AppearancePanel_1");
|
||||
ShowPack();
|
||||
}
|
||||
else
|
||||
{
|
||||
int curId = playerFishData.rodAccessoriesData.GloveID;
|
||||
btn_equip.gameObject.SetActive(curId != gloveData.ID);
|
||||
equipped.gameObject.SetActive(curId == gloveData.ID);
|
||||
waytoget.SetActive(false);
|
||||
}
|
||||
GContext.Publish(new SelectGloveEvent(gloveData.ID));
|
||||
}
|
||||
/// <summary>
|
||||
/// 当没有解锁时
|
||||
/// </summary>
|
||||
void ShowPack()
|
||||
{
|
||||
btn_equip.gameObject.SetActive(false);
|
||||
btn_unequip.gameObject.SetActive(false);
|
||||
equipped.gameObject.SetActive(false);
|
||||
waytoget.SetActive(true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中某个挂件
|
||||
/// </summary>
|
||||
//void OnSelectAccessories()
|
||||
//{
|
||||
// RodAccessoriesData rodAccessoriesData = rodAccessoriesDatas[curSubIndex];
|
||||
// text_name.text = LocalizationMgr.GetText(rodAccessoriesData.Name_l10n_key);
|
||||
// //btn_equip.gameObject.SetActive(curId != rodSkinData.ID);
|
||||
// //btn_unequip.gameObject.SetActive(curId == rodSkinData.ID);
|
||||
// GContext.Publish(new SelectAccessoriesEvent(rodAccessoriesData.ID));
|
||||
//}
|
||||
#endregion 选中Item
|
||||
async void OnClickClose()
|
||||
{
|
||||
Addressables.Release(fishingSkinTool);
|
||||
UIManager.Instance.DestroyUI(UITypes.AppearancePanel);
|
||||
switch (appearanceOpenType)
|
||||
{
|
||||
case AppearanceOpenType.FishingRodPanel:
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodPanel);
|
||||
GContext.Publish(new MapShowEvent() { isShow = false });
|
||||
break;
|
||||
default:
|
||||
GContext.Publish(new RestartShowHomeUIEvent());
|
||||
GContext.Publish(new ActChangeRodDataEvent(GContext.container.Resolve<PlayerData>().equipRodID));
|
||||
break;
|
||||
}
|
||||
fishingBehavior.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void InitRodData()
|
||||
{
|
||||
RodData rod = tables.GetRodData(rodID);
|
||||
text_grade_rod.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePanel_2", playerFishData.GetRodLevel(rod.ID) + 1);
|
||||
text_star_rod.text = playerFishData.GetRodPiece(rod.ID).ToString();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(bg_hud_god_image, bg_hud_gods[rod.Quality - 1], "HomePanel");
|
||||
int skindID = GContext.container.Resolve<PlayerFishData>().GetRodSkin(rod.ID);
|
||||
if (skindID <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var fishRodSkinData = tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (fishRodSkinData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(rawImage, fishRodSkinData.Avatar, "HomePanel");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Appearance/AppearancePanel.cs.meta
Normal file
11
Assets/Scripts/UI/Appearance/AppearancePanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40f2a3c284f4f124d93e7b11da52f6c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/Scripts/UI/Appearance/AppearanceRodChangePanel.cs
Normal file
117
Assets/Scripts/UI/Appearance/AppearanceRodChangePanel.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AppearanceRodChangePanel : MonoBehaviour
|
||||
{
|
||||
Button btn_back;
|
||||
Button mask;
|
||||
Button btn_confrim;
|
||||
GameObject item;
|
||||
Transform Content;
|
||||
List<SkinRodItemData> rodItemDatas = new List<SkinRodItemData>();
|
||||
private SkinRodItem currentRodItem;
|
||||
public Action<int> OnChangeRod;
|
||||
public int rodId;
|
||||
private void Awake()
|
||||
{
|
||||
mask = transform.Find("root/mask").GetComponent<Button>();
|
||||
btn_back = transform.Find("root/btn_back/btn_green").GetComponent<Button>();
|
||||
btn_confrim = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
|
||||
Content = transform.Find("root/ScrollView/Viewport/Content");
|
||||
item = transform.Find("root/ScrollView/Viewport/Content/item").gameObject;
|
||||
item.SetActive(false);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
InitRodList();
|
||||
btn_back.onClick.AddListener(() =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
mask.onClick.AddListener(() =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
btn_confrim.onClick.AddListener(OnClickConfrim);
|
||||
}
|
||||
void OnClickConfrim()
|
||||
{
|
||||
OnChangeRod?.Invoke(currentRodItem.data.id);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
void InitRodList()
|
||||
{
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
var dataList = _tables.TbRodData.DataList;
|
||||
int count = dataList.Count;
|
||||
RodData _rodData;
|
||||
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_rodData = dataList[i];
|
||||
bool isLock = playerFishData.NotRod(dataList[i].ID);
|
||||
int level = playerFishData.GetRodLevel(_rodData.ID);
|
||||
int star = playerFishData.GetRodPiece(_rodData.ID);
|
||||
SkinRodItemData rodItemData = new SkinRodItemData()
|
||||
{
|
||||
id = _rodData.ID,
|
||||
quality = _rodData.Quality,
|
||||
isLock = isLock,
|
||||
level = level + 1,
|
||||
start = star,
|
||||
isEquiped = dataList[i].ID == rodId,
|
||||
ascendID = _rodData.AscendID,
|
||||
};
|
||||
int skindID = playerFishData.GetRodSkin(_rodData.ID);
|
||||
if (skindID > 0)
|
||||
{
|
||||
var fishRodSkinData = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (fishRodSkinData != null)
|
||||
{
|
||||
rodItemData.avatar = fishRodSkinData.Avatar;
|
||||
}
|
||||
}
|
||||
rodItemDatas.Add(rodItemData);
|
||||
}
|
||||
rodItemDatas.Sort(Sort);
|
||||
//bool isCheck = true;
|
||||
for (int i = 0; i < rodItemDatas.Count; i++)
|
||||
{
|
||||
GameObject go = Instantiate(item, Content);
|
||||
go.SetActive(true);
|
||||
SkinRodItem rodItem = go.AddComponent<SkinRodItem>();
|
||||
rodItem.Init(rodItemDatas[i]);
|
||||
rodItem.onClick = OnRodItemClick;
|
||||
if (rodItemDatas[i].isEquiped)
|
||||
{
|
||||
currentRodItem = rodItem;
|
||||
rodItem.SetSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
int Sort(SkinRodItemData a, SkinRodItemData b)
|
||||
{
|
||||
int levelA = a.isLock ? -1 : a.level;
|
||||
int levelB = b.isLock ? -1 : b.level;
|
||||
if (levelA == levelB)
|
||||
{
|
||||
return b.quality.CompareTo(a.quality);
|
||||
}
|
||||
return levelB.CompareTo(levelA);
|
||||
}
|
||||
void OnRodItemClick(SkinRodItem duelRodItem)
|
||||
{
|
||||
if (currentRodItem != null)
|
||||
{
|
||||
currentRodItem.SetSelected(false);
|
||||
}
|
||||
currentRodItem = duelRodItem;
|
||||
currentRodItem.SetSelected(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 206c90f8e67084a44b3d05071f3947fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/Scripts/UI/Appearance/SkinRodItem.cs
Normal file
99
Assets/Scripts/UI/Appearance/SkinRodItem.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SkinRodItem : MonoBehaviour
|
||||
{
|
||||
Image bg;
|
||||
Image img_icon;
|
||||
Button btn_item;
|
||||
GameObject mask_empty;
|
||||
TMP_Text text_level;
|
||||
GameObject selected;
|
||||
Transform star;
|
||||
List<GameObject> star_empty_list;
|
||||
List<Image> star_empty_image;
|
||||
List<StarItem> starList = new List<StarItem>();
|
||||
|
||||
public SkinRodItemData data;
|
||||
public Action<SkinRodItem> onClick;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
bg = transform.Find("rod/bg").GetComponent<Image>();
|
||||
img_icon = transform.Find("rod/img_map").GetComponent<Image>();
|
||||
btn_item = GetComponent<Button>();
|
||||
mask_empty = transform.Find("rod/mask_empty").gameObject;
|
||||
text_level = transform.Find("rod/text_level").GetComponent<TMP_Text>();
|
||||
|
||||
selected = transform.Find("selected").gameObject;
|
||||
|
||||
star = transform.Find("rod/star");
|
||||
star_empty_list = new List<GameObject>();
|
||||
star_empty_image = new List<Image>();
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
starList.Add(star.Find($"star/star{i}").GetComponent<StarItem>());
|
||||
star_empty_list.Add(star.Find($"star_empty/star{i}").gameObject);
|
||||
star_empty_image.Add(star.Find($"star_empty/star{i}/star").GetComponent<Image>());
|
||||
}
|
||||
SetSelected(false);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_item.onClick.AddListener(OnBtnItem);
|
||||
}
|
||||
|
||||
public void Init(SkinRodItemData _data)
|
||||
{
|
||||
IUIService uIService = GContext.container.Resolve<IUIService>();
|
||||
data = _data;
|
||||
mask_empty.SetActive(data.isLock);
|
||||
text_level.gameObject.SetActive(!data.isLock);
|
||||
star.gameObject.SetActive(!data.isLock);
|
||||
if (!data.isLock)
|
||||
{
|
||||
SetLevel();
|
||||
SetStar();
|
||||
}
|
||||
uIService.SetImageSprite(bg, Define.sp_rod_card[data.quality - 1], BasePanel.PanelName);
|
||||
uIService.SetImageSprite(img_icon, data.avatar, BasePanel.PanelName);
|
||||
}
|
||||
void OnBtnItem()
|
||||
{
|
||||
onClick?.Invoke(this);
|
||||
}
|
||||
|
||||
public void SetLevel()
|
||||
{
|
||||
text_level.gameObject.SetActive(!data.isLock);
|
||||
text_level.text = data.level.ToString();
|
||||
}
|
||||
void SetStar()
|
||||
{
|
||||
int star = data.start;
|
||||
var curRodAscend = GContext.container.Resolve<Tables>().TbRodAscend.GetOrDefault(data.ascendID);
|
||||
|
||||
PlayerFishData.SetRodStar(star, curRodAscend.MaxAscent, star_empty_list, star_empty_image, starList);
|
||||
}
|
||||
public void SetSelected(bool value)
|
||||
{
|
||||
selected.SetActive(value);
|
||||
}
|
||||
}
|
||||
public class SkinRodItemData
|
||||
{
|
||||
public int id;
|
||||
public int level;
|
||||
public int start;
|
||||
public string avatar;
|
||||
public bool isEquiped;
|
||||
public bool isLock;
|
||||
public int ascendID;
|
||||
public int quality;
|
||||
}
|
||||
11
Assets/Scripts/UI/Appearance/SkinRodItem.cs.meta
Normal file
11
Assets/Scripts/UI/Appearance/SkinRodItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a94807f6071f1f44ab80c64c8e6457bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user