【建造】工具类
parent
c44e84122e
commit
a76b0a2b53
|
@ -17,7 +17,7 @@ public class BuildBoot : MonoBehaviour
|
|||
/// <summary>
|
||||
/// 节点类
|
||||
/// </summary>
|
||||
public class Node
|
||||
private class Node
|
||||
{
|
||||
public string Name;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class BuildBoot : MonoBehaviour
|
|||
/// <summary>
|
||||
/// 选项类
|
||||
/// </summary>
|
||||
public class Option
|
||||
private class Option
|
||||
{
|
||||
public GameObject NodeObj;
|
||||
public GameObject OptionObj;
|
||||
|
@ -64,6 +64,9 @@ public class BuildBoot : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物品栏类
|
||||
/// </summary>
|
||||
private class BuildBar
|
||||
{
|
||||
private GameObject _bar;
|
||||
|
@ -135,6 +138,9 @@ public class BuildBoot : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物品栏Icon类
|
||||
/// </summary>
|
||||
private class BuildItem
|
||||
{
|
||||
private Button _btn;
|
||||
|
@ -195,7 +201,7 @@ public class BuildBoot : MonoBehaviour
|
|||
|
||||
private void Start()
|
||||
{
|
||||
UpdateUI();
|
||||
UpdateBuildDisplay();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
@ -205,6 +211,9 @@ public class BuildBoot : MonoBehaviour
|
|||
|
||||
#region Build相关
|
||||
|
||||
/// <summary>
|
||||
/// 初始化建造物数据
|
||||
/// </summary>
|
||||
private void InitBuildData()
|
||||
{
|
||||
_nodes = new Dictionary<string, Node>();
|
||||
|
@ -216,41 +225,10 @@ public class BuildBoot : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI相关
|
||||
|
||||
private void InitUI()
|
||||
{
|
||||
_btnClose = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiTop/BG_Top/Btn_Close").GetComponent<Button>();
|
||||
_btnClose.onClick.AddListener(CloseBuildPanel);
|
||||
|
||||
InitTipPanel();
|
||||
InitBuildBar();
|
||||
}
|
||||
|
||||
private void InitTipPanel()
|
||||
{
|
||||
_tipObj = transform.Find("UIRoot/UIMainBuild/Build_Tip").gameObject;
|
||||
_btnTipClose = _tipObj.transform.Find("Btn_Close").GetComponent<Button>();
|
||||
_btnTipGoGame = _tipObj.transform.Find("Btn_Game").GetComponent<Button>();
|
||||
_btnTipClose.onClick.AddListener(CloseTipPanel);
|
||||
_btnTipGoGame.onClick.AddListener(TipGoGame);
|
||||
}
|
||||
|
||||
private void InitBuildBar()
|
||||
{
|
||||
var bar = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiBottom/Build_Bar").gameObject;
|
||||
_buildBar = new BuildBar(bar);
|
||||
_btnBarClose = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiBottom/Build_Bar/Btn_Close")
|
||||
.GetComponent<Button>();
|
||||
_btnBarYes = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiBottom/Build_Bar/Btn_Yes").GetComponent<Button>();
|
||||
|
||||
_btnBarClose.onClick.AddListener(CloseBar);
|
||||
_btnBarYes.onClick.AddListener(YesBar);
|
||||
}
|
||||
|
||||
private void UpdateUI()
|
||||
/// <summary>
|
||||
/// 刷新建造物表现
|
||||
/// </summary>
|
||||
private void UpdateBuildDisplay()
|
||||
{
|
||||
foreach (var node in _nodes)
|
||||
{
|
||||
|
@ -273,16 +251,66 @@ public class BuildBoot : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI相关
|
||||
|
||||
/// <summary>
|
||||
/// 初始化UI
|
||||
/// </summary>
|
||||
private void InitUI()
|
||||
{
|
||||
_btnClose = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiTop/BG_Top/Btn_Close").GetComponent<Button>();
|
||||
_btnClose.onClick.AddListener(CloseBuildPanel);
|
||||
|
||||
InitTipPanel();
|
||||
InitBuildBar();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化上锁提示界面
|
||||
/// </summary>
|
||||
private void InitTipPanel()
|
||||
{
|
||||
_tipObj = transform.Find("UIRoot/UIMainBuild/Build_Tip").gameObject;
|
||||
_btnTipClose = _tipObj.transform.Find("Btn_Close").GetComponent<Button>();
|
||||
_btnTipGoGame = _tipObj.transform.Find("Btn_Game").GetComponent<Button>();
|
||||
_btnTipClose.onClick.AddListener(CloseTipPanel);
|
||||
_btnTipGoGame.onClick.AddListener(TipGoGame);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化物品栏
|
||||
/// </summary>
|
||||
private void InitBuildBar()
|
||||
{
|
||||
var bar = transform.Find("UIRoot/UIMainBuild/UI_LiuHaiBottom/Build_Bar").gameObject;
|
||||
_btnBarClose = bar.transform.Find("Btn_Close").GetComponent<Button>();
|
||||
_btnBarClose.onClick.AddListener(CloseBar);
|
||||
_btnBarYes = bar.transform.Find("Btn_Yes").GetComponent<Button>();
|
||||
_btnBarYes.onClick.AddListener(YesBar);
|
||||
_buildBar = new BuildBar(bar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭建造界面
|
||||
/// </summary>
|
||||
private void CloseBuildPanel()
|
||||
{
|
||||
GameStateManager.Instance.ChangeState(new GameStateStart(UIConstants.UIMainPanel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭提示界面
|
||||
/// </summary>
|
||||
private void CloseTipPanel()
|
||||
{
|
||||
_tipObj.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始游戏
|
||||
/// </summary>
|
||||
private void TipGoGame()
|
||||
{
|
||||
var levelID = $"level{LevelSelectManager.Instance.CurPassLevelIndex + 1}";
|
||||
|
@ -292,12 +320,18 @@ public class BuildBoot : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭物品栏
|
||||
/// </summary>
|
||||
private void CloseBar()
|
||||
{
|
||||
_buildBar.Close();
|
||||
_curBubble.SetActive(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存更改
|
||||
/// </summary>
|
||||
private void YesBar()
|
||||
{
|
||||
DebugUtil.LogError("保存更改");
|
||||
|
@ -306,11 +340,19 @@ public class BuildBoot : MonoBehaviour
|
|||
|
||||
#endregion
|
||||
|
||||
private void OnBuilItemClick(GameObject obj)
|
||||
#region 点击事件
|
||||
|
||||
/// <summary>
|
||||
/// 建造物节点点击
|
||||
/// </summary>
|
||||
private void OnBuildItemClick(GameObject obj)
|
||||
{
|
||||
DebugUtil.LogError("obj");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 泡泡点击
|
||||
/// </summary>
|
||||
private void OnBuildBubbleClick(GameObject obj)
|
||||
{
|
||||
_curBubble = obj;
|
||||
|
@ -327,11 +369,17 @@ public class BuildBoot : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解锁图标点击
|
||||
/// </summary>
|
||||
private void BuildIconClick()
|
||||
{
|
||||
DebugUtil.LogError("点击了图标");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 未解锁图标点击
|
||||
/// </summary>
|
||||
private void BuildLockIconClick()
|
||||
{
|
||||
DebugUtil.LogError("点击了上锁图标");
|
||||
|
@ -340,13 +388,15 @@ public class BuildBoot : MonoBehaviour
|
|||
|
||||
private void RegisterClickEvent()
|
||||
{
|
||||
InputManager.Instance.OnBuildItemClick += OnBuilItemClick;
|
||||
InputManager.Instance.OnBuildItemClick += OnBuildItemClick;
|
||||
InputManager.Instance.OnBuildBubbleClick += OnBuildBubbleClick;
|
||||
}
|
||||
|
||||
private void UnregisterClickEvent()
|
||||
{
|
||||
InputManager.Instance.OnBuildItemClick -= OnBuilItemClick;
|
||||
InputManager.Instance.OnBuildItemClick -= OnBuildItemClick;
|
||||
InputManager.Instance.OnBuildBubbleClick -= OnBuildBubbleClick;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameBuild
|
||||
{
|
||||
public static class GameBuildUtils
|
||||
{
|
||||
public static int ExtractNumber(string input)
|
||||
{
|
||||
var str = input;
|
||||
int lastIndex = input.LastIndexOf('_');
|
||||
if (lastIndex != -1 && lastIndex < input.Length - 1)
|
||||
{
|
||||
str = input.Substring(lastIndex + 1);
|
||||
}
|
||||
|
||||
Match match = Regex.Match(str, @"\d+");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
return int.Parse(match.Value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 78df10e0d84464c68800c006f61d2d4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue