using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine.UI;
|
|
public partial class PhantasmPavilionManager : GameSystemManager<PhantasmPavilionManager>
|
{
|
public Redpoint parentRedpoint = new Redpoint(MainRedDot.MainAffairsRedpoint, MainRedDot.PhantasmPavilionRepoint);
|
public Dictionary<PhantasmPavilionRepointType, Redpoint> tabRedPointDict = new Dictionary<PhantasmPavilionRepointType, Redpoint>();
|
|
private void InitTabRedPoint()
|
{
|
|
|
tabRedPointDict[PhantasmPavilionRepointType.Model] = new Redpoint(MainRedDot.PhantasmPavilionRepoint, GetRedpointId(PhantasmPavilionRepointType.Model));
|
tabRedPointDict[PhantasmPavilionRepointType.Face] = new Redpoint(MainRedDot.PhantasmPavilionRepoint, GetRedpointId(PhantasmPavilionRepointType.Face));
|
tabRedPointDict[PhantasmPavilionRepointType.Title] = new Redpoint(MainRedDot.PhantasmPavilionRepoint, GetRedpointId(PhantasmPavilionRepointType.Title));
|
tabRedPointDict[PhantasmPavilionRepointType.ModelNormal] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Model), GetRedpointId(PhantasmPavilionRepointType.ModelNormal));
|
tabRedPointDict[PhantasmPavilionRepointType.ModelEvent] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Model), GetRedpointId(PhantasmPavilionRepointType.ModelEvent));
|
tabRedPointDict[PhantasmPavilionRepointType.FaceAvatar] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Face), GetRedpointId(PhantasmPavilionRepointType.FaceAvatar));
|
tabRedPointDict[PhantasmPavilionRepointType.FaceFrame] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Face), GetRedpointId(PhantasmPavilionRepointType.FaceFrame));
|
tabRedPointDict[PhantasmPavilionRepointType.FaceBubble] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Face), GetRedpointId(PhantasmPavilionRepointType.FaceBubble));
|
tabRedPointDict[PhantasmPavilionRepointType.TitlePalace] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Title), GetRedpointId(PhantasmPavilionRepointType.TitlePalace));
|
tabRedPointDict[PhantasmPavilionRepointType.TitleEvent] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Title), GetRedpointId(PhantasmPavilionRepointType.TitleEvent));
|
}
|
public int GetRedpointId(PhantasmPavilionRepointType type)
|
{
|
return MainRedDot.PhantasmPavilionRepoint * 100 + (int)type;
|
}
|
|
void UpdateRedPointByCanActivate(PhantasmPavilionType type, PhantasmPavilionRepointType redType, int tabType = 0)
|
{
|
List<int> list = ShowItemList(type, tabType);
|
if (list.IsNullOrEmpty() || !tabRedPointDict.ContainsKey(redType))
|
return;
|
foreach (var id in list)
|
{
|
if (!Has(type, id))
|
continue;
|
PhantasmPavilionState state = GetUnLockState(type, id);
|
if (state == PhantasmPavilionState.CanActivate)
|
{
|
tabRedPointDict[redType].state = RedPointState.Simple;
|
}
|
}
|
}
|
|
void UpdateRedPointByCanUpStar(PhantasmPavilionType type, PhantasmPavilionRepointType redType, int tabType = 0)
|
{
|
List<int> list = ShowItemList(type, tabType);
|
if (list.IsNullOrEmpty() || !tabRedPointDict.ContainsKey(redType))
|
return;
|
foreach (var id in list)
|
{
|
if (!Has(type, id))
|
continue;
|
bool isCanUpStar = CheckCanUpByItem(type, id);
|
if (isCanUpStar)
|
{
|
tabRedPointDict[redType].state = RedPointState.Simple;
|
}
|
}
|
}
|
|
void UpdateRedPointByNoSee(PhantasmPavilionType type, PhantasmPavilionRepointType redType, int tabType = 0)
|
{
|
List<int> list = ShowItemList(type, tabType);
|
if (list.IsNullOrEmpty() || !tabRedPointDict.ContainsKey(redType))
|
return;
|
foreach (var id in list)
|
{
|
if (!Has(type, id))
|
continue;
|
int unlockWay = GetUnlockWay(type, id);
|
int unlockValue = GetUnlockValue(type, id);
|
if (unlockWay != 3)
|
continue;
|
bool hasNewHero = HasNewHero(type, unlockValue);
|
if (hasNewHero)
|
{
|
tabRedPointDict[redType].state = RedPointState.Simple;
|
}
|
}
|
}
|
|
public void UpdateItemRedPoint(Image imgRed, PhantasmPavilionType type, int id)
|
{
|
imgRed.SetActive(false);
|
|
if (!Has(type, id))
|
return;
|
PhantasmPavilionState state = GetUnLockState(type, id);
|
if (state == PhantasmPavilionState.CanActivate)
|
{
|
imgRed.SetActive(true);
|
}
|
|
bool isCanUpStar = CheckCanUpByItem(type, id);
|
if (isCanUpStar)
|
{
|
imgRed.SetActive(true);
|
}
|
|
int unlockWay = GetUnlockWay(type, id);
|
if (unlockWay != 3)
|
return;
|
|
int unlockValue = GetUnlockValue(type, id);
|
bool hasNewHero = HasNewHero(type, unlockValue);
|
if (hasNewHero)
|
{
|
imgRed.SetActive(true);
|
}
|
}
|
public void UpdateRedPoint()
|
{
|
parentRedpoint.state = RedPointState.None;
|
|
if (!tabRedPointDict.IsNullOrEmpty())
|
{
|
foreach (var item in tabRedPointDict)
|
{
|
item.Value.state = RedPointState.None;
|
}
|
}
|
|
// 有可手动解锁的
|
UpdateRedPointByCanActivate(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelNormal, 1);
|
UpdateRedPointByCanActivate(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelEvent, 2);
|
UpdateRedPointByCanActivate(PhantasmPavilionType.Face, PhantasmPavilionRepointType.FaceAvatar);
|
UpdateRedPointByCanActivate(PhantasmPavilionType.FacePic, PhantasmPavilionRepointType.FaceFrame);
|
UpdateRedPointByCanActivate(PhantasmPavilionType.ChatBox, PhantasmPavilionRepointType.FaceBubble);
|
UpdateRedPointByCanActivate(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitlePalace, 1);
|
UpdateRedPointByCanActivate(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitleEvent, 2);
|
|
// 有可升级的
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelNormal, 1);
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelEvent, 2);
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.Face, PhantasmPavilionRepointType.FaceAvatar);
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.FacePic, PhantasmPavilionRepointType.FaceFrame);
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.ChatBox, PhantasmPavilionRepointType.FaceBubble);
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitlePalace, 1);
|
UpdateRedPointByCanUpStar(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitleEvent, 2);
|
|
// 自动解锁未查看的
|
UpdateRedPointByNoSee(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelNormal, 1);
|
UpdateRedPointByNoSee(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelEvent, 2);
|
UpdateRedPointByNoSee(PhantasmPavilionType.Face, PhantasmPavilionRepointType.FaceAvatar);
|
UpdateRedPointByNoSee(PhantasmPavilionType.FacePic, PhantasmPavilionRepointType.FaceFrame);
|
UpdateRedPointByNoSee(PhantasmPavilionType.ChatBox, PhantasmPavilionRepointType.FaceBubble);
|
UpdateRedPointByNoSee(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitlePalace, 1);
|
UpdateRedPointByNoSee(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitleEvent, 2);
|
|
}
|
|
public List<int> newHeroIDModelList = new List<int>();
|
public List<int> newHeroIDFaceList = new List<int>();
|
public void AddNewHero(int heroID)
|
{
|
AddNewHero(newHeroIDModelList, heroID);
|
AddNewHero(newHeroIDFaceList, heroID);
|
}
|
|
void AddNewHero(List<int> list, int heroID)
|
{
|
if (list.Contains(heroID))
|
return;
|
list.Add(heroID);
|
SaveLocal();
|
UpdateRedPoint();
|
}
|
|
public void RemoveNewHero(PhantasmPavilionType type, int id)
|
{
|
if (!Has(type, id))
|
return;
|
int unlockWay = GetUnlockWay(type, id);
|
int unlockValue = GetUnlockValue(type, id);
|
if (unlockWay != 3)
|
return;
|
|
switch (type)
|
{
|
case PhantasmPavilionType.Model:
|
RemoveNewHero(newHeroIDModelList, unlockValue);
|
break;
|
case PhantasmPavilionType.Face:
|
RemoveNewHero(newHeroIDFaceList, unlockValue);
|
break;
|
}
|
}
|
|
void RemoveNewHero(List<int> list, int heroID)
|
{
|
if (!list.Contains(heroID))
|
return;
|
list.Remove(heroID);
|
SaveLocal();
|
UpdateRedPoint();
|
}
|
|
public bool HasNewHero(PhantasmPavilionType type, int heroID)
|
{
|
switch (type)
|
{
|
case PhantasmPavilionType.Model:
|
return newHeroIDModelList.Contains(heroID);
|
case PhantasmPavilionType.Face:
|
return newHeroIDFaceList.Contains(heroID);
|
default:
|
return false;
|
}
|
|
}
|
|
string modelkey { get { return StringUtility.Contact("PhantasmPavilion_Redponit_Model_", PlayerDatas.Instance.PlayerId); } }
|
string facekey { get { return StringUtility.Contact("PhantasmPavilion_Redponit_Face_", PlayerDatas.Instance.PlayerId); } }
|
public void SaveLocal()
|
{
|
LocalSave.SetIntArray(modelkey, newHeroIDModelList.ToArray());
|
LocalSave.SetIntArray(facekey, newHeroIDFaceList.ToArray());
|
}
|
public void LoadLocal()
|
{
|
LoadLocalModel();
|
LoadLocalFace();
|
}
|
|
void LoadLocalModel()
|
{
|
if (!LocalSave.HasKey(modelkey))
|
{
|
newHeroIDModelList = new List<int>();
|
return;
|
}
|
|
int[] arr = LocalSave.GetIntArray(modelkey);
|
if (arr.IsNullOrEmpty())
|
{
|
newHeroIDModelList = new List<int>();
|
return;
|
}
|
|
newHeroIDModelList = arr.ToList();
|
}
|
|
void LoadLocalFace()
|
{
|
if (!LocalSave.HasKey(facekey))
|
{
|
newHeroIDFaceList = new List<int>();
|
return;
|
}
|
|
int[] arr = LocalSave.GetIntArray(facekey);
|
if (arr.IsNullOrEmpty())
|
{
|
newHeroIDFaceList = new List<int>();
|
return;
|
}
|
|
newHeroIDFaceList = arr.ToList();
|
}
|
}
|
|
public enum PhantasmPavilionRepointType
|
{
|
Model = 10,
|
Face = 20,
|
Title = 30,
|
|
ModelNormal = 11,
|
ModelEvent = 12,
|
|
FaceAvatar = 21,
|
FaceFrame = 22,
|
FaceBubble = 23,
|
|
TitlePalace = 31,
|
TitleEvent = 32,
|
}
|