using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
|
|
public class RuneResolveModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
Dictionary<int, float> m_RuneBaseResolveSplinters;
|
|
public List<ushort> resolveItems = new List<ushort>();
|
public List<Transform> resolveObjs = new List<Transform>();
|
public List<int> itemIndexs = new List<int>();
|
public Dictionary<int, bool> resolveSigns = new Dictionary<int, bool>();
|
|
bool specialItemColorSign = false;
|
|
public readonly Redpoint redpoint = new Redpoint(108, 10802);
|
|
public event Action<int> onResolveSelect;
|
|
RuneModel runeModel { get { return ModelCenter.Instance.GetModel<RuneModel>(); } }
|
VirtualPackModel virtualPackModel { get { return ModelCenter.Instance.GetModel<VirtualPackModel>(); } }
|
|
public override void Init()
|
{
|
ParseConfig();
|
StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
|
virtualPackModel.virtualPackRefresh += VirtualPackRefresh;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
}
|
|
public override void UnInit()
|
{
|
StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish;
|
virtualPackModel.virtualPackRefresh -= VirtualPackRefresh;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
}
|
|
private void OnFuncStateChangeEvent(int id)
|
{
|
if (id == (int)FuncOpenEnum.Rune)
|
{
|
RefreshRedpoint();
|
}
|
}
|
|
private void OnStageLoadFinish()
|
{
|
if (!(StageLoad.Instance.currentStage is DungeonStage))
|
{
|
specialItemColorSign = false;
|
}
|
}
|
|
void ParseConfig()
|
{
|
var config = FuncConfigConfig.Get("RuneExp");
|
m_RuneBaseResolveSplinters = ConfigParse.GetDic<int, float>(config.Numerical4);
|
}
|
|
public bool IsQualitySign(int itemColor)
|
{
|
if (itemColor == 4)
|
{
|
return specialItemColorSign;
|
}
|
var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
return LocalSave.GetBool(StringUtility.Contact("RuneBreakSelect_", playerId, "_", itemColor), itemColor == 1);
|
}
|
|
public bool IsComposeSource(int sourceType)
|
{
|
if (sourceType == 0 || sourceType == 2)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
public float GetRuneResolveGetSplinters(int id, int level, bool fromCompose = false)
|
{
|
var result = 0f;
|
var config = ItemConfig.Get(id);
|
if (config.Type == RuneModel.RUNE_CREAMTYPE)
|
{
|
return config.EffectValueA1;
|
}
|
for (int i = 1; i <= level; i++)
|
{
|
if (i == 1 && !fromCompose)
|
{
|
result += m_RuneBaseResolveSplinters[config.ItemColor];
|
}
|
else
|
{
|
result += runeModel.GetLevelUpRequireRuneEssence(id, i - 1);
|
}
|
}
|
return result;
|
}
|
|
public float GetRuneResolveGetSouls(int id)
|
{
|
ItemConfig config = ItemConfig.Get(id);
|
if (config.Type == RuneModel.RUNE_CREAMTYPE)
|
{
|
return config.EffectValueA1;
|
}
|
else
|
{
|
return m_RuneBaseResolveSplinters[config.ItemColor];
|
}
|
}
|
|
public void SetQualityMark(int itemColor, bool mark)
|
{
|
if (itemColor == 4)
|
{
|
specialItemColorSign = mark;
|
return;
|
}
|
var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
LocalSave.SetBool(StringUtility.Contact("RuneBreakSelect_", playerId, "_", itemColor), mark);
|
}
|
|
public void RefreshResolveSelect(int line)
|
{
|
if (onResolveSelect != null)
|
{
|
onResolveSelect(line);
|
}
|
}
|
|
private void VirtualPackRefresh(PackType packType)
|
{
|
if (packType == PackType.RunePack)
|
{
|
RefreshRedpoint();
|
}
|
}
|
|
void RefreshRedpoint()
|
{
|
var satisfyResolve = false;
|
if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Rune))
|
{
|
if (virtualPackModel.GetPackRemainCount(PackType.RunePack) == 0)
|
{
|
satisfyResolve = true;
|
}
|
}
|
redpoint.state = satisfyResolve ? RedPointState.Simple : RedPointState.None;
|
}
|
}
|
}
|
|