I am trying to implement difficulty levels. I have added the combobox at the new game screen using the following (it is an airline simulation):
lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1011"), cbDifficulty));
cbOpponents = new ComboBox();
cbOpponents.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
cbOpponents.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
cbOpponents.Width = 50;
cbOpponents.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
for (int i = 0; i < Airlines.GetAllAirlines().Count; i++)
cbOpponents.Items.Add(i);
cbOpponents.SelectedIndex = 3;// cbOpponents.Items.Count - 1;
private void cbDifficulty_Selectionchanged(object sender, SelectionchangedEventArgs e)
{
Airline airline = (Airline)cbDifficulty.SelectedItem;
int year = (int)cbStartYear.SelectedItem;
setAirportsView(year, airline.Profile.Country);
}
The combobox is displaying fine, however I am having a bit of trouble with setting the difficulty level when the Selectionchanged occurs.
This is the abbreviated code for the game object (where we set our initial settings for a new game):
public class GameObject
{
public enum DifficultyLevel { Easy, Normal, Hard }
public DifficultyLevel difficulty { get; set; }
private GameObject()
{
this.difficulty = DifficultyLevel.Easy;
}
//returns the starting money
private long getStartMoney()
{
long baseStartMoney = 125000000;
if (difficulty == Easy)
{ baseStartMoney *= (3 / 2); }
else if (difficulty == Normal)
{ baseStartMoney *= 1;}
else if (difficulty == Hard)
{ baseStartMoney *= (1/2);}
return Convert.ToInt64(GeneralHelpers.GetInflationPrice(baseStartMoney));
}
The difficulty levels are returning as not in context, but I have been staring at this screen for an hour or so and I'm running out of fresh ideas.
A gentle shove in the right direction would be greatly appreciated

New Topic/Question
Reply



MultiQuote




|