Here's the gist of what I'm going to do.
Heres' my hero class:
namespace TomeOfNewerth_WPF_
{
public enum HeroType
{
Agility,
Strength,
Intelligence
}
public enum AttackType
{
Melee,
Ranged,
}
class Hero
{
public string Faction;
public string Name;
public HeroType HeroType;
public string Backstory;
public double MinimumDamage;
public double MaximumDamage;
public double Armor;
public double MoveSpeed;
public AttackType AttackType;
public double AttackRange;
public double AttackRate;
public int Strength;
public int Agility;
public int Intelligence;
public string DOTAVersion;
//Default constructer required for XML serialization.
public Hero()
{ }
/// <summary>
/// This method returns a hero full of the necessary information.
/// </summary>
/// <param name="Name">Name of the hero.</param>
/// <returns>Returns an instace of the Hero class chock full of information.</returns>
public Hero GetHero(string Name)
{
Hero NewHero = new Hero();
NewHero.Faction = "Legion";
NewHero.Name = "Andromeda";
//Yada yada yada. I have to complete this, so disregard it.
return NewHero;
}
}
}
Each attribute of that class is an XML element. I have manually tabulated all the information into an XML file so I can deserialize it into the the Hero class and forward the instance to wherever it is needed.
There is one use case that I can't really get my head around.
I have two buttons, ViewGood and ViewEvil.
There is an attribute on the Hero class called Faction and I have to filter out which Heroes have Good and which heroes have Evil.
What I'm thinking of doing:
I'd have a method that cycles through each node in the XML and return a List containing all the hero names which match the HEROTYPE that was asked for.
Using that List, I can then do a foreach and since all Heroes have an Image control on the form with the x:Name set as the Hero name, I can do a .Visibilty = Visibility.False to all, and set it to true to every hero name on the list. Effectively hiding every Image control that is not on the List.
My question to you guys is, am I doing something completely retarded? I really want to take extra time and make this program have nice clean code because I want to learn more than anything.
As my father said, 'Bad habits are easy to learn, it's the good ones that rape you.'
Thanks SO. :)