You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
4.1 KiB
132 lines
4.1 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEditor; |
|
using UnityEngine; |
|
using UnityEngine.UIElements; |
|
using UnityEditor.UIElements; |
|
|
|
namespace PVSkill |
|
{ |
|
public class SkillSonElement |
|
{ |
|
private VisualElement root; |
|
private SkillSonConfig curSkillSonConfig; |
|
|
|
// elem |
|
private Label skillDescLbl; |
|
private Label actionTypeLbl; |
|
private Label objectTypeLbl; |
|
private Label scopeTypeLbl; |
|
private Label CDTypeLbl; |
|
|
|
private ListView buffListView; |
|
private SkillBuffElement buffElement; |
|
|
|
public SkillSonElement(VisualElement root) |
|
{ |
|
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Editor/SkillEditor/SkillSonElement.uxml"); |
|
visualTree.CloneTree(root); |
|
this.root = root; |
|
|
|
this.skillDescLbl = root.Q<Label>("SkillDescLbl"); |
|
this.actionTypeLbl = root.Q<Label>("ActionTypeLbl"); |
|
this.objectTypeLbl = root.Q<Label>("ObjectTypeLbl"); |
|
this.scopeTypeLbl = root.Q<Label>("ScopeTypeLbl"); |
|
this.CDTypeLbl = root.Q<Label>("CDTypeLbl"); |
|
|
|
this.buffListView = root.Q<ListView>("BuffListView"); |
|
this.buffListView.bindItem = this.BindBuffListItem; |
|
this.buffListView.makeItem = this.MakeBuffListItem; |
|
this.buffListView.onSelectionChange += this.OnBuffItemChosen; |
|
var buffInfo = root.Q<VisualElement>("BuffInfo"); |
|
this.buffElement = new SkillBuffElement(buffInfo); |
|
} |
|
|
|
private void RefreshBuffItems(int[] buffs) |
|
{ |
|
if (buffs == null || buffs[0] == 0) |
|
{ |
|
this.buffListView.itemsSource = new List<int>(); |
|
this.buffListView.ClearSelection(); |
|
this.buffElement.Hide(); |
|
} |
|
else |
|
{ |
|
this.buffListView.itemsSource = buffs; |
|
this.buffListView.selectedIndex = 0; |
|
} |
|
|
|
this.buffListView.RefreshItems(); |
|
} |
|
|
|
private void BindBuffListItem(VisualElement ve, int index) |
|
{ |
|
Label label = ve as Label; |
|
var buffId = this.curSkillSonConfig.Buff[index]; |
|
var config = SkillBuffConfigCategory.Instance.Get(buffId); |
|
label.text = config.Name; |
|
} |
|
|
|
private VisualElement MakeBuffListItem() |
|
{ |
|
var label = new Label(); |
|
// label.AddToClassList("FatherSkillLabel"); |
|
return label; |
|
} |
|
|
|
private void OnBuffItemChosen(IEnumerable<object> obj) |
|
{ |
|
foreach (object o in obj) |
|
{ |
|
int buffId = (int) o; |
|
var config = SkillBuffConfigCategory.Instance.Get(buffId); |
|
this.buffElement.SetDataByConfig(config); |
|
} |
|
} |
|
|
|
public void SetActionType(int type) |
|
{ |
|
this.actionTypeLbl.text = SkillEditorDefines.ActionTypeMap[type]; |
|
} |
|
|
|
public void SetObjectType(int type) |
|
{ |
|
this.objectTypeLbl.text = SkillEditorDefines.ObjectTypeMap[type]; |
|
} |
|
|
|
public void SetScopeType(int type) |
|
{ |
|
this.scopeTypeLbl.text = SkillEditorDefines.ScopeTypeMap[type]; |
|
} |
|
|
|
public void SetCDType(int type) |
|
{ |
|
this.CDTypeLbl.text = SkillEditorDefines.CDTypeMap[type]; |
|
} |
|
|
|
public void SetDesc(string desc) |
|
{ |
|
this.skillDescLbl.text = desc; |
|
} |
|
|
|
public void Hide() |
|
{ |
|
this.root.style.display = DisplayStyle.None; |
|
} |
|
|
|
public void SetDataByConfig(SkillSonConfig config) |
|
{ |
|
this.curSkillSonConfig = config; |
|
this.root.style.display = DisplayStyle.Flex; |
|
this.SetDesc(config.Describe); |
|
this.SetActionType(config.ActionType); |
|
this.SetObjectType(config.ObjectType); |
|
this.SetScopeType(config.ScopeType); |
|
// this.SetCDType(config.CDType); |
|
|
|
int[] buffs = this.curSkillSonConfig.Buff; |
|
this.RefreshBuffItems(buffs); |
|
} |
|
} |
|
} |
|
|
|
|