00001
00002
00003
00004
00005
00006 namespace MontyHallGame
00007 {
00008 using System.Threading;
00009 using System.Collections.Generic;
00010 using Microsoft.Xna.Framework;
00011 using Microsoft.Xna.Framework.Audio;
00012 using Microsoft.Xna.Framework.Content;
00013 using Microsoft.Xna.Framework.GamerServices;
00014 using Microsoft.Xna.Framework.Graphics;
00015 using Microsoft.Xna.Framework.Input;
00016 using Microsoft.Xna.Framework.Net;
00017 using Microsoft.Xna.Framework.Storage;
00018
00019 using NewGamePhysics;
00020 using NewGamePhysics.Mathematics;
00021 using NewGamePhysics.Physics;
00022 using NewGamePhysics.Utilities;
00023 using NewGamePhysics.StateManager;
00024
00028 public class MontyHallGame : Microsoft.Xna.Framework.Game
00029 {
00033 public static MontyHallGameState state = new MontyHallGameState();
00034
00035
00036 GraphicsDeviceManager graphics;
00037 ScreenManager screenManager;
00038 Viewport viewport;
00039 Matrix projectionMatrix;
00040
00041
00042 Gamepads gamepads;
00043
00048 public MontyHallGame(bool fullscreen)
00049 {
00050
00051 gamepads = new Gamepads();
00052
00053
00054 Content.RootDirectory = "Content";
00055
00056
00057 graphics = new GraphicsDeviceManager(this);
00058 graphics.PreferredBackBufferWidth = 853;
00059 graphics.PreferredBackBufferHeight = 480;
00060
00061
00062 graphics.IsFullScreen = fullscreen;
00063
00064
00065 graphics.PreferMultiSampling = true;
00066
00067
00068 screenManager = new ScreenManager(this);
00069 Components.Add(screenManager);
00070 }
00071
00078 protected override void Initialize()
00079 {
00080
00081 viewport = graphics.GraphicsDevice.Viewport;
00082
00083
00084 this.IsMouseVisible = true;
00085
00086
00087 float aspectRatio = graphics.GraphicsDevice.Viewport.Width /
00088 (float)graphics.GraphicsDevice.Viewport.Height;
00089
00090
00091 projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
00092 MathHelper.ToRadians(45.0f), aspectRatio, 1f, 10000);
00093
00094 base.Initialize();
00095 }
00096
00101 protected override void LoadContent()
00102 {
00103
00104 string[] doorFilenames = {
00105 "mdoor_ccc", "mdoor_cco", "mdoor_coc", "mdoor_coo",
00106 "mdoor_occ", "mdoor_oco", "mdoor_ooc", "mdoor_ooo"
00107 };
00108 foreach (string doorFilename in doorFilenames)
00109 {
00110 screenManager.AddTexture(doorFilename, "Textures/" + doorFilename);
00111 }
00112
00113
00114 screenManager.AddTexture("key", "Sprites/key");
00115 screenManager.AddTexture("opensign", "Sprites/opensign");
00116 screenManager.AddTexture("monty", "Sprites/monty");
00117 screenManager.AddTexture("potogold", "Sprites/potogold");
00118
00119
00120 screenManager.AddFont("courier", "Fonts/courier");
00121 screenManager.AddFont("retro", "Fonts/retroMedium");
00122
00123
00124 screenManager.AddSound("door", "Sounds/door");
00125 screenManager.AddSound("crowd", "Sounds/gameshow_crowd");
00126 screenManager.AddSound("show", "Sounds/gameshow");
00127 screenManager.AddSound("intro", "Sounds/intro_jingle");
00128 screenManager.AddSound("loser", "Sounds/loser");
00129 screenManager.AddSound("money", "Sounds/money");
00130 screenManager.AddSound("winner", "Sounds/pick_a_winner");
00131 screenManager.AddSound("click", "Sounds/click");
00132
00133
00134 screenManager.AddScreen(new MontyHallBackgroundScreen(), null);
00135 screenManager.AddScreen(new MontyHallMainMenuScreen(), null);
00136 }
00137
00142 protected override void UnloadContent()
00143 {
00144
00145 }
00146
00152 protected override void Update(GameTime gameTime)
00153 {
00154
00155 KeyboardState keyState = Keyboard.GetState();
00156 Keys[] keys = keyState.GetPressedKeys();
00157
00158
00159 if (keyState.IsKeyDown(Keys.Delete))
00160 {
00161 this.Exit();
00162 }
00163
00164 base.Update(gameTime);
00165 }
00166
00171 protected override void Draw(GameTime gameTime)
00172 {
00173
00174 graphics.GraphicsDevice.Clear(Color.Black);
00175
00176
00177 base.Draw(gameTime);
00178 }
00179 }
00180 }