using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using TableConfig;
|
using UnityEngine;
|
using LitJson;
|
|
public class BlastFurnaceModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
{
|
public BlastFurnaceFuncTitle funcTitle = BlastFurnaceFuncTitle.MakeDan;
|
|
public Action<AlchemySpecConfig> RefreshAddSpecMatEvent;
|
|
private TreasureModel _model;
|
public TreasureModel sTreasureModel
|
{
|
get
|
{
|
return _model ?? (_model = ModelCenter.Instance.GetModel<TreasureModel>());
|
}
|
}
|
|
private FuncConfigConfig _upTreasureRateModel;
|
private FuncConfigConfig _blastFurnaceExpModel;
|
private ItemConfig chinItemModel;
|
private Dictionary<int, int> _blastFurnaceExpDict;
|
public int[] extraMats { get; private set; }
|
|
public int MaxStoveLv { get; private set; }
|
public List<AlchemyConfig> alchemyModellist { get; private set; }
|
|
public int jumpToPrescripe { get; set; }
|
|
public event Action blastFurnacePromoteUpdate;
|
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
public override void Init()
|
{
|
_blastFurnaceExpDict = new Dictionary<int, int>();
|
extraMats = null;
|
alchemyModellist = null;
|
_upTreasureRateModel = Config.Instance.Get<FuncConfigConfig>("TreasureUpRateItem");
|
if (_upTreasureRateModel != null)
|
extraMats = ConfigParse.GetMultipleStr<int>(_upTreasureRateModel.Numerical2);
|
|
|
List<RefineStoveConfig> stovelist = Config.Instance.GetAllValues<RefineStoveConfig>();
|
MaxStoveLv = 0;
|
if (stovelist != null)
|
{
|
for (int i = 0; i < stovelist.Count; i++)
|
{
|
_blastFurnaceExpDict.Add(stovelist[i].LV, stovelist[i].Exp);
|
}
|
|
MaxStoveLv = stovelist[stovelist.Count - 1].LV;
|
}
|
|
alchemyModellist = Config.Instance.GetAllValues<AlchemyConfig>();
|
SetDandrugRedPointlist();
|
GlobalTimeEvent.Instance.secondEvent += SecondUpdate;
|
}
|
|
public override void UnInit()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= SecondUpdate;
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
isFirstGet = true;
|
isMakeDan = false;
|
_stovelv = 1;
|
_stoveExp = 0;
|
addExp = 0;
|
preStoveLv = 1;
|
jumpToPrescripe = 0;
|
treasureRefineDict.Clear();
|
FuncOpen.Instance.OnFuncStateChangeEvent -= RefreshFuncOpenState;
|
playerPack.RefreshItemCountAct -= RefreshMat;
|
playerPack.ItemCntReduceAct -= RefreshDanReduce;
|
playerPack.RefreshItemSumUseCntAct -= RefreshItemUsce;
|
WindowCenter.Instance.windowAfterCloseEvent -= StoveUpgradAfterClose;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshRealm;
|
|
}
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
private void RefreshFuncOpenState(int funcId)
|
{
|
if (funcId != (int)FuncOpenEnum.BlastFurnace) return;
|
|
CheckMakerDandrugCondition();
|
CheckRecycleStoreRed();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
CheckMakerDandrugCondition();
|
CheckRecycleStoreRed();
|
CheckMakeDrugRedPoint(true);
|
playerPack.RefreshItemCountAct += RefreshMat;
|
FuncOpen.Instance.OnFuncStateChangeEvent += RefreshFuncOpenState;
|
playerPack.RefreshItemSumUseCntAct += RefreshItemUsce;
|
WindowCenter.Instance.windowAfterCloseEvent += StoveUpgradAfterClose;
|
playerPack.ItemCntReduceAct += RefreshDanReduce;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += RefreshRealm;
|
}
|
|
public void RefreshAddSpecMat(AlchemySpecConfig alchemySpecModel)
|
{
|
if (RefreshAddSpecMatEvent != null)
|
RefreshAddSpecMatEvent(alchemySpecModel);
|
}
|
|
public bool isMakeDan { get; set; }
|
public bool isFirstGet { get; private set;}
|
private void SecondUpdate()
|
{
|
if (makerItemID == 0) return;
|
|
if(isMakeDan)
|
{
|
if(!WindowCenter.Instance.CheckOpen<MakerDrugSuccessWin>())
|
{
|
WindowCenter.Instance.Open<MakerDrugSuccessWin>();
|
}
|
isMakeDan = false;
|
}
|
else
|
{
|
if (WindowCenter.Instance.CheckOpen<MakerDrugSuccessWin>())
|
{
|
WindowCenter.Instance.CloseImmediately<MakerDrugSuccessWin>();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 得到服务端的炼丹炉数据
|
/// </summary>
|
private int _stovelv = 1;
|
private int preStoveLv = 1;
|
public int StoveLV { get { return _stovelv; } } // 炼丹炉等级
|
private int _stoveExp = 0;
|
public int StoveExp { get { return _stoveExp; } } // 炼丹炉经验
|
public int addExp = 0;
|
public event Action RefreshStoveModelEvent;
|
public int makerItemID { get; private set; }
|
public bool StoveIsUpGrade { get; private set; }
|
public void RefreshBlastFurnaceModel(HA3BF_tagMCPlayerStoveMsg data)
|
{
|
DebugEx.Log("RefreshBlastFurnaceModel");
|
addExp = (int)data.StoveExp - _stoveExp;
|
if (addExp < 0)
|
{
|
addExp = GetBlastFurnaceUpgradExp() - _stoveExp + (int)data.StoveExp;
|
}
|
_stovelv = data.StoveLV;
|
_stoveExp = (int)data.StoveExp;
|
makerItemID = (int)data.ItemID;
|
CheckMakerDandrugCondition();
|
if(!isFirstGet)
|
{
|
isMakeDan = true;
|
if(preStoveLv < data.StoveLV)
|
{
|
preStoveLv = data.StoveLV;
|
StoveIsUpGrade = true;
|
}
|
else
|
{
|
preStoveLv = data.StoveLV;
|
StoveIsUpGrade = false;
|
}
|
PlayRecycleGuid();
|
if (makerItemID == 0 && addExp > 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("RecyclingElixir", addExp);
|
}
|
}
|
else
|
{
|
isFirstGet = false;
|
preStoveLv = data.StoveLV;
|
}
|
if (RefreshStoveModelEvent != null)
|
RefreshStoveModelEvent();
|
|
}
|
|
public bool IsReachMaxStoveLv()
|
{
|
bool isReach = false;
|
if (StoveLV >= MaxStoveLv)
|
{
|
if (StoveExp >= GetBlastFurnaceUpgradExp())
|
{
|
isReach = true;
|
}
|
}
|
return isReach;
|
}
|
|
public Dictionary<uint, byte> treasureRefineDict = new Dictionary<uint, byte>(); //key 法宝ID value 等级
|
public event Action RefreshTreasureRefineEvent;
|
public Treasure treasureData { get; private set; }
|
public void RefreshTreasureRefineModel(HA3BE_tagMCMagicWeaponMsg data)
|
{
|
}
|
|
public int GetAllTreasureRefineLv()
|
{
|
int sumLv = 0;
|
foreach (var value in treasureRefineDict.Values)
|
{
|
sumLv += value;
|
}
|
return sumLv;
|
}
|
|
/// <summary>
|
/// 判断法宝是否精炼到满级
|
/// </summary>
|
/// <param name="treasureId"></param>
|
/// <param name="lv"></param>
|
/// <returns></returns>
|
public bool TreasureIsFullLv(int treasureId, int lv)
|
{
|
if (_tagTreasureRefineModeDict == null)
|
return false;
|
|
if (_tagTreasureRefineModeDict.ContainsKey(treasureId))
|
{
|
if (_tagTreasureRefineModeDict[treasureId][_tagTreasureRefineModeDict[treasureId].Count - 1].TreasureLV <= lv)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 得到炼丹和铸炼的结果
|
/// </summary>
|
public event Action<MakeType,int> RefreshMakeItemAnswerAct;
|
public void GetMakerResult(H0721_tagMakeItemAnswer answer)
|
{
|
DebugEx.Log("GetMakerResult" + answer.Result);
|
switch((MakeType)answer.MakeType)
|
{
|
case MakeType.Def_mitRefine:
|
if (answer.Result == 1)
|
{
|
if (makerItemID != 0)
|
{
|
if (!WindowCenter.Instance.CheckOpen<MakerDrugSuccessWin>())
|
{
|
WindowCenter.Instance.Open<MakerDrugSuccessWin>();
|
}
|
}
|
}
|
else
|
{
|
if (!WindowCenter.Instance.CheckOpen<MakerDrugFailWin>())
|
{
|
WindowCenter.Instance.Open<MakerDrugFailWin>();
|
}
|
}
|
break;
|
case MakeType.Def_mitMWUpLevel:
|
if (answer.Result == 1)
|
{
|
if (!WindowCenter.Instance.CheckOpen<TreasureRefineSuccessWin>())
|
{
|
WindowCenter.Instance.Open<TreasureRefineSuccessWin>();
|
}
|
}
|
else
|
{
|
if (!WindowCenter.Instance.CheckOpen<TreasureRefineFailWin>())
|
{
|
WindowCenter.Instance.Open<TreasureRefineFailWin>();
|
}
|
}
|
break;
|
}
|
if(RefreshMakeItemAnswerAct != null)
|
{
|
RefreshMakeItemAnswerAct((MakeType)answer.MakeType,answer.Result);
|
}
|
}
|
|
#region 灵丹和玄丹的逻辑处理
|
|
/// <summary>
|
/// 得到升级到下一级炼丹炉所需要的等级
|
/// </summary>
|
/// <returns></returns>
|
public int GetBlastFurnaceUpgradExp()
|
{
|
int exp = 0;
|
_blastFurnaceExpDict.TryGetValue(StoveLV, out exp);
|
return exp;
|
}
|
|
/// <summary>
|
/// 设置当前丹药所需材料
|
/// </summary>
|
private int[] materialIds;
|
private int[] materialNums;
|
private AlchemyConfig _tagAlchemyModel;
|
private Dictionary<int, int> _alchemyMaterialDict;
|
public void SetAlchemyMaterial(int alchemyId)
|
{
|
materialIds = null;
|
materialNums = null;
|
_tagAlchemyModel = Config.Instance.Get<AlchemyConfig>(alchemyId);
|
if (_tagAlchemyModel == null)
|
return;
|
|
_alchemyMaterialDict = ConfigParse.GetDic<int, int>(_tagAlchemyModel.MaterialAll);
|
materialIds = _alchemyMaterialDict.Keys.ToArray();
|
materialNums = _alchemyMaterialDict.Values.ToArray();
|
}
|
|
/// <summary>
|
/// 得到每个位置对应的材料
|
/// </summary>
|
public int materialId { get; private set; }
|
public int materialNum { get; private set; }
|
public void GetAlchemyMaterial(int pos)
|
{
|
materialId = 0;
|
materialNum = 0;
|
if (materialIds == null)
|
return;
|
if (pos < materialIds.Length)
|
{
|
materialId = materialIds[pos];
|
materialNum = materialNums[pos];
|
}
|
}
|
|
/// <summary>
|
/// 得到预览合成丹药的列表
|
/// </summary>
|
public Dictionary<int, int> GetPreviewMakeDruglist(AlchemyConfig alchemyModel)
|
{
|
JsonData jsonData = JsonMapper.ToObject(alchemyModel.AlchemPreviewItem);
|
PreviewItemDict.Clear();
|
if (jsonData.IsArray)
|
{
|
for (int i = 0; i < jsonData.Count; i++)
|
{
|
if (jsonData[i].IsArray)
|
{
|
int itemId = int.Parse(jsonData[i][0].ToString());
|
if (jsonData[i].Count > 1)
|
{
|
int effectId = int.Parse(jsonData[i][1].ToString());
|
PreviewItemDict.Add(itemId, effectId);
|
}
|
else
|
{
|
PreviewItemDict.Add(itemId, 0);
|
}
|
}
|
}
|
}
|
return PreviewItemDict;
|
}
|
|
Dictionary<int, int> PreviewItemDict = new Dictionary<int, int>();
|
public Dictionary<int, int> GetPreviewSpecMakeDruglist(AlchemySpecConfig alchemyModel)
|
{
|
JsonData jsonData = JsonMapper.ToObject(alchemyModel.AlchemPreviewItem);
|
PreviewItemDict.Clear();
|
if (jsonData.IsArray)
|
{
|
for (int i = 0; i < jsonData.Count; i++)
|
{
|
if(jsonData[i].IsArray)
|
{
|
int itemId = int.Parse(jsonData[i][0].ToString());
|
if (jsonData[i].Count > 1)
|
{
|
int effectId = int.Parse(jsonData[i][1].ToString());
|
PreviewItemDict.Add(itemId,effectId);
|
}
|
else
|
{
|
PreviewItemDict.Add(itemId,0);
|
}
|
}
|
}
|
}
|
return PreviewItemDict;
|
}
|
|
public int GetEffectIdByItemId(int itemId)
|
{
|
int effectId = 0;
|
PreviewItemDict.TryGetValue(itemId,out effectId);
|
return effectId;
|
}
|
|
/// <summary>
|
/// 设置特殊材料的数据
|
/// </summary>
|
private List<AlchemySpecConfig> _alchemySpecModellist = new List<AlchemySpecConfig>();
|
private AlchemySpecConfig _alchemySpecModel;
|
public void SetAlchemySpecModellist(int[] models)
|
{
|
_alchemySpecModellist.Clear();
|
if (models == null)
|
return;
|
int i = 0;
|
for (i = 0; i < models.Length; i++)
|
{
|
_alchemySpecModel = Config.Instance.Get<AlchemySpecConfig>(models[i]);
|
if (_alchemySpecModel != null)
|
{
|
_alchemySpecModellist.Add(_alchemySpecModel);
|
}
|
}
|
}
|
|
public List<AlchemySpecConfig> GetAlchemySpecModellist()
|
{
|
return _alchemySpecModellist;
|
}
|
#endregion
|
|
#region 法宝的逻辑处理
|
private List<int> collectedTreasurelist = new List<int>();
|
private Dictionary<int, List<TreasureRefineConfig>> _tagTreasureRefineModeDict;
|
public List<int> GetCollectedTreasureList()
|
{
|
collectedTreasurelist.Clear();
|
_tagTreasureRefineModeDict = TreasureRefineConfig.GetTreasureRefineDict();
|
foreach (var key in _tagTreasureRefineModeDict.Keys)
|
{
|
Treasure treasure = null;
|
sTreasureModel.TryGetTreasure(key, out treasure);
|
if (treasure != null)
|
{
|
if (treasure.state == TreasureState.Collected)
|
{
|
collectedTreasurelist.Add(key);
|
}
|
}
|
}
|
return collectedTreasurelist;
|
}
|
|
/// <summary>
|
/// 设置法宝铸炼的属性 材料
|
/// </summary>
|
|
public int[] attrIDs { get; private set; }
|
public int[] attrValues { get; private set; }
|
private Dictionary<int, int> _treasureAttrDict;
|
|
public void SetTreasureRefineModel(TreasureRefineConfig model)
|
{
|
_treasureAttrDict = null;
|
attrIDs = null;
|
attrValues = null;
|
|
if (model == null)
|
return;
|
_treasureAttrDict = ConfigParse.GetDic<int, int>(model.TreasureLVStatus);
|
attrIDs = _treasureAttrDict.Keys.ToArray();
|
attrValues = _treasureAttrDict.Values.ToArray();
|
|
}
|
|
public int[] nextAttrIDs { get; private set; }
|
public int[] nextAttrValues { get; private set; }
|
public int nextRefineMaterialID { get; private set; }
|
public int nextRefineMaterialNum { get; private set; }
|
private string[] arrays;
|
private Dictionary<int, int> _nextTreasureAttrDict;
|
public void SetNextTreasureRefineModel(TreasureRefineConfig model)
|
{
|
_nextTreasureAttrDict = null;
|
nextAttrIDs = null;
|
nextAttrValues = null;
|
|
if (model == null)
|
return;
|
_nextTreasureAttrDict = ConfigParse.GetDic<int, int>(model.TreasureLVStatus);
|
nextAttrIDs = _nextTreasureAttrDict.Keys.ToArray();
|
nextAttrValues = _nextTreasureAttrDict.Values.ToArray();
|
arrays = model.TreasureUpItems.Split('_');
|
nextRefineMaterialID = int.Parse(arrays[0]);
|
nextRefineMaterialNum = int.Parse(arrays[1]);
|
}
|
|
/// <summary>
|
/// 得到当前法宝的所有技能
|
/// </summary>
|
public Dictionary<int, TreasureSkillData> treasureSkillDict = new Dictionary<int, TreasureSkillData>(); // key 技能ID
|
private List<TreasureRefineConfig> _tagTreasureRefineModellist;
|
public void SetTreasureSkillDict(int treasureId, int lv)
|
{
|
treasureSkillDict.Clear();
|
_tagTreasureRefineModellist = TreasureRefineConfig.GetTreasureRefineList(treasureId);
|
if (_tagTreasureRefineModellist == null)
|
return;
|
|
int i = 0;
|
int length = _tagTreasureRefineModellist.Count;
|
for (i = 0; i < length; i++)
|
{
|
if (_tagTreasureRefineModellist[i].OpenSkill != 0)
|
{
|
|
if (lv >= _tagTreasureRefineModellist[i].TreasureLV)
|
{
|
TreasureSkillData skillData = new TreasureSkillData(_tagTreasureRefineModellist[i].TreasureLV, false);
|
AddTreasureSkillDict(_tagTreasureRefineModellist[i].OpenSkill, skillData);
|
}
|
else
|
{
|
TreasureSkillData skillData = new TreasureSkillData(_tagTreasureRefineModellist[i].TreasureLV, true);
|
AddTreasureSkillDict(_tagTreasureRefineModellist[i].OpenSkill, skillData);
|
}
|
}
|
}
|
}
|
private void AddTreasureSkillDict(int skillId, TreasureSkillData skillData)
|
{
|
if (treasureSkillDict.ContainsKey(skillId))
|
treasureSkillDict[skillId] = skillData;
|
else
|
treasureSkillDict.Add(skillId, skillData);
|
}
|
|
/// <summary>
|
/// 预览法宝属性值
|
/// </summary>
|
private PlayerPropertyConfig _playerProModel;
|
public string GetTreasureAttrStr(int proID, int value, bool showName)
|
{
|
_playerProModel = Config.Instance.Get<PlayerPropertyConfig>(proID);
|
if (_playerProModel == null)
|
return "";
|
string s = "";
|
if (showName)
|
{
|
if (_playerProModel.Name.Contains("%s"))
|
s = _playerProModel.Name.Replace("%s", GetProValueTypeStr(_playerProModel.ISPercentage, value));
|
else
|
s = _playerProModel.Name + ":" + GetProValueTypeStr(_playerProModel.ISPercentage, value);
|
|
}
|
else
|
{
|
s = GetProValueTypeStr(_playerProModel.ISPercentage, value);
|
}
|
return s;
|
}
|
|
public string GetFireSuccessRate(int proID, int value)
|
{
|
if (proID != 226)
|
return "";
|
|
string s = Language.Get("Supplement1006", Mathf.RoundToInt(value / 100));
|
return s;
|
}
|
|
public int fireId { get; private set; }
|
public event Action<float> RefreshSuccessRateEvent;
|
public void SetCurUseFire(int fireId, float value)
|
{
|
this.fireId = fireId;
|
if (RefreshSuccessRateEvent != null)
|
RefreshSuccessRateEvent(value);
|
}
|
|
#endregion
|
|
/// <summary>
|
/// 得到可以选择炉火的丹药
|
/// </summary>
|
public List<int> canUseFireDandrugIDs { get; private set; }
|
public void GetBlastFurnaceRecipe()
|
{
|
canUseFireDandrugIDs = null;
|
_tagfuncModel = Config.Instance.Get<FuncConfigConfig>("BlastFurnaceRecipe");
|
if (_tagfuncModel == null)
|
return;
|
canUseFireDandrugIDs = ConfigParse.GetMultipleStr<int>(_tagfuncModel.Numerical1).ToList();
|
}
|
|
#region 选择炉火逻辑处理
|
|
/// <summary>
|
/// 得到炼丹炉火和条件限制
|
/// </summary>
|
private FuncConfigConfig _tagfuncModel;
|
public int[] fireIds { get; private set; }
|
public int openBlastFurnaceLv { get; private set; }
|
public void GetRefineStoveConditions()
|
{
|
fireIds = null;
|
openBlastFurnaceLv = 0;
|
_tagfuncModel = Config.Instance.Get<FuncConfigConfig>("RefineStove");
|
if (_tagfuncModel == null)
|
return;
|
fireIds = ConfigParse.GetMultipleStr<int>(_tagfuncModel.Numerical1);
|
openBlastFurnaceLv = int.Parse(_tagfuncModel.Numerical2);
|
|
}
|
|
|
|
#endregion
|
|
public string GetProValueTypeStr(int isPercentage, int value)
|
{
|
string s = "";
|
if (isPercentage == 0)
|
{
|
s = value.ToString();
|
}
|
else if (isPercentage == 1)
|
{
|
s = (float)Math.Round(value / 100f, 1) + "%";
|
}
|
else if (isPercentage == 2)
|
{
|
s = ((float)Math.Round(value / 100f, 1)).ToString();
|
}
|
return s;
|
}
|
|
#region 发送请求
|
public void SendRefineTreasureQuest(uint treasureId, uint materId)
|
{
|
CA577_tagCMMWRefine cMMWRefine = new CA577_tagCMMWRefine();
|
cMMWRefine.MWID = treasureId;
|
cMMWRefine.MaterialID = materId;
|
GameNetSystem.Instance.SendInfo(cMMWRefine);
|
fireId = 0;
|
}
|
|
public void SendMakerDrugQuest(ushort drugId, uint specConfigID)
|
{
|
CA576_tagCMPlayerRefine cMPlayerRefine = new CA576_tagCMPlayerRefine();
|
cMPlayerRefine.RefineNum = drugId;
|
cMPlayerRefine.UseRateItem = specConfigID;
|
GameNetSystem.Instance.SendInfo(cMPlayerRefine);
|
fireId = 0;
|
}
|
|
#endregion
|
|
public event Action<bool> OnMakeDrugSuccess;
|
public void SetMakeDrugSuccessEvent(bool isClick)
|
{
|
if (OnMakeDrugSuccess != null)
|
{
|
OnMakeDrugSuccess(isClick);
|
}
|
}
|
|
#region 红点逻辑处理
|
public const int BLASTREDPOINT_KEY = 110;
|
public Redpoint blastRedpoint = new Redpoint(MainRedDot.RedPoint_key, BLASTREDPOINT_KEY);
|
public const int LINGDANREDPOINT_KEY = 11001;
|
public Redpoint lingDanRedpoint = new Redpoint(BLASTREDPOINT_KEY, LINGDANREDPOINT_KEY);
|
public const int SPECMATREDPOINT_KEY = 110011000;
|
private Redpoint specMatRedpoint = new Redpoint(SPECMATREDPOINT_KEY);
|
public const int RECYCLESTORE_KEY = 11003;
|
public Redpoint recycleStoreRedpoint = new Redpoint(BLASTREDPOINT_KEY, RECYCLESTORE_KEY);
|
public const int RECYCLEBTN_KEY = 110031000;
|
private Redpoint recycleBtnRedpoint = new Redpoint(RECYCLESTORE_KEY, RECYCLEBTN_KEY);
|
public List<Redpoint> danDrugRedPointlist { get; private set; }
|
|
public const int RedPoint_MakeDrugKey = 11002;
|
public Redpoint MakeDrugRedpoint = new Redpoint(BLASTREDPOINT_KEY, RedPoint_MakeDrugKey);
|
|
public void SetDandrugRedPointlist()
|
{
|
if (alchemyModellist == null) return;
|
|
danDrugRedPointlist = new List<Redpoint>();
|
int i = 0;
|
for (i = 0; i < alchemyModellist.Count; i++)
|
{
|
int id = LINGDANREDPOINT_KEY * 1000 + i;
|
Redpoint danRedPoint = new Redpoint(LINGDANREDPOINT_KEY, id);
|
danDrugRedPointlist.Add(danRedPoint);
|
}
|
}
|
|
private void RefreshMat(PackType type, int index, int id)
|
{
|
if (type != PackType.rptItem) return;
|
|
CheckMakerDandrugCondition();
|
CheckRecycleStoreRed();
|
|
if (playerPack.CheckIsDrugById(id))
|
{
|
CheckMakeDrugRedPoint();
|
if (blastFurnacePromoteUpdate != null)
|
{
|
blastFurnacePromoteUpdate();
|
}
|
}
|
}
|
|
private void RefreshItemUsce(int id)
|
{
|
if(playerPack.CheckIsDrugById(id))
|
{
|
CheckMakerDandrugCondition();
|
CheckRecycleStoreRed();
|
CheckMakeDrugRedPoint();
|
StoveIsUpGrade = false;
|
PlayRecycleGuid();
|
if (blastFurnacePromoteUpdate != null)
|
{
|
blastFurnacePromoteUpdate();
|
}
|
}
|
}
|
|
private void RefreshRealm(PlayerDataRefresh type)
|
{
|
if (type != PlayerDataRefresh.OfficialRank) return;
|
|
CheckMakeDrugRedPoint();
|
if (blastFurnacePromoteUpdate != null)
|
{
|
blastFurnacePromoteUpdate();
|
}
|
}
|
public bool IsMakeDrugWin { get;set; }
|
public void CheckMakeDrugRedPoint(bool isLogin = false,bool isClick = false)
|
{
|
bool isCheckRed = false;
|
if(!isClick)
|
{
|
if(PlayerDatas.Instance.baseData.LV <= 151)
|
{
|
isCheckRed = true;
|
}
|
else if(PlayerDatas.Instance.baseData.LV > 151 && !isLogin && !IsMakeDrugWin)
|
{
|
isCheckRed = true;
|
}
|
|
if(isCheckRed)
|
{
|
List<AttrFruitConfig> list = playerPack.makeDruglist;
|
if (list != null)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, list[i].ID);
|
if (haveCnt > 0 && !playerPack.IsReachMaxUseDrug(list[i]))
|
{
|
MakeDrugRedpoint.state = RedPointState.Simple;
|
return;
|
}
|
}
|
}
|
MakeDrugRedpoint.state = RedPointState.None;
|
}
|
else
|
{
|
MakeDrugRedpoint.state = RedPointState.None;
|
}
|
}
|
else
|
{
|
if(PlayerDatas.Instance.baseData.LV > 151)
|
{
|
MakeDrugRedpoint.state = RedPointState.None;
|
}
|
}
|
}
|
|
public bool CheckUseDrugLimit()
|
{
|
int realmLv = PlayerDatas.Instance.baseData.realmLevel;
|
List<AttrFruitConfig> list = playerPack.makeDruglist;
|
if (list != null)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, list[i].ID);
|
var itemConfig = Config.Instance.Get<ItemConfig>(list[i].ID);
|
if (haveCnt > 0 && !playerPack.IsReachMaxUseDrug(list[i])
|
&& itemConfig != null && itemConfig.RealmLimit <= realmLv)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
public void CheckMakerDandrugCondition()
|
{
|
for (int i = alchemyModellist.Count - 1; i > -1; i--)
|
{
|
danDrugRedPointlist[i].state = RedPointState.None;
|
}
|
|
if (alchemyModellist == null || !FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlastFurnace)) return;
|
|
for (int i = alchemyModellist.Count - 1; i > -1; i--)
|
{
|
if (StoveLV >= alchemyModellist[i].BlastFurnaceLV)
|
{
|
if (IsSpecMatEnough(alchemyModellist[i]) && IsNormalMatEnough(alchemyModellist[i]))
|
{
|
danDrugRedPointlist[i].state = RedPointState.Simple;
|
return;
|
}
|
}
|
}
|
|
for (int i = alchemyModellist.Count - 1; i > -1; i--)
|
{
|
if (StoveLV >= alchemyModellist[i].BlastFurnaceLV)
|
{
|
if(!CheckNormalAlchemyIsReachMaxUse(alchemyModellist[i]))
|
{
|
if (IsNormalMatEnough(alchemyModellist[i]) && !IsHaveReachFull(alchemyModellist[i]))
|
{
|
danDrugRedPointlist[i].state = RedPointState.Simple;
|
return;
|
}
|
}
|
}
|
}
|
|
}
|
|
public bool IsSpecMatEnough(AlchemyConfig alchemyConfig)
|
{
|
if (alchemyConfig == null) return false;
|
if (alchemyConfig.SpecialItem == null || alchemyConfig.SpecialItem.Length < 1) return false;
|
|
bool isEnough = false;
|
for (int i = 0; i < alchemyConfig.SpecialItem.Length; i++)
|
{
|
AlchemySpecConfig specConfig = Config.Instance.Get<AlchemySpecConfig>(alchemyConfig.SpecialItem[i]);
|
int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, specConfig.SpecialMaterialD);
|
if (haveCnt >= specConfig.SpecialMateriaNUM)
|
{
|
isEnough = true;
|
break;
|
}
|
}
|
return isEnough;
|
}
|
|
public bool IsNormalMatEnough(AlchemyConfig alchemyConfig)
|
{
|
if (alchemyConfig == null) return false;
|
bool isEnough = true;
|
Dictionary<int, int> matDict = ConfigParse.GetDic<int, int>(alchemyConfig.MaterialAll);
|
foreach (var id in matDict.Keys)
|
{
|
int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, id);
|
if (haveCnt < matDict[id])
|
{
|
isEnough = false;
|
break;
|
}
|
}
|
return isEnough;
|
}
|
|
public bool IsHaveReachFull(AlchemyConfig alchemyConfig)
|
{
|
if (alchemyConfig == null) return false;
|
List<int> previewlist = GetPreviewMakeDruglist(alchemyConfig).Keys.ToList();
|
for(int i = 0; i < previewlist.Count; i++)
|
{
|
if(playerPack.CheckIsDrugById(previewlist[i]))
|
{
|
AttrFruitConfig fruitConfig = Config.Instance.Get<AttrFruitConfig>(previewlist[i]);
|
if(!playerPack.IsReachMaxUseDrug(fruitConfig))
|
{
|
return false;
|
}
|
}
|
}
|
return true;
|
}
|
|
public bool CheckNormalAlchemyIsReachMaxUse(AlchemyConfig alchemyConfig)
|
{
|
if (alchemyConfig == null) return false;
|
|
List<int> previewlist = GetPreviewMakeDruglist(alchemyConfig).Keys.ToList();
|
for(int i = 0; i < previewlist.Count; i++)
|
{
|
if(playerPack.CheckIsDrugById(previewlist[i]))
|
{
|
AttrFruitConfig fruitConfig = Config.Instance.Get<AttrFruitConfig>(previewlist[i]);
|
if(!playerPack.IsReachMaxUseDrug(fruitConfig))
|
{
|
return false;
|
}
|
}
|
}
|
|
return true;
|
}
|
|
public void SpecMatRedPointCtrl(AlchemyConfig alchemyConfig, bool isShow = true)
|
{
|
if (alchemyConfig == null) return;
|
|
specMatRedpoint.state = RedPointState.None;
|
if (isShow)
|
{
|
if (IsSpecMatEnough(alchemyConfig) && alchemyConfig.BlastFurnaceLV <= StoveLV)
|
{
|
specMatRedpoint.state = RedPointState.Simple;
|
}
|
}
|
}
|
|
public void CheckRecycleStoreRed()
|
{
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlastFurnace)) return;
|
|
if(IsRecycleDanDrug())
|
{
|
recycleBtnRedpoint.state = RedPointState.Simple;
|
}
|
else
|
{
|
recycleBtnRedpoint.state = RedPointState.None;
|
}
|
}
|
|
public bool IsRecycleDanDrug()
|
{
|
List<ItemModel> itemModels = GetRecycleDanlist();
|
if(itemModels != null && itemModels.Count > 0)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
|
private void StoveUpgradAfterClose(Window win)
|
{
|
if (win.name != "StoveUpgradWin") return;
|
StoveIsUpGrade = false;
|
PlayRecycleGuid();
|
}
|
|
|
private void RefreshDanReduce(PackType type, int index, int id)
|
{
|
if (type != PackType.rptItem || !playerPack.CheckIsDrugById(id)) return;
|
StoveIsUpGrade = false;
|
PlayRecycleGuid();
|
}
|
|
public void PlayRecycleGuid()
|
{
|
if (IsRecycleDanDrug()
|
&& !NewBieCenter.Instance.completeGuidesBuf.Contains(93)
|
&& !StoveIsUpGrade)
|
{
|
NewBieCenter.Instance.StartNewBieGuide(93);
|
}
|
}
|
#endregion
|
|
#region 回收丹药逻辑处理
|
private bool isOpenPrompting = true;
|
/// <summary>
|
/// 回收丹药
|
/// </summary>
|
/// <param name="itemId"></param>
|
public void RecycleDrug(int itemId,int exp)
|
{
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(itemId);
|
if (isOpenPrompting)
|
{
|
int recycleNum = playerPack.GetItemCountByID(PackType.rptItem,itemId);
|
ConfirmCancel.IconConfirmCancel(Language.Get("Mail101"), Language.Get("BlastFurnace114",recycleNum ,UIHelper.GetTextColorByItemColor(itemConfig.ItemColor, itemConfig.ItemName),exp*recycleNum), itemConfig.ID,
|
playerPack.GetItemCountByID(PackType.rptItem, itemConfig.ID), 0,"", Language.Get("ConfirmCancel102"), (bool isOk, bool isToggle) =>
|
{
|
if (isOk)
|
{
|
int noBindNum = 0;
|
List<int> indexs = null;
|
List<int> nums = null;
|
if(CheckIsNoBindDrug(itemId,out noBindNum,out indexs,out nums))
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),Language.Get("BlastFurnace115",noBindNum, UIHelper.GetTextColorByItemColor(itemConfig.ItemColor, itemConfig.ItemName)),
|
(bool isRecycle)=>
|
{
|
if(isRecycle)
|
{
|
SendRecycleDrugQuest(indexs,nums);
|
}
|
});
|
}
|
else
|
{
|
SendRecycleDrugQuest(indexs, nums);
|
}
|
}
|
isOpenPrompting = !isToggle;
|
});
|
}
|
else
|
{
|
int noBindNum = 0;
|
List<int> indexs = null;
|
List<int> nums = null;
|
if (CheckIsNoBindDrug(itemId, out noBindNum, out indexs, out nums))
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("BlastFurnace115", noBindNum, UIHelper.GetTextColorByItemColor(itemConfig.ItemColor, itemConfig.ItemName)),
|
(bool isRecycle) =>
|
{
|
if (isRecycle)
|
{
|
SendRecycleDrugQuest(indexs, nums);
|
}
|
});
|
}
|
else
|
{
|
SendRecycleDrugQuest(indexs, nums);
|
}
|
}
|
|
}
|
|
private bool CheckIsNoBindDrug(int itemId,out int nobindNums,out List<int> indexs,out List<int> nums)
|
{
|
indexs = new List<int>();
|
nums = new List<int>();
|
nobindNums = 0;
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null) return false;
|
|
List<ItemModel> items;
|
singlePack.GetItemCountByID(itemId,out items);
|
for(int i = 0; i < items.Count; i++)
|
{
|
indexs.Add(items[i].itemInfo.ItemPlace);
|
nums.Add(items[i].itemInfo.ItemCount);
|
if (items[i].itemInfo.IsBind == 0)
|
{
|
nobindNums += items[i].itemInfo.ItemCount;
|
}
|
}
|
if(nobindNums > 0)
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
/// <summary>
|
/// 获得所有可回收丹药
|
/// </summary>
|
/// <returns></returns>
|
private List<ItemModel> GetRecycleDanlist()
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null) return null;
|
|
List<ItemModel> itemModels = new List<ItemModel>();
|
List<AttrFruitConfig> fruitlist = playerPack.makeDruglist;
|
Dictionary<int, ItemModel> itemDict = singlePack.GetPackModelIndexDict();
|
foreach (var index in itemDict.Keys)
|
{
|
if (playerPack.CheckIsDrugById(itemDict[index].itemId))
|
{
|
AttrFruitConfig fruitConfig = Config.Instance.Get<AttrFruitConfig>(itemDict[index].itemId);
|
if (playerPack.IsReachMaxUseDrug(fruitConfig))
|
{
|
itemModels.Add(itemDict[index]);
|
}
|
}
|
}
|
|
return itemModels;
|
}
|
|
Dictionary<string, List<ItemModel>> lookRecycleDict = new Dictionary<string, List<ItemModel>>();
|
public Dictionary<string,List<ItemModel>> GetLookRecycleDanlist()
|
{
|
lookRecycleDict.Clear();
|
recycleStrlist.Clear();
|
List<ItemModel> itemModels = GetRecycleDanlist();
|
if (itemModels == null) return lookRecycleDict;
|
|
itemModels.Sort(CompareByDanBindAndLv);
|
|
for(int i = 0; i < itemModels.Count; i++)
|
{
|
string key = StringUtility.Contact(itemModels[i].itemId,"IsBind",itemModels[i].itemInfo.IsBind);
|
if(!lookRecycleDict.ContainsKey(key))
|
{
|
List<ItemModel> modellist = new List<ItemModel>();
|
modellist.Add(itemModels[i]);
|
lookRecycleDict.Add(key,modellist);
|
if(itemModels[i].itemInfo.IsBind == 1)
|
{
|
AddSelectRecycleDan(itemModels[i]);
|
}
|
}
|
else
|
{
|
lookRecycleDict[key].Add(itemModels[i]);
|
}
|
}
|
|
return lookRecycleDict;
|
}
|
|
private int CompareByDanBindAndLv(ItemModel start,ItemModel end)
|
{
|
bool isBindStart = start.itemInfo.IsBind == 1 ? true : false;
|
bool isBindEnd = end.itemInfo.IsBind == 1 ? true : false;
|
if (isBindStart.CompareTo(isBindEnd) != 0) return -isBindStart.CompareTo(isBindEnd);
|
|
int startLv = start.chinItemModel.LV;
|
int endLv = end.chinItemModel.LV;
|
if (startLv.CompareTo(endLv) != 0) return startLv.CompareTo(endLv);
|
|
return 0;
|
}
|
|
Dictionary<int, int> recycleDanDict = new Dictionary<int, int>();
|
public List<string> recycleStrlist = new List<string>();
|
public event Action RefreshSelectRecycleAct;
|
public void AddSelectRecycleDan(ItemModel itemModel)
|
{
|
string key = StringUtility.Contact(itemModel.itemId, "IsBind", itemModel.itemInfo.IsBind);
|
if(!recycleStrlist.Contains(key))
|
{
|
recycleStrlist.Add(key);
|
}
|
|
if(RefreshSelectRecycleAct != null)
|
{
|
RefreshSelectRecycleAct();
|
}
|
}
|
|
public void RemoveSelectRecycleDan(ItemModel itemModel)
|
{
|
string key = StringUtility.Contact(itemModel.itemId, "IsBind", itemModel.itemInfo.IsBind);
|
if (recycleStrlist.Contains(key))
|
{
|
recycleStrlist.Remove(key);
|
}
|
|
if (RefreshSelectRecycleAct != null)
|
{
|
RefreshSelectRecycleAct();
|
}
|
}
|
|
public int GetRecycleMoney()
|
{
|
int money = 0;
|
foreach(var key in lookRecycleDict.Keys)
|
{
|
if(recycleStrlist.Contains(key))
|
{
|
List<ItemModel> itemModels = lookRecycleDict[key];
|
for(int i = 0; i < itemModels.Count; i++)
|
{
|
AttrFruitConfig fruitConfig = Config.Instance.Get<AttrFruitConfig>(itemModels[i].itemId);
|
money = money + fruitConfig.RecycleExp * itemModels[i].itemInfo.ItemCount;
|
}
|
}
|
}
|
return money;
|
}
|
|
public void SetSelectRecycleDan()
|
{
|
if(recycleStrlist.Count < 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("AlchemyRecycling");
|
return;
|
}
|
#region 设置回收数据
|
int unBindCnt = 0;
|
int sumCnt = 0;
|
int getMoney = 0;
|
recycleDanDict.Clear();
|
for (int i = 0; i < recycleStrlist.Count; i++)
|
{
|
List<ItemModel> modellist = null;
|
lookRecycleDict.TryGetValue(recycleStrlist[i],out modellist);
|
if(modellist != null)
|
{
|
for(int j = 0; j < modellist.Count; j++)
|
{
|
sumCnt += modellist[j].itemInfo.ItemCount;
|
if(modellist[j].itemInfo.IsBind == 0)
|
{
|
unBindCnt += modellist[j].itemInfo.ItemCount;
|
}
|
|
if(playerPack.CheckIsDrugById(modellist[j].itemId))
|
{
|
AttrFruitConfig fruitConfig = Config.Instance.Get<AttrFruitConfig>(modellist[j].itemId);
|
getMoney = getMoney + fruitConfig.RecycleExp * modellist[j].itemInfo.ItemCount;
|
}
|
|
if(!recycleDanDict.ContainsKey(modellist[j].itemInfo.ItemPlace))
|
{
|
recycleDanDict.Add(modellist[j].itemInfo.ItemPlace,modellist[j].itemInfo.ItemCount);
|
}
|
else
|
{
|
recycleDanDict[modellist[j].itemInfo.ItemPlace] += modellist[j].itemInfo.ItemCount;
|
}
|
}
|
}
|
}
|
#endregion
|
|
if (isOpenPrompting)
|
{
|
ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("BlastFurnace114",sumCnt,getMoney,string.Format("<Img chat={0}/>",StringUtility.Contact("Money_Type_",27))),
|
Language.Get("ConfirmCancel102"),(bool isOk, bool isToggle) =>
|
{
|
if (isOk)
|
{
|
if(unBindCnt > 0)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("BlastFurnace115", unBindCnt),
|
(bool isRecycle) =>
|
{
|
if (isRecycle)
|
{
|
SendRecycleDrugQuest(recycleDanDict.Keys.ToList(), recycleDanDict.Values.ToList());
|
}
|
});
|
}
|
else
|
{
|
SendRecycleDrugQuest(recycleDanDict.Keys.ToList(), recycleDanDict.Values.ToList());
|
}
|
}
|
isOpenPrompting = !isToggle;
|
});
|
}
|
else
|
{
|
if (unBindCnt > 0)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("BlastFurnace115", unBindCnt),
|
(bool isRecycle) =>
|
{
|
if (isRecycle)
|
{
|
SendRecycleDrugQuest(recycleDanDict.Keys.ToList(), recycleDanDict.Values.ToList());
|
}
|
});
|
}
|
else
|
{
|
SendRecycleDrugQuest(recycleDanDict.Keys.ToList(), recycleDanDict.Values.ToList());
|
}
|
}
|
|
}
|
|
public void SendRecycleDrugQuest(List<int> indexs,List<int> nums)
|
{
|
CA32A_tagCMRecycleAttrFruit recycleAttrFruit = new CA32A_tagCMRecycleAttrFruit();
|
recycleAttrFruit.IndexCount = (byte)indexs.Count;
|
byte[] indexByte = new byte[indexs.Count];
|
ushort[] numShort = new ushort[indexs.Count];
|
for (int i = 0; i < indexs.Count; i++)
|
{
|
indexByte[i] = (byte)indexs[i];
|
numShort[i] = (ushort)nums[i];
|
}
|
recycleAttrFruit.IndexList = indexByte;
|
recycleAttrFruit.RecycleCountList = numShort;
|
GameNetSystem.Instance.SendInfo(recycleAttrFruit);
|
}
|
#endregion
|
}
|
|
public struct TreasureSkillData
|
{
|
public int treasureLv { get; private set; }
|
public bool islock { get; private set; }
|
|
public TreasureSkillData(int lv, bool islock)
|
{
|
this.treasureLv = lv;
|
this.islock = islock;
|
}
|
}
|
|
public struct PreviewXuanDan
|
{
|
public int code { get; private set; }
|
public int id { get; private set; }
|
public int count { get; private set; }
|
public bool isUpgrade { get; private set; }
|
|
public PreviewXuanDan(int code, int id, int count, bool upgrade = false)
|
{
|
this.code = code;
|
this.id = id;
|
this.count = count;
|
this.isUpgrade = upgrade;
|
}
|
}
|
|
public struct UpgradeDan
|
{
|
public int id { get; private set; }
|
public int lv { get; private set; }
|
public int code { get; private set; }
|
|
public UpgradeDan(int code, int id, int lv)
|
{
|
this.id = id;
|
this.lv = lv;
|
this.code = code;
|
}
|
}
|
|
public enum BlastFurnaceFuncTitle
|
{
|
MakeDan, //炼丹
|
AttrDan, //丹药属性
|
}
|
|
|
|