当前位置: 首页>>代码示例>>C#>>正文


C# Ability.GetDefaultName方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:IdcNoob,项目名称:Ensage,代码行数:101,代码来源:MenuManager.cs


注:本文中的Ability.GetDefaultName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。