//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace ElementalGame.Menus
{
#region Using Statements
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using System.Threading;
using System.Xml;
#endregion
using DarkWynterEngine;
using DarkWynterEngine.Controllers;
using DarkWynterEngine.Globals;
using DarkWynterEngine.ObjectLib;
using DarkWynterEngine.Menus;
///
/// The Game Setup screen.
///
public class GameSetup : GameScreen
{
private Texture2D storyModeTexture;
private Texture2D deathMatchTexture;
private Texture2D survivalTexture;
private Texture2D lastmanTexture;
///
/// Menu that allows the user to select from multiple game types.
///
public GameSetup(Enums.EngineState GameEngineState)
: base(GameEngineState)
{
// Instantiate the GameMenu
menu = new GameMenu("Game Setup", 100, 100);
menu.SetDrawMenuTitle(false);
menu.AddLabel("Game options:");
menu.AddLabel("");
menu.AddMenuOption("Game type:", "Deathmatch", "Story Mode", "Survival", "Last man standing");
menu.AddLabel("");
menu.AddValueInput("# Players:",
Statics.GameSettings.MIN_NUMBER_OF_PLAYERS,
Statics.GameSettings.MAX_NUMBER_OF_PLAYERS,
Statics.GameSettings.DEFAULT_NUMBER_OF_PLAYERS,
Statics.GameSettings.NUMBER_OF_PLAYERS_PER_TEAM
);
menu.AddLabel("");
menu.AddMenuOption("Difficulty:", "Lamer", "Average Joe", "Uber Mental");
menu.AddLabel("");
menu.AddValueInput("Max kills:", 1, 10, 3, 1);
menu.AddLabel("");
menu.AddValueInput("Bots:", 0, 10, 1, 1);
menu.AddLabel("");
menu.AddValueInput("Bot intelligence:", 1, 10, 5, 1);
menu.AddLabel("");
storyModeTexture = Statics.SystemSettings.content.Load("Content/_textures/DMatch");
}
///
/// Check for updates to Game Setup menu.
///
/// Current ObjectLibrary.
/// Menu controller used to update input.
public override void Update(ObjectLibrary objectLibrary)
{
base.Update(objectLibrary);
//Check for recently connecting players and update
DarkWynterGame.menuController.SetBlockStartBackInput(false);
int numControllersBefore = Statics.SystemSettings.TOTAL_PLAYERS;
Controller.CheckForControllers(objectLibrary);
if (Statics.SystemSettings.TOTAL_PLAYERS != numControllersBefore)
{
((GameMenuValueInput)GetMenu().GetMenuElement("# Players:")).SetRange(1, Statics.SystemSettings.TOTAL_PLAYERS);
((GameMenuValueInput)GetMenu().GetMenuElement("# Players:")).SetValue(Statics.SystemSettings.TOTAL_PLAYERS);
}
if (GetMenu().GetActiveMenuElement().GetTitle() == "Game type:")
{
GameMenuOption option = (GameMenuOption)GetMenu().GetActiveMenuElement();
//need to change the settings depending on what is available here
if (option.GetActiveOption() == "Story Mode")
{
GetMenu().GetMenuElement("# Players:").Hide();
GetMenu().GetMenuElement("Max kills:").Hide();
GetMenu().GetMenuElement("Difficulty:").Show();
GetMenu().GetMenuElement("Bots:").Hide();
GetMenu().GetMenuElement("Bot intelligence:").Show();
SetBackground(storyModeTexture);
}
else if (option.GetActiveOption() == "Last man standing")
{
GetMenu().GetMenuElement("# Players:").Show();
GetMenu().GetMenuElement("Max kills:").Hide();
GetMenu().GetMenuElement("Difficulty:").Hide();
GetMenu().GetMenuElement("Bots:").Show();
GetMenu().GetMenuElement("Bot intelligence:").Show();
SetBackground(lastmanTexture);
}
else if (option.GetActiveOption() == "Deathmatch")
{
GetMenu().GetMenuElement("# Players:").Show();
GetMenu().GetMenuElement("Max kills:").Show();
GetMenu().GetMenuElement("Difficulty:").Hide();
GetMenu().GetMenuElement("Bots:").Show();
GetMenu().GetMenuElement("Bot intelligence:").Show();
SetBackground(deathMatchTexture);
}
else if (option.GetActiveOption() == "Survival")
{
GetMenu().GetMenuElement("# Players:").Show();
GetMenu().GetMenuElement("Max kills:").Hide();
GetMenu().GetMenuElement("Difficulty:").Show();
GetMenu().GetMenuElement("Bots:").Hide();
GetMenu().GetMenuElement("Bot intelligence:").Show();
SetBackground(survivalTexture);
}
}
}
///
/// Commit user selections.
///
public void GameSetupCommit()
{
GameMenuOption option; // Text Option
GameMenuValueInput value; // Numeric Option
// Number of players that will play
value = (GameMenuValueInput)GetMenu().GetMenuElement("# Players:");
Statics.GameSettings.numberOfHumansActive = value.GetValue();
// Game type selection
option = (GameMenuOption)GetMenu().GetMenuElement("Game type:");
if (option.GetActiveOption() == "Story Mode")
{
Statics.GameSettings.gameType = Enums.GameType.STORY_MODE;
}
else if (option.GetActiveOption() == "Last man standing")
{
Statics.GameSettings.gameType = Enums.GameType.LAST_MAN_STANDING;
}
else if (option.GetActiveOption() == "Deathmatch")
{
Statics.GameSettings.gameType = Enums.GameType.DEATHMATCH;
}
else if (option.GetActiveOption() == "Survival")
{
Statics.GameSettings.gameType = Enums.GameType.SURVIVAL;
}
// Max number of kills to win
value = (GameMenuValueInput)GetMenu().GetMenuElement("Max kills:");
Statics.GameSettings.maxNumberOfKills = value.GetValue();
// Number of AI Bots
if (option.GetActiveOption() != "Survival" && option.GetActiveOption() != "Story Mode")
{
value = (GameMenuValueInput)GetMenu().GetMenuElement("Bots:");
Statics.GameSettings.botCount = value.GetValue();
}
else
{
string difficultyLevel = ((GameMenuOption)GetMenu().GetMenuElement("Difficulty:")).GetActiveOption();
if (difficultyLevel == "Lamer")
{
Statics.GameSettings.botCount = 3;
}
else if (difficultyLevel == "Average Joe")
{
Statics.GameSettings.botCount = 6;
}
else if (difficultyLevel == "Uber Mental")
{
Statics.GameSettings.botCount = 10;
}
}
// Bot intelligence (1= dumb, 10= super smart)
value = (GameMenuValueInput)GetMenu().GetMenuElement("Bot intelligence:");
Statics.GameSettings.botIntelligence = value.GetValue();
}
}
}