【建造】选择切换表现
parent
0451039a5f
commit
54247e110c
|
@ -760,7 +760,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 7644366489302203207, guid: e9c96c211fb08417084dbd9a3f85ab3c,
|
- target: {fileID: 7644366489302203207, guid: e9c96c211fb08417084dbd9a3f85ab3c,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_text
|
propertyPath: m_text
|
||||||
value: Build_Game
|
value: Start Game
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8263868880915436829, guid: e9c96c211fb08417084dbd9a3f85ab3c,
|
- target: {fileID: 8263868880915436829, guid: e9c96c211fb08417084dbd9a3f85ab3c,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
@ -770,7 +770,9 @@ PrefabInstance:
|
||||||
- target: {fileID: 8779257074991400646, guid: e9c96c211fb08417084dbd9a3f85ab3c,
|
- target: {fileID: 8779257074991400646, guid: e9c96c211fb08417084dbd9a3f85ab3c,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_text
|
propertyPath: m_text
|
||||||
value: Build_Tip
|
value: 'Not yet unlocked
|
||||||
|
|
||||||
|
Go explore more levels!'
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
|
@ -1541,7 +1543,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 9b618b5bdf3884745b8cccd94ea6fcf1, type: 3}
|
m_Script: {fileID: 11500000, guid: 9b618b5bdf3884745b8cccd94ea6fcf1, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
CurCondition: 50
|
CurCondition: 0
|
||||||
--- !u!1 &655320739
|
--- !u!1 &655320739
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -4099,7 +4101,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 1919860221}
|
m_GameObject: {fileID: 1919860221}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: -0.4, y: 0.41, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
|
@ -4730,7 +4732,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 2135953382}
|
m_GameObject: {fileID: 2135953382}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: -0.09, y: -0.26, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
using TMPro;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using UnityEngine;
|
||||||
using Framework.Constants;
|
|
||||||
using Framework.Manager;
|
|
||||||
using Gameplay.Game;
|
using Gameplay.Game;
|
||||||
|
using UnityEngine.UI;
|
||||||
using Gameplay.Level;
|
using Gameplay.Level;
|
||||||
using Gameplay.Manager;
|
using Gameplay.Manager;
|
||||||
|
using Framework.Manager;
|
||||||
|
using Framework.Constants;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using TMPro;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using LC.Google.Protobuf.WellKnownTypes;
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class BuildBoot : MonoBehaviour
|
public class BuildBoot : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
@ -25,19 +26,18 @@ public class BuildBoot : MonoBehaviour
|
||||||
|
|
||||||
public GameObject BubbleObj;
|
public GameObject BubbleObj;
|
||||||
|
|
||||||
public List<Option> Options;
|
public Dictionary<string, Option> Options;
|
||||||
|
|
||||||
public Node(GameObject root)
|
public Node(GameObject root)
|
||||||
{
|
{
|
||||||
Name = root.name;
|
Name = root.name;
|
||||||
Options = new List<Option>();
|
Options = new Dictionary<string, Option>();
|
||||||
foreach (Transform child in root.transform)
|
foreach (Transform child in root.transform)
|
||||||
{
|
{
|
||||||
if (!child.gameObject.name.Equals("Btn"))
|
if (!child.gameObject.name.Equals("Btn"))
|
||||||
{
|
{
|
||||||
//DebugUtil.LogError("当前节点{0}有选项{1}", root.gameObject.name, child.gameObject.name);
|
|
||||||
var option = new Option(child.gameObject);
|
var option = new Option(child.gameObject);
|
||||||
Options.Add(option);
|
Options.Add(child.gameObject.name, option);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,22 @@ public class BuildBoot : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Option GetOption(string optionName)
|
||||||
|
{
|
||||||
|
return Options.GetValueOrDefault(optionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭其他选项表现
|
||||||
|
/// </summary>
|
||||||
|
public void OptionDisplay(Option option)
|
||||||
|
{
|
||||||
|
foreach (var optionInfo in Options.Values)
|
||||||
|
{
|
||||||
|
optionInfo.SetOptionActive(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -52,16 +68,23 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class Option
|
private class Option
|
||||||
{
|
{
|
||||||
|
public string Name;
|
||||||
public GameObject NodeObj;
|
public GameObject NodeObj;
|
||||||
public GameObject OptionObj;
|
public GameObject OptionObj;
|
||||||
public GameObject NormalObj;
|
public GameObject NormalObj;
|
||||||
|
|
||||||
public Option(GameObject root)
|
public Option(GameObject root)
|
||||||
{
|
{
|
||||||
|
Name = root.name;
|
||||||
NodeObj = root.transform.parent.gameObject;
|
NodeObj = root.transform.parent.gameObject;
|
||||||
OptionObj = root;
|
OptionObj = root;
|
||||||
NormalObj = root.transform.Find("Normal").gameObject;
|
NormalObj = root.transform.Find("Normal").gameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetOptionActive(Option option)
|
||||||
|
{
|
||||||
|
OptionObj.SetActive(Name.Equals(option.Name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -70,59 +93,65 @@ public class BuildBoot : MonoBehaviour
|
||||||
private class BuildBar
|
private class BuildBar
|
||||||
{
|
{
|
||||||
private GameObject _bar;
|
private GameObject _bar;
|
||||||
public Dictionary<string, BuildItem> buildItem;
|
private Dictionary<string, BuildItem> _buildItem;
|
||||||
private Dictionary<string, Transform> itemTrans;
|
private Dictionary<string, Transform> _itemTrans;
|
||||||
private TMP_Text _condition;
|
private TMP_Text _condition;
|
||||||
private const string ContentPath = "Bar_Tip/Scroll View/Viewport/Content";
|
private const string ContentPath = "Bar_Tip/Scroll View/Viewport/Content";
|
||||||
private const string IconItemTemplate = "Bar_Tip/Scroll View/Viewport/Content/Item";
|
private const string IconItemTemplate = "Bar_Tip/Scroll View/Viewport/Content/Item";
|
||||||
private const string TipPath = "Bar_Tip";
|
private const string TipPath = "Bar_Tip";
|
||||||
private const string ConditionText = "Level\n{0}/{1}";
|
private const string ConditionText = "Level\n{0}/{1}";
|
||||||
private const string ItemName = "Item{0}";
|
private const string ItemName = "Item{0}";
|
||||||
|
private Action<Option> _optionCallBack;
|
||||||
|
|
||||||
public BuildBar(GameObject root)
|
public BuildBar(GameObject root)
|
||||||
{
|
{
|
||||||
_bar = root;
|
_bar = root;
|
||||||
_condition = root.transform.Find(TipPath).GetComponent<TMP_Text>();
|
_condition = root.transform.Find(TipPath).GetComponent<TMP_Text>();
|
||||||
buildItem = new Dictionary<string, BuildItem>();
|
_buildItem = new Dictionary<string, BuildItem>();
|
||||||
itemTrans = new Dictionary<string, Transform>();
|
_itemTrans = new Dictionary<string, Transform>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Open(Node node, Action callBack, Action lockCallBack, int reachCondition, int condition)
|
public void Open(Node node, Action<Option> callBack, Action lockCallBack, int reachCondition, int condition)
|
||||||
{
|
{
|
||||||
|
_optionCallBack = callBack;
|
||||||
_bar.SetActive(true);
|
_bar.SetActive(true);
|
||||||
_condition.text = string.Format(ConditionText, reachCondition, condition);
|
_condition.text = string.Format(ConditionText, reachCondition, condition);
|
||||||
var content = _bar.transform.Find(ContentPath);
|
var content = _bar.transform.Find(ContentPath);
|
||||||
var iconTemplate = _bar.transform.Find(IconItemTemplate);
|
var iconTemplate = _bar.transform.Find(IconItemTemplate);
|
||||||
|
|
||||||
buildItem.Clear();
|
_buildItem.Clear();
|
||||||
|
var index = 1;
|
||||||
for (var i = 0; i < node.Options.Count; i++)
|
foreach (var option in node.Options)
|
||||||
{
|
{
|
||||||
var optionName = node.Options[i].OptionObj.name;
|
var optionName = option.Value.OptionObj.name;
|
||||||
var iconName = string.Format(ItemName, i + 1);
|
var iconName = string.Format(ItemName, index);
|
||||||
if (!itemTrans.TryGetValue(iconName, out var iconItem))
|
if (!_itemTrans.TryGetValue(iconName, out var iconItem))
|
||||||
{
|
{
|
||||||
iconItem = Instantiate(iconTemplate, content);
|
iconItem = Instantiate(iconTemplate, content);
|
||||||
iconItem.name = iconName;
|
iconItem.name = iconName;
|
||||||
itemTrans.Add(iconName, iconItem);
|
_itemTrans.Add(iconName, iconItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
iconItem.gameObject.SetActive(true);
|
iconItem.gameObject.SetActive(true);
|
||||||
var sprite = BuildManager.Instance.GetOptionIcon(node.Name, optionName);
|
var sprite = BuildManager.Instance.GetOptionIcon(node.Name, optionName);
|
||||||
var item = new BuildItem(iconItem.gameObject);
|
var unlock = reachCondition >= condition;
|
||||||
buildItem.Add(optionName, item);
|
var item = new BuildItem(iconItem.gameObject, option.Value);
|
||||||
item.SetInfo(sprite, () =>
|
_buildItem.Add(optionName, item);
|
||||||
{
|
item.SetInfo(sprite, unlock, ItemCallBack, lockCallBack);
|
||||||
callBack?.Invoke();
|
index++;
|
||||||
PickItemDisplay(optionName);
|
|
||||||
}, lockCallBack);
|
|
||||||
//DebugUtil.Log("Bar添加物品Icon:{0}", iconItem.name);
|
//DebugUtil.Log("Bar添加物品Icon:{0}", iconItem.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PickItemDisplay(string optionName)
|
private void ItemCallBack(Option option)
|
||||||
{
|
{
|
||||||
foreach (var item in buildItem)
|
_optionCallBack?.Invoke(option);
|
||||||
|
PickItemDisplay(option.OptionObj.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PickItemDisplay(string optionName)
|
||||||
|
{
|
||||||
|
foreach (var item in _buildItem)
|
||||||
{
|
{
|
||||||
item.Value.SetPickActive(item.Key.Equals(optionName));
|
item.Value.SetPickActive(item.Key.Equals(optionName));
|
||||||
}
|
}
|
||||||
|
@ -131,7 +160,7 @@ public class BuildBoot : MonoBehaviour
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
_bar.SetActive(false);
|
_bar.SetActive(false);
|
||||||
foreach (var item in buildItem)
|
foreach (var item in _buildItem)
|
||||||
{
|
{
|
||||||
item.Value.SetPickActive(false);
|
item.Value.SetPickActive(false);
|
||||||
}
|
}
|
||||||
|
@ -143,14 +172,16 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class BuildItem
|
private class BuildItem
|
||||||
{
|
{
|
||||||
|
public Option Option;
|
||||||
private Button _btn;
|
private Button _btn;
|
||||||
private Button _lockBtn;
|
private Button _lockBtn;
|
||||||
private Image _imgIcon;
|
private Image _imgIcon;
|
||||||
private GameObject _lock;
|
private GameObject _lock;
|
||||||
private GameObject _imgPick;
|
private GameObject _imgPick;
|
||||||
|
|
||||||
public BuildItem(GameObject root)
|
public BuildItem(GameObject root, Option option)
|
||||||
{
|
{
|
||||||
|
this.Option = option;
|
||||||
_btn = root.transform.Find("Img_Item").GetComponent<Button>();
|
_btn = root.transform.Find("Img_Item").GetComponent<Button>();
|
||||||
_imgIcon = root.transform.Find("Img_Item").GetComponent<Image>();
|
_imgIcon = root.transform.Find("Img_Item").GetComponent<Image>();
|
||||||
_lock = root.transform.Find("Img_Lock").gameObject;
|
_lock = root.transform.Find("Img_Lock").gameObject;
|
||||||
|
@ -158,15 +189,17 @@ public class BuildBoot : MonoBehaviour
|
||||||
_imgPick = root.transform.Find("Bg_Pick").gameObject;
|
_imgPick = root.transform.Find("Bg_Pick").gameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetInfo(Sprite sprite, Action callBack, Action lockCallBack)
|
public void SetInfo(Sprite sprite, bool unlock, Action<Option> callBack, Action lockCallBack)
|
||||||
{
|
{
|
||||||
|
_lock.SetActive(!unlock);
|
||||||
_btn.onClick.RemoveAllListeners();
|
_btn.onClick.RemoveAllListeners();
|
||||||
_btn.onClick.AddListener(() => { callBack?.Invoke(); });
|
_btn.onClick.AddListener(() => { callBack?.Invoke(Option); });
|
||||||
_lockBtn.onClick.RemoveAllListeners();
|
_lockBtn.onClick.RemoveAllListeners();
|
||||||
_lockBtn.onClick.AddListener(() => { lockCallBack?.Invoke(); });
|
_lockBtn.onClick.AddListener(() => { lockCallBack?.Invoke(); });
|
||||||
_imgIcon.sprite = sprite;
|
_imgIcon.sprite = sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetPickActive(bool pick)
|
public void SetPickActive(bool pick)
|
||||||
{
|
{
|
||||||
_imgPick.SetActive(pick);
|
_imgPick.SetActive(pick);
|
||||||
|
@ -184,6 +217,10 @@ public class BuildBoot : MonoBehaviour
|
||||||
//当前点击的泡泡按钮
|
//当前点击的泡泡按钮
|
||||||
private GameObject _curBubble;
|
private GameObject _curBubble;
|
||||||
|
|
||||||
|
//当前选择的选项
|
||||||
|
private Option _curOption;
|
||||||
|
private Node _curNode;
|
||||||
|
|
||||||
//当前节点字典
|
//当前节点字典
|
||||||
private Dictionary<string, Node> _nodes;
|
private Dictionary<string, Node> _nodes;
|
||||||
|
|
||||||
|
@ -192,6 +229,10 @@ public class BuildBoot : MonoBehaviour
|
||||||
private Button _btnTipGoGame;
|
private Button _btnTipGoGame;
|
||||||
private Button _btnTipClose;
|
private Button _btnTipClose;
|
||||||
|
|
||||||
|
//遮罩
|
||||||
|
private GameObject _mask;
|
||||||
|
private bool _isChanging;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
RegisterClickEvent();
|
RegisterClickEvent();
|
||||||
|
@ -230,6 +271,7 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateBuildDisplay()
|
private void UpdateBuildDisplay()
|
||||||
{
|
{
|
||||||
|
//TODO 加载玩家选择节点
|
||||||
foreach (var node in _nodes)
|
foreach (var node in _nodes)
|
||||||
{
|
{
|
||||||
if (BuildManager.Instance.NodeInfos.TryGetValue(node.Key, out var nodeInfo))
|
if (BuildManager.Instance.NodeInfos.TryGetValue(node.Key, out var nodeInfo))
|
||||||
|
@ -242,7 +284,7 @@ public class BuildBoot : MonoBehaviour
|
||||||
{
|
{
|
||||||
foreach (var option in node.Value.Options)
|
foreach (var option in node.Value.Options)
|
||||||
{
|
{
|
||||||
option.NormalObj.SetActive(false);
|
option.Value.NormalObj.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +305,8 @@ public class BuildBoot : MonoBehaviour
|
||||||
_btnClose = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiTop/BG_Top/Btn_Close").GetComponent<Button>();
|
_btnClose = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiTop/BG_Top/Btn_Close").GetComponent<Button>();
|
||||||
_btnClose.onClick.AddListener(CloseBuildPanel);
|
_btnClose.onClick.AddListener(CloseBuildPanel);
|
||||||
|
|
||||||
|
_mask = transform.Find("UIRoot/UIMainBuild/Mask").gameObject;
|
||||||
|
|
||||||
InitTipPanel();
|
InitTipPanel();
|
||||||
InitBuildBar();
|
InitBuildBar();
|
||||||
}
|
}
|
||||||
|
@ -325,8 +369,16 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CloseBar()
|
private void CloseBar()
|
||||||
{
|
{
|
||||||
|
_isChanging = false;
|
||||||
_buildBar.Close();
|
_buildBar.Close();
|
||||||
|
_mask.SetActive(false);
|
||||||
|
if (_curBubble != null)
|
||||||
_curBubble.SetActive(true);
|
_curBubble.SetActive(true);
|
||||||
|
//放弃修改
|
||||||
|
if (_curNode == null || _curOption == null) return;
|
||||||
|
_curNode.OptionDisplay(_curOption);
|
||||||
|
_curNode = null;
|
||||||
|
_curOption = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -334,8 +386,12 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void YesBar()
|
private void YesBar()
|
||||||
{
|
{
|
||||||
DebugUtil.LogError("保存更改");
|
_isChanging = false;
|
||||||
|
_mask.SetActive(false);
|
||||||
_buildBar.Close();
|
_buildBar.Close();
|
||||||
|
|
||||||
|
if (_curNode == null || _curOption == null) return;
|
||||||
|
//TODO 保存至本地
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -347,7 +403,26 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnBuildItemClick(GameObject obj)
|
private void OnBuildItemClick(GameObject obj)
|
||||||
{
|
{
|
||||||
DebugUtil.LogError("obj");
|
if (_isChanging) return;
|
||||||
|
_isChanging = true;
|
||||||
|
_mask.SetActive(true);
|
||||||
|
|
||||||
|
var optionObj = obj.transform.parent.gameObject;
|
||||||
|
var nodeName = optionObj.transform.parent.name;
|
||||||
|
var optionName = optionObj.name;
|
||||||
|
|
||||||
|
if (_nodes.TryGetValue(nodeName, out var node))
|
||||||
|
{
|
||||||
|
_curNode = node;
|
||||||
|
_curOption = node.GetOption(optionName);
|
||||||
|
var condition = BuildManager.Instance.GetCondition(nodeName);
|
||||||
|
_buildBar.Open(node, BuildIconClick, BuildLockIconClick, CurCondition, condition);
|
||||||
|
_buildBar.PickItemDisplay(optionName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugUtil.LogError("节点获取信息错误: {0}", nodeName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -355,6 +430,9 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnBuildBubbleClick(GameObject obj)
|
private void OnBuildBubbleClick(GameObject obj)
|
||||||
{
|
{
|
||||||
|
if (_isChanging) return;
|
||||||
|
_isChanging = true;
|
||||||
|
_mask.SetActive(true);
|
||||||
_curBubble = obj;
|
_curBubble = obj;
|
||||||
obj.SetActive(false);
|
obj.SetActive(false);
|
||||||
var nodeName = obj.transform.parent.name;
|
var nodeName = obj.transform.parent.name;
|
||||||
|
@ -372,9 +450,19 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解锁图标点击
|
/// 解锁图标点击
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void BuildIconClick()
|
private void BuildIconClick(Option option)
|
||||||
{
|
{
|
||||||
DebugUtil.LogError("点击了图标");
|
var nodeName = option.NodeObj.name;
|
||||||
|
//切换UI表现
|
||||||
|
if (_nodes.TryGetValue(nodeName, out var node))
|
||||||
|
{
|
||||||
|
foreach (var optionInfo in node.Options.Values)
|
||||||
|
{
|
||||||
|
optionInfo.OptionObj.SetActive(option.Name.Equals(optionInfo.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//DebugUtil.LogError("点击了{0}节点的{1}选项", nodeName, option.OptionObj.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -382,6 +470,7 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void BuildLockIconClick()
|
private void BuildLockIconClick()
|
||||||
{
|
{
|
||||||
|
_mask.SetActive(true);
|
||||||
DebugUtil.LogError("点击了上锁图标");
|
DebugUtil.LogError("点击了上锁图标");
|
||||||
_tipObj.SetActive(true);
|
_tipObj.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using Framework.GameBuild;
|
|
||||||
using PhxhSDK;
|
using PhxhSDK;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Framework.GameBuild;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using UnityEditor;
|
using System.Collections.Generic;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
|
||||||
namespace Framework.Manager
|
namespace Framework.Manager
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@ namespace Framework.Manager
|
||||||
public int ID;
|
public int ID;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
public string IconPath;
|
public string IconName;
|
||||||
|
|
||||||
//按主题解锁条件
|
//按主题解锁条件
|
||||||
public int Condition;
|
public int Condition;
|
||||||
|
@ -94,7 +94,11 @@ namespace Framework.Manager
|
||||||
|
|
||||||
public class BuildManager
|
public class BuildManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前选择
|
||||||
|
/// </summary>
|
||||||
private const string NodeName = "Node{0}";
|
private const string NodeName = "Node{0}";
|
||||||
|
|
||||||
private const string OptionName = "Option{0}";
|
private const string OptionName = "Option{0}";
|
||||||
|
|
||||||
private static BuildManager _instance;
|
private static BuildManager _instance;
|
||||||
|
@ -115,6 +119,9 @@ namespace Framework.Manager
|
||||||
|
|
||||||
public Dictionary<string, NodeInfo> NodeInfos;
|
public Dictionary<string, NodeInfo> NodeInfos;
|
||||||
|
|
||||||
|
//动态加载的图标
|
||||||
|
private Dictionary<string, Sprite> _iconSprites;
|
||||||
|
|
||||||
private BuildData _curBuildData;
|
private BuildData _curBuildData;
|
||||||
private bool _isInit;
|
private bool _isInit;
|
||||||
private bool _isInGame;
|
private bool _isInGame;
|
||||||
|
@ -122,7 +129,9 @@ namespace Framework.Manager
|
||||||
public void Init(BuildData buildData, bool inGame = true)
|
public void Init(BuildData buildData, bool inGame = true)
|
||||||
{
|
{
|
||||||
if (_isInit) return;
|
if (_isInit) return;
|
||||||
|
|
||||||
NodeInfos = new Dictionary<string, NodeInfo>();
|
NodeInfos = new Dictionary<string, NodeInfo>();
|
||||||
|
_iconSprites = new Dictionary<string, Sprite>();
|
||||||
_curBuildData = buildData;
|
_curBuildData = buildData;
|
||||||
foreach (var node in buildData.nodeInfos)
|
foreach (var node in buildData.nodeInfos)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +150,7 @@ namespace Framework.Manager
|
||||||
ID = index,
|
ID = index,
|
||||||
Name = option
|
Name = option
|
||||||
};
|
};
|
||||||
optionInfo.IconPath = InitOptionIconPath(node.IconPath, index);
|
|
||||||
nodeInfo.Options.Add(option, optionInfo);
|
nodeInfo.Options.Add(option, optionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,9 +158,23 @@ namespace Framework.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
InitCondition();
|
InitCondition();
|
||||||
|
InitIcon();
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void InitIcon()
|
||||||
|
{
|
||||||
|
foreach (var nodeInfo in NodeInfos.Values)
|
||||||
|
{
|
||||||
|
foreach (var optionInfo in nodeInfo.Options.Values)
|
||||||
|
{
|
||||||
|
var index = GameBuildUtils.ExtractNumber(optionInfo.Name);
|
||||||
|
|
||||||
|
optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化条件
|
/// 初始化条件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -167,7 +190,7 @@ namespace Framework.Manager
|
||||||
if (NodeInfos.TryGetValue(nodeName, out var nodeInfo))
|
if (NodeInfos.TryGetValue(nodeName, out var nodeInfo))
|
||||||
{
|
{
|
||||||
nodeInfo.Condition = unlockInfo.condition;
|
nodeInfo.Condition = unlockInfo.condition;
|
||||||
DebugUtil.LogError("挂点解锁:节点{0}的解锁条件是:{1}", nodeInfo.Name, unlockInfo.condition);
|
//DebugUtil.LogError("挂点解锁:节点{0}的解锁条件是:{1}", nodeInfo.Name, unlockInfo.condition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +222,7 @@ namespace Framework.Manager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得选项对应的Icon路径
|
/// 获得选项对应的Icon路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private string InitOptionIconPath(string iconsPath, int index)
|
private async UniTask<string> InitOptionIcon(string iconsPath, int index)
|
||||||
{
|
{
|
||||||
var fileEntries = Directory.GetFiles(iconsPath, "*.png");
|
var fileEntries = Directory.GetFiles(iconsPath, "*.png");
|
||||||
foreach (var filePath in fileEntries)
|
foreach (var filePath in fileEntries)
|
||||||
|
@ -209,7 +232,9 @@ namespace Framework.Manager
|
||||||
if (GameBuildUtils.ExtractNumber(name) == index)
|
if (GameBuildUtils.ExtractNumber(name) == index)
|
||||||
{
|
{
|
||||||
var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/');
|
var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/');
|
||||||
return assetPath;
|
var sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(assetPath);
|
||||||
|
_iconSprites.TryAdd(name, sprite);
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,8 +250,7 @@ namespace Framework.Manager
|
||||||
{
|
{
|
||||||
if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo))
|
if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo))
|
||||||
{
|
{
|
||||||
var sprite = AssetManager.Instance.LoadAsset<Sprite>(optionInfo.IconPath);
|
if (_iconSprites.TryGetValue(optionInfo.IconName, out var sprite))
|
||||||
if (sprite != null)
|
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue