Skip to content

Commit f44c9fa

Browse files
committed
now can use and view skill cooldowns from skill window
1 parent 0af103a commit f44c9fa

File tree

10 files changed

+191
-163
lines changed

10 files changed

+191
-163
lines changed

l2-unity/Assets/Scripts/Game/Shortcut/PlayerShortcuts.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,15 @@ public void ToggleShortcutItem(int itemId, bool enable)
211211
{
212212
if (!_toggledIds.Contains(itemId))
213213
{
214+
Debug.LogWarning($"Adding toggled item with id: {itemId}");
214215
_toggledIds.Add(itemId);
215216
}
216217
}
217218
else
218219
{
219220
if (_toggledIds.Contains(itemId))
220221
{
222+
Debug.LogWarning($"Removing toggled item with id: {itemId}");
221223
_toggledIds.Remove(itemId);
222224
}
223225
}

l2-unity/Assets/Scripts/Game/Skill/PlayerSkill.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public class PlayerSkill : MonoBehaviour
88
private static PlayerSkill _instance;
99
public static PlayerSkill Instance => _instance;
1010
private Dictionary<int, SkillInfo> _skills;
11-
private (int SkillId, int Lvl, int SpCost)? _skillToLearn;
1211

1312
public bool Initialized { get; private set; }
1413

@@ -39,21 +38,6 @@ public void SetSkills(SkillInfo[] skills)
3938
SkillWindow.Instance.SetSkills(GetSkillsForWindow());
4039
}
4140

42-
// public Skill[] GetSkills()
43-
// {
44-
// if (_skills == null) return Array.Empty<Skill>();
45-
46-
// Skill[] skillDetails = new Skill[_skills.Count];
47-
// for (var i = 0; i < _skills.Count; i++)
48-
// {
49-
// Skill skill = SkillTable.Instance.GetSkill(_skills[i].Id);
50-
// skillDetails[i] = skill;
51-
// }
52-
53-
// Initialized = true;
54-
// return skillDetails;
55-
// }
56-
5741
public SkillInfo GetSkillInfo(int skillId)
5842
{
5943
if (_skills == null)
@@ -69,6 +53,16 @@ public SkillInfo GetSkillInfo(int skillId)
6953
return null;
7054
}
7155

