/// <summary> /// 从红点dic里面取到一个红点 /// </summary> /// <returns></returns> public RedPoint GetRedPointFromDic(RedPointType redPointType, UInt64 id) { if (!RedPointDic.ContainsKey(redPointType)) { return(AddRedPointToDic(redPointType, id)); } else { //字典该类有这个id bool haveSameId = false; List <RedPoint> redPointList = RedPointDic[redPointType]; for (int i = 0; i < redPointList.Count; i++) { RedPoint thePoint = redPointList[i]; UInt64 theId = thePoint.id; if (id == theId) { haveSameId = true; return(thePoint); } } //字典该类没有id if (!haveSameId) { return(AddRedPointToDic(redPointType, id)); } } return(null); }
public RedPointNode GetNode(RedPointType type) { RedPointNode node = null; if (root != null) { node = FindNode(root, type); } return(node); }
/// <summary> /// dic里面增加一种红点 /// </summary> public RedPoint AddRedPointToDic(RedPointType redPointType, UInt64 id) { RedPoint point = new RedPoint(); point.id = id; point.redPointType = redPointType; if (!RedPointDic.ContainsKey(redPointType)) { RedPointDic.Add(redPointType, new List <RedPoint>()); } RedPointDic[redPointType].Add(point); //AddRedPointToDic() return(point); }
/// <summary> /// 改变某个红点状态 /// </summary> public void ChangeRedPointStatus(RedPointType redPointType, UInt64 id, bool status) { if (RedPointDic.ContainsKey(redPointType)) { List <RedPoint> redPointList = RedPointDic[redPointType]; for (int i = 0; i < redPointList.Count; i++) { RedPoint thePoint = redPointList[i]; UInt64 theId = thePoint.id; if (id == theId) { thePoint.nodeVal = status; UpdateStatus(thePoint); } } } }
/// <summary> /// 设置ui的显示 /// </summary> /// <param name="obj"></param> /// <param name=""></param> public void SetRedPointUI(GameObject obj, RedPointType redPointType, UInt64 id) { if (RedPointDic.ContainsKey(redPointType)) { List <RedPoint> redPointList = RedPointDic[redPointType]; for (int i = 0; i < redPointList.Count; i++) { RedPoint thePoint = redPointList[i]; UInt64 theId = thePoint.id; if (id == theId) { obj.gameObject.SetActive(thePoint.nodeVal); } } } else { Debug.Log("字典没有注册该红点就永不显示" + redPointType); obj.gameObject.SetActive(false); } }
private RedPointNode FindNode(RedPointNode source, RedPointType type) { RedPointNode node = null; for (int i = 0; i < source.childs.Count; i++) { node = source.childs[i]; if (node.type != type) { node = FindNode(node, type); if (node != null) { break; } } else { break; } } return(node); }
public RedPointNode(RedPointType type) { this.type = type; }
public void Set(RedPointType type, int id = 0) { this.type = type; this.id = id; Refresh(); }