using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
using UnityEngine;
|
using LitJson;
|
|
public class BlastFurnaceModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
{
|
public BlastFurnaceFuncTitle funcTitle = BlastFurnaceFuncTitle.MakeDan;
|
private int makeDrugRedLv;
|
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 MaxStoveLv { get; private set; }
|
public List<AlchemyConfig> alchemyModellist { get; private set; }
|
|
public int jumpToPrescripe { get; set; }
|
|
public event Action blastFurnacePromoteUpdate;
|
|
PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
|
|
public override void Init()
|
{
|
ParseAlchemyConfig();
|
ParseAlchemySpecConfig();
|
_blastFurnaceExpDict = new Dictionary<int, int>();
|
List<RefineStoveConfig> stovelist = RefineStoveConfig.GetValues();
|
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;
|
}
|
|
FuncConfigConfig alchemyRedPoint = FuncConfigConfig.Get("AlchemyRedPoint");
|
int.TryParse(alchemyRedPoint.Numerical1, out makeDrugRedLv);
|
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;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= RefreshFuncOpenState;
|
playerPack.refreshItemCountEvent -= RefreshMat;
|
playerPack.itemCntReduceEvent -= RefreshDanReduce;
|
playerPack.refreshItemSumUseCountEvent -= RefreshItemUsce;
|
WindowCenter.Instance.windowAfterCloseEvent -= StoveUpgradAfterClose;
|
|
}
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
CheckMakerDandrugCondition();
|
CheckRecycleStoreRed();
|
CheckMakeDrugRedPoint(true);
|
playerPack.refreshItemCountEvent += RefreshMat;
|
FuncOpen.Instance.OnFuncStateChangeEvent += RefreshFuncOpenState;
|
playerPack.refreshItemSumUseCountEvent += RefreshItemUsce;
|
WindowCenter.Instance.windowAfterCloseEvent += StoveUpgradAfterClose;
|
playerPack.itemCntReduceEvent += RefreshDanReduce;
|
|
}
|
|
#region 解析本地数据
|
public Dictionary<int, AlchemyData> alchemyDataDict { get; private set; }
|
private void ParseAlchemyConfig()
|
{
|
alchemyDataDict = new Dictionary<int, AlchemyData>();
|
alchemyModellist = AlchemyConfig.GetValues();
|
//for (int i = 0; i < alchemyModellist.Count; i++)
|
//{
|
// var alchemyConfig = alchemyModellist[i];
|
// AlchemyData alchemyData = new AlchemyData();
|
// alchemyData.id = alchemyConfig.AlchemyID;
|
// alchemyData.alchemyConfig = alchemyConfig;
|
// alchemyData.normalMatDic = ConfigParse.GetDic<int, int>(alchemyConfig.MaterialAll);
|
// alchemyData.previewDict = GetPreviewDict(alchemyConfig.AlchemPreviewItem);
|
// if (!alchemyDataDict.ContainsKey(alchemyConfig.AlchemyID))
|
// {
|
// alchemyDataDict.Add(alchemyConfig.AlchemyID, alchemyData);
|
// }
|
//}
|
}
|
public Dictionary<int, AlchemySpecData> alchemySpecDataDict { get; private set; }
|
private void ParseAlchemySpecConfig()
|
{
|
alchemySpecDataDict = new Dictionary<int, AlchemySpecData>();
|
var speclist = AlchemySpecConfig.GetValues();
|
for (int i = 0; i < speclist.Count; i++)
|
{
|
var specConfig = speclist[i];
|
AlchemySpecData specData = new AlchemySpecData();
|
specData.id = specConfig.ID;
|
specData.specConfig = specConfig;
|
specData.previewDict = GetPreviewDict(specConfig.AlchemPreviewItem);
|
if (!alchemySpecDataDict.ContainsKey(specConfig.ID))
|
{
|
alchemySpecDataDict.Add(specConfig.ID, specData);
|
}
|
}
|
}
|
/// <summary>
|
/// 得到预览合成丹药的列表
|
/// </summary>
|
private Dictionary<int, int> GetPreviewDict(string alchemyPreview)
|
{
|
Dictionary<int, int> keyValues = new Dictionary<int, int>();
|
JsonData jsonData = JsonMapper.ToObject(alchemyPreview);
|
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());
|
keyValues.Add(itemId, effectId);
|
}
|
else
|
{
|
keyValues.Add(itemId, 0);
|
}
|
}
|
}
|
}
|
return keyValues;
|
}
|
|
public AlchemyData GetAlchemyData(int id)
|
{
|
AlchemyData alchemyData = null;
|
alchemyDataDict.TryGetValue(id, out alchemyData);
|
return alchemyData;
|
}
|
|
public AlchemySpecData GetAlchemySpecData(int id)
|
{
|
AlchemySpecData specData = null;
|
alchemySpecDataDict.TryGetValue(id, out specData);
|
return specData;
|
}
|
|
public class AlchemyData
|
{
|
public int id;
|
public AlchemyConfig alchemyConfig;
|
public Dictionary<int, int> normalMatDic;
|
public Dictionary<int, int> previewDict;
|
}
|
|
public class AlchemySpecData
|
{
|
public int id;
|
public AlchemySpecConfig specConfig;
|
public Dictionary<int, int> previewDict;
|
}
|
#endregion
|
|
private void RefreshFuncOpenState(int funcId)
|
{
|
if (funcId != (int)FuncOpenEnum.BlastFurnace) return;
|
|
CheckMakerDandrugCondition();
|
CheckRecycleStoreRed();
|
}
|
|
|
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)
|
{
|
isMakeDan = false;
|
}
|
else
|
{
|
}
|
}
|
|
/// <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;
|
}
|
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;
|
}
|
|
/// <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.DrugRefine:
|
if (answer.Result == 1)
|
{
|
if (makerItemID != 0)
|
{
|
}
|
}
|
else
|
{
|
}
|
break;
|
}
|
if (RefreshMakeItemAnswerAct != null)
|
{
|
RefreshMakeItemAnswerAct((MakeType)answer.MakeType, answer.Result);
|
}
|
}
|
|
#region 丹药筛选
|
public List<int> sortDruglist = new List<int>();
|
public void SetSortDruglist(int lv, bool isAdd, int sumNum)
|
{
|
if (lv != 0)
|
{
|
if (isAdd)
|
{
|
if (!sortDruglist.Contains(lv))
|
{
|
sortDruglist.Add(lv);
|
}
|
|
if (sortDruglist.Count >= sumNum - 1)
|
{
|
if (!sortDruglist.Contains(0))
|
{
|
sortDruglist.Add(0);
|
}
|
}
|
}
|
else
|
{
|
if (sortDruglist.Contains(lv))
|
{
|
sortDruglist.Remove(lv);
|
}
|
|
if (sortDruglist.Contains(0))
|
{
|
sortDruglist.Remove(0);
|
}
|
}
|
}
|
else
|
{
|
sortDruglist.Clear();
|
if (isAdd)
|
{
|
sortDruglist.Add(lv);
|
}
|
}
|
}
|
#endregion
|
|
#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;
|
var alchemyData = GetAlchemyData(alchemyId);
|
if (alchemyData == null)
|
return;
|
|
_alchemyMaterialDict = alchemyData.normalMatDic;
|
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)
|
{
|
//if (alchemyModel == null) return null;
|
//var alchmeyData = GetAlchemyData(alchemyModel.AlchemyID);
|
//if (alchmeyData == null) return null;
|
|
return null;
|
}
|
|
public Dictionary<int, int> GetPreviewSpecMakeDruglist(AlchemySpecConfig alchemyModel)
|
{
|
if (alchemyModel == null) return null;
|
var specData = GetAlchemySpecData(alchemyModel.ID);
|
if (specData == null) return null;
|
|
return specData.previewDict;
|
}
|
|
public List<int> GetPreviewIdlist(AlchemyConfig alchemyConfig)
|
{
|
if (alchemyConfig == null) return null;
|
var dict = GetPreviewMakeDruglist(alchemyConfig);
|
if (dict == null) return null;
|
|
return dict.Keys.ToList();
|
}
|
|
public List<int> GetSpecPreviewIdlist(AlchemySpecConfig specConfig)
|
{
|
if (specConfig == null) return null;
|
var dict = GetPreviewSpecMakeDruglist(specConfig);
|
if (dict == null) return null;
|
|
return dict.Keys.ToList();
|
}
|
|
/// <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 = AlchemySpecConfig.Get(models[i]);
|
if (_alchemySpecModel != null)
|
{
|
_alchemySpecModellist.Add(_alchemySpecModel);
|
}
|
}
|
}
|
|
public List<AlchemySpecConfig> GetAlchemySpecModellist()
|
{
|
return _alchemySpecModellist;
|
}
|
#endregion
|
|
#region 发送请求
|
public void SendMakerDrugQuest(ushort drugId, uint specConfigID)
|
{
|
//CA576_tagCMPlayerRefine cMPlayerRefine = new CA576_tagCMPlayerRefine();
|
//cMPlayerRefine.RefineNum = drugId;
|
//cMPlayerRefine.UseRateItem = specConfigID;
|
//GameNetSystem.Instance.SendInfo(cMPlayerRefine);
|
}
|
|
#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.Item) 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;
|
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 <= makeDrugRedLv)
|
{
|
isCheckRed = true;
|
}
|
else if (PlayerDatas.Instance.baseData.LV > makeDrugRedLv && !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.Item, 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 > makeDrugRedLv)
|
{
|
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.Item, list[i].ID);
|
var itemConfig = ItemConfig.Get(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])
|
// && !CheckIsHavePetOrMount(alchemyModellist[i]))
|
// {
|
// danDrugRedPointlist[i].state = RedPointState.Simple;
|
// 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;
|
// }
|
// }
|
// }
|
//}
|
|
}
|
|
private bool CheckIsHavePetOrMount(AlchemyConfig alchemyConfig)
|
{
|
if (alchemyConfig == null) return true;
|
|
Dictionary<int, List<int>> specDrugDict = null;
|
IsSpecMatEnough(alchemyConfig, out specDrugDict);
|
|
foreach (var key in specDrugDict.Keys)
|
{
|
List<int> idlist = specDrugDict[key];
|
for (int i = 0; i < idlist.Count; i++)
|
{
|
if (tipsModel.unlockPetDict.ContainsKey(idlist[i]))
|
{
|
PetInfoConfig petInfo = tipsModel.unlockPetDict[idlist[i]];
|
var petmodel = ModelCenter.Instance.GetModel<PetModel>();
|
if (!petmodel._DicPetBack.ContainsKey(petInfo.ID))
|
{
|
return false;
|
}
|
}
|
|
if (tipsModel.unlockMountDict.ContainsKey(idlist[i]))
|
{
|
HorseConfig horseConfig = tipsModel.unlockMountDict[idlist[i]];
|
var mountModel = ModelCenter.Instance.GetModel<MountModel>();
|
if (!mountModel._DicHorse.ContainsKey(horseConfig.HorseID))
|
{
|
return false;
|
}
|
}
|
}
|
}
|
|
return true;
|
}
|
|
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 = AlchemySpecConfig.Get(alchemyConfig.SpecialItem[i]);
|
// int haveCnt = playerPack.GetItemCountByID(PackType.Item, specConfig.SpecialMaterialD);
|
// if (haveCnt >= specConfig.SpecialMateriaNUM)
|
// {
|
// isEnough = true;
|
// break;
|
// }
|
//}
|
return false;
|
}
|
|
public bool IsSpecMatEnough(AlchemyConfig alchemyConfig, out Dictionary<int, List<int>> specDurgDict)
|
{
|
specDurgDict = null;
|
//specDurgDict = new Dictionary<int, List<int>>();
|
//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 = AlchemySpecConfig.Get(alchemyConfig.SpecialItem[i]);
|
// int haveCnt = playerPack.GetItemCountByID(PackType.Item, specConfig.SpecialMaterialD);
|
// if (haveCnt >= specConfig.SpecialMateriaNUM)
|
// {
|
// isEnough = true;
|
// List<int> specIdlist = GetSpecPreviewIdlist(specConfig);
|
// specDurgDict.Add(specConfig.SpecialMaterialD, specIdlist);
|
// }
|
//}
|
return false;
|
}
|
|
public bool IsNormalMatEnough(AlchemyConfig alchemyConfig)
|
{
|
//if (alchemyConfig == null) return false;
|
//bool isEnough = true;
|
//var matDict = GetAlchemyData(alchemyConfig.AlchemyID).normalMatDic;
|
//foreach (var id in matDict.Keys)
|
//{
|
// int haveCnt = playerPack.GetItemCountByID(PackType.Item, id);
|
// if (haveCnt < matDict[id])
|
// {
|
// isEnough = false;
|
// break;
|
// }
|
//}
|
return false;
|
}
|
|
public bool IsHaveReachFull(AlchemyConfig alchemyConfig)
|
{
|
var previewlist = GetPreviewIdlist(alchemyConfig);
|
if (previewlist == null) return false;
|
|
for (int i = 0; i < previewlist.Count; i++)
|
{
|
if (playerPack.CheckIsDrugById(previewlist[i]))
|
{
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(previewlist[i]);
|
if (!playerPack.IsReachMaxUseDrug(fruitConfig))
|
{
|
return false;
|
}
|
}
|
}
|
return true;
|
}
|
|
public bool CheckNormalAlchemyIsReachMaxUse(AlchemyConfig alchemyConfig)
|
{
|
var previewlist = GetPreviewIdlist(alchemyConfig);
|
if (previewlist == null) return false;
|
|
for (int i = 0; i < previewlist.Count; i++)
|
{
|
if (playerPack.CheckIsDrugById(previewlist[i]))
|
{
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(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;
|
}
|
|
private void RefreshDanReduce(PackType type, int index, int id)
|
{
|
if (type != PackType.Item || !playerPack.CheckIsDrugById(id)) return;
|
StoveIsUpGrade = false;
|
}
|
|
#endregion
|
|
#region 回收丹药逻辑处理
|
private bool isOpenPrompting = true;
|
/// <summary>
|
/// 回收丹药
|
/// </summary>
|
/// <param name="itemId"></param>
|
public void RecycleDrug(int itemId, int exp)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
if (isOpenPrompting)
|
{
|
int recycleNum = playerPack.GetItemCountByID(PackType.Item, itemId);
|
ConfirmCancel.IconConfirmCancel(Language.Get("Mail101"), Language.Get("BlastFurnace114", recycleNum, UIHelper.AppendColor(itemConfig.ItemColor, itemConfig.ItemName), exp * recycleNum), itemConfig.ID,
|
playerPack.GetItemCountByID(PackType.Item, itemConfig.ID), 0, "", Language.Get("ConfirmCancel102"), (bool isOk, bool isToggle) =>
|
{
|
if (isOk)
|
{
|
var drugs = GetDrugs(itemId);
|
SendRecycleDrugQuest(drugs);
|
}
|
isOpenPrompting = !isToggle;
|
});
|
}
|
else
|
{
|
var drugs = GetDrugs(itemId);
|
SendRecycleDrugQuest(drugs);
|
}
|
}
|
|
private Dictionary<int, int> GetDrugs(int itemId)
|
{
|
var drugs = new Dictionary<int, int>();
|
var items = playerPack.GetItemsById(PackType.Item, itemId);
|
if (!items.IsNullOrEmpty())
|
{
|
for (int i = 0; i < items.Count; i++)
|
{
|
var item = items[i];
|
drugs[item.gridIndex] = item.count;
|
}
|
}
|
|
return drugs;
|
}
|
|
/// <summary>
|
/// 获得所有可回收丹药
|
/// </summary>
|
/// <returns></returns>
|
private List<ItemModel> GetRecycleDanlist()
|
{
|
SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
|
if (singlePack == null) return null;
|
|
List<ItemModel> itemModels = new List<ItemModel>();
|
List<AttrFruitConfig> fruitlist = playerPack.makeDruglist;
|
Dictionary<int, ItemModel> itemDict = singlePack.GetAllItems();
|
foreach (var index in itemDict.Keys)
|
{
|
if (playerPack.CheckIsDrugById(itemDict[index].itemId))
|
{
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(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 = itemModels[i].itemId.ToString();
|
if (!lookRecycleDict.ContainsKey(key))
|
{
|
List<ItemModel> modellist = new List<ItemModel>();
|
modellist.Add(itemModels[i]);
|
lookRecycleDict.Add(key, modellist);
|
AddSelectRecycleDan(itemModels[i]);
|
}
|
else
|
{
|
lookRecycleDict[key].Add(itemModels[i]);
|
}
|
}
|
|
return lookRecycleDict;
|
}
|
|
private int CompareByDanBindAndLv(ItemModel start, ItemModel end)
|
{
|
int startLv = start.config.LV;
|
int endLv = end.config.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 = itemModel.itemId.ToString();
|
if (!recycleStrlist.Contains(key))
|
{
|
recycleStrlist.Add(key);
|
}
|
|
if (RefreshSelectRecycleAct != null)
|
{
|
RefreshSelectRecycleAct();
|
}
|
}
|
|
public void RemoveSelectRecycleDan(ItemModel itemModel)
|
{
|
string key = itemModel.itemId.ToString();
|
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 = AttrFruitConfig.Get(itemModels[i].itemId);
|
money = money + fruitConfig.RecycleExp * itemModels[i].count;
|
}
|
}
|
}
|
return money;
|
}
|
|
public void SetSelectRecycleDan()
|
{
|
if (recycleStrlist.Count < 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("AlchemyRecycling");
|
return;
|
}
|
#region 设置回收数据
|
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++)
|
{
|
if (playerPack.CheckIsDrugById(modellist[j].itemId))
|
{
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(modellist[j].itemId);
|
getMoney += fruitConfig.RecycleExp * modellist[j].count;
|
}
|
|
if (!recycleDanDict.ContainsKey(modellist[j].gridIndex))
|
{
|
recycleDanDict.Add(modellist[j].gridIndex, modellist[j].count);
|
}
|
else
|
{
|
recycleDanDict[modellist[j].gridIndex] += modellist[j].count;
|
}
|
}
|
}
|
}
|
#endregion
|
|
SendRecycleDrugQuest(recycleDanDict);
|
}
|
|
public void SendRecycleDrugQuest(Dictionary<int, int> drugs)
|
{
|
var recycleAttrFruit = new CA32A_tagCMRecycleAttrFruit();
|
recycleAttrFruit.IndexCount = (byte)drugs.Count;
|
byte[] indexByte = new byte[drugs.Count];
|
ushort[] numShort = new ushort[drugs.Count];
|
|
var index = 0;
|
foreach (var drug in drugs)
|
{
|
indexByte[index] = (byte)drug.Key;
|
numShort[index] = (ushort)drug.Value;
|
index++;
|
}
|
|
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, //丹药属性
|
DrugStore, //回收商店
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
}
|
|
|
|