using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
public class ZhanLingHBuyModel : Model
|
{
|
public int zhanLingType; //高级战令类型
|
public int showGiftType; //1 普通战令礼包 2 高级战令礼包
|
public string bgIconkey; //背景在Icon表中的KEY
|
|
public Dictionary<int, List<int>> ctgIdDictH = new Dictionary<int, List<int>>();
|
public Dictionary<int, List<int>> ctgIdDict = new Dictionary<int, List<int>>();
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
GatheringSoulZhanLingModel model { get { return ModelCenter.Instance.GetModel<GatheringSoulZhanLingModel>(); } }
|
|
public override void Init()
|
{
|
ctgIdDict = GeneralDefine.ZhanLingCtgIdDict;
|
ctgIdDictH = GeneralDefine.ZhanLingCtgIdHDict;
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void ShowZhanLingHBuy(int zhanLingType, int showGiftType, string bgIconkey = null)
|
{
|
this.zhanLingType = zhanLingType;
|
this.showGiftType = showGiftType;
|
this.bgIconkey = bgIconkey;
|
if (!WindowCenter.Instance.IsOpen<ZhanLingHBuyWin>())
|
WindowCenter.Instance.Open<ZhanLingHBuyWin>();
|
}
|
|
public int GetCtgID()
|
{
|
int ctgid = 0;
|
if (showGiftType == 1)
|
{
|
ctgid = ctgIdDict[zhanLingType][0];
|
}
|
else if (showGiftType == 2)
|
{
|
ctgid = ctgIdDictH[zhanLingType][0];
|
}
|
return ctgid;
|
}
|
|
public List<Item> GetGiftAllItem()
|
{
|
List<Item> result = new List<Item>();
|
//itemID,count
|
Dictionary<int, int> resultDict = new Dictionary<int, int>();
|
var dict = ILZhanlingConfig.GetTypeToIDDict(zhanLingType);
|
var list = dict.Keys.ToList();
|
for (int i = 0; i < list.Count; i++)
|
{
|
int needValue = list[i];
|
int zhanLingID = dict[needValue];
|
int[][] itemArr;
|
if (showGiftType == 1)
|
{
|
itemArr = ILZhanlingConfig.Get(zhanLingID).ZLRewardItemList;
|
}
|
else if (showGiftType == 2)
|
{
|
itemArr = ILZhanlingConfig.Get(zhanLingID).ZLRewardItemListH;
|
}
|
else
|
{
|
itemArr = new int[][] { };
|
}
|
|
if (itemArr.IsNullOrEmpty())
|
continue;
|
for (int j = 0; j < itemArr.Length; j++)
|
{
|
int itemID = itemArr[j][0];
|
int count = itemArr[j][1];
|
if (resultDict.ContainsKey(itemID))
|
{
|
resultDict[itemID] += count;
|
}
|
else
|
{
|
resultDict[itemID] = count;
|
}
|
}
|
}
|
list = resultDict.Keys.ToList();
|
list.Sort((a, b) =>
|
{
|
int count1 = resultDict[a];
|
int count2 = resultDict[b];
|
int quality1 = ItemConfig.Get(a).ItemColor;
|
int quality2 = ItemConfig.Get(b).ItemColor;
|
|
//品质高的排在前面
|
if (quality1 != quality2)
|
{
|
return quality2.CompareTo(quality1);
|
}
|
|
// 品质相同时,数量多的排在前面
|
if (count1 != count2)
|
{
|
return count2.CompareTo(count1);
|
}
|
|
// 如果品质和数量都相同,保持原有顺序
|
return 0;
|
});
|
|
for (int i = 0; i < list.Count; i++)
|
{
|
int itemID = list[i];
|
int count = resultDict[itemID];
|
result.Add(new Item(itemID, count));
|
}
|
return result;
|
}
|
|
|
}
|