| | |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | System.Type type = typeof(ComposeWinModel); |
| | | Utils.BeginObjectRegister(type, L, translator, 0, 47, 10, 7); |
| | | Utils.BeginObjectRegister(type, L, translator, 0, 46, 10, 7); |
| | | |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "Init", _m_Init); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "UnInit", _m_UnInit); |
| | |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "SendComposeRequest", _m_SendComposeRequest); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "SendComposeQuest", _m_SendComposeQuest); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "IsBindByFixedAndUnFixedMat", _m_IsBindByFixedAndUnFixedMat); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetBindOrNoBindMinCnt", _m_GetBindOrNoBindMinCnt); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetComposeSuccessRate", _m_GetComposeSuccessRate); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "IsComposeTicketByType", _m_IsComposeTicketByType); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "CheckComposeItemById", _m_CheckComposeItemById); |
| | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_GetBindOrNoBindMinCnt(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | |
| | | ComposeWinModel gen_to_be_invoked = (ComposeWinModel)translator.FastGetCSObj(L, 1); |
| | | |
| | | |
| | | |
| | | { |
| | | int _minBindCnt; |
| | | int _minNoBindCnt; |
| | | |
| | | gen_to_be_invoked.GetBindOrNoBindMinCnt( out _minBindCnt, out _minNoBindCnt ); |
| | | LuaAPI.xlua_pushinteger(L, _minBindCnt); |
| | | |
| | | LuaAPI.xlua_pushinteger(L, _minNoBindCnt); |
| | | |
| | | |
| | | |
| | | |
| | | return 2; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | |
| | | fileFormatVersion: 2 |
| | | guid: e0e359da308439d4e87a7d7ce8fd4cc5 |
| | | timeCreated: 1550120588 |
| | | timeCreated: 1552375168 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetMaterialNeed", _m_GetMaterialNeed); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetMaxTrainLevel", _m_GetMaxTrainLevel); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetCandidatePlaces", _m_GetCandidatePlaces); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "IsEquipPlaceTrainable", _m_IsEquipPlaceTrainable); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetEquipPlaceTrainState", _m_GetEquipPlaceTrainState); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetUnSavedProperties", _m_GetUnSavedProperties); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetTrainedProperties", _m_GetTrainedProperties); |
| | | |
| | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_IsEquipPlaceTrainable(RealStatePtr L) |
| | | static int _m_GetEquipPlaceTrainState(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | |
| | | |
| | | |
| | | { |
| | | string _equipGuid = LuaAPI.lua_tostring(L, 2); |
| | | int _level = LuaAPI.xlua_tointeger(L, 2); |
| | | int _place = LuaAPI.xlua_tointeger(L, 3); |
| | | |
| | | Snxxz.UI.EquipTrainModel.TrainState gen_ret = gen_to_be_invoked.GetEquipPlaceTrainState( _level, _place ); |
| | | translator.Push(L, gen_ret); |
| | | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | |
| | | fileFormatVersion: 2 |
| | | guid: ff2dde43802d1d14795873c131842a1e |
| | | timeCreated: 1552374367 |
| | | timeCreated: 1552375168 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | |
| | | <type fullname="mapbornConfig" preserve="all"/> |
| | | <type fullname="mapnpcConfig" preserve="all"/> |
| | | <type fullname="maptransportConfig" preserve="all"/> |
| | | <type fullname="PlayerStoneData" preserve="all"/> |
| | | <type fullname="PlayerDatas" preserve="all"/> |
| | | <type fullname="Snxxz.UI.RealmModel" preserve="all"/> |
| | | <type fullname="SnxxzGame" preserve="all"/> |
| | |
| | | <type fullname="Snxxz.UI.JadeDynastyBossModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.JadeDynastyDecomposeModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.JadeDynastyEquipModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.JadeDynastyGemModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.JadeDynastySkillModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.JadeDynastyTowerModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.FBHelpPointExchageModel" preserve="all"/> |
| | |
| | | <type fullname="Snxxz.UI.BuySuccessModel" preserve="all"/> |
| | | <type fullname="StoreModel" preserve="all"/> |
| | | <type fullname="EquipReinforceModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.GemModel" preserve="all"/> |
| | | <type fullname="GodBeastModel" preserve="all"/> |
| | | <type fullname="HowToPlayModel" preserve="all"/> |
| | | <type fullname="Snxxz.UI.WingsRedDotModel" preserve="all"/> |
| | |
| | |
|
| | | for (int i = 0; i < itemModels.Count; i++)
|
| | | {
|
| | | string key = StringUtility.Contact(itemModels[i].itemId, "IsBind", itemModels[i].isBind);
|
| | | string key = itemModels[i].itemId.ToString();
|
| | | if (!lookRecycleDict.ContainsKey(key))
|
| | | {
|
| | | List<ItemModel> modellist = new List<ItemModel>();
|
| | | modellist.Add(itemModels[i]);
|
| | | lookRecycleDict.Add(key, modellist);
|
| | | if (itemModels[i].isBind == 1)
|
| | | {
|
| | | AddSelectRecycleDan(itemModels[i]);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | |
|
| | | private int CompareByDanBindAndLv(ItemModel start, ItemModel end)
|
| | | {
|
| | | bool isBindStart = start.isBind == 1 ? true : false;
|
| | | bool isBindEnd = end.isBind == 1 ? true : false;
|
| | | if (isBindStart.CompareTo(isBindEnd) != 0) return -isBindStart.CompareTo(isBindEnd);
|
| | |
|
| | | int startLv = start.config.LV;
|
| | | int endLv = end.config.LV;
|
| | | if (startLv.CompareTo(endLv) != 0) return startLv.CompareTo(endLv);
|
| | |
| | | public event Action RefreshSelectRecycleAct;
|
| | | public void AddSelectRecycleDan(ItemModel itemModel)
|
| | | {
|
| | | string key = StringUtility.Contact(itemModel.itemId, "IsBind", itemModel.isBind);
|
| | | string key = itemModel.itemId.ToString();
|
| | | if (!recycleStrlist.Contains(key))
|
| | | {
|
| | | recycleStrlist.Add(key);
|
| | |
| | |
|
| | | public void RemoveSelectRecycleDan(ItemModel itemModel)
|
| | | {
|
| | | string key = StringUtility.Contact(itemModel.itemId, "IsBind", itemModel.isBind);
|
| | | string key = itemModel.itemId.ToString();
|
| | | if (recycleStrlist.Contains(key))
|
| | | {
|
| | | recycleStrlist.Remove(key);
|
| | |
| | | return;
|
| | | }
|
| | | #region 设置回收数据
|
| | | int unBindCnt = 0;
|
| | | int sumCnt = 0;
|
| | | int getMoney = 0;
|
| | | recycleDanDict.Clear();
|
| | | for (int i = 0; i < recycleStrlist.Count; i++)
|
| | |
| | | {
|
| | | for (int j = 0; j < modellist.Count; j++)
|
| | | {
|
| | | sumCnt += modellist[j].count;
|
| | | if (modellist[j].isBind == 0)
|
| | | {
|
| | | unBindCnt += modellist[j].count;
|
| | | }
|
| | |
|
| | | if (playerPack.CheckIsDrugById(modellist[j].itemId))
|
| | | {
|
| | | AttrFruitConfig fruitConfig = AttrFruitConfig.Get(modellist[j].itemId);
|
| | | getMoney = getMoney + fruitConfig.RecycleExp * modellist[j].count;
|
| | | getMoney += fruitConfig.RecycleExp * modellist[j].count;
|
| | | }
|
| | |
|
| | | if (!recycleDanDict.ContainsKey(modellist[j].itemPlace))
|
| | |
| | | }
|
| | | #endregion
|
| | | SendRecycleDrugQuest(recycleDanDict.Keys.ToList(), recycleDanDict.Values.ToList());
|
| | | //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();
|
| | | var recycleAttrFruit = new CA32A_tagCMRecycleAttrFruit();
|
| | | recycleAttrFruit.IndexCount = (byte)indexs.Count;
|
| | | byte[] indexByte = new byte[indexs.Count];
|
| | | ushort[] numShort = new ushort[indexs.Count];
|
| | |
| | | {
|
| | | itemCell.gameObject.SetActive(true);
|
| | | ItemModel itemModel = list[0];
|
| | | string key = StringUtility.Contact(itemModel.itemId, "IsBind", itemModel.isBind);
|
| | | string key = itemModel.itemId.ToString();
|
| | | if (blastFurnace.recycleStrlist.Contains(key))
|
| | | {
|
| | | selectImg.SetActive(true);
|
| | |
| | | [SerializeField] UIEffect failEffect;
|
| | |
|
| | | ComposeWinModel _composeWinModel;
|
| | | ComposeWinModel composeWinModel
|
| | | {
|
| | | ComposeWinModel composeWinModel {
|
| | | get { return _composeWinModel ?? (_composeWinModel = ModelCenter.Instance.GetModel<ComposeWinModel>()); }
|
| | | }
|
| | |
|
| | | PackModel _playerPack;
|
| | | PackModel playerPack
|
| | | {
|
| | | PackModel playerPack {
|
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
| | | }
|
| | |
|
| | |
| | | bool isIncreaseRate = false;
|
| | | int successRate = 0;
|
| | | SelectEquipModel _selectModel;
|
| | | SelectEquipModel selectModel |
| | | {
|
| | | SelectEquipModel selectModel {
|
| | | get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel<SelectEquipModel>()); }
|
| | | }
|
| | | protected override void BindController()
|
| | |
| | | SinglePack singlePack = playerPack.GetSinglePack(packType);
|
| | | if (singlePack == null) return;
|
| | |
|
| | | int minBindCnt = 0;
|
| | | int minNoBindCnt = 0;
|
| | | composeWinModel.GetBindOrNoBindMinCnt(out minBindCnt, out minNoBindCnt);
|
| | | int[] fixedIds = compoundModel.itemID;
|
| | | int[] fixedCounts = compoundModel.itemCount;
|
| | | for (int i = 0; i < fixedIds.Length; i++)
|
| | | {
|
| | | List<int> itemIndexlist = null;
|
| | | if (minBindCnt >= fixedCounts[i])
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i], true);
|
| | | }
|
| | | else if (minNoBindCnt >= fixedCounts[i])
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i], false);
|
| | | }
|
| | | else
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i]);
|
| | | }
|
| | |
|
| | | var itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i]);
|
| | | if (itemIndexlist != null)
|
| | | {
|
| | | fixedItemIndexDict.Add(fixedIds[i], itemIndexlist);
|
| | |
| | | [SerializeField] List<ComposeMatCell> makeItems = new List<ComposeMatCell>();
|
| | |
|
| | | ComposeWinModel _composeWinModel;
|
| | | ComposeWinModel composeWinModel
|
| | | {
|
| | | ComposeWinModel composeWinModel {
|
| | | get { return _composeWinModel ?? (_composeWinModel = ModelCenter.Instance.GetModel<ComposeWinModel>()); }
|
| | | }
|
| | |
|
| | |
|
| | | PackModel _playerPack;
|
| | | PackModel playerPack
|
| | | {
|
| | | PackModel playerPack {
|
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
| | | }
|
| | |
|
| | |
| | | SinglePack singlePack = playerPack.GetSinglePack(packType);
|
| | | if (singlePack == null) return;
|
| | |
|
| | | int minBindCnt = 0;
|
| | | int minNoBindCnt = 0;
|
| | | composeWinModel.GetBindOrNoBindMinCnt(out minBindCnt,out minNoBindCnt);
|
| | | int[] fixedIds = compoundModel.itemID;
|
| | | int[] fixedCounts = compoundModel.itemCount;
|
| | |
|
| | | for (int i = 0; i < fixedIds.Length; i++)
|
| | | {
|
| | | List<int> itemIndexlist = null;
|
| | | if (minBindCnt >= fixedCounts[i])
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i],fixedCounts[i], true);
|
| | | }
|
| | | else if(minNoBindCnt >= fixedCounts[i])
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i],fixedCounts[i],false);
|
| | | }
|
| | | else
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i],fixedCounts[i]);
|
| | | }
|
| | |
|
| | | var itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i]);
|
| | | if (itemIndexlist != null)
|
| | | {
|
| | | fixedItemIndexDict.Add(fixedIds[i], itemIndexlist);
|
| | |
| | | [SerializeField] UIEffect composeEffect;
|
| | |
|
| | | ComposeWinModel _composeWinModel;
|
| | | ComposeWinModel composeWinModel
|
| | | {
|
| | | ComposeWinModel composeWinModel {
|
| | | get { return _composeWinModel ?? (_composeWinModel = ModelCenter.Instance.GetModel<ComposeWinModel>()); }
|
| | | }
|
| | |
|
| | |
| | | private Dictionary<int,List<int>> fixedItemIndexDict = new Dictionary<int, List<int>>();
|
| | |
|
| | | PackModel _playerPack;
|
| | | PackModel playerPack
|
| | | {
|
| | | PackModel playerPack {
|
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
| | | }
|
| | |
|
| | |
| | | SinglePack singlePack = playerPack.GetSinglePack(packType);
|
| | | if (singlePack == null) return;
|
| | |
|
| | | int minBindCnt = 0;
|
| | | int minNoBindCnt = 0;
|
| | | composeWinModel.GetBindOrNoBindMinCnt(out minBindCnt, out minNoBindCnt);
|
| | | int[] fixedIds = compoundModel.itemID;
|
| | | int[] fixedCounts = compoundModel.itemCount;
|
| | | for (int i = 0; i < fixedIds.Length; i++)
|
| | | {
|
| | | List<int> itemIndexlist = null;
|
| | | if (minBindCnt >= fixedCounts[i])
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i],fixedCounts[i], true);
|
| | | }
|
| | | else if (minNoBindCnt >= fixedCounts[i])
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i],fixedCounts[i], false);
|
| | | }
|
| | | else
|
| | | {
|
| | | itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i],fixedCounts[i]);
|
| | | }
|
| | |
|
| | | var itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i]);
|
| | | if (itemIndexlist != null)
|
| | | {
|
| | | fixedItemIndexDict.Add(fixedIds[i], itemIndexlist);
|
| | |
| | | return itemArray;
|
| | | }
|
| | |
|
| | | public void GetBindOrNoBindMinCnt(out int minBindCnt, out int minNoBindCnt)
|
| | | {
|
| | | minBindCnt = 0;
|
| | | minNoBindCnt = 0;
|
| | | if (CurComposeModel == null) return;
|
| | |
|
| | | Dictionary<int, int> bindCntDic = new Dictionary<int, int>();
|
| | | Dictionary<int, int> noBindCntDic = new Dictionary<int, int>();
|
| | | int[] fixedIds = CurComposeModel.itemID;
|
| | | for (int i = 0; i < fixedIds.Length; i++)
|
| | | {
|
| | | var list = playerPack.GetSinglePack(PackType.Item).GetItemsById(fixedIds[i]);
|
| | | if (list != null)
|
| | | {
|
| | | int bindCnt = 0;
|
| | | int noBindCnt = 0;
|
| | | for (int j = 0; j < list.Count; j++)
|
| | | {
|
| | | if (list[j].isBind == 1)
|
| | | {
|
| | | bindCnt += list[j].count;
|
| | |
|
| | | }
|
| | | else if (list[j].isBind == 0)
|
| | | {
|
| | | noBindCnt += list[j].count;
|
| | | }
|
| | | }
|
| | | bindCntDic.Add(fixedIds[i], bindCnt);
|
| | | noBindCntDic.Add(fixedIds[i], noBindCnt);
|
| | | }
|
| | | }
|
| | |
|
| | | List<int> bindCntlist = bindCntDic.Values.ToList();
|
| | | bindCntlist.Sort();
|
| | | if (bindCntlist.Count > 0)
|
| | | {
|
| | | minBindCnt = bindCntlist[0];
|
| | | }
|
| | |
|
| | | List<int> noBindCntlist = noBindCntDic.Values.ToList();
|
| | | noBindCntlist.Sort();
|
| | | if (noBindCntlist.Count > 0)
|
| | | {
|
| | | minNoBindCnt = noBindCntlist[0];
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 计算附加材料增加的成功率
|
| | | /// </summary>
|
| | |
| | | var packType = composeWinModel.GetPackTypeByMakerId(compoundModel.makeID);
|
| | | SinglePack singlePack = playerPack.GetSinglePack(packType);
|
| | | if (singlePack == null) return;
|
| | | int isBind = 0;
|
| | |
|
| | | if(IsComposeBind)
|
| | | {
|
| | | isBind = 1;
|
| | | }
|
| | | else
|
| | | {
|
| | | isBind = 0;
|
| | | }
|
| | | int[] fixedIds = compoundModel.itemID;
|
| | | int[] fixedCounts = compoundModel.itemCount;
|
| | | for (int i = 0; i < fixedIds.Length; i++)
|
| | | {
|
| | | List<int> itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i],isBind==1);
|
| | | List<int> itemIndexlist = singlePack.GetItemIndexsAppointedCount(fixedIds[i], fixedCounts[i]);
|
| | | if (itemIndexlist != null)
|
| | | {
|
| | | fixedItemIndexDict.Add(fixedIds[i], itemIndexlist);
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | y = end.config.StarLevel;
|
| | | if (x.CompareTo(y) != 0) return x.CompareTo(y);
|
| | |
|
| | | x = start.isBind;
|
| | | y = end.isBind;
|
| | | if (x.CompareTo(y) != 0) return -x.CompareTo(y);
|
| | |
|
| | | x = oneKeyPutlist.IndexOf(start);
|
| | | y = oneKeyPutlist.IndexOf(end);
|
| | | if (x.CompareTo(y) != 0) return x.CompareTo(y);
|
| | |
| | |
|
| | | public int CompareByCondition(ItemModel start, ItemModel end)
|
| | | {
|
| | | int startIsBind = start.isBind;
|
| | | int endIsBind = end.isBind;
|
| | | if (startIsBind.CompareTo(endIsBind) != 0) return startIsBind.CompareTo(endIsBind);
|
| | |
|
| | | int startQuality = start.config.ItemColor;
|
| | | int endQuality = end.config.ItemColor;
|
| | | if (startQuality.CompareTo(endQuality) != 0) return startQuality.CompareTo(endQuality);
|
| | |
| | | } |
| | | } |
| | | |
| | | goalItems.Sort(CompareIsBind); |
| | | |
| | | var itemIndexs = new List<int>(); |
| | | var count = 0; |
| | | for (var i = 0; i < goalItems.Count; i++) |
| | |
| | | } |
| | | |
| | | return itemIndexs; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 得到同一个id物品指定数量的格子序号 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="preferBind">优先条件(true 为绑定,false为不绑定)</param> |
| | | /// <returns></returns> |
| | | public List<int> GetItemIndexsAppointedCount(int itemId, int needCnt, bool preferBind) |
| | | { |
| | | var itemPool = new List<ItemModel>(); |
| | | foreach (var item in items.Values) |
| | | { |
| | | if (item.itemId == itemId) |
| | | { |
| | | itemPool.Add(item); |
| | | } |
| | | } |
| | | |
| | | var preferCondition = preferBind ? 1 : 0; |
| | | var indexs = new List<int>(); |
| | | int count = 0; |
| | | for (int i = 0; count < needCnt && i < itemPool.Count; i++) |
| | | { |
| | | if (itemPool[i].isBind == preferCondition) |
| | | { |
| | | indexs.Add(itemPool[i].itemPlace); |
| | | count += itemPool[i].count; |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; count < needCnt && i < itemPool.Count; i++) |
| | | { |
| | | if (itemPool[i].isBind != preferCondition) |
| | | { |
| | | indexs.Add(itemPool[i].itemPlace); |
| | | count += itemPool[i].count; |
| | | } |
| | | } |
| | | |
| | | return indexs; |
| | | } |
| | | |
| | | private int CompareIsBind(ItemModel x, ItemModel y) |
| | | { |
| | | return -x.isBind.CompareTo(y.isBind); |
| | | } |
| | | |
| | | /// <summary> |