【建造】顺序解锁泡泡按钮
parent
566454bc66
commit
9268d2197d
|
@ -74,21 +74,21 @@ public class GameBuildWindow : OdinEditorWindow
|
||||||
private void LoadBuildData(BuildData buildData)
|
private void LoadBuildData(BuildData buildData)
|
||||||
{
|
{
|
||||||
_curWindow.curBuildData = buildData;
|
_curWindow.curBuildData = buildData;
|
||||||
curBuildData.BuildID = GameBuildUtils.GetFileNameWithoutExtension(_buildEditor.BuildDataJson.name);
|
curBuildData.buildID = GameBuildUtils.GetFileNameWithoutExtension(_buildEditor.BuildDataJson.name);
|
||||||
var root = GameObject.Find(NodeRootPath);
|
var root = GameObject.Find(NodeRootPath);
|
||||||
if (buildData.nodeInfos == null)
|
if (buildData.NodeInfos == null)
|
||||||
{
|
{
|
||||||
DebugUtil.LogError("需要重启该场景");
|
DebugUtil.LogError("需要重启该场景");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
editorNodes = new List<NodeEditor>(buildData.nodeCount);
|
editorNodes = new List<NodeEditor>(buildData.nodeCount);
|
||||||
foreach (var node in buildData.nodeInfos)
|
foreach (var node in buildData.NodeInfos)
|
||||||
{
|
{
|
||||||
var nodeObj = root.transform.Find(node.name).gameObject;
|
var nodeObj = root.transform.Find(node.Name).gameObject;
|
||||||
if (nodeObj != null)
|
if (nodeObj != null)
|
||||||
{
|
{
|
||||||
var editorNode = new NodeEditor(node.name, buildData.thematicCount);
|
var editorNode = new NodeEditor(node.Name, buildData.thematicCount);
|
||||||
foreach (Transform child in nodeObj.transform)
|
foreach (Transform child in nodeObj.transform)
|
||||||
{
|
{
|
||||||
if (!child.gameObject.name.Equals(BtnBubble))
|
if (!child.gameObject.name.Equals(BtnBubble))
|
||||||
|
@ -142,11 +142,11 @@ public class GameBuildWindow : OdinEditorWindow
|
||||||
private void InitBuildInfo(int count)
|
private void InitBuildInfo(int count)
|
||||||
{
|
{
|
||||||
//挂点初始化
|
//挂点初始化
|
||||||
curBuildData.nodeInfos = new List<BuildData.BuildNode>(curBuildData.nodeCount);
|
curBuildData.NodeInfos = new List<BuildData.BuildNode>(curBuildData.nodeCount);
|
||||||
for (int i = 0; i < curBuildData.nodeCount; i++)
|
for (int i = 0; i < curBuildData.nodeCount; i++)
|
||||||
{
|
{
|
||||||
var node = new BuildData.BuildNode(string.Format(NodeName, i + 1));
|
var node = new BuildData.BuildNode(string.Format(NodeName, i + 1));
|
||||||
curBuildData.nodeInfos.Add(node);
|
curBuildData.NodeInfos.Add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
//解锁条件初始化
|
//解锁条件初始化
|
||||||
|
@ -169,25 +169,25 @@ public class GameBuildWindow : OdinEditorWindow
|
||||||
var root = GameObject.Find(NodeRootPath);
|
var root = GameObject.Find(NodeRootPath);
|
||||||
editorNodes = new List<NodeEditor>(curBuildData.nodeCount);
|
editorNodes = new List<NodeEditor>(curBuildData.nodeCount);
|
||||||
var nodeTemplate = AssetDatabase.LoadAssetAtPath<GameObject>(NodeTemplatePath);
|
var nodeTemplate = AssetDatabase.LoadAssetAtPath<GameObject>(NodeTemplatePath);
|
||||||
foreach (var node in curBuildData.nodeInfos)
|
foreach (var node in curBuildData.NodeInfos)
|
||||||
{
|
{
|
||||||
//生成节点
|
//生成节点
|
||||||
var nodeObj = Instantiate(nodeTemplate, root.transform);
|
var nodeObj = Instantiate(nodeTemplate, root.transform);
|
||||||
nodeObj.name = node.name;
|
nodeObj.name = node.Name;
|
||||||
_tempNodeObj.Add(nodeObj);
|
_tempNodeObj.Add(nodeObj);
|
||||||
|
|
||||||
//生成选项
|
//生成选项
|
||||||
|
|
||||||
node.options = new List<string>(curBuildData.thematicCount);
|
node.Options = new List<string>(curBuildData.thematicCount);
|
||||||
|
|
||||||
var optionTemplate = nodeObj.transform.Find(OptionTemplatePath).gameObject;
|
var optionTemplate = nodeObj.transform.Find(OptionTemplatePath).gameObject;
|
||||||
var tempEditorNode = new NodeEditor(node.name, curBuildData.thematicCount);
|
var tempEditorNode = new NodeEditor(node.Name, curBuildData.thematicCount);
|
||||||
for (int i = 0; i < curBuildData.thematicCount; i++)
|
for (int i = 0; i < curBuildData.thematicCount; i++)
|
||||||
{
|
{
|
||||||
var optionObj = Instantiate(optionTemplate, nodeObj.transform);
|
var optionObj = Instantiate(optionTemplate, nodeObj.transform);
|
||||||
optionObj.name = string.Format(OptionName, i + 1);
|
optionObj.name = string.Format(OptionName, i + 1);
|
||||||
tempEditorNode.optionObj.Add(optionObj);
|
tempEditorNode.optionObj.Add(optionObj);
|
||||||
node.options.Add(optionObj.name);
|
node.Options.Add(optionObj.name);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
optionObj.SetActive(false);
|
optionObj.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,7 +810,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 361927967}
|
m_GameObject: {fileID: 361927967}
|
||||||
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, y: -0.08, 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:
|
||||||
|
@ -1501,7 +1501,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!4 &602695269
|
--- !u!4 &602695269
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1566,7 +1566,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: 21
|
CurCondition: 90
|
||||||
--- !u!1 &655320739
|
--- !u!1 &655320739
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3378,7 +3378,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 1318959386}
|
m_GameObject: {fileID: 1318959386}
|
||||||
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, y: -0.078, 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:
|
||||||
|
@ -3816,7 +3816,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 1518559024}
|
m_GameObject: {fileID: 1518559024}
|
||||||
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.606, y: 0.486, z: 0}
|
m_LocalPosition: {x: -0.606, y: 0.56, 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:
|
||||||
|
@ -4274,7 +4274,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.07, z: 0}
|
m_LocalPosition: {x: 0, y: -0.203, 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:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 7d19a6fd60cc848fb99936d7127ae027
|
guid: 5dd3492a2616e404cbfb904bd8d05590
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Gameplay.Game;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Gameplay.Level;
|
using Gameplay.Level;
|
||||||
using Gameplay.Manager;
|
using Gameplay.Manager;
|
||||||
using Framework.Manager;
|
using Framework.Manager;
|
||||||
using Framework.Constants;
|
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
@ -294,6 +292,7 @@ public class BuildBoot : MonoBehaviour
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nextLockNode = BuildManager.Instance.GetNextLockNode(CurCondition);
|
||||||
foreach (var chooseNode in chooseNodeInfo)
|
foreach (var chooseNode in chooseNodeInfo)
|
||||||
{
|
{
|
||||||
if (_nodes.TryGetValue(chooseNode.Key, out var node))
|
if (_nodes.TryGetValue(chooseNode.Key, out var node))
|
||||||
|
@ -306,8 +305,7 @@ public class BuildBoot : MonoBehaviour
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO 顺序节点
|
node.CloseAllOptionButBubble(node.Name.Equals(nextLockNode));
|
||||||
node.CloseAllOptionButBubble(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,7 +442,6 @@ public class BuildBoot : MonoBehaviour
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描边展示
|
/// 描边展示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="option"></param>
|
|
||||||
private void ChangePickItem(Option option)
|
private void ChangePickItem(Option option)
|
||||||
{
|
{
|
||||||
if (option == null) return;
|
if (option == null) return;
|
||||||
|
|
|
@ -2,10 +2,11 @@ using System;
|
||||||
using PhxhSDK;
|
using PhxhSDK;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.Linq;
|
||||||
using Framework.GameBuild;
|
using Framework.GameBuild;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Framework.Manager
|
namespace Framework.Manager
|
||||||
{
|
{
|
||||||
|
@ -32,13 +33,13 @@ namespace Framework.Manager
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BuildData
|
public class BuildData
|
||||||
{
|
{
|
||||||
[ReadOnly] public string BuildID;
|
[ReadOnly] public string buildID;
|
||||||
[LabelText("挂点数量")] public int nodeCount;
|
[LabelText("挂点数量")] public int nodeCount;
|
||||||
[LabelText("主题数量")] public int thematicCount;
|
[LabelText("主题数量")] public int thematicCount;
|
||||||
[LabelText("解锁类型")] [SerializeField] public UnlockType unlockType;
|
[LabelText("解锁类型")] [SerializeField] public UnlockType unlockType;
|
||||||
[LabelText("解锁条件类型")] [SerializeField] public UnlockConditionType unlockConditionType;
|
[LabelText("解锁条件类型")] [SerializeField] public UnlockConditionType unlockConditionType;
|
||||||
[LabelText("解锁条件")] public List<UnlockInfo> unlockInfos;
|
[LabelText("解锁条件")] public List<UnlockInfo> unlockInfos;
|
||||||
[LabelText("挂点数据")] public List<BuildNode> nodeInfos;
|
[LabelText("挂点数据")] public List<BuildNode> NodeInfos;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class UnlockInfo
|
public class UnlockInfo
|
||||||
|
@ -51,15 +52,15 @@ namespace Framework.Manager
|
||||||
|
|
||||||
public class BuildNode
|
public class BuildNode
|
||||||
{
|
{
|
||||||
[LabelText("挂点名称")] [ReadOnly] public string name;
|
[LabelText("挂点名称")] [ReadOnly] public readonly string Name;
|
||||||
|
|
||||||
[HideInInspector] public List<string> options;
|
[HideInInspector] public List<string> Options;
|
||||||
|
|
||||||
[HideInInspector] public string IconPath;
|
[HideInInspector] public string IconPath;
|
||||||
|
|
||||||
public BuildNode(string name)
|
public BuildNode(string name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.Name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,6 +150,9 @@ namespace Framework.Manager
|
||||||
private set => _userBuildInfo = value;
|
private set => _userBuildInfo = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//已达到的条件
|
||||||
|
public int ReachCondition;
|
||||||
|
|
||||||
//动态加载的图标
|
//动态加载的图标
|
||||||
private Dictionary<string, Sprite> _iconSprites;
|
private Dictionary<string, Sprite> _iconSprites;
|
||||||
|
|
||||||
|
@ -175,16 +179,16 @@ namespace Framework.Manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitNodesInfo()
|
private void InitNodesInfo()
|
||||||
{
|
{
|
||||||
foreach (var node in _curBuildData.nodeInfos)
|
foreach (var node in _curBuildData.NodeInfos)
|
||||||
{
|
{
|
||||||
var nodeInfo = new NodeInfo
|
var nodeInfo = new NodeInfo
|
||||||
{
|
{
|
||||||
Name = node.name,
|
Name = node.Name,
|
||||||
Options = new Dictionary<string, OptionInfo>(),
|
Options = new Dictionary<string, OptionInfo>(),
|
||||||
IconPath = node.IconPath
|
IconPath = node.IconPath
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var option in node.options)
|
foreach (var option in node.Options)
|
||||||
{
|
{
|
||||||
var optionInfo = new OptionInfo()
|
var optionInfo = new OptionInfo()
|
||||||
{
|
{
|
||||||
|
@ -214,7 +218,7 @@ namespace Framework.Manager
|
||||||
_userBuildInfo = StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
|
_userBuildInfo = StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
|
||||||
if (_userBuildInfo == null)
|
if (_userBuildInfo == null)
|
||||||
{
|
{
|
||||||
var buildId = _curBuildData.BuildID;
|
var buildId = _curBuildData.buildID;
|
||||||
_userBuildInfo = new UserBuildInfo(buildId);
|
_userBuildInfo = new UserBuildInfo(buildId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,10 +237,10 @@ namespace Framework.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
//打印Debug玩家Build信息
|
//打印Debug玩家Build信息
|
||||||
foreach (var infos in _userBuildInfo.ChooseNodeInfo)
|
/*foreach (var infos in _userBuildInfo.ChooseNodeInfo)
|
||||||
{
|
{
|
||||||
DebugUtil.LogError("玩家 节点 {0} 选择的的是 {1}", infos.Key, infos.Value);
|
DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void InitIcon()
|
private async void InitIcon()
|
||||||
|
@ -338,7 +342,6 @@ namespace Framework.Manager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据节点获得解锁条件
|
/// 根据节点获得解锁条件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
|
||||||
public int GetCondition(string nodeName)
|
public int GetCondition(string nodeName)
|
||||||
{
|
{
|
||||||
var condition = 0;
|
var condition = 0;
|
||||||
|
@ -366,6 +369,49 @@ namespace Framework.Manager
|
||||||
StorageManager.Instance.SaveWithoutUpdate();
|
StorageManager.Instance.SaveWithoutUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetNextLockNode(int condition)
|
||||||
|
{
|
||||||
|
DebugUtil.LogError("当前达到条件:{0}", condition);
|
||||||
|
string nodeName = null;
|
||||||
|
|
||||||
|
switch (_curBuildData.unlockType)
|
||||||
|
{
|
||||||
|
case UnlockType.ForGroup:
|
||||||
|
{
|
||||||
|
var nodeList = NodeInfos.Values.Where(node => node.Condition > condition).ToList();
|
||||||
|
|
||||||
|
nodeName = nodeList[0].Name;
|
||||||
|
int minCondition = nodeList[0].Condition;
|
||||||
|
|
||||||
|
foreach (var nodeInfo in nodeList)
|
||||||
|
{
|
||||||
|
if (nodeInfo.Condition < minCondition)
|
||||||
|
{
|
||||||
|
nodeName = nodeInfo.Name;
|
||||||
|
minCondition = nodeInfo.Condition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//TODO 按主题解锁
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugUtil.LogError("得到最小的节点是{0}", nodeName);
|
||||||
|
|
||||||
|
return nodeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新已经达到的条件
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateReachCondition(int condition)
|
||||||
|
{
|
||||||
|
ReachCondition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
public void Release()
|
public void Release()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue