protected override void LoadContent() { device = GraphicsDevice; this._spriteBatch = new SpriteBatch(device); this._spriteLargeFont = Content.Load <SpriteFont>("FONT\\LargeGameFont"); this._spriteRegularFont = Content.Load <SpriteFont>("FONT\\GameFont"); _soundManager.AddSound("Neutral", Content.Load <SoundEffect>("SOUND//Gear1")); _soundManager.AddSound("First", Content.Load <SoundEffect>("SOUND//Gear1")); _soundManager.AddSound("Second", Content.Load <SoundEffect>("SOUND//Gear2")); _soundManager.AddSound("Third", Content.Load <SoundEffect>("SOUND//Gear3")); _soundManager.AddSound("Fourth", Content.Load <SoundEffect>("SOUND//Gear4")); _soundManager.AddSound("Fifth", Content.Load <SoundEffect>("SOUND//Gear5")); _soundManager.AddSound("Reverse", Content.Load <SoundEffect>("SOUND//Gear2")); _soundManager.AddSound("GearChange", Content.Load <SoundEffect>("SOUND//Gear1ToGear2")); _soundManager.AddSound("BrakeMajor", Content.Load <SoundEffect>("SOUND//BrakeMajor")); _soundManager.AddSound("BrakeCurveMajor", Content.Load <SoundEffect>("SOUND//BrakeCurveMajor")); _gears = new Dictionary <string, Texture2D>(); _gears.Add("Neutral", Content.Load <Texture2D>("SPRITES//Gear_Neutral")); _gears.Add("First", Content.Load <Texture2D>("SPRITES//Gear_First")); _gears.Add("Second", Content.Load <Texture2D>("SPRITES//Gear_Second")); _gears.Add("Third", Content.Load <Texture2D>("SPRITES//Gear_Third")); _gears.Add("Fourth", Content.Load <Texture2D>("SPRITES//Gear_Fourth")); _gears.Add("Fifth", Content.Load <Texture2D>("SPRITES//Gear_Fifth")); _gears.Add("Sixth", Content.Load <Texture2D>("SPRITES//Gear_Neutral")); _gears.Add("Reverse", Content.Load <Texture2D>("SPRITES//Gear_Reverse")); _revBG = Content.Load <Texture2D>("SPRITES//RevBG"); _revCount = Content.Load <Texture2D>("SPRITES//RevCount"); _effect = Content.Load <Effect>("EFFECT//m_effects"); _skyDome = new SkyDome(Content.Load <Model>("MODEL//DOME//dome"), Content.Load <Texture2D>("MODEL//DOME//cloudMap"), _effect.Clone(device)); _terrain = new ColoredTerrain(_effect.Clone(device), new Vector2(500, 500), Content.Load <Texture2D>("TEXTURE//heightmap6")); //_terrain = new ColoredTerrain(_effect.Clone(device), new Vector2(500, 500), Content.Load<Texture2D>("TEXTURE//flatheightmap")); _car = new CarObject(Content.Load <Model>("MODEL//SL500//SL500"), CreateSL500Spec(), _steeringWheelDevice); _car.initialise(); _camera = new Camera[3]; _camera[0] = new ChaseCamera(_car, new Vector3(-0.35f * 2.8f, 1.0f * 2.8f, 0.3f * 2.8f), device.Viewport, new Vector2(MathHelper.TwoPi, MathHelper.TwoPi), true); _camera[1] = new ChaseCamera(_car, new Vector3(0f * 2.8f, 2f * 2.8f, 7f * 2.8f), device.Viewport, new Vector2(MathHelper.TwoPi, MathHelper.TwoPi), false); _camera[2] = new StationaryCamera(new Vector3(1000, 150, 500), device.Viewport, new Vector2(MathHelper.PiOver2, -MathHelper.Pi / 10f)); _camera[0].initialise(); _camera[1].initialise(); _camera[2].initialise(); _currentCam = _camera[0]; _terrain.intialize(device); }
public override void LoadContent() { base.LoadContent(); _BackgroundMusic = SoundManager.AddSound(new CutlassSong("Content/Sounds/Music/TellerOfTheTales")); SoundManager.GetSound(_BackgroundMusic).PlayFadeIn(5000); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); _Player = new Player(this, _PlayerInitialPosition); _Camera = new Camera(this, ResolutionManager.VirtualWidth, ResolutionManager.VIRTUAL_HEIGHT, _CameraInitialPositionCenter); _Player.PlayerMoved += _Camera.UpdateCameraPosition; ObjectManager.AddObjects(_Scenery.ToArray()); ObjectManager.AddObjects(_Player, _Camera); // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. CutlassEngine.Game.ResetElapsedTime(); SoundId backgroundMusic = SoundManager.AddSound(new CutlassSong("Content/Sounds/Music/Constance")); SoundManager.GetSound(backgroundMusic).Play(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Console.Write("Loading music... "); _musicManager = MusicManager.GetInstance(); _musicManager.AddSong("mainMenuBgm", Content.Load <Song>("Audio/Music/mainmenu")); _musicManager.AddSong("gameBgm", Content.Load <Song>("Audio/Music/ambientbgm1_2")); _musicManager.AddSong("hackLoop", Content.Load <Song>("Audio/Music/hackloop1")); Console.Write("done\nLoading sounds... "); _soundManager = SoundManager.GetInstance(); _soundManager.AddSound("nodeClick", Content.Load <SoundEffect>("Audio/Sounds/click1")); _soundManager.AddSound("nodeHover", Content.Load <SoundEffect>("Audio/Sounds/hover1")); _soundManager.AddSound("traceWarn", Content.Load <SoundEffect>("Audio/Sounds/traceWarn")); Console.WriteLine("done"); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); mScream = contentManager.Load <SoundEffect>("Audio/Gibbons_singen"); mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); mTotalWindowSize = new Vector2(mGraphicsDevice.Viewport.Width, mGraphicsDevice.Viewport.Height); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; // Load background image mBackgroundImageStatistics = contentManager.Load <Texture2D>("scare"); IsVisible = true; // Play Scream SoundManager.AddSound(mScream); mMenuList = new List <UIv2.Menu>(); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); // Instantiate a new menu var menu = new UIv2.Menu(deviceManager.GraphicsDevice, 5, 5, 90, 90); // Create the Back Button var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Back", font, Color.White); backButton.AddTo(menu); backButton.AddListener(System.Windows.Forms.MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); mScream.Dispose(); IsVisible = false; }); mMenuList.Add(menu); mMainMenuScreen = new MainMenuScreen(); }
public static void Run() { // Settingss Settings.Load(); // Add the music var menuMusic = new Sound(new SoundBuffer("assets/music/menu.ogg")); menuMusic.Loop = true; menuMusic.Volume = Settings.Volume; SoundManager.AddSound("MenuSound", menuMusic); var gameMusic = new Sound(new SoundBuffer("assets/music/game.ogg")); gameMusic.Loop = true; gameMusic.Volume = Settings.Volume; SoundManager.AddSound("GameSound", gameMusic); Game = new Game("Tetris", new SFML.System.Vector2f(450, 600)); Game.Run(); }
IEnumerator prompt() { SoundManager.AddSound(PhoneSound); SoundManager.ChangeVolume(PhoneSound, 1.5f); yield return(null); for (float f = 0; Mathf.Clamp(f, 0, 1) != 1; f += (Time.deltaTime * 2)) { popup.alpha = Mathf.Clamp(f, 0, 1); popup.gameObject.GetComponent <RectTransform>().localPosition = new Vector3(0, Mathf.Lerp(popup.gameObject.GetComponent <RectTransform>().localPosition.y, -70, Mathf.Clamp(f, 0, 1)), 0); yield return(null); } yield return(new WaitForSeconds(5f)); for (float f = 1; Mathf.Clamp(f, 0, 1) != 0f; f -= (Time.deltaTime * 2)) { popup.alpha = Mathf.Clamp(f, 0, 1); popup.gameObject.GetComponent <RectTransform>().localPosition = new Vector3(0, Mathf.Lerp(popup.gameObject.GetComponent <RectTransform>().localPosition.y, -190, Mathf.Clamp(f, 0, 1)), 0); yield return(null); } popup.alpha = 0; }
public Level(ContentManager contentManager, SoundManager soundManager, GraphicsDevice device, bool editMode) : base() { mContentManager = contentManager; mSoundManager = soundManager; mDevice = device; mEditMode = editMode; var currentDirectoryPath = Directory.GetCurrentDirectory(); if (!currentDirectoryPath.EndsWith("Content") && !currentDirectoryPath.EndsWith("Content/") && !currentDirectoryPath.EndsWith("Content\\")) { Directory.SetCurrentDirectory("../../../../Content"); } mModelLoader = new ModelLoader(device); mQuadTree = new QuadTree <Actor>(new Rectangle(-128, -128, 256, 256), 4, 7); // Load silverback mSilverback = new Silverback(new Vector3(0.0f), new Vector2(0.0f), mModelLoader.LoadMesh("Mesh/gorilla_idle.fbx")); mSilverback.mQuadTree = mQuadTree; mHutMesh = mModelLoader.LoadMesh("Mesh/spawningcabin_scaled 0.015.fbx"); mHuts = new List <Hut>(); Hut.mAmount = 0; mGlobalSoundSourceBuffer = new AudioBuffer("Audio/ForestSoundMono.wav"); mGlobalSoundSource = new AudioSource(mGlobalSoundSourceBuffer); mGlobalSoundSource.Relative = true; mSoundManager.AddSound(mGlobalSoundSource); mInitialSilverbackLocation = new Vector3(0.0f); if (!mEditMode) { mSilverback.Actor.mAnimator.SetStandardAnimation("idle"); mModelLoader.LoadAnimation(mSilverback.Actor.mMesh, "Mesh/gorilla_walking.fbx"); mModelLoader.LoadAnimation(mSilverback.Actor.mMesh, "Mesh/gorilla_smash.fbx"); Add(mSilverback); mQuadTree.Insert(mSilverback.Actor, mSilverback.Actor.mBoundingRectangle.GetAxisAlignedRectangle(1)); // Load all the other meshes // Load Lumberjack mesh mLumberjackMesh = mModelLoader.LoadMesh("Mesh/lumberjack_idle.fbx"); mModelLoader.LoadAnimation(mLumberjackMesh, "Mesh/lumberjack_walk.fbx"); mModelLoader.LoadAnimation(mLumberjackMesh, "Mesh/lumberjack_hit.fbx"); mModelLoader.LoadAnimation(mLumberjackMesh, "Mesh/lumberjack_run.fbx"); mLumberjacks = new ActorBatch(mLumberjackMesh, true); mActorBatches.Add(mLumberjacks); // Load DoubleAxeKiller mesh mDoubleAxeKillerMesh = mModelLoader.LoadMesh("Mesh/lumberjack_distance_idle.fbx"); mModelLoader.LoadAnimation(mDoubleAxeKillerMesh, "Mesh/lumberjack_distance_walk.fbx"); mModelLoader.LoadAnimation(mDoubleAxeKillerMesh, "Mesh/lumberjack_distance_hit.fbx"); mModelLoader.LoadAnimation(mDoubleAxeKillerMesh, "Mesh/lumberjack_distance_run.fbx"); mDoubleAxeKillers = new ActorBatch(mDoubleAxeKillerMesh, true); mActorBatches.Add(mDoubleAxeKillers); // Load Baboon Mesh mBaboonMesh = mModelLoader.LoadMesh("Mesh/gibbon_idle.fbx"); mModelLoader.LoadAnimation(mBaboonMesh, "Mesh/gibbon_walk.fbx"); mModelLoader.LoadAnimation(mBaboonMesh, "Mesh/gibbon_singing.fbx"); mBaboonBatch = new ActorBatch(mBaboonMesh, true); mActorBatches.Add(mBaboonBatch); // Load Capuchin Mesh mCapuchinMesh = mModelLoader.LoadMesh("Mesh/kapuziner_idle.fbx"); mModelLoader.LoadAnimation(mCapuchinMesh, "Mesh/kapuziner_walk.fbx"); mModelLoader.LoadAnimation(mCapuchinMesh, "Mesh/kapuziner_heal.fbx"); mCapuchinBatch = new ActorBatch(mCapuchinMesh, true); mActorBatches.Add(mCapuchinBatch); // Load Chimpanezze Mesh mChimpanezzeMesh = mModelLoader.LoadMesh("Mesh/chimp_idle.fbx"); mModelLoader.LoadAnimation(mChimpanezzeMesh, "Mesh/chimp_walk.fbx"); mModelLoader.LoadAnimation(mChimpanezzeMesh, "Mesh/chimp_attack.fbx"); mChimpanezzeBatch = new ActorBatch(mChimpanezzeMesh, true); mActorBatches.Add(mChimpanezzeBatch); // Load Gibbon Mesh mGibbonMesh = mModelLoader.LoadMesh("Mesh/Gibbon_idle.fbx"); mModelLoader.LoadAnimation(mGibbonMesh, "Mesh/Gibbon_walk.fbx"); mModelLoader.LoadAnimation(mGibbonMesh, "Mesh/Gibbon_singing.fbx"); mGibbonBatch = new ActorBatch(mGibbonMesh, true); mActorBatches.Add(mGibbonBatch); // Load Orang Utan Mesh mOrangUtanMesh = mModelLoader.LoadMesh("Mesh/orangutan_idle.fbx"); mModelLoader.LoadAnimation(mOrangUtanMesh, "Mesh/orangutan_walk.fbx"); mModelLoader.LoadAnimation(mOrangUtanMesh, "Mesh/orangutan_throw.fbx"); mOrangutanBatch = new ActorBatch(mOrangUtanMesh, true); mActorBatches.Add(mOrangutanBatch); mAxeMesh = mModelLoader.LoadMesh("Mesh/axe.fbx"); } mPostProcessing.mBloom.Activated = Options.Bloom; mPostProcessing.mBloom.mPasses = Options.BloomPasses; mPostProcessing.mFxaa.Activated = Options.Fxaa; mSky.Light.mShadow.mActivated = Options.Shadows; mSky.Light.mShadow.mDistance = Options.ShadowDistance; mSky.Light.mShadow.mNumSamples = Options.ShadowSamples; mSky.Light.mShadow.mBias = Options.ShadowBias; Directory.SetCurrentDirectory(currentDirectoryPath); }
/// <summary> /// Update the state of the screen. /// </summary> /// <param name="gameTime">Current time of the game.</param> /// <param name="otherScreenHasFocus">true if other screen has the focus, false otherwise.</param> /// <param name="coveredByOtherScreen">true if other screen cover this screen, false otherwise.</param> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); _safeTime += gameTime.ElapsedGameTime.Milliseconds; if (_resources.Count != 0) { string resource = _resources[0]; string[] information = resource.Split('_'); if (information[1] == "Texture") { if (_create) { ThreadStart threadStarter = delegate { TextureManager.AddTexture(information[0], new GameTexture("Content/Textures/" + information[0])); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else { ThreadStart threadStarter = delegate { TextureManager.RemoveTexture(information[0]); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } _loadedResources.Add(resource); _resources.Remove(resource); } else if (information[1] == "Model") { if (_create) { ThreadStart threadStarter = delegate { ModelManager.AddModel(information[0], new GameModel("Content/Models/" + information[0])); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else { ThreadStart threadStarter = delegate { ModelManager.RemoveModel(information[0]); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } _loadedResources.Add(resource); _resources.Remove(resource); } else if (information[1] == "Sound") { if (_create) { ThreadStart threadStarter = delegate { SoundManager.AddSound(information[0], new GameSound("Content/Sounds/" + information[0])); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else { ThreadStart threadStarter = delegate { SoundManager.RemoveSound(information[0]); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } _loadedResources.Add(resource); _resources.Remove(resource); } else { if (_create) { foreach (string loadedResource in _loadedResources) { try { string[] loadedInformation = loadedResource.Split('_'); if (loadedInformation[1] == "Model" && ModelManager.GetModel(loadedInformation[0]).Model.Meshes == null) { throw new Exception(); } else if (loadedInformation[1] == "Texture" && TextureManager.GetTexture(loadedInformation[0]).BaseTexture.IsDisposed) { throw new Exception(); } else if (loadedInformation[1] == "Sound" && SoundManager.GetSound(loadedInformation[0]).GameSoundEffect.IsDisposed) { throw new Exception(); } } catch (Exception e) { return; } } ThreadStart threadStarter = delegate { LevelManager.AddLevel(resource, new Scene.SceneRenderer( FileHelper.readMapInformation(resource))); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else { ThreadStart threadStarter = delegate { LevelManager.RemoveLevel(resource); _numberOfLoadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } _loadedResources.Add(resource); _resources.Remove(resource); } } if (_numberOfLoadedResources >= _totalResources - 1) { EngineManager.Game.IsFixedTimeStep = false; if (_create) { ScreenManager.RemoveScreen("LoadingScreen"); ScreenManager.AddScreen("ContinueGame", new MainGameScreen( "ContinueGame", _mapName, _mapInformation, _savedGame)); } else if (_safeTime > totalSafeTime) { ScreenManager.RemoveScreen("LoadingScreen"); EngineManager.Loader.Unload(); ScreenManager.RemoveScreen("LoadingScreen"); ScreenManager.AddScreen("Background", new BackgroundScreen("Background")); ScreenManager.AddScreen("MainMenu", new MainMenuScreen("MainMenu")); } } }
/// <summary> /// Load and calculate all the necessary content of the game. /// </summary> public override void Load() { base.Load(); // Set the camera CameraManager.AddCamera(CameraManager.DefaultCamera, new TargetCamera(new Vector3(0, 0, 70), new Vector3(0, 0, 0))); CameraManager.SetActiveCamera(CameraManager.DefaultCamera); // Create the post processing elements renderCapture = new RenderCapture(); postProcessor = new GaussianBlur(10);//2f); // Load all needed textures TextureManager.AddTexture(backgroundTexture, new GameTexture("Content/Textures/MenuBackground", true)); TextureManager.AddTexture("DeadBackground", new GameTexture("Content/Textures/DeadBackground", true)); TextureManager.AddTexture("SeparationBar", new GameTexture("Content/Textures/SeparationBar", true)); TextureManager.AddTexture("SelectedMenuEntry", new GameTexture("Content/Textures/SelectedMenuEntry", true)); TextureManager.AddTexture("DummyTexture15T", new GameTexture("Content/Textures/DummyTexture15T", true)); TextureManager.AddTexture("DummyTexture", new GameTexture("Content/Textures/DummyTexture", true)); TextureManager.AddTexture("BarTexture", new GameTexture("Content/Textures/BarTexture", true)); TextureManager.AddTexture("DialogBackground", new GameTexture("Content/Textures/DialogBackground", true)); TextureManager.AddTexture("EasyDifficult", new GameTexture("Content/Textures/EasyDifficult", true)); TextureManager.AddTexture("NormalDifficult", new GameTexture("Content/Textures/NormalDifficult", true)); TextureManager.AddTexture("HardDifficult", new GameTexture("Content/Textures/HardDifficult", true)); TextureManager.AddTexture("LoadingBackground", new GameTexture("Content/Textures/LoadingBackground", true)); // Load all needed sounds SoundManager.AddSound("Menu", new GameSound("Content/Sounds/Menu", true)); SoundManager.GetSound("Menu").Volume = GameSettings.DefaultInstance.MusicVolume; SoundManager.GetSound("Menu").Play(true, true); SoundManager.AddSound("MenuSelect", new GameSound("Content/Sounds/MenuSelect", true)); SoundManager.GetSound("MenuSelect").Volume = GameSettings.DefaultInstance.SoundVolume; SoundManager.AddSound("MenuAccept", new GameSound("Content/Sounds/MenuAccept", true)); SoundManager.GetSound("MenuAccept").Volume = GameSettings.DefaultInstance.SoundVolume; // Load all needed models ModelManager.AddModel(spacecraftModel, new GameModel("Content/Models/Spacecraft", true)); ModelManager.AddModel("AnimatedMonster", new GameModel("Content/Models/AnimatedMonster", true)); _model = new DrawableModel((GameModel)ModelManager.GetModel(spacecraftModel), new Vector3(-10, 20, 0), new Vector3(-45, 120, 0), new Vector3(1.25f, 1.25f, 1.25f), 0); // Fix the animation elements _animationRing1 = new ObjectAnimation(Vector3.Zero, Vector3.Zero, _model.Rotation, _model.Rotation + new Vector3(0, MathHelper.TwoPi, 0), TimeSpan.FromSeconds(1f), true); _animationRing2 = new ObjectAnimation(Vector3.Zero, Vector3.Zero, _model.Rotation + new Vector3(0, MathHelper.Pi, 0), _model.Rotation + new Vector3(0, MathHelper.TwoPi + MathHelper.Pi, 0), TimeSpan.FromSeconds(1f), true); _individualTransformations.Add("polySurface26", Matrix.CreateScale(_animationRing1.Scale) * Matrix.CreateRotationX(_animationRing1.Rotation.X) * Matrix.CreateRotationY(_animationRing1.Rotation.Y) * Matrix.CreateRotationZ(_animationRing1.Rotation.Z) * Matrix.CreateTranslation(_animationRing1.Position)); _individualTransformations.Add("polySurface27", Matrix.CreateScale(_animationRing2.Scale) * Matrix.CreateRotationX(_animationRing2.Rotation.X) * Matrix.CreateRotationY(_animationRing2.Rotation.Y) * Matrix.CreateRotationZ(_animationRing2.Rotation.Z) * Matrix.CreateTranslation(_animationRing2.Position)); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); mMainMenuMusic = contentManager.Load <SoundEffect>("Audio/slowmo"); SoundManager.AddMusic(mMainMenuMusic); // We should remove this for a more stable framerate later deviceManager.SynchronizeWithVerticalRetrace = false; deviceManager.ApplyChanges(); mMenuList = new List <UIv2.Menu>(); IsVisible = true; mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Load font var font = contentManager.Load <SpriteFont>("Font"); var headerFont = contentManager.Load <SpriteFont>("Heading"); var buttonTexture = contentManager.Load <Texture2D>("button"); IsVisible = true; // Load background image mBackgroundImage = contentManager.Load <Texture2D>("Forest"); IsVisible = true; mOptionsScreen = new OptionsMenu(false); mStatisticsScreen = new StatisticsScreen(); mCreditsScreen = new CreditsScreen(); mEditorHudScreen = new EditorHudScreen(); mAchievementsScreen = new AchievementsScreen(); mScreamScreen = new ScreamScreen(); var menu = new UIv2.Menu(mGraphicsDevice, 0, 0, 100, 100); mMenuList.Add(menu); var texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); var heading = new UIv2.Components.Label(mGraphicsDevice, 10, 0, 80, 30, "Silverback", headerFont, Color.DarkSlateGray); heading.FontType = FontManager.FontType.Heading; heading.AddTo(menu); var newGameButton = new UIv2.Components.Button(mGraphicsDevice, 35, 24, 30, 7, texture2D, "New Game", font, Color.White); newGameButton.AddTo(menu); newGameButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); Statistic.CurrentSaveTime = 0; var loadingScreen = new LoadingScreen("..\\..\\..\\..\\Content\\tutorial.lvl"); ScreenManager.Add(loadingScreen); IsVisible = false; }); var loadGameButton = new UIv2.Components.Button(mGraphicsDevice, 35, 32, 30, 7, texture2D, "Load Game", font, Color.White); loadGameButton.AddTo(menu); // Add an event listener to the button loadGameButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); if (!File.Exists(PauseScreen.GetSavedGamesPath() + "\\Camera.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\CapuchinPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\ChimpPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\GibbonPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\HudScreen.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Huts.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Level.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\OrangPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Silverback.xml")) { return; } // Get the level file using (var fs = File.OpenRead(PauseScreen.GetSavedGamesPath() + "\\HudScreen.xml")) { var serializer = new XmlSerializer(typeof(HudScreen)); HudScreen hudScreen = null; try { hudScreen = (HudScreen)serializer.Deserialize(fs); } catch (Exception ex) { Console.WriteLine(ex.GetBaseException()); } if (hudScreen != null) { var loadingScreen = new LoadingScreen(hudScreen.mLevelPath); loadingScreen.LoadSaveGame(); ScreenManager.Add(loadingScreen); } IsVisible = false; } }); // Create Statistic button var statisticsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 40, 30, 7, texture2D, "Statistics", font, Color.White); statisticsButton.AddTo(menu); // Add an event listener to the button statisticsButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Add(mStatisticsScreen); IsVisible = false; }); // Create Achievements button var achievementsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 48, 30, 7, texture2D, "Achievements", font, Color.White); achievementsButton.AddTo(menu); // Add an event listener to the button achievementsButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Add(mAchievementsScreen); IsVisible = false; }); // Create Credits button var creditsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 56, 30, 7, texture2D, "Credits", font, Color.White); creditsButton.AddTo(menu); // Add an event listener to the button creditsButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); // ScreenManager.Add(mScreamScreen); ScreenManager.Add(mCreditsScreen); IsVisible = false; }); // Create Option button var optionsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 64, 30, 7, texture2D, "Options", font, Color.White); optionsButton.AddTo(menu); // Add an event listener to the button optionsButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Add(mOptionsScreen); IsVisible = false; }); var editorButton = new UIv2.Components.Button(mGraphicsDevice, 35, 72, 30, 7, texture2D, "Editor", font, Color.White); editorButton.AddTo(menu); editorButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Add(mEditorHudScreen); IsVisible = false; }); var exitButton = new UIv2.Components.Button(mGraphicsDevice, 35, 80, 30, 7, texture2D, "Exit", font, Color.White); exitButton.AddTo(menu); exitButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); }); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); mTotalWindowSize = new Vector2(mGraphicsDevice.Viewport.Width, mGraphicsDevice.Viewport.Height); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; // Load background image mBackgroundImageStatistics = contentManager.Load <Texture2D>("forest"); IsVisible = true; mMenuList = new List <UIv2.Menu>(); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); // Instantiate a new menu var menu = new UIv2.Menu(deviceManager.GraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(mGraphicsDevice, (int)mTotalWindowSize.X, (int)mTotalWindowSize.Y, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); var heading = new UIv2.Components.Label(mGraphicsDevice, 35, 5, 30, 15, "Statistics", subHeaderFont, Color.White); heading.FontType = FontManager.FontType.Subheading; heading.AddTo(menu); var time = TimeSpan.FromMilliseconds(Statistic.Time); // Gesamtspielzeit var timeString = "Total playing time: " + time.Days + " days " + time.Hours + " hours " + time.Minutes + " minutes " + time.Seconds + " seconds"; var totalPlayingTime = new UIv2.Components.Label(mGraphicsDevice, 30, 20, 40, 7, timeString, font, Color.White); totalPlayingTime.AddTo(menu); // Escaped Mit-Primaten beim Durchspielen var fledPrimatesString = "Total amount of primates fled: " + Statistic.EscapedApes; var fledPrimatesLabel = new UIv2.Components.Label(mGraphicsDevice, 30, 30, 40, 7, fledPrimatesString, font, Color.White); fledPrimatesLabel.AddTo(menu); // Escaped Holzfäller var lumberjacksFledString = "Total number of lumberjacks defeated: " + Statistic.EscapedLumberjacks; var lumberjacksFledLabel = new UIv2.Components.Label(mGraphicsDevice, 30, 40, 40, 7, lumberjacksFledString, font, Color.White); lumberjacksFledLabel.AddTo(menu); // Wie oft hat man gewonnen / verloren var lostWonString = "Games won: " + Statistic.Win + " " + "Games lost: " + Statistic.Lost; var lostWonLabel = new UIv2.Components.Label(mGraphicsDevice, 30, 50, 40, 7, lostWonString, font, Color.White); lostWonLabel.AddTo(menu); // Minimale Zeit zum Durchspielen time = TimeSpan.FromMilliseconds(Statistic.Time); // Gesamtspielzeit timeString = "Total playing time: " + time.Days + " days " + time.Hours + " hours " + time.Minutes + " minutes " + time.Seconds + " seconds"; var minTimeString = Statistic.MinimalTime == 0 ? "Shortest time to finish the whole game: Not finished" : "Shortest time to finish the whole game: " + timeString; var minTimeLabel = new UIv2.Components.Label(mGraphicsDevice, 30, 60, 40, 7, minTimeString, font, Color.White); minTimeLabel.AddTo(menu); // Create the Back Button var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Back", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; }); mMenuList.Add(menu); mMainMenuScreen = new MainMenuScreen(); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); Device = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Unlock the framerate. Later we want to remove this piece of code mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Load font var font = contentManager.Load <SpriteFont>("Font"); var headerFont = contentManager.Load <SpriteFont>("Heading"); IsVisible = true; // Load background image mBackgroundImage = contentManager.Load <Texture2D>("Forest"); mMenuList = new List <UIv2.Menu>(); var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); mMenuList.Add(menu); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White); // Congratulations! var congratz = new UIv2.Components.Label(mGraphicsDevice, 10, 0, 80, 30, "Congratulations!", headerFont, Color.DarkSlateGray); congratz.FontType = FontManager.FontType.Heading; congratz.AddTo(menu); // You've won var win = new UIv2.Components.Label(mGraphicsDevice, 10, 30, 80, 30, "You've won", headerFont, Color.DarkSlateGray); win.FontType = FontManager.FontType.Heading; win.AddTo(menu); var winString = "Nice work dude!"; var winLabel = new UIv2.Components.Label(mGraphicsDevice, 20, 60, 60, 10, winString, font, Color.White); winLabel.AddTo(menu); if (mHudScreen.mGameScreen.mLevel.mNextLevelFilename != "null") { var nextLevelButton = new UIv2.Components.Button(mGraphicsDevice, 40, 70, 20, 7, texture2D, "Next level", font, Color.White); nextLevelButton.AddTo(menu); nextLevelButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { var nextLevelFilename = mHudScreen.mGameScreen.mLevel.mNextLevelFilename; // Check if path is relative if (!Path.IsPathRooted(nextLevelFilename)) { var levelFilename = mHudScreen.mGameScreen.mLevel.mLevelFilename; var directoryPath = Path.GetDirectoryName(levelFilename); nextLevelFilename = directoryPath + "/" + nextLevelFilename; } SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; var loadingScreen = new LoadingScreen(nextLevelFilename); ScreenManager.Add(loadingScreen); }); } else { winLabel.Text += " You've finished the game."; if (Statistic.CurrentSaveTime < Statistic.MinimalTime || Statistic.MinimalTime == 0) { Statistic.MinimalTime = Statistic.CurrentSaveTime; Achievements.Gamemaster = true; if (Statistic.MinimalTime < 3600000) { Achievements.Speedrunner = true; } } } // Create Main Menu Button (Back Button) var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Main menu", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; }); }
/// <summary> /// Plays the sound. /// </summary> /// <param name="sound">The sound.</param> public static void PlaySound(SoundBuffer sound) { SoundManager.AddSound(sound); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); mGraphicsDevice = deviceManager.GraphicsDevice; mPauseScreen = new PauseScreen(this); mWinScreen = new WinScreen(this); mLoseScreen = new LoseScreen(this); mGameScreen = new GameScreen(mLevelPath); ScreenManager.Add(mGameScreen); mTotalCunter = mGameScreen.mLevel.mSpawnablePrimatesCount; mSpriteBatch = new SpriteBatch(mGraphicsDevice); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; // Instantiate a new menu mMenuList = new List <UIv2.Menu>(); mButtonTexture = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); var textureTransparent = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 10, 10, pixel => Color.Transparent); //Highlighted Button mHighlightedButtonTexture = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Orange); var menu = new UIv2.Menu(mGraphicsDevice, 0, 95, 100, 5); menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, windowWidth, 200, pixel => new Color(0.0f, 0.0f, 0.0f, 0.15f)), 0, 0, 100, 100); mMenuList.Add(menu); mCounterMenu = new UIv2.Menu(mGraphicsDevice, 40, 15, 20, 4); mCounterMenu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, windowWidth, 200, pixel => new Color(0.0f, 0.0f, 0.0f, 0.15f)), 0, 0, 100, 100); mCounterMenu.NonSolid(); mMenuList.Add(mCounterMenu); var counterLabel = new UIv2.Components.Label(mGraphicsDevice, 0, 0, 100, 100, "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount, font, Color.White); counterLabel.AddTo(mCounterMenu); var pauseButton = new UIv2.Components.Button(mGraphicsDevice, 90, 0, 7, 100, mButtonTexture, "Pause", font, Color.White); pauseButton.AddTo(menu); pauseButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Add(mPauseScreen); mGameScreen.mCameraHandler.Lock(); IsVisible = false; mWasVisible = false; mGameScreen.IsVisible = false; }); mHPLabel = new UIv2.Components.Label(mGraphicsDevice, 0, 0, 45, 100, "HP: ", font, Color.White); mHPLabel.AddTo(menu); mTimeLabel = new UIv2.Components.Label(mGraphicsDevice, 0, 0, 10, 100, "", font, Color.White); mTimeLabel.AddTo(menu); var levelLabel = new UIv2.Components.Label(mGraphicsDevice, 10, 0, 7, 100, "Level: Tutorial", font, Color.White); levelLabel.AddTo(menu); for (var i = 0; i < 0; i++) { var morang = new OrangUtan(mGameScreen.mLevel.mOrangUtanMesh, mGameScreen.mLevel.mTerrain, mGameScreen.mLevel.mSilverback, mGameScreen.mLevel, ref mRandom); //morang.mScene = mGameScreen.mLevel; mGameScreen.mLevel.Add(morang); } // Create selection button for Baboon mApe1Button = new UIv2.Components.Button(mGraphicsDevice, 30, 0, 7, 100, mButtonTexture, "Orang", font, Color.White); mApe1Button.AddTo(menu); mApe1Button.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { if (mGameScreen.mLevel.mOrangutanBatch.mActors.Count > 0) { UnHiglightSelectedActorBatch(); mActorBatch = mGameScreen.mLevel.mOrangutanBatch; mHighlitedButton = mApe1Button; HighlightSelectedActorBatch(); } } else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0) { mGameScreen.mLevel.mSpawnablePrimatesCount--; mOrangCounter++; counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount; var morang = new OrangUtan(mGameScreen.mLevel.mOrangUtanMesh, mGameScreen.mLevel.mTerrain, mGameScreen.mLevel.mSilverback, mGameScreen.mLevel, ref mRandom); //morang.mScene = mGameScreen.mLevel; mGameScreen.mLevel.Add(morang); LumberChoice.AddApe(2); } if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { mCounterMenu.mIsVisible = false; DisableUnusedApeSelectorButtons(); } }); // Create selection button for Capuchin mApe2Button = new UIv2.Components.Button(mGraphicsDevice, 41, 0, 7, 100, mButtonTexture, "Capuchin", font, Color.White); mApe2Button.AddTo(menu); mApe2Button.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { if (mGameScreen.mLevel.mCapuchinBatch.mActors.Count > 0) { UnHiglightSelectedActorBatch(); mActorBatch = mGameScreen.mLevel.mCapuchinBatch; mHighlitedButton = mApe2Button; HighlightSelectedActorBatch(); } } else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0) { mCapuchinCounter++; counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount; mGameScreen.mLevel.mSpawnablePrimatesCount--; var mcapuchin = new Capuchin(mGameScreen.mLevel.mCapuchinMesh, mGameScreen.mLevel.mTerrain, mGameScreen.mLevel.mSilverback, mGameScreen.mLevel, ref mRandom); mGameScreen.mLevel.Add(mcapuchin); LumberChoice.AddApe(3); } if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { mCounterMenu.mIsVisible = false; DisableUnusedApeSelectorButtons(); } }); // Create selection button for Chimpaneeze mApe3Button = new UIv2.Components.Button(mGraphicsDevice, 52, 0, 7, 100, mButtonTexture, "Chimp", font, Color.White); mApe3Button.AddTo(menu); mApe3Button.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { if (mGameScreen.mLevel.mChimpanezzeBatch.mActors.Count > 0) { UnHiglightSelectedActorBatch(); mActorBatch = mGameScreen.mLevel.mChimpanezzeBatch; mHighlitedButton = mApe3Button; HighlightSelectedActorBatch(); } } else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0) { mChimpCounter++; mGameScreen.mLevel.mSpawnablePrimatesCount--; counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount; var mchimpanezee = new Chimpanezee(mGameScreen.mLevel.mChimpanezzeMesh, mGameScreen.mLevel.mTerrain, mGameScreen.mLevel.mSilverback, mGameScreen.mLevel, ref mRandom); mGameScreen.mLevel.Add(mchimpanezee); LumberChoice.AddApe(1); } if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { mCounterMenu.mIsVisible = false; DisableUnusedApeSelectorButtons(); } } ); // Create selection button for Gibbon mApe4Button = new UIv2.Components.Button(mGraphicsDevice, 63, 0, 7, 100, mButtonTexture, "Gibbon", font, Color.White); mApe4Button.AddTo(menu); mApe4Button.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { if (mGameScreen.mLevel.mGibbonBatch.mActors.Count > 0) { UnHiglightSelectedActorBatch(); mActorBatch = mGameScreen.mLevel.mGibbonBatch; mHighlitedButton = mApe4Button; HighlightSelectedActorBatch(); } } else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0) { mGibbonCounter++; mGameScreen.mLevel.mSpawnablePrimatesCount--; counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount; var mgibbon = new Gibbon(mGameScreen.mLevel.mGibbonMesh, mGameScreen.mLevel.mTerrain, mGameScreen.mLevel.mSilverback, mGameScreen.mLevel, ref mRandom); mGameScreen.mLevel.Add(mgibbon); LumberChoice.AddApe(4); } if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0) { mCounterMenu.mIsVisible = false; DisableUnusedApeSelectorButtons(); } }); // Display the level text before the level starts if (mGameScreen.mLevel.mLevelStory != null) { mGameScreen.mCameraHandler.Lock(); var textMenu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90); textMenu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.15f)), 5, 5, 90, 90); var heading = new UIv2.Components.Label(mGraphicsDevice, 5, 5, 90, 15, mGameScreen.mLevel.mLevelTitle, subHeaderFont, Color.DarkSlateGray); heading.FontType = FontManager.FontType.Subheading; heading.AddTo(textMenu); var textLabel = new UIv2.Components.Label(mGraphicsDevice, 25, 28, 50, 35, mGameScreen.mLevel.mLevelStory, font, Color.White); textLabel.DisableAutobreak(); textLabel.AddTo(textMenu); mContinueLabel = new UIv2.Components.Label(mGraphicsDevice, 25, 80, 50, 10, "Press the left mouse button to continue", font, Color.White); mContinueLabel.AddTo(textMenu); var textButton = new UIv2.Components.Button(mGraphicsDevice, 0, 0, 100, 100, textureTransparent, "", font, Color.White); textButton.AddTo(textMenu); textButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { menu.mIsVisible = true; mCounterMenu.mIsVisible = true; textMenu.mIsVisible = false; mGameScreen.mCameraHandler.Unlock(); }); mMenuList.Add(textMenu); menu.mIsVisible = false; mCounterMenu.mIsVisible = false; } mMenuList.Add(menu); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); // Unlock the framerate. Later we want to remove this piece of code // deviceManager.SynchronizeWithVerticalRetrace = false; // deviceManager.ApplyChanges(); mMenuList = new List <UIv2.Menu>(); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; mGraphicsDevice = deviceManager.GraphicsDevice; mTotalWindowSize = new Vector2(mGraphicsDevice.Viewport.Width, mGraphicsDevice.Viewport.Height); mSpriteBatch = new SpriteBatch(mGraphicsDevice); // Load background image mBackgroundImageAchievements = contentManager.Load <Texture2D>("forest"); IsVisible = true; // Instantiate a new menu // var windowWidth = deviceManager.GraphicsDevice.Viewport.Width; // var windowHeight = deviceManager.GraphicsDevice.Viewport.Height; // mEditorScreen = new EditorScreen(); // ScreenManager.Add(mEditorScreen); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); Texture2D Checked = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.DarkOliveGreen); // Instantiate a new menu var menu = new UIv2.Menu(deviceManager.GraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(mGraphicsDevice, (int)mTotalWindowSize.X, (int)mTotalWindowSize.Y, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); var screenName = new UIv2.Components.Label(deviceManager.GraphicsDevice, 35, 5, 30, 15, "Achievements", subHeaderFont, Color.White); screenName.FontType = FontManager.FontType.Subheading; screenName.AddTo(menu); // “Gamemaster”: Beende das Spiel erfolgreich. var gamemasterString = "Gamemaster: You've played through the whole game. Nice work!"; var gamemasterButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 15, 25, 70, 7, texture2D, Checked, gamemasterString, font, Color.White, Achievements.Gamemaster); gamemasterButton.AddTo(menu); // “Lumberjack’s nightmare”: Vertreibe 42 Holzfäller. var lumberjackString = "Lumberjack's nightmare: You've made 42 lumberjacks run away. Awesome!"; var lumberjackLabel = new UIv2.Components.CheckedButton(mGraphicsDevice, 15, 35, 70, 7, texture2D, Checked, lumberjackString, font, Color.White, Achievements.LumberjacksNightmare); lumberjackLabel.AddTo(menu); // “Speed runner”: Beende das Spiel innerhalb von 60 Minuten. var speedyString = "Speed runner: You've finished the whole game within 1 hour. Speedy Gonzales huh?!"; var speedyLabel = new UIv2.Components.CheckedButton(mGraphicsDevice, 15, 45, 70, 7, texture2D, Checked, speedyString, font, Color.White, Achievements.Speedrunner); speedyLabel.AddTo(menu); // “Redundancy”: Erhalte ein Achievement. var redundancyString = "Redundancy: An achievement is officially yours. Hopefully you're happy with it!"; var redundancyLabel = new UIv2.Components.CheckedButton(mGraphicsDevice, 15, 55, 70, 7, texture2D, Checked, redundancyString, font, Color.White, Achievements.Redundancy); redundancyLabel.AddTo(menu); // “Tribute to the creators”: Credits angeschaut. var creditsString = "Tribute to the creators: You've had a look at the credits. Thanks man!"; var creditsLabel = new UIv2.Components.CheckedButton(mGraphicsDevice, 15, 65, 70, 7, texture2D, Checked, creditsString, font, Color.White, Achievements.TributeToTheCreators); creditsLabel.AddTo(menu); var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Back", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; }); mMenuList.Add(menu); mMainMenuScreen = new MainMenuScreen(); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); Device = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); mOptionsScreen = new OptionsMenu(true); // Unlock the framerate. Later we want to remove this piece of code mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; // Load background image mBackgroundImageOptions = contentManager.Load <Texture2D>("forest"); mMenuList = new List <UIv2.Menu>(); var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); mMenuList.Add(menu); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White); var heading = new UIv2.Components.Label(mGraphicsDevice, 35, 5, 30, 15, "Pause", subHeaderFont, Color.White); heading.FontType = FontManager.FontType.Subheading; heading.AddTo(menu); // Create new Resume Button var resumeButton = new UIv2.Components.Button(mGraphicsDevice, 40, 20, 20, 7, texture2D, "Resume", font, Color.White); resumeButton.AddTo(menu); resumeButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); mHudScreen.IsVisible = true; ScreenManager.Remove(this); IsVisible = false; }); // Create new Save Button var saveButton = new UIv2.Components.Button(mGraphicsDevice, 40, 30, 20, 7, texture2D, "Save Game", font, Color.White); saveButton.AddTo(menu); saveButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); var serializer = new XmlSerializer(typeof(Camera)); Console.WriteLine("########################################################"); Console.WriteLine("Saving Camera to " + GetSavedGamesPath() + "\\Camera.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Camera.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(stream, mHudScreen.mGameScreen.mCamera); stream.Close(); } serializer = new XmlSerializer(typeof(Level)); Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\Level.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Level.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(stream, mHudScreen.mGameScreen.mLevel); stream.Close(); } serializer = new XmlSerializer(typeof(HudScreen)); Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\HudScreen.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\HudScreen.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(stream, mHudScreen); stream.Close(); } serializer = new XmlSerializer(typeof(Silverback)); Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\Silverback.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Silverback.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(stream, mHudScreen.mGameScreen.mLevel.mSilverback); stream.Close(); } serializer = new XmlSerializer(typeof(List <Matrix>)); Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\CapuchinPositions.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\CapuchinPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { var toSerialize = new List <Matrix>(); mHudScreen.mGameScreen.mLevel.mCapuchinBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix)); serializer.Serialize(stream, toSerialize); stream.Close(); } Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\GibbonPositions.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\GibbonPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { var toSerialize = new List <Matrix>(); mHudScreen.mGameScreen.mLevel.mGibbonBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix)); serializer.Serialize(stream, toSerialize); stream.Close(); } Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\OrangPositions.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\OrangPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { var toSerialize = new List <Matrix>(); mHudScreen.mGameScreen.mLevel.mOrangutanBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix)); serializer.Serialize(stream, toSerialize); stream.Close(); } Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\ChimpPositions.xml"); Console.WriteLine("########################################################"); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\ChimpPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { var toSerialize = new List <Matrix>(); mHudScreen.mGameScreen.mLevel.mChimpanezzeBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix)); serializer.Serialize(stream, toSerialize); stream.Close(); } Console.WriteLine("########################################################"); Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\Huts.xml"); Console.WriteLine("########################################################"); serializer = new XmlSerializer(typeof(List <Hut>)); using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Huts.xml", FileMode.Create, FileAccess.Write, FileShare.None)) { var toSerialize = new List <Hut>(); var hutActorBatch = mHudScreen.mGameScreen.mLevel.mActorBatches.Find(ele => ele.mMesh == mHudScreen.mGameScreen.mLevel.mHutMesh); mHudScreen.mGameScreen.mLevel.mHuts.ForEach(hut => toSerialize.Add(hut)); serializer.Serialize(stream, toSerialize); stream.Close(); } }); // Error label | Savegame var errLabel = new UIv2.Components.Label(mGraphicsDevice, 10, 90, 80, 4, "Could not load the savegame", font, Color.White); errLabel.FontType = FontManager.FontType.Default; errLabel.SetVisibility(false); errLabel.AddTo(menu); // Create new Load Game Button var loadButton = new UIv2.Components.Button(mGraphicsDevice, 40, 40, 20, 7, texture2D, "Load Checkpoint", font, Color.White); loadButton.AddTo(menu); loadButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { if (!File.Exists(PauseScreen.GetSavedGamesPath() + "\\Camera.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\CapuchinPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\ChimpPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\GibbonPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\HudScreen.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Huts.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Level.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\OrangPositions.xml") || !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Silverback.xml")) { errLabel.SetVisibility(true); return; } errLabel.SetVisibility(false); ScreenManager.Remove(this); ScreenManager.Remove(mHudScreen.mGameScreen); ScreenManager.Remove(mHudScreen); var loadingScreen = new LoadingScreen(mHudScreen.mLevelPath); loadingScreen.LoadSaveGame(); ScreenManager.Add(loadingScreen); }); // Create new Options Button var optionsButton = new UIv2.Components.Button(mGraphicsDevice, 40, 50, 20, 7, texture2D, "Options", font, Color.White); optionsButton.AddTo(menu); optionsButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Add(mOptionsScreen); IsVisible = false; }); // Create new Back Button var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 60, 20, 7, texture2D, "Main Menu", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(mHudScreen); ScreenManager.Remove(this); IsVisible = false; }); }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); _safeTime += gameTime.ElapsedGameTime.Milliseconds; if (_state == false) { if (_removableResources.Count != 0) { string resource = _removableResources[0]; string[] information = resource.Split('_'); if (information[1] == "Texture") { ThreadStart threadStarter = delegate { TextureManager.RemoveTexture(information[0]); _releasedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else if (information[1] == "Model") { ThreadStart threadStarter = delegate { ModelManager.RemoveModel(information[0]); _releasedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else if (information[1] == "Sound") { ThreadStart threadStarter = delegate { SoundManager.RemoveSound(information[0]); _releasedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } _removableResources.Remove(resource); } else { _state = true; } } else { if (_loadableResources.Count != 0) { string resource = _loadableResources[0]; string[] information = resource.Split('_'); if (information[1] == "Texture") { ThreadStart threadStarter = delegate { TextureManager.AddTexture(information[0], new GameTexture("Content/Textures/" + information[0])); _loadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else if (information[1] == "Model") { ThreadStart threadStarter = delegate { ModelManager.AddModel(information[0], new GameModel("Content/Models/" + information[0])); _loadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } else if (information[1] == "Sound") { ThreadStart threadStarter = delegate { SoundManager.AddSound(information[0], new GameSound("Content/Sounds/" + information[0])); _loadedResources++; }; Thread addResourceThread = new Thread(threadStarter); addResourceThread.Start(); } _loadableResources.Remove(resource); } } if (_releasedResources >= _totalReleasablesResources - 1 && _loadedResources >= _totalLoadableResources - 1 && _safeTime > totalSafeTime) { ScreenManager.RemoveScreen("LoadScene"); ScreenManager.AddScreen("ContinueGame", new MainGameScreen(this.GameGraphicsDevice, "ContinueGame", _mapInformation)); } }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; Achievements.TributeToTheCreators = true; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); mTotalWindowSize = new Vector2(mGraphicsDevice.Viewport.Width, mGraphicsDevice.Viewport.Height); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; // Load backround Image mBackgroundImageCredits = contentManager.Load <Texture2D>("forest"); IsVisible = true; Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); mMenuList = new List <UIv2.Menu>(); // Instantiate a new menu var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(mGraphicsDevice, (int)mTotalWindowSize.X, (int)mTotalWindowSize.Y, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); mMenuList.Add(menu); var heading = new UIv2.Components.Label(mGraphicsDevice, 35, 5, 30, 15, "Credits", subHeaderFont, Color.White); heading.FontType = FontManager.FontType.Subheading; heading.AddTo(menu); var scrollListRowCount = 3; var rowHeight = 3; var rowSpace = 4; var labelWidth = 40; var labelX = 5; /* * var tt = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "The Team", font, Color.White); * tt.AddTo(menu); * * var jb = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Josephine Bergmeier", font, Color.White); * jb.AddTo(menu); * * var df = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Domenico Frei", font, Color.White); * df.AddTo(menu); * * var bf = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Benjamin Fuchs", font, Color.White); * bf.AddTo(menu); * * var sg = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Steven Gilgin", font, Color.White); * sg.AddTo(menu); * * var mk = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Mario Kantz", font, Color.White); * mk.AddTo(menu); * * var dl = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "David Leimroth", font, Color.White); * dl.AddTo(menu); * * var mr = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Maximilian Roth", font, Color.White); * mr.AddTo(menu); * * var st = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Simon Tippe", font, Color.White); * st.AddTo(menu); * * var sr = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Tutor: Samuel Roth", font, Color.White); * sr.AddTo(menu); * * var noMonkeys = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "No monkeys were harmed during the creation of the game...", font, Color.White); * noMonkeys.AddTo(menu); * * var wellSome = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "well, some students suffered but that's probably okay. :-)", font, Color.White); * wellSome.AddTo(menu); * * var nowGo = new UIv2.Components.Label(mGraphicsDevice, labelX, scrollListRowCount++ * rowSpace, labelWidth, rowHeight, "Now go out and hug a tree!", font, Color.White); * nowGo.AddTo(menu); */ // Credits: Team + Tutor var teamString = "The Team:\nJosephine Bergmeier\nDomenico Frei\nBenjamin Fuchs\nSteven Gilgin\nMario Kantz" + "\nDavid Leimroth\nMaximilian Roth\nSimon Tippe\nTutor: Samuel Roth\n\n" + "No monkeys were harmed during the creation of the game...\n" + "well, some students suffered but that's probably okay.\n\n" + "Now go out and hug a tree!"; var teamLabel = new UIv2.Components.Label(mGraphicsDevice, 35, 40, 30, 15, teamString, font, Color.White); teamLabel.DisableAutobreak(); teamLabel.AddTo(menu); // Create the Back Button var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Back", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; }); }
public override void Check(AbilityHitDetector.ChallengeStates state, GameObject player) { if (state != AbilityHitDetector.ChallengeStates.NONE) { if (!PS.isPlaying) { PS.Play(); SoundManager.AddSound(yawn); SoundManager.ChangeVolume(yawn, 0.1f); } if (Vector3.Distance(player.transform.position, otherStudent.transform.position) <= 6) { close = true; } else { close = false; } if (fill >= 1) { Destroy(Hat.gameObject); close = false; complete = true; alert = false; } else if (fill <= 0) { Destroy(Hat.gameObject); close = false; complete = true; alert = true; } if (fill >= 0.75f && !se) { se = true; scan(); } if (!complete) { if (close) { zeroOne += Time.deltaTime * 2; } else { zeroOne -= Time.deltaTime * 2; } zeroOne = Mathf.Clamp(zeroOne, 0, 1); } else { zeroOne -= Time.deltaTime * 2; } pb.alpha = Mathf.Lerp(0, 1, zeroOne); pb.gameObject.GetComponent <RectTransform>().localPosition = new Vector3(0, Mathf.Lerp(-50, 20, zeroOne), 0f); if (close && !complete) { if (!pup) { StartCoroutine(pop()); } if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.Q)) { fill += 0.01f; } else { fill -= 0.0005f; } over.fillAmount = fill; } } if (alert) { PS.Stop(); setState(cStates.ALERT); } else if (complete) { StartCoroutine(ScriptedEvent()); setState(cStates.COMPLETED); } if ((alert || complete) && pb.alpha == 0 && pb.gameObject.GetComponent <RectTransform>().localPosition == new Vector3(0, -50, 0f)) { Finalized = true; } }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); Device = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Unlock the framerate. Later we want to remove this piece of code mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Load font var font = contentManager.Load <SpriteFont>("Font"); var headerFont = contentManager.Load <SpriteFont>("Heading"); IsVisible = true; // Load background image mBackgroundImage = contentManager.Load <Texture2D>("Forest"); mMenuList = new List <UIv2.Menu>(); var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); mMenuList.Add(menu); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White); // GAME OVER Text var heading = new UIv2.Components.Label(mGraphicsDevice, 10, 20, 80, 30, "GAME OVER", headerFont, Color.DarkSlateGray); heading.FontType = FontManager.FontType.Heading; heading.AddTo(menu); var loseString = "The lumberjacks won... Now go bury yourself!"; var loseLabel = new UIv2.Components.Label(mGraphicsDevice, 20, 60, 60, 10, loseString, font, Color.White); loseLabel.AddTo(menu); var repeatButton = new UIv2.Components.Button(mGraphicsDevice, 40, 70, 20, 7, texture2D, "Try again", font, Color.White); repeatButton.AddTo(menu); repeatButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { var levelString = mHudScreen.mGameScreen.mLevel.mLevelFilename; SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; var loadingScreen = new LoadingScreen(levelString); ScreenManager.Add(loadingScreen); }); // Create Main Menu Button (Back Button) var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Main menu", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; }); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { mScreenWidth = windowWidth; mScreenHeight = windowHeight; //Load SoundEffects mClickSound = contentManager.Load <SoundEffect>("Audio/click2"); // Unlock the framerate. Later we want to remove this piece of code mGraphicsDevice = deviceManager.GraphicsDevice; mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice); // Load font var font = contentManager.Load <SpriteFont>("Font"); var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont"); IsVisible = true; // Load backround Image mBackgroundImageOptions = contentManager.Load <Texture2D>("forest"); mMenuList = new List <UIv2.Menu>(); var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90); menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90); mMenuList.Add(menu); Texture2D Checked = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.DarkOliveGreen); Texture2D texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black); Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White); var heading = new Label(mGraphicsDevice, 35, 5, 30, 15, "Options", subHeaderFont, Color.White); heading.FontType = FontManager.FontType.Subheading; heading.AddTo(menu); var resolutionLabel = new Label(mGraphicsDevice, 10, 20, 30, 3, "Resolution", font, Color.White); resolutionLabel.AddTo(menu); var resolutionValueBox = new Label(mGraphicsDevice, 60, 20, 20, 3, "", font, Color.White); resolutionValueBox.AddTo(menu); var resolutionSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 20, 20, 3, texture2D, texture2DSliderPoint, 25, 200, Options.Resolution); // We want to allow the user to set the resolution to 25%. // Lets assume the user has a 4K monitor then we would allow // a resolution range of [1024x540-8192x4320]. The higher resolution // is for PCs which have a lot of hardware power and will be used for super sampling // which gives us really clean edges (no FXAA needed anymore) // You can manually set the slider value // The ui will be updated accordingly // Add one or more callbacks as arguments // The function(s) will be called, after the value changed resolutionSlider.AddOnChangeListeners((val) => { var value = (int)Math.Round(val); var width = (int)(mScreenWidth * (value / 100.0f)); var height = (int)(mScreenHeight * (value / 100.0f)); resolutionValueBox.Text = width + "x" + height + " pixel"; ScreenManager.ChangeRenderingResolution(width, height); Options.Resolution = value; }); var musicLabel = new Label(mGraphicsDevice, 10, 28, 30, 3, "Music Volume", font, Color.White); musicLabel.AddTo(menu); var musicValueBox = new Label(mGraphicsDevice, 60, 28, 20, 3, "", font, Color.White); musicValueBox.AddTo(menu); var musicSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 28, 20, 3, texture2D, texture2DSliderPoint, 0, 100, Options.MusicVolume); musicSlider.AddOnChangeListeners((val) => { var value = (int)Math.Round(val); Options.MusicVolume = value; musicValueBox.Text = value + "%"; //Soundmanager has to be set //SoundManager.ChangeVolume("Music", value / 100.0f); }); var effectLabel = new Label(mGraphicsDevice, 10, 36, 30, 3, "Sound Effects Volume", font, Color.White); effectLabel.AddTo(menu); var effectValueBox = new Label(mGraphicsDevice, 60, 36, 20, 3, "", font, Color.White); effectValueBox.AddTo(menu); var effectSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 36, 20, 3, texture2D, texture2DSliderPoint, 0, 100, Options.SoundEffectVolume); effectSlider.AddOnChangeListeners((val) => { var value = (int)Math.Round(val); Options.SoundEffectVolume = value; effectValueBox.Text = value + "%"; }); /* * // TODO adding function of brightness * var brightnessLabel = new Label(mGraphicsDevice, 10, 44, 30, 3, "Brightness", font, Color.White); * brightnessLabel.AddTo(menu); * var brightnessValueBox = new Label(mGraphicsDevice, 60, 44, 20, 3, "", font, Color.White); * brightnessValueBox.AddTo(menu); * * var brightnessSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 44, 20, 3, texture2D, texture2DSliderPoint, 0, 1, Options.Brightness); * * brightnessSlider.AddOnChangeListeners((val) => { * var value = (int)Math.Round(val * 100); // here I'm unsure * Options.Brightness = val; * brightnessValueBox.Text = value + "%"; * }); */ var fxaaLabel = new Label(mGraphicsDevice, 10, 44, 30, 3, "Antialiasing", font, Color.White); fxaaLabel.AddTo(menu); var fxaaButtonOn = new UIv2.Components.CheckedButton(mGraphicsDevice, 40, 44, 5, 5, texture2D, Checked, "On", font, Color.White, Options.Fxaa); fxaaButtonOn.AddTo(menu); var fxaaButtonOff = new UIv2.Components.CheckedButton(mGraphicsDevice, 46, 44, 5, 5, texture2D, Checked, "Off", font, Color.White, !Options.Fxaa); fxaaButtonOff.AddTo(menu); if (!mPauseScreen) { fxaaButtonOn.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); fxaaButtonOn.Check(); fxaaButtonOff.Uncheck(); Options.Fxaa = true; }); fxaaButtonOff.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); fxaaButtonOff.Check(); fxaaButtonOn.Uncheck(); Options.Fxaa = false; }); } var graphicsLabel = new Label(mGraphicsDevice, 10, 52, 30, 3, "Graphics Quality", font, Color.White); graphicsLabel.AddTo(menu); var graphicsVeryLowButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 40, 52, 8, 5, texture2D, Checked, "Very low", font, Color.White, Options.GraphicsQuality == 0); graphicsVeryLowButton.AddTo(menu); var graphicsLowButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 49, 52, 8, 5, texture2D, Checked, "Low", font, Color.White, Options.GraphicsQuality == 1); graphicsLowButton.AddTo(menu); var graphicsMediumButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 58, 52, 8, 5, texture2D, Checked, "Medium", font, Color.White, Options.GraphicsQuality == 2); graphicsMediumButton.AddTo(menu); var graphicsHighButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 67, 52, 8, 5, texture2D, Checked, "High", font, Color.White, Options.GraphicsQuality == 3); graphicsHighButton.AddTo(menu); var graphicsVeryHighButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 76, 52, 8, 5, texture2D, Checked, "Very high", font, Color.White, Options.GraphicsQuality == 4); graphicsVeryHighButton.AddTo(menu); // We just want to use the handlers if this screen isn't initialized by the PauseScreen if (!mPauseScreen) { graphicsVeryLowButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); graphicsVeryLowButton.Check(); graphicsLowButton.Uncheck(); graphicsMediumButton.Uncheck(); graphicsHighButton.Uncheck(); graphicsVeryHighButton.Uncheck(); Options.GraphicsQuality = 0; }); graphicsLowButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); graphicsVeryLowButton.Uncheck(); graphicsLowButton.Check(); graphicsMediumButton.Uncheck(); graphicsHighButton.Uncheck(); graphicsVeryHighButton.Uncheck(); Options.GraphicsQuality = 1; }); graphicsMediumButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); graphicsVeryLowButton.Uncheck(); graphicsLowButton.Uncheck(); graphicsMediumButton.Check(); graphicsHighButton.Uncheck(); graphicsVeryHighButton.Uncheck(); Options.GraphicsQuality = 2; }); graphicsHighButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); graphicsVeryLowButton.Uncheck(); graphicsLowButton.Uncheck(); graphicsMediumButton.Uncheck(); graphicsHighButton.Check(); graphicsVeryHighButton.Uncheck(); Options.GraphicsQuality = 3; }); graphicsVeryHighButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); graphicsVeryLowButton.Uncheck(); graphicsLowButton.Uncheck(); graphicsMediumButton.Uncheck(); graphicsHighButton.Uncheck(); graphicsVeryHighButton.Check(); Options.GraphicsQuality = 4; }); } else { var graphicsInformationLabel = new Label(mGraphicsDevice, 20, 65, 60, 10, "Graphics quality and Antialiasing can only be changed from the main menu", font, Color.Orange); graphicsInformationLabel.AddTo(menu); } var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Back", font, Color.White); backButton.AddTo(menu); backButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { SoundManager.AddSound(mClickSound); ScreenManager.Remove(this); IsVisible = false; }); var techDemoButton = new UIv2.Components.Button(mGraphicsDevice, 70, 80, 20, 7, texture2D, "Techdemo", font, Color.White); techDemoButton.AddTo(menu); techDemoButton.AddListener(MouseButtons.Left, InputState.Pressed, () => { var techDemoScreen = new TechDemoScreen(); ScreenManager.Add(techDemoScreen); IsVisible = false; }); }