少年修仙传客户端代码仓库
client_linchunjie
2018-10-18 4e196740debaffb8a79a014046e9dd530a450dd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using System;
 
namespace Snxxz.UI
{
    public class WishingPoolWin : Window
    {
        [SerializeField] DragItem dragItem;
        [SerializeField] List<PoolItemCell> poolItemCells = new List<PoolItemCell>();
        [SerializeField] List<WishingCell> wishingCells = new List<WishingCell>();
 
        ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
        WishingPoolModel wishingModel { get { return ModelCenter.Instance.GetModel<WishingPoolModel>(); } }
        #region Built-in
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
           
        }
 
        protected override void OnPreOpen()
        {
 
        }
 
        protected override void OnAfterOpen()
        {
           
        }
        protected override void OnPreClose()
        {
            
        }
 
        protected override void OnAfterClose()
        {
 
        }
        #endregion
 
        private void Display()
        {
            UpdatePoolItem();
            for(int i = 0; i < wishingCells.Count; i++)
            {
                UpdateWishItemByIndex(i);
            }
        }
 
 
        protected override void LateUpdate()
        {
           if(wishingModel.isDraging)
            {
 
            }
        }
 
        private void UpdatePoolItem()
        {
            for (int i = 0; i < poolItemCells.Count; i++)
            {
                UpdatePoolItemByIndex(i);
            }
        }
 
        private void UpdatePoolItemByIndex(int index)
        {
            int id = 0;
            var poolItemCell = poolItemCells[index];
            bool isPoolData = wishingModel.TryGetPoolDataByIndex(index, out id);
            if (isPoolData)
            {
                poolItemCell.gameObject.SetActive(true);
                poolItemCell.Display(id);
            }
            else
            {
                poolItemCell.gameObject.SetActive(false);
            }
        }
 
        private void UpdateWishItemByIndex(int index)
        {
            int id = 0;
            var wishCell = wishingCells[index];
            bool isWishData = wishingModel.TryGetWishDataByIndex(index, out id);
            if (isWishData)
            {
                wishCell.itemBaisc.gameObject.SetActive(true);
                wishCell.noneItemObj.gameObject.SetActive(false);
                ItemCellModel cellModel = new ItemCellModel(id);
                wishCell.itemBaisc.Init(cellModel);
                wishCell.itemBaisc.cellBtn.RemoveAllListeners();
                wishCell.itemBaisc.cellBtn.AddListener(() =>
                {
                    ItemAttrData attrData = new ItemAttrData(id);
                    tipsModel.SetItemTipsModel(attrData);
                });
            }
            else
            {
                wishCell.itemBaisc.gameObject.SetActive(false);
                wishCell.noneItemObj.gameObject.SetActive(true);
            }
        }
 
        [Serializable]
        public class WishingCell
        {
            public CommonItemBaisc itemBaisc;
            public GameObject noneItemObj;
            public Button noneItemBtn;
        }
 
        [Serializable]
        public class DragItem
        {
            [SerializeField] CommonItemBaisc dragItemBasic;
            [SerializeField] GameObject dragBestIcon;
        }
    }
}