From 4fde46699701b1a8b74b4dab516624852b24a86d Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 23 六月 2025 14:24:50 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
---
Main/System/Redpoint/RedpointCenter.cs | 244 ++++++++++++++++++++++++------------------------
1 files changed, 122 insertions(+), 122 deletions(-)
diff --git a/Main/System/Redpoint/RedpointCenter.cs b/Main/System/Redpoint/RedpointCenter.cs
index b197f86..408a26f 100644
--- a/Main/System/Redpoint/RedpointCenter.cs
+++ b/Main/System/Redpoint/RedpointCenter.cs
@@ -3,128 +3,128 @@
using UnityEngine;
using System;
-
- public class RedpointCenter : Singleton<RedpointCenter>
+
+public class RedpointCenter : Singleton<RedpointCenter>
+{
+ public event Action<int> redpointValueChangeEvent;
+
+ Dictionary<int, Redpoint> redpoints = new Dictionary<int, Redpoint>();
+ Dictionary<int, List<int>> parentChildren = new Dictionary<int, List<int>>();
+
+ public RedpointCenter()
{
- public event Action<int> redpointValueChangeEvent;
-
- Dictionary<int, Redpoint> redpoints = new Dictionary<int, Redpoint>();
- Dictionary<int, List<int>> parentChildren = new Dictionary<int, List<int>>();
-
- public RedpointCenter()
- {
-
- }
-
- public void ResetAllRedpointState()
- {
- foreach (var redpoint in redpoints.Values)
- {
- redpoint.state = RedPointState.None;
- }
- }
-
- public void Register(Redpoint _redpoint)
- {
- var id = _redpoint.id;
- if (redpoints.ContainsKey(id))
- {
- Debug.LogErrorFormat("閲嶅娉ㄥ唽绾㈢偣锛歩d->{0}", id);
- }
-
- redpoints[id] = _redpoint;
-
- var parentId = _redpoint.parent;
- if (parentId > 0)
- {
- List<int> children = null;
- if (!parentChildren.TryGetValue(parentId, out children))
- {
- parentChildren[parentId] = children = new List<int>();
- }
-
- if (!children.Contains(id))
- {
- children.Add(id);
- }
- }
- }
-
- public void Report(Redpoint _redpoint)
- {
- var parentId = _redpoint.parent;
-
- if (redpointValueChangeEvent != null)
- {
- redpointValueChangeEvent(_redpoint.id);
- }
-
- if (parentId > 0)
- {
- TestParentValue(_redpoint.parent);
- }
- }
-
- public void ReportWithoutParent(Redpoint _redpoint)
- {
- if (redpointValueChangeEvent != null)
- {
- redpointValueChangeEvent(_redpoint.id);
- }
- }
-
- public RedPointState GetRedpointState(int _id)
- {
- Redpoint redpoint = null;
- if (this.redpoints.TryGetValue(_id, out redpoint))
- {
- return redpoint.state;
- }
- else
- {
- return RedPointState.None;
- }
- }
-
- public int GetRedpointCount(int _id)
- {
- Redpoint redpoint = null;
- if (this.redpoints.TryGetValue(_id, out redpoint))
- {
- return redpoint.count;
- }
- else
- {
- return 0;
- }
- }
-
- void TestParentValue(int _parentId)
- {
- List<int> children = null;
- Redpoint parent = null;
- if (redpoints.TryGetValue(_parentId, out parent) && parentChildren.TryGetValue(_parentId, out children))
- {
- var parentState = RedPointState.None;
- for (int i = 0; i < children.Count; i++)
- {
- Redpoint child = null;
- if (redpoints.TryGetValue(children[i], out child))
- {
- if (child.state > parentState)
- {
- parentState = child.state;
- }
- }
-
- if (parentState == RedPointState.Full)
- {
- break;
- }
-
- }
- parent.state = parentState;
- }
- }
}
+
+ public void ResetAllRedpointState()
+ {
+ foreach (var redpoint in redpoints.Values)
+ {
+ redpoint.state = RedPointState.None;
+ }
+ }
+
+ public void Register(Redpoint _redpoint)
+ {
+ var id = _redpoint.id;
+ if (redpoints.ContainsKey(id))
+ {
+ Debug.LogErrorFormat("閲嶅娉ㄥ唽绾㈢偣锛歩d->{0}", id);
+ }
+
+ redpoints[id] = _redpoint;
+
+ var parentId = _redpoint.parent;
+ if (parentId > 0)
+ {
+ List<int> children = null;
+ if (!parentChildren.TryGetValue(parentId, out children))
+ {
+ parentChildren[parentId] = children = new List<int>();
+ }
+
+ if (!children.Contains(id))
+ {
+ children.Add(id);
+ }
+ }
+ }
+
+ public void Report(Redpoint _redpoint)
+ {
+ var parentId = _redpoint.parent;
+
+ if (redpointValueChangeEvent != null)
+ {
+ redpointValueChangeEvent(_redpoint.id);
+ }
+
+ if (parentId > 0)
+ {
+ TestParentValue(_redpoint.parent);
+ }
+ }
+
+ public void ReportWithoutParent(Redpoint _redpoint)
+ {
+ if (redpointValueChangeEvent != null)
+ {
+ redpointValueChangeEvent(_redpoint.id);
+ }
+ }
+
+ public RedPointState GetRedpointState(int _id)
+ {
+ Redpoint redpoint = null;
+ if (this.redpoints.TryGetValue(_id, out redpoint))
+ {
+ return redpoint.state;
+ }
+ else
+ {
+ return RedPointState.None;
+ }
+ }
+
+ public int GetRedpointCount(int _id)
+ {
+ Redpoint redpoint = null;
+ if (this.redpoints.TryGetValue(_id, out redpoint))
+ {
+ return redpoint.count;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ void TestParentValue(int _parentId)
+ {
+ List<int> children = null;
+ Redpoint parent = null;
+ if (redpoints.TryGetValue(_parentId, out parent) && parentChildren.TryGetValue(_parentId, out children))
+ {
+ var parentState = RedPointState.None;
+ for (int i = 0; i < children.Count; i++)
+ {
+ Redpoint child = null;
+ if (redpoints.TryGetValue(children[i], out child))
+ {
+ if (child.state > parentState)
+ {
+ parentState = child.state;
+ }
+ }
+
+ if (parentState == RedPointState.Full)
+ {
+ break;
+ }
+
+ }
+ parent.state = parentState;
+ }
+ }
+
+}
--
Gitblit v1.8.0