Ejemplo n.º 1
0
        /// <summary>
        /// Allow change between VillageTypes (Offensive, Defensive, Nobles, ...)
        /// </summary>
        private static void AddVillageTypeCommand(UICommand menu, VillageType typeToSet, VillageType typeCurrent, CommandEventHandler onVillageTypeChange)
        {
            bool isCurrentlySet = typeCurrent.HasFlag(typeToSet);

            var command = new UICommand("", typeToSet.GetDescription());

            command.Tag     = typeToSet;
            command.Image   = typeToSet.GetImage(true);
            command.Checked = isCurrentlySet ? InheritableBoolean.True : InheritableBoolean.False;
            command.Click  += onVillageTypeChange;
            menu.Commands.Add(command);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the description of the most important type
        /// </summary>
        public static string GetDescription(this VillageType type)
        {
            if (type.HasFlag(VillageType.Noble))
            {
                return(VillageGridExRes.VillageType_Noble);
            }

            if (type.HasFlag(VillageType.Attack))
            {
                return(VillageGridExRes.VillageType_Offensive);
            }

            if (type.HasFlag(VillageType.Catapult))
            {
                return(VillageGridExRes.VillageType_Catapults);
            }

            if (type.HasFlag(VillageType.Defense))
            {
                return(VillageGridExRes.VillageType_Defensive);
            }

            if (type.HasFlag(VillageType.Scout))
            {
                return(VillageGridExRes.VillageType_Scouts);
            }

            if (type.HasFlag(VillageType.Farm))
            {
                return(VillageGridExRes.VillageType_Farm);
            }

            if (type.HasFlag(VillageType.Comments))
            {
                return(VillageGridExRes.VillageType_Comments);
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the most important image
        /// (in case multiple flags are active)
        /// </summary>
        public static Image GetImage(this VillageType type, bool displayComments)
        {
            if (type.HasFlag(VillageType.Noble))
            {
                return(UnitImages.Noble);
            }

            if (type.HasFlag(VillageType.Attack))
            {
                return(UnitImages.Axe);
            }

            if (type.HasFlag(VillageType.Catapult))
            {
                return(UnitImages.Catapult);
            }

            if (type.HasFlag(VillageType.Defense))
            {
                return(Properties.Resources.Defense);
            }

            if (type.HasFlag(VillageType.Scout))
            {
                return(UnitImages.Scout);
            }

            if (type.HasFlag(VillageType.Farm))
            {
                return(BuildingImages.Farm);
            }

            if (displayComments && type.HasFlag(VillageType.Comments))
            {
                return(Other.Note);
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Allow change between VillageTypes (Offensive, Defensive, Nobles, ...)
        /// </summary>
        private static void AddVillageTypeCommand(UICommand menu, VillageType typeToSet, VillageType typeCurrent, CommandEventHandler onVillageTypeChange)
        {
            bool isCurrentlySet = typeCurrent.HasFlag(typeToSet);

            var command = new UICommand("", typeToSet.GetDescription());
            command.Tag = typeToSet;
            command.Image = typeToSet.GetImage(true);
            command.Checked = isCurrentlySet ? InheritableBoolean.True : InheritableBoolean.False;
            command.Click += onVillageTypeChange;
            menu.Commands.Add(command);
        }