本文整理匯總了C#中Ability.GetDefaultName方法的典型用法代碼示例。如果您正苦於以下問題:C# Ability.GetDefaultName方法的具體用法?C# Ability.GetDefaultName怎麽用?C# Ability.GetDefaultName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Ability
的用法示例。
在下文中一共展示了Ability.GetDefaultName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddMenuItem
public async Task AddMenuItem(
Hero hero,
Ability ability,
Ranges.CustomRange customRange = Ranges.CustomRange.None)
{
var isItem = ability is Item;
var abilityName = isItem ? ability.GetDefaultName() : ability?.StoredName();
var texture = abilityName;
var menuName = string.Empty;
switch (customRange)
{
case Ranges.CustomRange.Attack:
abilityName = "attackRange";
menuName = "Attack range";
texture = null;
break;
case Ranges.CustomRange.Expiriece:
abilityName = "expRange";
menuName = "Exp range";
texture = null;
break;
}
if (string.IsNullOrEmpty(abilityName))
{
return;
}
var key = hero.StoredName() + abilityName;
if (hero.Equals(myHero))
{
key += "myHero";
}
var abilityMenu = new Menu(texture == null ? menuName : " ", key, false, texture, true);
var enable = new MenuItem(key + "enabled", "Enabled").SetValue(false);
await Task.Delay(100);
var radiusOnly = new MenuItem(key + "radius", "Damage radius only").SetValue(false);
await Task.Delay(100);
var red = new MenuItem(key + "red", "Red").SetValue(new Slider(255, 0, 255));
await Task.Delay(100);
var green = new MenuItem(key + "green", "Green").SetValue(new Slider(0, 0, 255));
await Task.Delay(100);
var blue = new MenuItem(key + "blue", "Blue").SetValue(new Slider(0, 0, 255));
await Task.Delay(100);
enable.ValueChanged += (sender, arg) => {
var enabled = arg.GetNewValue<bool>();
abilityMenu.DisplayName = enabled
? abilityMenu.DisplayName + "*"
: abilityMenu.DisplayName.Replace("*", "");
OnChange?.Invoke(
this,
new AbilityEventArgs
{
Hero = hero,
Name = abilityName,
Enabled = enabled,
Redraw = true
});
};
radiusOnly.ValueChanged += (sender, args) => {
OnChange?.Invoke(
this,
new AbilityEventArgs
{
Hero = hero,
Name = abilityName,
Enabled = enable.IsActive(),
RadiusOnly = args.GetNewValue<bool>(),
Redraw = true
});
};
red.ValueChanged += (sender, arg) => {
OnChange?.Invoke(
this,
new AbilityEventArgs
{
Hero = hero,
Name = abilityName,
Red = arg.GetNewValue<Slider>().Value
});
};
green.ValueChanged += (sender, arg) => {
OnChange?.Invoke(
this,
new AbilityEventArgs
{
Hero = hero,
Name = abilityName,
Green = arg.GetNewValue<Slider>().Value
//.........這裏部分代碼省略.........