コード例 #1
0
        // event handler that sets the color of secondary type comboboxes font color and highlight color
        private void secondaryTypeComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            // Draw the background
            e.DrawBackground();

            // Get the item text
            IPkmnType item = (IPkmnType)(((ComboBox)sender).Items[e.Index]);

            ColorConverter cc = new ColorConverter();

            using (SolidBrush highlightBrush = new SolidBrush(Color.FromArgb(28, 28, 28)))
            {
                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    e.Graphics.FillRectangle(highlightBrush, e.Bounds);
                }
            }

            // Determine the forecolor based on whether or not the item is selected
            using (SolidBrush brush = new SolidBrush((Color)cc.ConvertFromString(item.TypeColor)))
            {
                // Draw the text
                e.Graphics.DrawString(item.TypeName, ((Control)sender).Font, brush, e.Bounds.X, e.Bounds.Y);
            }
            e.DrawFocusRectangle();
        }
コード例 #2
0
        // listview row draw event handler sets background color corresponding to pkmn type
        private void pkmnTypeObjectListView_FormatRow(object sender, BrightIdeasSoftware.FormatRowEventArgs e)
        {
            IPkmnType      pkmnTypeModel = (IPkmnType)e.Model;
            ColorConverter cc            = new ColorConverter();

            e.Item.BackColor = (Color)cc.ConvertFromString(pkmnTypeModel.TypeColor);
        }
コード例 #3
0
        public void OnGet()
        {
            //PrimaryPkmnTypeList = PkmnTypeFactory.GeneratePkmnTypeList();
            //SecondaryPkmnTypeList = PkmnTypeFactory.GeneratePkmnTypeList();
            //PrimaryPkmnTypeList.Insert(0, PkmnTypeFactory.CreateEmptyPkmnType());
            //SecondaryPkmnTypeList.Insert(0, PkmnTypeFactory.CreateEmptyPkmnType());

            // check for nulls and change to (none) if types are not selected
            if (SelectedPrimaryTypeName == null)
            {
                SelectedPrimaryTypeName  = "(none)";
                SelectedPrimaryTypeColor = "white";
            }
            //if(SelectedPrimaryType == null)
            //{
            //    SelectedPrimaryType = PkmnTypeFactory.CreateEmptyPkmnType();
            //}
            //if(SelectedSecondaryType == null)
            //{
            //    SelectedSecondaryType = PkmnTypeFactory.CreateEmptyPkmnType();
            //}
            if (SelectedSecondaryTypeName == null)
            {
                SelectedSecondaryTypeName  = "(none)";
                SelectedSecondaryTypeColor = "white";
            }



            selectedPrimaryType   = PrimaryPkmnTypeList.Where(type => type.TypeName == SelectedPrimaryTypeName).FirstOrDefault();
            selectedSecondaryType = SecondaryPkmnTypeList.Where(type => type.TypeName == SelectedSecondaryTypeName).FirstOrDefault();

            // delete selected type from the other list
            //PrimaryPkmnTypeList.Remove(SecondaryPkmnTypeList.Where(type => type.TypeName == SelectedSecondaryTypeName).FirstOrDefault());
            //SecondaryPkmnTypeList.Remove(PrimaryPkmnTypeList.Where(type => type.TypeName == SelectedPrimaryTypeName).FirstOrDefault());

            SelectedPrimaryTypeColor   = selectedPrimaryType.TypeColor;
            SelectedSecondaryTypeColor = selectedSecondaryType.TypeColor;

            // check if both comboboxes select the (none) type
            if (SelectedPrimaryTypeName == "(none)" && SelectedSecondaryTypeName == "(none)")
            {
                return;
            }

            // calculate damage multiplier for each pkmn type in the list
            foreach (var pkmnType in PkmnTypeList)
            {
                pkmnType.DmgMultiplier = pkmnType.CalculateDmgMultiplier(selectedPrimaryType, selectedSecondaryType);
            }

            // sort by damage multiplier from highest to lowest
            PkmnTypeList.Sort((x, y) => y.DmgMultiplier.CompareTo(x.DmgMultiplier));
        }
