先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
104 lines
3.1 KiB
C#
104 lines
3.1 KiB
C#
using asap.core;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class RedPointManager
|
|
{
|
|
private static RedPointManager instance;
|
|
public static RedPointManager Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new RedPointManager();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
public void Init()
|
|
{
|
|
redPointDic.Clear();
|
|
redPointStateDic.Clear();
|
|
redPointCountDic.Clear();
|
|
}
|
|
Dictionary<string, IUIRedPoint> redPointDic = new Dictionary<string, IUIRedPoint>();
|
|
Dictionary<string, Dictionary<string, bool>> redPointStateDic = new Dictionary<string, Dictionary<string, bool>>();
|
|
Dictionary<string, int> redPointCountDic = new Dictionary<string, int>();
|
|
public void AddRedPoint(string key, IUIRedPoint uiRedPoint)
|
|
{
|
|
if (redPointDic.ContainsKey(key))
|
|
{
|
|
GameDebug.LogWarning("key is already exist");
|
|
}
|
|
redPointDic[key] = uiRedPoint;
|
|
//GameDebug.Log("RedPointManager AddRedPoint key:" + key);
|
|
}
|
|
public void RemoveRedPoint(string key)
|
|
{
|
|
//GameDebug.Log("RedPointManager RemoveRedPoint key:" + key);
|
|
if (!redPointDic.ContainsKey(key))
|
|
{
|
|
GameDebug.LogWarning("key is not exist");
|
|
return;
|
|
}
|
|
redPointDic.Remove(key);
|
|
}
|
|
public bool GetRedPointState(string key)
|
|
{
|
|
if (!redPointStateDic.ContainsKey(key))
|
|
{
|
|
return false;
|
|
}
|
|
return redPointStateDic[key].Values.Contains(true);
|
|
}
|
|
public int GetRedPointCount(string key)
|
|
{
|
|
if (!redPointCountDic.ContainsKey(key))
|
|
{
|
|
return 0;
|
|
}
|
|
return redPointCountDic[key];
|
|
}
|
|
public void SetRedPointState(string key, bool state, int count = 0)
|
|
{
|
|
if (string.IsNullOrEmpty(key))
|
|
{
|
|
GameDebug.LogError("key is null");
|
|
return;
|
|
}
|
|
redPointCountDic[key] = count;
|
|
if (!redPointStateDic.ContainsKey(key))
|
|
{
|
|
redPointStateDic[key] = new Dictionary<string, bool>();
|
|
}
|
|
redPointStateDic[key][key] = state;
|
|
if (redPointDic.ContainsKey(key))
|
|
{
|
|
redPointDic[key].SetRedPointState(GetRedPointState(key));
|
|
}
|
|
string[] keys = key.Split('.');
|
|
if (keys.Length > 1)
|
|
{
|
|
string parentKey = keys[0];
|
|
for (int i = 0; i < keys.Length - 1; i++)
|
|
{
|
|
if (!redPointStateDic.ContainsKey(parentKey))
|
|
{
|
|
redPointStateDic[parentKey] = new Dictionary<string, bool>();
|
|
}
|
|
//redPointStateDic[parentKey][parentKey] = state;
|
|
redPointStateDic[parentKey][parentKey + "." + keys[i + 1]] = state;
|
|
|
|
if (redPointDic.ContainsKey(parentKey))
|
|
{
|
|
redPointDic[parentKey].SetRedPointState(GetRedPointState(parentKey));
|
|
}
|
|
parentKey += "." + keys[i + 1];
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|