提交 fda96fc9 编写于 作者: L linxinfa

新增红点系统

上级 d6e61dba
此差异已折叠。
此差异已折叠。
......@@ -299,8 +299,6 @@ MonoBehaviour:
obj: {fileID: 3190646328964235041}
- name: redpointBtn
obj: {fileID: 1170740374806143586}
- name: redpointObj
obj: {fileID: 2231633638448600168}
- name: redpointText
obj: {fileID: 6154726871490356}
--- !u!1 &1346032198865300369
......@@ -641,7 +639,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1174548104332698780
RectTransform:
m_ObjectHideFlags: 0
......@@ -1714,7 +1712,7 @@ MonoBehaviour:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 22
m_FontSize: 16
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 2
......
......@@ -298,7 +298,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &8630817889605702701
RectTransform:
m_ObjectHideFlags: 0
......@@ -532,7 +532,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &885348046922738247
RectTransform:
m_ObjectHideFlags: 0
......@@ -682,7 +682,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &5851606526797702846
RectTransform:
m_ObjectHideFlags: 0
......@@ -1112,7 +1112,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &9035606793222068818
RectTransform:
m_ObjectHideFlags: 0
......@@ -1851,7 +1851,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &3809102330246643935
RectTransform:
m_ObjectHideFlags: 0
......@@ -2197,7 +2197,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &704922229448584010
RectTransform:
m_ObjectHideFlags: 0
......
......@@ -4,8 +4,10 @@ RedpointNode = RedpointNode or {}
RedpointNode.__index = RedpointNode
function RedpointNode.New()
function RedpointNode.New(name)
local self = {}
-- 节点名
self.name = name
-- 节点被经过的次数
self.passCnt = 0
-- 节点作为末尾节点的次数
......@@ -13,7 +15,7 @@ function RedpointNode.New()
-- 红点数(子节点的红点数的和)
self.redpointCnt = 0
-- 子节点
self.nexts = {}
self.children = {}
-- 红点更新时回调
self.updateCb = {}
setmetatable(self, RedpointNode)
......
......@@ -3,6 +3,7 @@
RedpointTree = RedpointTree or {}
local this = RedpointTree
-- 根节点
this.root = nil
-- 节点名
......@@ -20,7 +21,7 @@ RedpointTree.NodeNames = {
function RedpointTree.Init()
-- 先创建根节点
this.root = RedpointNode.New()
this.root = RedpointNode.New("Root")
-- 构建前缀树
for _, name in pairs(RedpointTree.NodeNames) do
this.InsertNode(name)
......@@ -50,10 +51,10 @@ function RedpointTree.InsertNode(name)
node.passCnt = node.passCnt + 1
local pathList = LuaUtil.SplitString(name, "|")
for _, path in pairs(pathList) do
if nil == node.nexts[path] then
node.nexts[path] = RedpointNode.New()
if nil == node.children[path] then
node.children[path] = RedpointNode.New(path)
end
node = node.nexts[path]
node = node.children[path]
node.passCnt = node.passCnt + 1
end
node.endCnt = node.endCnt + 1
......@@ -67,10 +68,10 @@ function RedpointTree.SearchNode(name)
local node = this.root
local pathList = LuaUtil.SplitString(name, "|")
for _, path in pairs(pathList) do
if nil == node.nexts[path] then
if nil == node.children[path] then
return nil
end
node = node.nexts[path]
node = node.children[path]
end
if node.endCnt > 0 then
return node
......@@ -87,13 +88,13 @@ function RedpointTree.DeleteNode(name)
node.passCnt = node.passCnt - 1
local pathList = LuaUtil.SplitString(name, '.')
for _, path in pairs(pathList) do
local nextNode = node.nexts[path]
nextNode.passCnt = nextNode.passCnt - 1
if 0 == nextNode.passCnt then
node.nexts[path] = nil
local childNode = node.children[path]
childNode.passCnt = childNode.passCnt - 1
if 0 == childNode.passCnt then
node.children[path] = nil
return
end
node = nextNode
node = childNode
end
node.endCnt = node.endCnt - 1
end
......@@ -112,9 +113,9 @@ function RedpointTree.ChangeRedpointCnt(name, delta)
local node = this.root
local pathList = LuaUtil.SplitString(name, "|")
for _, path in pairs(pathList) do
local nextNode = node.nexts[path]
nextNode.redpointCnt = nextNode.redpointCnt + delta
node = nextNode
local childNode = node.children[path]
childNode.redpointCnt = childNode.redpointCnt + delta
node = childNode
-- 调用回调函数
for _, cb in pairs(node.updateCb) do
cb(node.redpointCnt)
......@@ -122,7 +123,7 @@ function RedpointTree.ChangeRedpointCnt(name, delta)
end
end
-- 获取节点的红点数
-- 查询节点的红点数
function RedpointTree.GetRedpointCnt(name)
local node = this.SearchNode(name)
if nil == node then
......@@ -142,9 +143,9 @@ end
-- 递归获取整棵树的路径
function RedpointTree.GetFullTreePath(parent, pathList)
for path, node in pairs(parent.nexts) do
for path, node in pairs(parent.children) do
table.insert(pathList, path)
if LuaUtil.TableCount(node.nexts) > 0 then
if LuaUtil.TableCount(node.children) > 0 then
this.GetFullTreePath(node, pathList)
end
end
......
......@@ -48,6 +48,7 @@ function GameHallPanel:SetUi(binder)
end
-- 更新红点
function GameHallPanel:UpdateRedPoint(redpointCnt)
self.redpointText.text = tostring(redpointCnt)
LuaUtil.SafeActiveObj(self.redpointText.transform.parent, redpointCnt > 0)
......
......@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
m_IndirectSpecularColor: {r: 0.37311992, g: 0.38074034, b: 0.35872713, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
......
fileFormatVersion: 2
guid: 659d8d4d3b8b1694b851a28a79baae38
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
m_EditorVersion: 2021.1.7f1c1
m_EditorVersionWithRevision: 2021.1.7f1c1 (4e944ebb9621)
m_EditorVersion: 2021.1.9f1c1
m_EditorVersionWithRevision: 2021.1.9f1c1 (a9c352b271d7)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册