コード例 #4
0
        // calculates dmg multiplier by executing CalculateDmgMultiplierForASingleType on selected types
        public double CalculateDmgMultiplier(IPkmnType defendingPkmnPrimaryType, IPkmnType defendingPkmnSecondaryType)
        {
            double primaryTypeMultiplier   = CalculateDmgMultiplierForASingleType(defendingPkmnPrimaryType);
            double secondaryTypeMultiplier = CalculateDmgMultiplierForASingleType(defendingPkmnSecondaryType);

            // check if both types are the same type
            if (defendingPkmnPrimaryType.TypeName == defendingPkmnSecondaryType.TypeName)
            {
                return(primaryTypeMultiplier);
            }
            else
            {
                return(primaryTypeMultiplier * secondaryTypeMultiplier);
            }
        }
コード例 #5
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is FightingPkmnType || pkmnType is DragonPkmnType || pkmnType is DarkPkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is PoisonPkmnType || pkmnType is SteelPkmnType || pkmnType is FirePkmnType)
            {
                output = 0.5;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #6
0
ファイル: FirePkmnType.cs プロジェクト: iyarashii/PkmnCalcWPF
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is BugPkmnType || pkmnType is SteelPkmnType || pkmnType is GrassPkmnType || pkmnType is IcePkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is RockPkmnType || pkmnType is FirePkmnType || pkmnType is WaterPkmnType || pkmnType is DragonPkmnType)
            {
                output = 0.5;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #7
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is RockPkmnType || pkmnType is SteelPkmnType)
            {
                output = 0.5;
            }
            else if (pkmnType is GhostPkmnType)
            {
                output = 0.0;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #8
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is FightingPkmnType || pkmnType is BugPkmnType || pkmnType is GrassPkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is RockPkmnType || pkmnType is SteelPkmnType || pkmnType is ElectricPkmnType)
            {
                output = 0.5;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #9
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is GhostPkmnType || pkmnType is PsychicPkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is FightingPkmnType || pkmnType is DarkPkmnType || pkmnType is FairyPkmnType)
            {
                output = 0.5;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #10
0
ファイル: RockPkmnType.cs プロジェクト: iyarashii/PkmnCalcWPF
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is FlyingPkmnType || pkmnType is BugPkmnType || pkmnType is FirePkmnType ||
                pkmnType is IcePkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is FightingPkmnType || pkmnType is GroundPkmnType || pkmnType is SteelPkmnType)
            {
                output = 0.5;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #11
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is FlyingPkmnType || pkmnType is WaterPkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is GrassPkmnType || pkmnType is ElectricPkmnType || pkmnType is DragonPkmnType)
            {
                output = 0.5;
            }
            else if (pkmnType is GroundPkmnType)
            {
                output = 0.0;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #12
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is DragonPkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is SteelPkmnType)
            {
                output = 0.5;
            }
            else if (pkmnType is FairyPkmnType)
            {
                output = 0.0;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #13
0
        public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
        {
            double output;

            if (pkmnType is NormalPkmnType || pkmnType is RockPkmnType || pkmnType is SteelPkmnType || pkmnType is IcePkmnType || pkmnType is DarkPkmnType)
            {
                output = 2.0;
            }
            else if (pkmnType is FlyingPkmnType || pkmnType is PoisonPkmnType || pkmnType is BugPkmnType || pkmnType is PsychicPkmnType || pkmnType is FairyPkmnType)
            {
                output = 0.5;
            }
            else if (pkmnType is GhostPkmnType)
            {
                output = 0.0;
            }
            else
            {
                output = 1.0;
            }
            return(output);
        }
コード例 #14
0
 // abstract method that is defined differently by every pokemon type
 public abstract double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType);
コード例 #15
0
 public PkmnTypeViewModel(IPkmnType pkmnType)
 {
     PokemonType = pkmnType;
 }
コード例 #16
0
 public static IPkmnType CreatePkmnTypeViewModel(IPkmnType pkmnType)
 {
     return(new PkmnTypeViewModel(pkmnType));
 }
コード例 #17
0
 public override double CalculateDmgMultiplierForASingleType(IPkmnType pkmnType)
 {
     return(1.0);
 }