| | |
| | | |
| | | [SerializeField] Button m_WHYJButton;
|
| | | [SerializeField] GameObject m_Container_WHYJ;
|
| | | [SerializeField] Transform m_Horizontal;
|
| | | [SerializeField] ItemCell[] m_Items;
|
| | | [SerializeField] Image m_Rating;//评级
|
| | | DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
| | | List<int> ListRating = new List<int>();
|
| | | Dictionary<int, List<Item>> rewardItems = new Dictionary<int, List<Item>>();
|
| | | public void Init()
|
| | | {
|
| | | ListRating.Clear();
|
| | |
| | | private void SetTranItemCell()
|
| | | {
|
| | | int lineID = model.mission.lineID;
|
| | | var WHYJConfig = WHYJRewardConfig.Get(lineID+1);
|
| | | int[] RewardList = ConfigParse.GetMultipleStr<int>(WHYJConfig.Reward);
|
| | | int[] QuantityList = ConfigParse.GetMultipleStr<int>(WHYJConfig.Quantity);
|
| | | for (int i = 0; i < m_Horizontal.childCount; i++)
|
| | |
|
| | | if (!rewardItems.ContainsKey(lineID + 1))
|
| | | {
|
| | | if (i < RewardList.Length)
|
| | | rewardItems.Add(lineID + 1, new List<Item>());
|
| | | var WHYJConfig = WHYJRewardConfig.Get(lineID + 1);
|
| | | for (int i = 0; i < WHYJConfig.Reward.Length; i++)
|
| | | {
|
| | | m_Horizontal.GetChild(i).gameObject.SetActive(true);
|
| | | ItemCell ItemCell = m_Horizontal.GetChild(i).GetComponent<ItemCell>();
|
| | | float value = GetRating() * QuantityList[i];
|
| | | ItemCellModel cellModel = new ItemCellModel(RewardList[i], true, (ulong)Math.Round(value,0));
|
| | | ItemCell.Init(cellModel);
|
| | | rewardItems[lineID + 1].Add(new Item()
|
| | | {
|
| | | id = WHYJConfig.Reward[i],
|
| | | count = WHYJConfig.Quantity[i],
|
| | | });
|
| | | }
|
| | | rewardItems[lineID + 1].Sort(Compare);
|
| | | }
|
| | |
|
| | | List<Item> RewardList = rewardItems[lineID + 1];
|
| | |
|
| | | for (int i = 0; i < m_Items.Length; i++)
|
| | | {
|
| | | if (i < RewardList.Count)
|
| | | {
|
| | | m_Items[i].gameObject.SetActive(true);
|
| | | float value = GetRating() * RewardList[i].count;
|
| | | ItemCellModel cellModel = new ItemCellModel(RewardList[i].id, true, (ulong)Math.Round(value,0));
|
| | | m_Items[i].Init(cellModel);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Horizontal.GetChild(i).gameObject.SetActive(false);
|
| | | m_Items[i].gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | |
|
| | | private int Compare(Item x, Item y)
|
| | | {
|
| | | var lhs_config = ItemConfig.Get(x.id);
|
| | | var rhs_config = ItemConfig.Get(y.id);
|
| | | if (lhs_config.ItemColor != rhs_config.ItemColor)
|
| | | {
|
| | | return -lhs_config.ItemColor.CompareTo(rhs_config.ItemColor);
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private void OnClickButton()
|
| | | {
|
| | | m_Container_WHYJ.SetActive(!m_Container_WHYJ.activeSelf);
|