提交 | 用户 | age
|
e37863
|
1 |
//-------------------------------------------------------- |
CX |
2 |
// [Author]: 第二世界 |
|
3 |
// [ Date ]: Thursday, February 28, 2019 |
|
4 |
//-------------------------------------------------------- |
|
5 |
using UnityEngine; |
|
6 |
using System.Collections; |
|
7 |
using UnityEngine.UI; |
|
8 |
|
4465b6
|
9 |
namespace vnxbqy.UI |
e37863
|
10 |
{ |
CX |
11 |
|
3d54e4
|
12 |
public class EquipStarUpgradeCandidateSlot : MonoBehaviour |
e37863
|
13 |
{ |
acc67c
|
14 |
[SerializeField] Image m_BackGround; |
3d54e4
|
15 |
[SerializeField] Image m_EmptyItem; |
8fb00d
|
16 |
[SerializeField] ItemCell m_ItemCell; |
807064
|
17 |
[SerializeField] Text m_EquipStar; |
3d54e4
|
18 |
[SerializeField] Text m_Description1; |
CX |
19 |
[SerializeField] Text m_Description2; |
e37863
|
20 |
[SerializeField] Button m_Select; |
a72128
|
21 |
[SerializeField] RedpointBehaviour m_Redpoint; |
e37863
|
22 |
|
d9b03f
|
23 |
public bool suitEffectDirty { get; set; } |
C |
24 |
|
8fb00d
|
25 |
EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } } |
3d54e4
|
26 |
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } } |
8fb00d
|
27 |
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } } |
CX |
28 |
|
3d54e4
|
29 |
EquipStarUpgradeCandidate candidate; |
e37863
|
30 |
|
ace1a4
|
31 |
public void Display(EquipStarUpgradeCandidate candidate) |
3d54e4
|
32 |
{ |
ace1a4
|
33 |
this.candidate = candidate; |
a72128
|
34 |
this.m_Redpoint.redpointId = 1720000 + this.candidate.equipPosition.x * 100 + this.candidate.equipPosition.y; |
3d54e4
|
35 |
DisplayBaseInfo(); |
8fb00d
|
36 |
DisplayDynamicInfo(true); |
CX |
37 |
|
642426
|
38 |
m_Select.SetListener(() => { model.SelectPlace(this.candidate.equipPosition); }); |
e37863
|
39 |
} |
CX |
40 |
|
3d54e4
|
41 |
public void Dispose() |
e37863
|
42 |
{ |
CX |
43 |
} |
|
44 |
|
8fb00d
|
45 |
private void LateUpdate() |
CX |
46 |
{ |
|
47 |
DisplayDynamicInfo(false); |
|
48 |
} |
e37863
|
49 |
|
3d54e4
|
50 |
private void DisplayBaseInfo() |
8fb00d
|
51 |
{ |
642426
|
52 |
var guid = equipModel.GetEquip(this.candidate.equipPosition); |
3d54e4
|
53 |
var item = packModel.GetItemByGuid(guid); |
CX |
54 |
if (item == null) |
|
55 |
{ |
f23c81
|
56 |
m_ItemCell.SetActive(false); |
H |
57 |
m_EmptyItem.SetActive(true); |
642426
|
58 |
var place = this.candidate.equipPosition.y; |
dee74a
|
59 |
m_Description1.text = Language.Get("L1076", UIHelper.GetEquipPlaceName(place)); |
c6f329
|
60 |
m_Description1.color = UIHelper.GetUIColor(TextColType.NavyBrown, true); |
dee74a
|
61 |
m_Description2.text = Language.Get("EquipSuitPanel_IsPutOnText_1"); |
3d54e4
|
62 |
} |
CX |
63 |
else |
|
64 |
{ |
d9b03f
|
65 |
m_ItemCell.suitEffectDirty = suitEffectDirty; |
f23c81
|
66 |
m_ItemCell.SetActive(true); |
H |
67 |
m_EmptyItem.SetActive(false); |
3d54e4
|
68 |
m_ItemCell.Init(item); |
76a845
|
69 |
m_ItemCell.button.enabled = false; |
3d54e4
|
70 |
m_Description1.text = item.config.ItemName; |
281147
|
71 |
m_Description1.color = UIHelper.GetUIColor(item.config.ItemColor, true); |
3d54e4
|
72 |
m_Description2.text = string.Empty; |
d9b03f
|
73 |
|
C |
74 |
suitEffectDirty = false; |
3d54e4
|
75 |
} |
8fb00d
|
76 |
} |
CX |
77 |
|
|
78 |
private void DisplayDynamicInfo(bool force) |
|
79 |
{ |
|
80 |
if (force || this.candidate.selected.dirty) |
|
81 |
{ |
acc67c
|
82 |
var selected = this.candidate.selected.Fetch(); |
3d54e4
|
83 |
m_BackGround.SetSprite(selected ? "Title_RightWindow" : "Title_PopupWindow"); |
8fb00d
|
84 |
} |
807064
|
85 |
|
CX |
86 |
if (force || this.candidate.starLevel.dirty) |
|
87 |
{ |
|
88 |
var starLevel = this.candidate.starLevel.Fetch(); |
dee74a
|
89 |
m_EquipStar.text = starLevel >= 1 ? Language.Get("EquipStarLevel", starLevel) : ""; |
807064
|
90 |
} |
CX |
91 |
|
8fb00d
|
92 |
} |
dbdbd5
|
93 |
} |
e37863
|
94 |
|
dbdbd5
|
95 |
public class EquipStarUpgradeCandidateSlotPool |
CX |
96 |
{ |
|
97 |
static GameObjectPool pool; |
|
98 |
|
|
99 |
public static EquipStarUpgradeCandidateSlot Get() |
|
100 |
{ |
|
101 |
if (pool == null) |
|
102 |
{ |
|
103 |
pool = new GameObjectPool(UILoader.LoadPrefab("EquipStarUpgradeCandidateSlot")); |
|
104 |
} |
|
105 |
|
|
106 |
var instance = pool.Request(); |
f23c81
|
107 |
instance.SetActive(true); |
dbdbd5
|
108 |
return instance.GetComponent<EquipStarUpgradeCandidateSlot>(); |
CX |
109 |
} |
|
110 |
|
|
111 |
public static void Release(EquipStarUpgradeCandidateSlot behaviour) |
|
112 |
{ |
|
113 |
if (pool == null) |
|
114 |
{ |
|
115 |
return; |
|
116 |
} |
|
117 |
|
|
118 |
if (behaviour == null) |
|
119 |
{ |
|
120 |
return; |
|
121 |
} |
|
122 |
|
d9b03f
|
123 |
behaviour.suitEffectDirty = true; |
f23c81
|
124 |
behaviour.SetActive(false); |
6c76e5
|
125 |
behaviour.transform.SetParent(null); |
dbdbd5
|
126 |
pool.Release(behaviour.gameObject); |
CX |
127 |
} |
e37863
|
128 |
} |
CX |
129 |
|
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 |
|