56+
public List<SkillInfo> GetAllSkills()
57+
{
58+
if (_skills == null)
59+
{
60+
return new List<SkillInfo>();
61+
}
62+
63+
return _skills.Values.ToList();
64+
}
65+
7266
public List<SkillWindowInfo>[] GetSkillsForWindow()
7367
{
7468
if (_skills == null) return new List<SkillWindowInfo>[2];

l2-unity/Assets/Scripts/UI/Game/Skill/SkillSlot.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,38 @@
33

44
public class SkillSlot : L2DraggableSlot
55
{
6-
private SlotClickSoundManipulator _slotClickSoundManipulator;
6+
protected SkillInfo _skillInfo;
7+
protected bool _toggled;
8+
protected ButtonClickSoundManipulator _buttonClickSoundManipulator;
9+
protected SlotAnimationManipulator _slotAnimationManipulator;
10+
public bool Toggled { get => _toggled; set => _toggled = value; }
11+
712
public SkillWindowInfo Skill { get; private set; }
13+
public SkillInfo SkillInfo { get => _skillInfo; set => _skillInfo = value; }
14+
public SlotAnimationManipulator SlotAnimationManipulator { get => _slotAnimationManipulator; }
815

916
public SkillSlot(int position, VisualElement slotElement, SlotType slotType)
1017
: base(position, slotElement, slotType, true, false)
1118
{
12-
_slotClickSoundManipulator = new SlotClickSoundManipulator(_slotElement);
13-
_slotElement.AddManipulator(_slotClickSoundManipulator);
19+
1420
}
1521

1622
public void AssignSkill(SkillWindowInfo skill)
1723
{
24+
_buttonClickSoundManipulator = new ButtonClickSoundManipulator(_slotElement);
25+
_slotElement.AddManipulator(_buttonClickSoundManipulator);
26+
27+
_slotAnimationManipulator = new SlotAnimationManipulator(_slotElement, this);
28+
1829
StyleBackground background = new StyleBackground(IconTable.Instance.LoadTextureByName(skill.Icon));
1930
_slotBg.style.backgroundImage = background;
2031

2132
_slotElement.RemoveFromClassList("empty");
2233
_slotDragManipulator.enabled = true;
2334
_id = skill.SkillId;
2435

36+
_skillInfo = PlayerSkill.Instance.GetSkillInfo(_id);
37+
2538
Skill = skill;
2639
AddTooltip();
2740
}
@@ -30,10 +43,16 @@ public override void ClearManipulators()
3043
{
3144
base.ClearManipulators();
3245

33-
if (_slotClickSoundManipulator != null)
46+
if (_buttonClickSoundManipulator != null)
47+
{
48+
_slotElement.RemoveManipulator(_buttonClickSoundManipulator);
49+
_buttonClickSoundManipulator = null;
50+
}
51+
52+
if (_slotAnimationManipulator != null)
3453
{
35-
_slotElement.RemoveManipulator(_slotClickSoundManipulator);
36-
_slotClickSoundManipulator = null;
54+
_slotElement.RemoveManipulator(_slotAnimationManipulator);
55+
_slotAnimationManipulator = null;
3756
}
3857
}
3958

l2-unity/Assets/Scripts/UI/Game/Skill/SkillTab.cs

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using UnityEngine;
4-
using UnityEngine.Serialization;
54
using UnityEngine.UIElements;
65

76
[System.Serializable]
@@ -10,9 +9,7 @@ public class SkillTab : L2Tab
109
public enum SkillTabType { ACTIVE, PASSIVE }
1110

1211
[SerializeField] private SkillTabType _tabType;
13-
private SkillSlot[] _skillSlots;
1412
private VisualElement _contentContainer;
15-
private short skillSlotIx;
1613

1714
public override void Initialize(L2TabView tabView, VisualElement tabContainer, VisualElement tabHeader)
1815
{
@@ -22,25 +19,14 @@ public override void Initialize(L2TabView tabView, VisualElement tabContainer, V
2219

2320
public void UpdateSkills(List<SkillWindowInfo>[] skills)
2421
{
25-
if (_skillSlots != null)
26-
{
27-
foreach (SkillSlot slot in _skillSlots)
28-
{
29-
slot.UnregisterClickableCallback();
30-
slot.ClearManipulators();
31-
}
32-
}
33-
34-
skillSlotIx = 0;
3522
_contentContainer.Clear();
23+
3624
if (_tabType == SkillTabType.PASSIVE)
3725
{
38-
_skillSlots = new SkillSlot[skills[1].Count];
3926
ShowPassiveSkills(skills[1]);
4027
}
4128
else if (_tabType == SkillTabType.ACTIVE)
4229
{
43-
_skillSlots = new SkillSlot[skills[0].Count];
4430
ShowActiveSkills(skills[0]);
4531
}
4632
}
@@ -83,31 +69,31 @@ private void ShowPassiveSkills(List<SkillWindowInfo> skills)
8369

8470
if (equipmentSkills.Any())
8571
{
86-
VisualElement section = AddSection(equipmentSkills, "Equipment Skills");
72+
VisualElement section = AddSection(equipmentSkills, SysStringTable.Instance.GetSysString(1702).Name);
8773
_contentContainer.Add(section);
8874
}
8975

9076
if (abilitySkills.Any())
9177
{
92-
VisualElement section = AddSection(abilitySkills, "Ability Skills");
78+
VisualElement section = AddSection(abilitySkills, SysStringTable.Instance.GetSysString(1703).Name);
9379
_contentContainer.Add(section);
9480
}
9581

9682
if (clanHeroMentoringSkills.Any())
9783
{
98-
VisualElement section = AddSection(clanHeroMentoringSkills, "Clan/Hero/Mentoring Skills");
84+
VisualElement section = AddSection(clanHeroMentoringSkills, SysStringTable.Instance.GetSysString(1699).Name);
9985
_contentContainer.Add(section);
10086
}
10187

10288
if (itemSkills.Any())
10389
{
104-
VisualElement section = AddSection(itemSkills, "Item Skills");
90+
VisualElement section = AddSection(itemSkills, SysStringTable.Instance.GetSysString(1700).Name);
10591
_contentContainer.Add(section);
10692
}
10793

10894
if (raceSkills.Any())
10995
{
110-
VisualElement section = AddSection(raceSkills, "Race Skills");
96+
VisualElement section = AddSection(raceSkills, SysStringTable.Instance.GetSysString(1704).Name);
11197
_contentContainer.Add(section);
11298
}
11399
}
@@ -174,42 +160,42 @@ private void ShowActiveSkills(List<SkillWindowInfo> skills)
174160

175161
if (physicalSkills.Any())
176162
{
177-
VisualElement section = AddSection(physicalSkills, "Physical Skills");
163+
VisualElement section = AddSection(physicalSkills, SysStringTable.Instance.GetSysString(1694).Name);
178164
_contentContainer.Add(section);
179165
}
180166
if (magicSkills.Any())
181167
{
182-
VisualElement section = AddSection(magicSkills, "Magical Skills");
168+
VisualElement section = AddSection(magicSkills, SysStringTable.Instance.GetSysString(1695).Name);
183169
_contentContainer.Add(section);
184170
}
185171
if (reinforcementSkills.Any())
186172
{
187-
VisualElement section = AddSection(reinforcementSkills, "Reinforcement Skills");
173+
VisualElement section = AddSection(reinforcementSkills, SysStringTable.Instance.GetSysString(1696).Name);
188174
_contentContainer.Add(section);
189175
}
190176
if (weakenSkills.Any())
191177
{
192-
VisualElement section = AddSection(weakenSkills, "Weaken Skills");
178+
VisualElement section = AddSection(weakenSkills, SysStringTable.Instance.GetSysString(1697).Name);
193179
_contentContainer.Add(section);
194180
}
195181
if (clanHeroMentoringSkills.Any())
196182
{
197-
VisualElement section = AddSection(clanHeroMentoringSkills, "Clan/Hero/Mentoring Skills");
183+
VisualElement section = AddSection(clanHeroMentoringSkills, SysStringTable.Instance.GetSysString(1699).Name);
198184
_contentContainer.Add(section);
199185
}
200186
if (itemSkills.Any())
201187
{
202-
VisualElement section = AddSection(itemSkills, "Item Skills");
188+
VisualElement section = AddSection(itemSkills, SysStringTable.Instance.GetSysString(1700).Name);
203189
_contentContainer.Add(section);
204190
}
205191
if (toggleSkills.Any())
206192
{
207-
VisualElement section = AddSection(toggleSkills, "Toggle Skills");
193+
VisualElement section = AddSection(toggleSkills, SysStringTable.Instance.GetSysString(1698).Name);
208194
_contentContainer.Add(section);
209195
}
210196
if (transformSkills.Any())
211197
{
212-
VisualElement section = AddSection(transformSkills, "Transform Skills");
198+
VisualElement section = AddSection(transformSkills, SysStringTable.Instance.GetSysString(1701).Name);
213199
_contentContainer.Add(section);
214200
}
215201
}
@@ -220,59 +206,23 @@ public VisualElement AddSection(List<SkillWindowInfo> skills, string name)
220206
section.Q<Label>("SkillsSectionHeaderLabel").text = name;
221207
VisualElement sectionContainer = section.Q<VisualElement>("SkillsSectionBarContainer");
222208

223-
//TODO: Use L2SlotContainers
224-
225209
// maybe use onclick on whole header
226210
Button btn = section.Q<Button>("PlusMinusBtn");
227211
btn.RegisterCallback<ClickEvent>(HandleSlotClick, TrickleDown.TrickleDown);
228212

229-
// for (var i = 0; i < skills.Count; ++i)
230-
// {
231-
// VisualElement slotElement = L2SlotManager.Instance.SkillSlotTemplate.Instantiate()[0];
232-
// SkillSlot skillSlot = new SkillSlot(i, slotElement, L2Slot.SlotType.Skill);
233-
// _skillSlots[skillSlotIx++] = skillSlot;
234-
// skillSlot.AssignSkill(skills[i]);
235-
// sectionContainer.Add(slotElement);
236-
// }
237-
238-
// int rowLength = 6;
239-
// int padSlot = 0;
240-
// if (skills.Count < 8 * rowLength)
241-
// {
242-
// padSlot = 8 * rowLength - skills.Count;
243-
// }
244-
// else if (skills.Count % rowLength != 0)
245-
// {
246-
// padSlot = rowLength - skills.Count % rowLength;
247-
// }
248-
249-
// for (int i = 0; i < padSlot; i++)
250-
// {
251-
// VisualElement slotElement = L2SlotManager.Instance.SkillSlotTemplate.Instantiate()[0];
252-
// slotElement.AddToClassList("skillbar-slot.empty");
253-
// // slotElement.AddToClassList("disabled");
254-
// sectionContainer.Add(slotElement);
255-
// }
256-
// return section;
257-
258213
L2SlotContainer basicSlotContainer = new L2SlotContainer();
259214
basicSlotContainer.Initialize(sectionContainer, 6, 6);
260215
basicSlotContainer.CreateSlots(skills.Count, L2Slot.SlotType.Skill);
261216

262217
for (var i = 0; i < skills.Count; ++i)
263218
{
264219
basicSlotContainer.AssignSkill(i, skills[i]);
220+
SkillWindow.Instance.AddSlot(basicSlotContainer.Slots[i]);
265221
}
266222

267223
return section;
268224
}
269225

270-
public override void SelectSlot(int slotPosition)
271-
{
272-
// use skill
273-
274-
}
275-
276226
private void HandleSlotClick(ClickEvent evt)
277227
{
278228
ToggleShrink((VisualElement)evt.currentTarget);

0 commit comments

Comments
 (0)