//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, September 12, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
using System;
|
using vnxbqy.UI;
|
|
//功能预告红点
|
|
public class FeatureNoticeModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
public List<FunctionForecastConfig> FunctionList = new List<FunctionForecastConfig>();
|
public Dictionary<int, ImpactRankModel.RankAwardItem> DicAwardItem = new Dictionary<int, ImpactRankModel.RankAwardItem>();//奖励物品
|
public Dictionary<int, OpenFuncState> DicOpenFuncState = new Dictionary<int, OpenFuncState>();
|
public Dictionary<int, Redpoint> DicRedPoint = new Dictionary<int, Redpoint>();//红点
|
public event Action UpdateAwarfItem;
|
private const int Redpoint_key1 = 38;
|
public Redpoint redPointStre1 = new Redpoint(Redpoint_key1);
|
public int FunctionForecastIndex = 0;
|
|
public int ShowLV = 20;//入口显示等级
|
|
public override void Init()
|
{
|
AddList();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
FunctionForecastIndex = 0;
|
DicOpenFuncState.Clear();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
RedPoint_State();
|
}
|
|
|
public override void UnInit()
|
{
|
|
}
|
|
private void AddList()//添加列表信息
|
{
|
if (FunctionList.Count <= 0)
|
{
|
var configs = FunctionForecastConfig.GetKeys();
|
foreach (var key in configs)
|
{
|
var functionForecastConfig = FunctionForecastConfig.Get(key);
|
FunctionList.Add(functionForecastConfig);
|
AddAwardItem(functionForecastConfig);
|
AddRedPoint(functionForecastConfig);
|
}
|
}
|
}
|
|
|
private void AddAwardItem(FunctionForecastConfig functionForecastConfig)
|
{
|
if (!DicAwardItem.ContainsKey(functionForecastConfig.FuncId))
|
{
|
ImpactRankModel.RankAwardItem _award = new ImpactRankModel.RankAwardItem();
|
if (functionForecastConfig.Award == string.Empty)
|
{
|
return;
|
}
|
var _jsonData = LitJson.JsonMapper.ToObject(functionForecastConfig.Award);
|
foreach (string _key in _jsonData.Keys)
|
{
|
var _job = int.Parse(_key);
|
var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(_jsonData[_key].ToJson());
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
_award.Add(_job, new Item(_itemArray[j][0], _itemArray[j][1]));
|
}
|
}
|
DicAwardItem.Add(functionForecastConfig.FuncId, _award);
|
}
|
}
|
|
private void AddRedPoint(FunctionForecastConfig functionForecastConfig)
|
{
|
if (!DicRedPoint.ContainsKey(functionForecastConfig.FuncId))
|
{
|
int RedPointkey = Redpoint_key1 * 10000 + functionForecastConfig.FuncId;
|
Redpoint redPointMountStare = new Redpoint(Redpoint_key1, RedPointkey);
|
DicRedPoint.Add(functionForecastConfig.FuncId, redPointMountStare);
|
}
|
}
|
|
private void RedPoint_State()
|
{
|
foreach (var key in DicRedPoint.Keys)
|
{
|
DicRedPoint[key].state=RedPointState.None;
|
}
|
if (PlayerDatas.Instance.baseData.LV <= ShowLV)//功能预告红点x级前不显示
|
{
|
return;
|
}
|
foreach (var _key in DicOpenFuncState.Keys)
|
{
|
if (DicRedPoint.ContainsKey(_key) && DicOpenFuncState[_key].State==1
|
&& DicOpenFuncState[_key].AwardState==0 && DicAwardItem.ContainsKey(_key))
|
{
|
DicRedPoint[_key].state = RedPointState.Simple;
|
}
|
}
|
}
|
//TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
//public IEnumerator WhetherToPlayTheBox()
|
//{
|
// yield return new WaitForSeconds(0.7f);
|
// var inDungeon = IsDungeon();
|
// var IsOpenMaininterface = WindowCenter.Instance.IsOpen<MainInterfaceWin>();
|
// var IsOpenOffLineOnHook = WindowCenter.Instance.IsOpen<OffLineOnHookWin>();
|
// var treasureModel = ModelCenter.Instance.GetModel<TreasureModel>();
|
// var IsLoading = StageLoad.Instance.isLoading;
|
// if (NewBieCenter.Instance.inGuiding || treasureModel.newGotShowing || inDungeon || !IsOpenMaininterface
|
// || treasureModel.treasureStageUpShow || WindowCenter.Instance.ExistAnyFullScreenOrMaskWin() ||
|
// IsOpenOffLineOnHook || IsLoading)
|
// {
|
// yield break;
|
// }
|
// for (int i = 0; i < FunctionList.Count; i++)
|
// {
|
// if (!FuncOpen.Instance.IsFuncOpen(FunctionList[i].FuncId))
|
// {
|
// var functionForecastConfig = FunctionForecastConfig.Get(FunctionList[i].FuncId);
|
// if (functionForecastConfig.FrameLevel <= 0)
|
// {
|
// yield break;
|
// }
|
// string strKey = "FeatureNotice" + functionForecastConfig.FrameLevel + PlayerDatas.Instance.baseData.PlayerID;
|
// int type = LocalSave.GetInt(strKey);
|
// bool IsOpenMain = WindowCenter.Instance.IsOpen<MainInterfaceWin>();
|
// if (PlayerDatas.Instance.baseData.LV >= functionForecastConfig.FrameLevel && type == 0)
|
// {
|
// LocalSave.SetInt(strKey, functionForecastConfig.FrameLevel);
|
// var IsOpenFeatureNotice = WindowCenter.Instance.IsOpen<FeatureNotice2Win>();
|
// if (!IsOpenFeatureNotice)
|
// {
|
// WindowCenter.Instance.Close<MainInterfaceWin>();
|
// WindowCenter.Instance.Open<FeatureNotice2Win>();
|
// }
|
// }
|
// }
|
// }
|
//}
|
//public bool IsShowFeatureN()
|
//{
|
// bool IsBool = false;
|
// for (int i = 0; i < FunctionList.Count; i++)
|
// {
|
// if (!FuncOpen.Instance.IsFuncOpen(FunctionList[i].FuncId))
|
// {
|
// var functionForecastConfig = FunctionForecastConfig.Get(FunctionList[i].FuncId);
|
// if (functionForecastConfig.FrameLevel <= 0)
|
// {
|
// return false;
|
// }
|
// string strKey = "FeatureNotice" + functionForecastConfig.FrameLevel + PlayerDatas.Instance.baseData.PlayerID;
|
// int type = LocalSave.GetInt(strKey);
|
// bool IsOpenMain = WindowCenter.Instance.IsOpen<MainInterfaceWin>();
|
// if (PlayerDatas.Instance.baseData.LV >= functionForecastConfig.FrameLevel && type == 0)
|
// {
|
// IsBool = true;
|
// }
|
// }
|
// }
|
// return IsBool;
|
//}
|
//private bool IsDungeon()
|
//{
|
// var mapId = PlayerDatas.Instance.baseData.MapID;
|
// var mapConfig = MapConfig.Get(mapId);
|
// return mapConfig != null && mapConfig.MapFBType != 0;
|
//}
|
//List<FunctionForecastConfig> functionForecastValue = new List<FunctionForecastConfig>();
|
//public int GetOpenLv(int Inedx)
|
//{
|
// int lv = 0;
|
// if (functionForecastValue.Count <= 0)
|
// {
|
// functionForecastValue= FunctionForecastConfig.GetValues();
|
// }
|
// foreach (var value in functionForecastValue)
|
// {
|
// if (value.OpenNumber == Inedx)
|
// {
|
// lv = value.DisplayLevel;
|
// return lv;
|
// }
|
// }
|
// return lv;
|
//}
|
public class OpenFuncState
|
{
|
public int State;
|
public int AwardState;
|
|
}
|
|
public void OpenFuncAwardState(HA302_tagMCFuncOpenStateList info)
|
{
|
for (int i = 0; i < info.FuncCount; i++)
|
{
|
int FuncID = info.FuncStateList[i].FuncID;
|
if (!DicOpenFuncState.ContainsKey(FuncID))
|
{
|
OpenFuncState openFuncState = new OpenFuncState();
|
openFuncState.State = info.FuncStateList[i].State;
|
openFuncState.AwardState = info.FuncStateList[i].AwardState;
|
DicOpenFuncState.Add(FuncID, openFuncState);
|
}
|
else
|
{
|
DicOpenFuncState[FuncID].State= info.FuncStateList[i].State;
|
DicOpenFuncState[FuncID].AwardState = info.FuncStateList[i].AwardState;
|
}
|
}
|
if (UpdateAwarfItem != null)
|
{
|
UpdateAwarfItem();
|
}
|
RedPoint_State();
|
}
|
public void SendGetAward(int OpenFuncId)
|
{
|
CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
|
getReward.RewardType = (byte)GotServerRewardType.Def_RewardType_OpenFunc;
|
getReward.DataEx = (uint)OpenFuncId;
|
getReward.DataExStrLen = 0;
|
getReward.DataExStr = string.Empty;
|
GameNetSystem.Instance.SendInfo(getReward);
|
}
|
}
|
|
|
|
|