Beispiel #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Menu" /> class.
        /// </summary>
        /// <param name="displayName">
        ///     The display name.
        /// </param>
        /// <param name="name">
        ///     The name.
        /// </param>
        /// <param name="isRootMenu">
        ///     The is root menu.
        /// </param>
        /// <param name="textureName">
        ///     The texture name.
        /// </param>
        /// <param name="showTextWithTexture">
        ///     The show text with texture.
        /// </param>
        public Menu(
            string displayName,
            string name,
            bool isRootMenu          = false,
            string textureName       = null,
            bool showTextWithTexture = false)
            : base(20)
        {
            this.DisplayName         = displayName;
            this.Name                = name;
            this.IsRootMenu          = isRootMenu;
            this.Style               = FontStyle.Regular;
            this.Color               = new Color(195, 186, 173, 255);
            this.TextureName         = textureName;
            this.ShowTextWithTexture = showTextWithTexture;
            this.transition          = new ExpoEaseInOut(0.25);
            if (textureName != null && !TextureDictionary.ContainsKey(textureName))
            {
                if (textureName.Contains("npc_dota_hero_"))
                {
                    this.Texture = Textures.GetHeroTexture(textureName);
                }
                else if (textureName.Contains("item_"))
                {
                    this.Texture = Textures.GetItemTexture(textureName);
                }
                else
                {
                    this.Texture = Textures.GetSpellTexture(textureName);
                }

                if (this.Texture == null)
                {
                    this.TextureName = null;
                }
            }

            AppDomain.CurrentDomain.DomainUnload += delegate { this.SaveAll(); };
            AppDomain.CurrentDomain.ProcessExit  += delegate { this.SaveAll(); };
            Events.OnClose += delegate { this.SaveAll(); };
        }
Beispiel #2
0
        public void Turn(Direction direction)
        {
            switch (direction)
            {
            case Direction.Left:
                SetRotation(Rotation - TurnRate);
                if (TextureDictionary.ContainsKey(direction.ToString()))
                {
                    TextureIndexCounter = direction.ToString();
                }
                break;

            case Direction.Right:
                SetRotation(Rotation + TurnRate);
                if (TextureDictionary.ContainsKey(direction.ToString()))
                {
                    TextureIndexCounter = direction.ToString();
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }