using Snxxz.UI;
|
using System.Collections.Generic;
|
using System.Text;
|
using UnityEngine;
|
using TableConfig;
|
using System;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class PackSendQuestMgr : Singleton<PackSendQuestMgr>
|
|
{
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
PlayerStrengthengDatas _strengthModel;
|
PlayerStrengthengDatas strengthModel
|
{
|
get
|
{
|
return _strengthModel ?? (_strengthModel = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>());
|
}
|
}
|
|
EquipWashModel _equipWashModel;
|
EquipWashModel equipWashModel
|
{
|
get
|
{
|
return _equipWashModel ?? (_equipWashModel = ModelCenter.Instance.GetModel<EquipWashModel>());
|
}
|
}
|
|
PackModelInterface _modelInterface;
|
PackModelInterface modelInterface
|
{
|
get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); }
|
}
|
|
PlayerBuffDatas _buffModel;
|
PlayerBuffDatas Buffmodel
|
{
|
get
|
{
|
return _buffModel ?? (_buffModel = ModelCenter.Instance.GetModel<PlayerBuffDatas>());
|
}
|
}
|
|
ItemOverdueModel _itemOverdue;
|
ItemOverdueModel itemOverdue
|
{
|
get { return _itemOverdue ?? (_itemOverdue = ModelCenter.Instance.GetModel<ItemOverdueModel>()); }
|
}
|
|
FairyModel m_FairyModel;
|
FairyModel fairyModel
|
{
|
get
|
{
|
return m_FairyModel ?? (m_FairyModel = ModelCenter.Instance.GetModel<FairyModel>());
|
}
|
}
|
|
BoxGetItemModel boxModel;
|
BoxGetItemModel BoxModel
|
{
|
get { return boxModel ?? (boxModel = ModelCenter.Instance.GetModel<BoxGetItemModel>()); }
|
}
|
|
VipModel m_vipModel;
|
VipModel vipModel
|
{
|
get
|
{
|
return m_vipModel ?? (m_vipModel = ModelCenter.Instance.GetModel<VipModel>());
|
}
|
}
|
|
PlayerSuitModel _suitModel;
|
PlayerSuitModel SuitModel
|
{
|
get { return _suitModel ?? (_suitModel = ModelCenter.Instance.GetModel<PlayerSuitModel>()); }
|
}
|
|
RolePointModel rolePointModel { get { return ModelCenter.Instance.GetModel<RolePointModel>(); } }
|
DogzModel dogzModel { get { return ModelCenter.Instance.GetModel<DogzModel>(); } }
|
|
|
#region 发送穿戴装备的请求
|
ItemConfig sendItemConfig = null;
|
public ItemModel sendItemModel = null;
|
int itemIndex = -1;
|
public void SendPutOnQuest(ItemWinBtnType btnType,string guid)
|
{
|
sendItemModel = playerPack.GetItemModelByGUID(guid);
|
if (sendItemModel == null) return;
|
|
sendItemConfig = Config.Instance.Get<ItemConfig>(sendItemModel.itemInfo.ItemID);
|
if(sendItemConfig.JobLimit != 0 && sendItemConfig.JobLimit / 100 != PlayerDatas.Instance.baseData.Job)
|
{
|
SysNotifyMgr.Instance.ShowTip("GeRen_lhs_31379");
|
return;
|
}
|
|
itemIndex = sendItemModel.itemInfo.ItemPlace;
|
List<int> putOnlimitList = sendItemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetCancelUseLimit);
|
if (putOnlimitList != null)
|
{
|
if(putOnlimitList[0] == 1)
|
{
|
CheckPutOnPlace();
|
}
|
else
|
{
|
CheckEquipUselimit(sendItemConfig);
|
}
|
}
|
else
|
{
|
CheckEquipUselimit(sendItemConfig);
|
}
|
}
|
|
public bool CheckEquipUselimit(ItemConfig config)
|
{
|
int[] uselimits = config.UseCondiType;
|
if (uselimits == null || uselimits.Length < 1)
|
{
|
CheckPutOnPlace();
|
return true;
|
}
|
|
bool isCanPut = true;
|
for(int i = 0; i < uselimits.Length; i++)
|
{
|
switch(uselimits[i])
|
{
|
case 0:
|
int playerLv = PlayerDatas.Instance.baseData.LV;
|
if (playerLv < config.UseLV)
|
{
|
isCanPut = false;
|
int remainLv = config.UseLV - playerLv;
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("EquipWinLevelLimit", config.UseLV, remainLv));
|
}
|
break;
|
case 1:
|
isCanPut = CheckPutOnRealm(config);
|
break;
|
case 2:
|
isCanPut = CheckPutOnNeed();
|
break;
|
}
|
}
|
if(isCanPut)
|
{
|
CheckPutOnPlace();
|
}
|
return isCanPut;
|
}
|
|
/// <summary>
|
/// 检测穿戴装备所需要的条件
|
/// </summary>
|
private StringBuilder offsetConditionStr = new StringBuilder();
|
private StringBuilder upgradConditionStr = new StringBuilder();
|
private StringBuilder needConditionStr = new StringBuilder();
|
private Dictionary<AttrEnum, float> sumOffsetlist = new Dictionary<AttrEnum, float>();
|
private Dictionary<AttrEnum, int> sumNeedlist = new Dictionary<AttrEnum, int>();
|
private float sumOffsetPoint = 0;
|
private int sumNeedPoint = 0;
|
private bool CheckPutOnNeed()
|
{
|
int playerJob = PlayerDatas.Instance.baseData.Job;
|
if (playerJob != Math.Floor((double)sendItemConfig.JobLimit / 100) && sendItemConfig.JobLimit != 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("GeRen_lhs_31379");
|
return false;
|
}
|
|
int jobRank = sendItemConfig.JobLimit % 10;
|
offsetConditionStr.Length = 0;
|
sumOffsetlist.Clear();
|
sumNeedlist.Clear();
|
sumOffsetPoint = 0;
|
sumNeedPoint = 0;
|
needConditionStr.Length = 0;
|
upgradConditionStr.Length = 0;
|
float offset = 0;
|
if (sendItemConfig.LimitSTR != 0)
|
{
|
offset = sendItemConfig.LimitSTR - UIHelper.GetPropertyMapPlayerData(AttrEnum.POWER);
|
if (offset > 0)
|
{
|
if (offsetConditionStr.Length > 0)
|
{
|
offsetConditionStr.Append("\n" + Language.Get("KnapS136", offset));
|
}
|
else
|
{
|
offsetConditionStr.Append(Language.Get("KnapS136", offset));
|
}
|
|
if (upgradConditionStr.Length > 0)
|
{
|
upgradConditionStr.Append("\n" + Language.Get("KnapS141", Language.Get("KnapS136", sendItemConfig.LimitSTR), offset));
|
}
|
else
|
{
|
upgradConditionStr.Append(Language.Get("KnapS141", Language.Get("KnapS136", sendItemConfig.LimitSTR), offset));
|
}
|
|
sumOffsetPoint += offset;
|
sumNeedPoint += sendItemConfig.LimitSTR;
|
sumOffsetlist.Add(AttrEnum.POWER, offset);
|
}
|
sumNeedlist.Add(AttrEnum.POWER, sendItemConfig.LimitSTR);
|
if (needConditionStr.Length > 0)
|
{
|
needConditionStr.Append("\n" + Language.Get("KnapS136", sendItemConfig.LimitSTR));
|
}
|
else
|
{
|
needConditionStr.Append(Language.Get("KnapS136", sendItemConfig.LimitSTR));
|
}
|
|
}
|
|
if (sendItemConfig.LimitPHY != 0)
|
{
|
offset = sendItemConfig.LimitPHY - UIHelper.GetPropertyMapPlayerData(AttrEnum.AGILITY);
|
if (offset > 0)
|
{
|
if (offsetConditionStr.Length > 0)
|
{
|
offsetConditionStr.Append("\n" + Language.Get("KnapS135", offset));
|
}
|
else
|
{
|
offsetConditionStr.Append(Language.Get("KnapS135", offset));
|
}
|
|
if (upgradConditionStr.Length > 0)
|
{
|
upgradConditionStr.Append("\n" + Language.Get("KnapS141", Language.Get("KnapS135", sendItemConfig.LimitPHY), offset));
|
}
|
else
|
{
|
upgradConditionStr.Append(Language.Get("KnapS141", Language.Get("KnapS135", sendItemConfig.LimitPHY), offset));
|
}
|
|
sumOffsetPoint += offset;
|
sumNeedPoint += sendItemConfig.LimitPHY;
|
sumOffsetlist.Add(AttrEnum.AGILITY, offset);
|
}
|
sumNeedlist.Add(AttrEnum.AGILITY, sendItemConfig.LimitPHY);
|
if (needConditionStr.Length > 0)
|
{
|
needConditionStr.Append("\n" + Language.Get("KnapS135", sendItemConfig.LimitPHY));
|
}
|
else
|
{
|
needConditionStr.Append(Language.Get("KnapS135", sendItemConfig.LimitPHY));
|
}
|
|
}
|
|
if (sendItemConfig.LimitPNE != 0)
|
{
|
offset = sendItemConfig.LimitPNE - UIHelper.GetPropertyMapPlayerData(AttrEnum.MENTALITY);
|
if (offset > 0)
|
{
|
if (offsetConditionStr.Length > 0)
|
{
|
offsetConditionStr.Append("\n" + Language.Get("KnapS137", offset));
|
}
|
else
|
{
|
offsetConditionStr.Append(Language.Get("KnapS137", offset));
|
}
|
|
if (upgradConditionStr.Length > 0)
|
{
|
upgradConditionStr.Append("\n" + Language.Get("KnapS141", Language.Get("KnapS137", sendItemConfig.LimitPNE), offset));
|
}
|
else
|
{
|
upgradConditionStr.Append(Language.Get("KnapS141", Language.Get("KnapS137", sendItemConfig.LimitPNE), offset));
|
}
|
|
sumOffsetPoint += offset;
|
sumOffsetlist.Add(AttrEnum.MENTALITY, offset);
|
sumNeedPoint += sendItemConfig.LimitPNE;
|
}
|
sumNeedlist.Add(AttrEnum.MENTALITY, sendItemConfig.LimitPNE);
|
|
if (needConditionStr.Length > 0)
|
{
|
needConditionStr.Append("\n" + Language.Get("KnapS137", sendItemConfig.LimitPNE));
|
}
|
else
|
{
|
needConditionStr.Append(Language.Get("KnapS137", sendItemConfig.LimitPNE));
|
}
|
|
}
|
|
if (offsetConditionStr.Length > 0)
|
{
|
if (sumOffsetPoint <= PlayerDatas.Instance.baseData.FreePoint)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("KnapS132", offsetConditionStr.ToString()), (bool isOk) => {
|
|
if (isOk)
|
{
|
if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.AddPoint))
|
{
|
foreach (var key in sumOffsetlist.Keys)
|
{
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += RefreshFreePoint;
|
rolePointModel.SendAddPoint((int)key, (int)sumOffsetlist[key]);
|
}
|
}
|
else
|
{
|
FuncOpen.Instance.ProcessorFuncErrorTip((int)FuncOpenEnum.AddPoint);
|
}
|
}
|
});
|
}
|
else
|
{
|
FuncConfigConfig addPointFunc = Config.Instance.Get<FuncConfigConfig>("LVUPAddPoint");
|
int[] rankValue = ConfigParse.GetMultipleStr<int>(addPointFunc.Numerical1);
|
if (addPointFunc != null)
|
{
|
double needUpgradLV = System.Math.Ceiling((sumOffsetPoint - PlayerDatas.Instance.baseData.FreePoint) / rankValue[jobRank - 1]);
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("KnapS134", upgradConditionStr.ToString(), needUpgradLV.ToString()));
|
}
|
}
|
|
return false;
|
}
|
return true;
|
}
|
|
private StringBuilder curRealmImgStr = new StringBuilder();
|
private StringBuilder needRealmImgStr = new StringBuilder();
|
private bool CheckPutOnRealm(ItemConfig config)
|
{
|
curRealmImgStr.Length = 0;
|
needRealmImgStr.Length = 0;
|
var _realmLv = config.RealmLimit;
|
var needRealmConfig = Config.Instance.Get<RealmConfig>(_realmLv);
|
var curRealmConfig = Config.Instance.Get<RealmConfig>(PlayerDatas.Instance.baseData.realmLevel);
|
|
if (PlayerDatas.Instance.baseData.realmLevel < _realmLv)
|
{
|
needRealmImgStr.AppendFormat("<Img img={0}/>", needRealmConfig.Img);
|
if(curRealmConfig != null && PlayerDatas.Instance.baseData.realmLevel > 0)
|
{
|
curRealmImgStr.AppendFormat("<Img img={0}/>", curRealmConfig.Img);
|
}
|
else
|
{
|
curRealmImgStr.AppendFormat("<Img img={0}/>", "NoRealm");
|
}
|
switch(config.EquipPlace)
|
{
|
case 0:
|
ConfirmCancel.ShowRealmPopConfirm(Language.Get("Mail101"), Language.Get("RealmNeeds", needRealmImgStr.ToString(), curRealmImgStr.ToString()),Language.Get("PopConfirmWin_Promote"),()=>
|
{
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.RealmFunc1);
|
});
|
break;
|
default:
|
ConfirmCancel.ShowRealmPopConfirm(Language.Get("Mail101"), Language.Get("KnapS142", needRealmImgStr.ToString(), curRealmImgStr.ToString()), Language.Get("PopConfirmWin_Promote"), () =>
|
{
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.RealmFunc1);
|
});
|
break;
|
}
|
return false;
|
}
|
return true;
|
}
|
|
private void RefreshFreePoint(PlayerDataRefresh refreshType)
|
{
|
switch (refreshType)
|
{
|
case PlayerDataRefresh.STR:
|
case PlayerDataRefresh.PNE:
|
case PlayerDataRefresh.PHY:
|
case PlayerDataRefresh.CON:
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("KnapS138"), Language.Get("KnapS139"), () => {
|
|
CheckPutOnPlace();
|
});
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshFreePoint;
|
}
|
break;
|
}
|
}
|
|
/// <summary>
|
/// 检测穿戴的位置对仙器进行特殊处理
|
/// </summary>
|
private void CheckPutOnPlace()
|
{
|
if ((RoleEquipType)sendItemConfig.EquipPlace == RoleEquipType.retFairyCan)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptEquip);
|
|
ItemModel putOnModel1 = singlePack.GetItemModelByIndex(sendItemConfig.EquipPlace);
|
ItemModel putOnModel2 = singlePack.GetItemModelByIndex((int)RoleEquipType.retFairyCan2);
|
if (putOnModel1 != null || putOnModel2 != null)
|
{
|
WindowCenter.Instance.Open<FairyWearWin>();
|
return;
|
}
|
}
|
CheckSuitReplaceInfo(sendItemConfig.EquipPlace);
|
//CheckBackSuitStone(sendItemConfig.EquipPlace);
|
}
|
|
public void CheckSuitReplaceInfo(int equipPlace)
|
{
|
if (sendItemModel == null) return;
|
|
Dictionary<SuitType,ReplaceSuit> replaceDic = SuitModel.SetReplaceSuitModel(sendItemModel.itemId,equipPlace);
|
if(replaceDic[SuitType.LowSuit].isNoEffect && !replaceDic[SuitType.HighSuit].isNoEffect)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ReplaceSuitPrompt102", UIHelper.GetEquipAreaName(equipPlace), Language.Get("EquipSuitNormal2")),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
else if (replaceDic[SuitType.LowSuit].isPerfect && replaceDic[SuitType.HighSuit].isNoEffect)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ReplaceSuitPrompt102", UIHelper.GetEquipAreaName(equipPlace), Language.Get("EquipSuitHigh")),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
else if(replaceDic[SuitType.LowSuit].isNoEffect && replaceDic[SuitType.HighSuit].isNoEffect)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ReplaceSuitPrompt104", UIHelper.GetEquipAreaName(equipPlace)),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
else if(replaceDic[SuitType.LowSuit].effectLv > 0 && replaceDic[SuitType.HighSuit].effectLv <= 0
|
&& !replaceDic[SuitType.HighSuit].isNoEffect)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ReplaceSuitPrompt101", UIHelper.GetEquipAreaName(equipPlace), Language.Get("EquipSuitNormal2"), replaceDic[SuitType.LowSuit].effectLv),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
else if (replaceDic[SuitType.HighSuit].effectLv > 0 && replaceDic[SuitType.LowSuit].effectLv <= 0)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ReplaceSuitPrompt101", UIHelper.GetEquipAreaName(equipPlace), Language.Get("EquipSuitHigh"), replaceDic[SuitType.LowSuit].effectLv),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
else if(replaceDic[SuitType.HighSuit].isNoEffect && replaceDic[SuitType.LowSuit].effectLv > 0)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ReplaceSuitPrompt103", UIHelper.GetEquipAreaName(equipPlace), replaceDic[SuitType.LowSuit].effectLv),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
else if(replaceDic[SuitType.LowSuit].effectLv > 0 && replaceDic[SuitType.HighSuit].effectLv > 0)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
|
Language.Get("ReplaceSuitPrompt105", UIHelper.GetEquipAreaName(equipPlace), replaceDic[SuitType.HighSuit].effectLv,replaceDic[SuitType.LowSuit].effectLv),
|
(bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
}
|
);
|
return;
|
}
|
|
SendPutOnQuest(equipPlace, itemIndex);
|
}
|
|
public void SendPutOnQuest(int equipPlace, int itemIndex)
|
{
|
EquipAttrShift(equipPlace);
|
C0703_tagCEquipItem putOnEquip = new C0703_tagCEquipItem();
|
putOnEquip.RoleEquipType = (byte)equipPlace;
|
putOnEquip.ItemIndex = (byte)itemIndex;
|
GameNetSystem.Instance.SendInfo(putOnEquip);
|
|
SoundPlayer.Instance.PlayUIAudio(24);
|
}
|
|
|
/// <summary>
|
/// 替换装备时属性转移提示
|
/// </summary>
|
private void EquipAttrShift(int equipPlace)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptEquip);
|
ItemModel putOnModel = singlePack.GetItemModelByIndex(equipPlace);
|
if (putOnModel == null)
|
return;
|
|
Dictionary<int, EquipmentInitialization> equipStrengthDic = strengthModel._EqInfo;
|
bool isPrompt = strengthModel.TheRatingPrompt(sendItemModel.itemInfo.ItemID);
|
if (isPrompt && !PlayerPrefs.HasKey(PlayerPackModel.StrengthAttrShift_RecordKey))
|
{
|
LocalSave.SetBool(PlayerPackModel.StrengthAttrShift_RecordKey,true);
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("SwitchEquip_Strengthen"));
|
}
|
|
if (equipStrengthDic.ContainsKey(equipPlace))
|
{
|
if (equipStrengthDic[equipPlace].EquipPartStarLV >= 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("SwitchEquip_Strengthen2");
|
}
|
}
|
|
uint[] stones = PlayerStoneData.Instance.GetStoneInfo(equipPlace);
|
|
if (stones != null)
|
{
|
int i = 0;
|
for (i = 0; i < stones.Length; i++)
|
{
|
if (stones[i] != 0 && sendItemConfig.LV >= itemTipsModel.gemOpenLvs[0])
|
{
|
SysNotifyMgr.Instance.ShowTip("SwitchEquip_Gem");
|
break;
|
}
|
}
|
}
|
|
if (SuitModel.IsPerfectGetSuitLv(sendItemConfig.ID,equipPlace))
|
{
|
SysNotifyMgr.Instance.ShowTip("SwitchEquip_SuitPanel");
|
}
|
|
WashProCount washPro = equipWashModel.GetWashEquipInfo(equipPlace);
|
|
if (washPro != null)
|
{
|
int i = 0;
|
for (i = 0; i < washPro.XLAttrCnt; i++)
|
{
|
if (washPro.proValuelist[i].XLAttrValue > 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("SwitchEquip_Wash");
|
break;
|
}
|
}
|
}
|
|
}
|
#endregion
|
|
#region 发送脱下装备的请求
|
public void SendPutOffQuest(ItemWinBtnType btnType,string guid)
|
{
|
ItemModel putOnModel = playerPack.GetItemModelByGUID(guid);
|
if (putOnModel == null || putOnModel.packType != PackType.rptEquip) return;
|
|
SinglePackModel rptItemPack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (rptItemPack == null) return;
|
|
if (rptItemPack.GetRemainGridCount() < 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_998371");
|
}
|
else
|
{
|
C0704_tagCUnEquipItem putOffEquip = new C0704_tagCUnEquipItem();
|
putOffEquip.EquipIndex = (byte)putOnModel.itemInfo.ItemPlace;
|
putOffEquip.PackIndex = (byte)rptItemPack.GetNullGridIndex();
|
GameNetSystem.Instance.SendInfo(putOffEquip);
|
SoundPlayer.Instance.PlayUIAudio(25);
|
}
|
}
|
#endregion
|
|
#region 发送放入仓库请求
|
public void SendPutInQuest(ItemWinBtnType btnType, string guid)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByGUID(guid);
|
if (itemModel == null) return;
|
|
C0C01_tagCPutItemInWarehouse putInWarehouse = new C0C01_tagCPutItemInWarehouse();
|
putInWarehouse.ItemIndex = (ushort)itemModel.itemInfo.ItemPlace;
|
//putInWarehouse.WarehouseIndex = (ushort)wareHousePack.GetNullGridIndex();
|
putInWarehouse.WarehouseIndex = 0;
|
putInWarehouse.Count = (ushort)itemModel.itemInfo.ItemCount;
|
GameNetSystem.Instance.SendInfo(putInWarehouse);
|
}
|
#endregion
|
|
#region 发送从仓库取出请求
|
public void SendPutOutQuest(ItemWinBtnType btnType, string guid)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByGUID(guid);
|
if (itemModel == null) return;
|
|
C0C02_tagCGetItemInWarehouse putOutWarehouse = new C0C02_tagCGetItemInWarehouse();
|
putOutWarehouse.WarehouseIndex = (ushort)itemModel.itemInfo.ItemPlace;
|
//putOutWarehouse.ItemIndex = (ushort)singlePack.GetNullGridIndex();
|
putOutWarehouse.ItemIndex = 0;
|
putOutWarehouse.Count = (ushort)itemModel.itemInfo.ItemCount;
|
GameNetSystem.Instance.SendInfo(putOutWarehouse);
|
}
|
#endregion
|
|
#region 发送使用物品请求
|
|
public ItemModel useItemModel { get; set; }
|
public void SendUseItemQuest(ItemWinBtnType btnType,int itemIndex)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null) return;
|
|
useItemModel = singlePack.GetItemModelByIndex(itemIndex);
|
if (useItemModel == null) return;
|
|
if(useItemModel.chinItemModel.Type == (int)ItemType.Box)
|
{
|
BoxModel.SetModel(useItemModel.itemInfo.ItemGUID, useItemModel.itemInfo.ItemID);
|
return;
|
}
|
|
if (useItemModel.itemId == 951)
|
{
|
int startLockIndex = singlePack.openGridCount - playerPack.InitBagGridCnt;
|
int chooseGridCnt = singlePack.openGridCount + GetExtendGridCnt(startLockIndex);
|
modelInterface.OpenGrid(chooseGridCnt, PackType.rptItem);
|
return;
|
}
|
|
if(playerPack.CheckIsDrugById(useItemModel.itemInfo.ItemID))
|
{
|
if(CheckItemUselimit(useItemModel.chinItemModel))
|
{
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.MakeDrug);
|
}
|
return;
|
}
|
|
int dungeonID = playerPack.GetDungeonIDByDrugID(useItemModel.itemInfo.ItemID);
|
if (dungeonID != 0)
|
{
|
MapConfig tagMapModel = Config.Instance.Get<MapConfig>(PlayerDatas.Instance.baseData.MapID);
|
if (tagMapModel.MapFBType == 0)
|
{
|
DungeonOpenTimeConfig timeConfig = Config.Instance.Get<DungeonOpenTimeConfig>(dungeonID);
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("DrugUsePrompt", useItemModel.chinItemModel.ItemName, timeConfig.FBName),
|
(bool isOk) =>
|
{
|
if (isOk)
|
{
|
CheckUseCondition(useItemModel);
|
}
|
});
|
return;
|
}
|
}
|
|
for (int i = 0; i < itemTipsModel.jumpAndUseTypes.Length; i++)
|
{
|
if (itemTipsModel.jumpAndUseTypes[i] == useItemModel.chinItemModel.Type)
|
{
|
CheckUseCondition(useItemModel);
|
if (useItemModel.chinItemModel.Jump != 0)
|
{
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)useItemModel.chinItemModel.Jump);
|
}
|
return;
|
}
|
}
|
|
if (useItemModel.chinItemModel.Jump != 0)
|
{
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)useItemModel.chinItemModel.Jump);
|
}
|
else
|
{
|
CheckUseCondition(useItemModel);
|
}
|
}
|
|
/// <summary>
|
/// 获取当前道具可以开启的格子数
|
/// </summary>
|
/// <param name="startLockIndex"></param>
|
/// <param name="needTool"></param>
|
/// <param name="extendCnt"></param>
|
/// <returns></returns>
|
private int GetExtendGridCnt(int startLockIndex, int needTool = 0, int extendCnt = 0)
|
{
|
FuncConfigConfig _tagFuncModel = Config.Instance.Get<FuncConfigConfig>("OpenBagItem");
|
int haveCount = playerPack.GetItemCountByID(PackType.rptItem, useItemModel.itemId);
|
startLockIndex += 1;
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("index", startLockIndex);
|
needTool += Equation.Instance.Eval<int>(_tagFuncModel.Numerical2);
|
if (haveCount >= needTool)
|
{
|
extendCnt += 1;
|
return GetExtendGridCnt(startLockIndex, needTool, extendCnt);
|
}
|
else
|
{
|
if (extendCnt <= 0)
|
{
|
extendCnt = 1;
|
}
|
int remianLock = playerPack.MaxBagGridCnt - playerPack.GetSinglePackModel(PackType.rptItem).openGridCount;
|
if(extendCnt > remianLock)
|
{
|
extendCnt = remianLock;
|
}
|
return extendCnt;
|
}
|
}
|
|
public bool CheckItemUselimit(ItemConfig config)
|
{
|
int[] uselimits = config.UseCondiType;
|
if (uselimits == null) return true;
|
|
for (int i = 0; i < uselimits.Length; i++)
|
{
|
switch (uselimits[i])
|
{
|
case 0:
|
int playerLv = PlayerDatas.Instance.baseData.LV;
|
if (playerLv < config.UseLV)
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("MakeUseItem101", useItemModel.chinItemModel.UseLV));
|
return false;
|
}
|
break;
|
case 1:
|
return CheckPutOnRealm(config);
|
}
|
}
|
|
return true;
|
}
|
|
public void CheckUseCondition(ItemModel itemModel)
|
{
|
if(!CheckItemUselimit(itemModel.chinItemModel))
|
{
|
return;
|
}
|
|
if(itemModel.chinItemModel.Type == 59)
|
{
|
playerPack.SetWashAttrPointModel(itemModel.itemInfo.ItemGUID);
|
WindowCenter.Instance.Open<WashAttrPointWin>();
|
return;
|
}
|
|
if (itemModel.chinItemModel.Effect1 == 209
|
&& !PlayerDatas.Instance.fairyData.HasFairy)
|
{
|
SysNotifyMgr.Instance.ShowTip("jiazu_andyshao_0");
|
return;
|
}
|
|
if(itemModel.itemId == 952)
|
{
|
int maxUseCnt = GetOfflineMaxNum(itemModel);
|
if(maxUseCnt <= 1)
|
{
|
if (!CheckIsMaxOfflineTime(maxUseCnt,itemModel))
|
{
|
SendMakeUseQuest(itemModel.itemInfo.ItemPlace);
|
}
|
}
|
else
|
{
|
BatchUseModel.Instance.SetOfflineUseModel(itemModel.itemInfo.ItemGUID);
|
WindowCenter.Instance.Open<OfflineHangUpUseWin>();
|
}
|
return;
|
}
|
|
if (itemModel.itemInfo.ItemID == fairyModel.changeFairyNameItem)
|
{
|
if (PlayerDatas.Instance.fairyData.HasFairy)
|
{
|
WindowCenter.Instance.Open<FamilyChangeNameWin>();
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("jiazu_andyshao_0");
|
}
|
return;
|
}
|
|
if(dogzModel.AddAssistItem == itemModel.itemInfo.ItemID)
|
{
|
dogzModel.MakeUseAddAssistNum();
|
return;
|
}
|
|
ulong maxValue = 0;
|
playerPack.IsReachUseLimit(itemModel.itemInfo.ItemGUID, out maxValue);
|
if (itemModel.chinItemModel.BatchUse != 0 && maxValue > 1)
|
{
|
BatchUseModel.Instance.SetBatchModel(itemModel.itemInfo.ItemGUID);
|
WindowCenter.Instance.Open<BatchWin>();
|
}
|
else
|
{
|
if (Buffmodel.BuffCover(itemModel.itemInfo.ItemID))
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("FairyLand_Func22"), (bool isOk) =>
|
{
|
if (isOk)
|
{
|
SendMakeUseQuest(itemModel.itemInfo.ItemPlace);
|
}
|
}
|
);
|
}
|
else
|
{
|
switch (itemModel.itemInfo.ItemID)
|
{
|
case RoleRenameWin.renameToolId:
|
WindowCenter.Instance.Open<RoleRenameWin>();
|
break;
|
default:
|
ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.itemInfo.ItemGUID);
|
if (cool == null || cool.GetRemainTime() <= 0)
|
{
|
SendMakeUseQuest(itemModel.itemInfo.ItemPlace);
|
}
|
break;
|
}
|
|
}
|
}
|
}
|
public int GetOfflineMaxNum(ItemModel itemModel)
|
{
|
int remainOffline = HangUpSetModel.Instance.maxOfflinePluginTime - HangUpSetModel.Instance.offlinePluginTime;
|
int maxUseCnt = 0;
|
if (remainOffline > 0)
|
{
|
int extraCnt = remainOffline % itemModel.chinItemModel.EffectValueA1 > 0 ? 1 : 0;
|
maxUseCnt = remainOffline / itemModel.chinItemModel.EffectValueA1 + extraCnt;
|
if (maxUseCnt > itemModel.itemInfo.ItemCount)
|
{
|
return itemModel.itemInfo.ItemCount;
|
}
|
}
|
return maxUseCnt;
|
}
|
|
public bool CheckIsMaxOfflineTime(int useNum, ItemModel itemModel)
|
{
|
int remainOffline = HangUpSetModel.Instance.maxOfflinePluginTime - HangUpSetModel.Instance.offlinePluginTime;
|
if (remainOffline <= 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("OfflinePluginTime");
|
return true;
|
}
|
else
|
{
|
int willTime = HangUpSetModel.Instance.offlinePluginTime + itemModel.chinItemModel.EffectValueA1 * useNum;
|
if (willTime > HangUpSetModel.Instance.maxOfflinePluginTime)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("OfflinePluginTime102"), Language.Get("OfflinePluginTime101"), (bool isOk) =>
|
{
|
if (isOk)
|
{
|
SendMakeUseQuest(itemModel.itemInfo.ItemPlace,useNum);
|
}
|
});
|
return true;
|
}
|
}
|
return false;
|
}
|
public void SendMakeUseQuest(int index, int useCnt = 1, int extra = 0)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptItem,index);
|
if (itemModel == null) return;
|
|
int haveUseCnt = playerPack.GetDayUseCntByID(itemModel.itemInfo.ItemID);
|
if (itemModel.chinItemModel.MaxSkillCnt > 0 && itemModel.chinItemModel.MaxSkillCnt <= haveUseCnt)
|
{
|
SysNotifyMgr.Instance.ShowTip("EverydayUseLimit");
|
return;
|
}
|
int sumHaveUseCnt = playerPack.GetSumUseCntByID(itemModel.itemInfo.ItemID);
|
AttrFruitConfig fruitConfig = Config.Instance.Get<AttrFruitConfig>(itemModel.itemInfo.ItemID);
|
if(fruitConfig != null && (sumHaveUseCnt >= fruitConfig.MaxUseCnt || useCnt > fruitConfig.MaxUseCnt))
|
{
|
SysNotifyMgr.Instance.ShowTip("UseCntLimit");
|
return;
|
}
|
|
CA323_tagCMUseItems useItem = new CA323_tagCMUseItems();
|
useItem.ItemIndex = (byte)index;
|
useItem.UseCnt = (ushort)useCnt;
|
useItem.ExData = (uint)extra;
|
GameNetSystem.Instance.SendInfo(useItem); //使用物品
|
}
|
|
#endregion
|
|
#region 发送拆分请求
|
public void OnClickSplitBtn(ItemWinBtnType btnType, string guid)
|
{
|
WindowCenter.Instance.Open<SplitWin>();
|
}
|
public void SendSplitQuest(string guid,int splitCount)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null) return;
|
|
ItemModel itemModel = playerPack.GetItemModelByGUID(guid);
|
if (itemModel == null || itemModel.packType != PackType.rptItem) return;
|
|
if (playerPack.GetReaminGridCount(PackType.rptItem) < 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_998371");
|
}
|
else
|
{
|
C0708_tagCDragItem itemSplit = new C0708_tagCDragItem();
|
itemSplit.SrcIndex = (ushort)itemModel.itemInfo.ItemPlace;
|
itemSplit.DestIndex = (ushort)singlePack.GetNullGridIndex();
|
itemSplit.ItemCount = (ushort)splitCount;
|
GameNetSystem.Instance.SendInfo(itemSplit); //拆分物体
|
}
|
|
}
|
#endregion
|
|
#region 发送上架请求
|
public void SendPutAwayQuest(ItemWinBtnType btnType, string guid)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByGUID(guid);
|
if (itemModel == null || itemModel.packType != PackType.rptItem) return;
|
|
PutawayData.Instance.Init();
|
PutawayData.Instance.itemModel = itemModel;
|
WindowCenter.Instance.Open<PutawayWin>();
|
}
|
#endregion
|
|
#region 点击镶嵌按钮
|
public void ClickInlayBtn(ItemWinBtnType btnType, string guid)
|
{
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.StrengthFunc2);
|
}
|
#endregion
|
|
#region 点击合成按钮
|
public void ClickComposeBtn(ItemWinBtnType btnType, int jumpId)
|
{
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)jumpId);
|
}
|
#endregion
|
|
#region 发送出售请求
|
public void SendSellQuest(ItemWinBtnType btnType,ItemAttrData attrData)
|
{
|
|
if (attrData.itemConfig.EquipPlace > 0 && attrData.itemConfig.EquipPlace <= (int)RoleEquipType.retSpiritAnimal)
|
{
|
bool isOverdue = modelInterface.IsOverdue(attrData.guid, attrData.itemConfig.ID, attrData.useDataDict);
|
bool isLimit = Math.Floor((double)attrData.itemConfig.JobLimit / 100) == PlayerDatas.Instance.baseData.Job
|
|| attrData.itemConfig.JobLimit == 0 ? true : false;
|
ItemModel putModel = playerPack.GetItemModelByIndex(PackType.rptEquip, attrData.itemConfig.EquipPlace);
|
if (attrData.itemConfig.EquipPlace == (int)RoleEquipType.retFairyCan)
|
{
|
ItemModel fairy2Model = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retFairyCan2);
|
if (fairy2Model == null || putModel == null)
|
{
|
putModel = null;
|
}
|
else
|
{
|
putModel = putModel.equipScore > fairy2Model.equipScore ? fairy2Model : putModel;
|
}
|
}
|
|
if (!isLimit || isOverdue || (putModel != null && attrData.score < putModel.equipScore))
|
{
|
if (attrData.itemConfig.SellTip == 0)
|
{
|
SendSellQuest(attrData.packType, attrData.index);
|
}
|
else if (attrData.itemConfig.SellTip == 1)
|
{
|
SetSellItemPrompt(attrData, "KnapS128", attrData.itemConfig.ItemName);
|
}
|
}
|
else
|
{
|
if (putModel == null)
|
{
|
SetSellItemPrompt(attrData, "KnapS147", UIHelper.GetEquipAreaName(attrData.itemConfig.EquipPlace));
|
}
|
else
|
{
|
if (attrData.itemConfig.SellTip == 0)
|
{
|
SetSellItemPrompt(attrData, "KnapS146", attrData.itemConfig.ItemName);
|
}
|
else if (attrData.itemConfig.SellTip == 1)
|
{
|
SetSellItemPrompt(attrData, "KnapS128", attrData.itemConfig.ItemName);
|
}
|
}
|
}
|
}
|
else
|
{
|
if (attrData.itemConfig.SellTip == 0)
|
{
|
SendSellQuest(attrData.packType, attrData.index);
|
}
|
else if (attrData.itemConfig.SellTip == 1)
|
{
|
SetSellItemPrompt(attrData, "KnapS128", attrData.itemConfig.ItemName);
|
}
|
}
|
|
}
|
|
private void SetSellItemPrompt(ItemAttrData attrData,string key,string parms)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get(key,parms), (bool isOK) =>
|
{
|
if (isOK)
|
{
|
SendSellQuest(attrData.packType, attrData.index);
|
|
}
|
});
|
}
|
|
private void SendSellQuest(PackType type,int index)
|
{
|
C0806_tagCPlayerSellItem sellItem = new C0806_tagCPlayerSellItem();
|
sellItem.PackType = (byte)type;
|
sellItem.ItemIndex = (byte)index;
|
GameNetSystem.Instance.SendInfo(sellItem);
|
|
}
|
#endregion
|
|
#region 发送拆解请求
|
public void SendDismantleQuest(ItemWinBtnType btnType, ItemAttrData attrData)
|
{
|
List<int> dismantleReturnlist = attrData.GetUseDataModel((int)ItemUseDataKey.Def_IudetItemDecompound);
|
int needGridCnt = 0;
|
int fixedMatcnt = 0;
|
int unfixedMatId = 0;
|
for (int i = 0; i < dismantleReturnlist.Count; i++)
|
{
|
if (i == 0)
|
{
|
if (dismantleReturnlist[i] != 0)
|
{
|
needGridCnt += 1;
|
unfixedMatId = dismantleReturnlist[i];
|
}
|
}
|
else
|
{
|
if ((i - 1) % 3 == 0)
|
{
|
if (dismantleReturnlist[i] != 0)
|
{
|
needGridCnt += 1;
|
fixedMatcnt += dismantleReturnlist[i + 1];
|
}
|
}
|
}
|
}
|
|
int offsetGrid = needGridCnt - playerPack.GetReaminGridCount(PackType.rptItem);
|
if (offsetGrid > 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("BagFull102", attrData.itemConfig.ItemName, offsetGrid);
|
return;
|
}
|
else
|
{
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(unfixedMatId);
|
if(itemConfig != null)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("PinkChaiRemind2", fixedMatcnt,itemConfig.LV),
|
(bool isOk)=>
|
{
|
if(isOk)
|
{
|
CA313_tagCMItemDecompound decompound = new CA313_tagCMItemDecompound();
|
decompound.Index = (byte)attrData.index;
|
GameNetSystem.Instance.SendInfo(decompound);
|
}
|
});
|
}
|
else
|
{
|
CA313_tagCMItemDecompound decompound = new CA313_tagCMItemDecompound();
|
decompound.Index = (byte)attrData.index;
|
GameNetSystem.Instance.SendInfo(decompound);
|
}
|
}
|
}
|
#endregion
|
|
#region 发送续费请求
|
public void SendRenewalQuest(ItemWinBtnType btnType,string guid)
|
{
|
GuardOverdueWin.guid = guid;
|
WindowCenter.Instance.Open<GuardOverdueWin>();
|
}
|
#endregion
|
|
#region 解锁背包格子数据
|
public int OpenCount
|
{
|
get; private set;
|
}
|
|
public PackType packType
|
{
|
get; private set;
|
}
|
|
public int Index
|
{
|
get; private set;
|
}
|
|
public void SetExtendGirdModel(int openCount = 0, int index = -1, PackType type = PackType.rptDeleted)
|
{
|
this.OpenCount = openCount;
|
this.packType = type;
|
this.Index = index;
|
}
|
|
#endregion
|
|
#region 获取仓库数据
|
public void SendOpenWarehouse()
|
{
|
CA204_tagCMOpenLongWarehouse openWarehouse = new CA204_tagCMOpenLongWarehouse();
|
GameNetSystem.Instance.SendInfo(openWarehouse);
|
}
|
#endregion
|
}
|
}
|