public CreditsScreen(bool end_game) { credits_time_passed = 0.0f; BackGroundAudio.playSong("Menu", false); this.end_game = end_game; }
public override ScreenStateType nextLevelState() { BackGroundAudio.stopAllSongs(); if (end_game) { return(ScreenStateType.HighScoresStateComplete); } else { return(ScreenStateType.OptionsMenu); } }
public override void render(SpriteBatch sb) { switch (state) { case LoadingState.LevelRunning: BackGroundAudio.changeVolume(1.0f); renderGameStuff(sb); break; case LoadingState.LevelPaused: BackGroundAudio.changeVolume(0.4f); renderGameStuff(sb); renderPauseOverlay(sb); break; case LoadingState.LevelLoading: renderLoadScreen(sb); break; default: break; } }
private void loadContent2() { #if XBOX Thread.CurrentThread.SetProcessorAffinity(3); #endif backGroundPic = Content.Load <Texture2D>("titleScreenPic"); frostTreeLogo = Content.Load <Texture2D>("FrostTreeLogo"); testArrow = Content.Load <Texture2D>("gfx/testArrow"); laserPic = Content.Load <Texture2D>("gfx/laser"); healthBar = Content.Load <Texture2D>("bg"); healthColor = Content.Load <Texture2D>("healthTexture"); energyColor = Content.Load <Texture2D>("ammoTexture"); energyOverlay = Content.Load <Texture2D>("overlay"); popUpBackground = Content.Load <Texture2D>("popUpBackground"); greyBar = Content.Load <Texture2D>("grayTexture"); creditImage = Content.Load <Texture2D>("EndCredits"); heartPic = Content.Load <Texture2D>("heartSheet"); guardIcon = Content.Load <Texture2D>("guard"); prisonerIcon = Content.Load <Texture2D>("prisoner"); p2Icon = Content.Load <Texture2D>("P2Icon"); TextureLib ts = new TextureLib(GraphicsDevice); TextureLib.loadFromManifest(); aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; bloomFilter = Content.Load <Effect>("BloomShader"); BackGroundAudio music = new BackGroundAudio(Content); music.addSong("Menu"); music.addSong("RPG Game"); AudioLib lb = new AudioLib(); tenbyFive8 = Content.Load <SpriteFont>("tenbyFive/tenbyFive8"); tenbyFive10 = Content.Load <SpriteFont>("tenbyFive/tenbyFive10"); tenbyFive14 = Content.Load <SpriteFont>("tenbyFive/tenbyFive14"); tenbyFive24 = Content.Load <SpriteFont>("tenbyFive/tenbyFive24"); tenbyFive72 = Content.Load <SpriteFont>("tenbyFive/tenbyFive72"); font = tenbyFive14; testComputerFont = tenbyFive24; levelExitVideo = Content.Load <Video>("fmv/elevatorExit"); levelEnterVideo = Content.Load <Video>("fmv/levelStart"); titleScreenVideo = Content.Load <Video>("fmv/menu"); introCutScene = Content.Load <Video>("fmv/intro"); introCutSceneCoop = Content.Load <Video>("fmv/intro COOP"); levelEnterVideoCoop = Content.Load <Video>("fmv/levelStartCOOP"); levelExitVideoCoop = Content.Load <Video>("fmv/elevatorExitCOOP"); guardEndCutScene = Content.Load <Video>("fmv/endGuardSingle"); alienEndCutScene = Content.Load <Video>("fmv/endAlienSingle"); prisonerEndCutScene = Content.Load <Video>("fmv/endPrisonerSingle"); guardEndCutSceneCoop = Content.Load <Video>("fmv/endGuardCoop"); alienEndCutSceneCoop = Content.Load <Video>("fmv/endAlienCoop"); prisonerEndCutSceneCoop = Content.Load <Video>("fmv/endPrisonerCoop"); videoPlayer = new VideoPlayer(); ChunkLib cs = new ChunkLib(); AnimationLib.loadFrameFromManifest(); GlobalGameConstants.WeaponDictionary.InitalizePriceData(); GameCampaign.InitalizeCampaignData(); GameCampaign.ResetPlayerValues("INIT", 0); // lol so many game screens currentGameScreen = new TitleScreen(TitleScreen.titleScreens.logoScreen); //currentGameScreen = new CutsceneVideoState(testVideo, ScreenState.ScreenStateType.LevelReviewState); //currentGameScreen = new CampaignLobbyState(); //currentGameScreen = new HighScoresState(true); // DANIEL UNCOMMMENT THIS LINE BEFORE YOU MERGE WITH MASTER preloadedAssets = true; }
private void gameLogicUpdate(Microsoft.Xna.Framework.GameTime currentTime) { if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton) && !player1Dead) { state = LoadingState.LevelPaused; pauseDialogMinimumTime = 0; pauseMenuItem = 0; AudioLib.playSoundEffect("monitorOpening"); } if (GameCampaign.Player_Ammunition < 0) { GameCampaign.Player_Ammunition = 0; } if (GameCampaign.Player2_Ammunition < 0) { GameCampaign.Player2_Ammunition = 0; } if (GameCampaign.Player_Ammunition > 100) { GameCampaign.Player_Ammunition = 100; } if (GameCampaign.Player2_Ammunition > 100) { GameCampaign.Player2_Ammunition = 100; } if (messageQueueState == PushMessageQueueState.Wait) { if (pushMessageQueue.Count > 0) { messageQueueState = PushMessageQueueState.FadeIn; queueTimer = 0; } } else if (messageQueueState == PushMessageQueueState.ShowMessage) { queueTimer += currentTime.ElapsedGameTime.Milliseconds; if (queueTimer > 1000f + (25 * pushMessageQueue.Peek().Length)) { messageQueueState = PushMessageQueueState.FadeOut; queueTimer = 0; } } else if (messageQueueState == PushMessageQueueState.FadeIn) { queueTimer += currentTime.ElapsedGameTime.Milliseconds; if (queueTimer > 200f) { messageQueueState = PushMessageQueueState.ShowMessage; queueTimer = 0; } } else if (messageQueueState == PushMessageQueueState.FadeOut) { queueTimer += currentTime.ElapsedGameTime.Milliseconds; if (queueTimer > 200f) { messageQueueState = PushMessageQueueState.Wait; queueTimer = 0; pushMessageQueue.Dequeue(); } } for (int i = 0; i < entityList.Count; i++) { if (Vector2.Distance(cameraFocus.CenterPoint, entityList[i].CenterPoint) < 800 || entityList[i] is Player) { entityList[i].update(currentTime); } } elapsedLevelTime += currentTime.ElapsedGameTime.Milliseconds; particleSet.update(currentTime); #if WINDOWS entityList.RemoveAll(en => en.Remove_From_List == true); #elif XBOX XboxTools.RemoveAll(entityList, XboxTools.IsEntityToBeRemoved); XboxTools.RemoveAll(acidSpitters, XboxTools.IsEntityToBeRemoved); #endif if (cameraFocus != null) { int pointX = (int)cameraFocus.CenterPoint.X; int pointY = (int)cameraFocus.CenterPoint.Y; camera = Matrix.CreateTranslation(new Vector3((pointX * -1) + (GlobalGameConstants.GameResolutionWidth / 2), (pointY * -1) + (GlobalGameConstants.GameResolutionHeight / 2), 0.0f)); //camera = Matrix.CreateScale(0.1f); } gui.update(currentTime); if (player1Dead) { fadeOutTime += currentTime.ElapsedGameTime.Milliseconds; gui.BlackFadeOverlay = fadeOutTime / fadeOutDuration; if (fadeOutTime >= fadeOutDuration) { BackGroundAudio.stopAllSongs(); isComplete = true; } } if (endFlagReached) { BackGroundAudio.stopAllSongs(); isComplete = true; } #if DEBUG if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.SwitchItem2) != InputDevice2.PlayerPad.NoPad) { showStats = true; } else { showStats = false; } #endif }
private void loadLevel() { for (int i = 0; i < GameCampaign.CampaignIntroductionValues[GameCampaign.PlayerLevelProgress].Length; i++) { GameCampaign.AvailableEntityTypes.Add(GameCampaign.CampaignIntroductionValues[GameCampaign.PlayerLevelProgress][i]); } nodeMap = generateFourDungeons(); //nodeMap = DungeonGenerator.generateEntityZoo(); map = new TileMap(this, nodeMap, GlobalGameConstants.TileSize); string tileSetName = "deathStar"; if (GameCampaign.PlayerFloorHeight == 0) { tileSetName = "hightech"; } if (GameCampaign.PlayerFloorHeight == 1) { tileSetName = "factory"; } if (GameCampaign.PlayerFloorHeight == 2) { tileSetName = "prisoncell"; } map.TileSkin[0] = TextureLib.getLoadedTexture(tileSetName + "/0.png"); map.TileSkin[1] = TextureLib.getLoadedTexture(tileSetName + "/1.png"); map.TileSkin[2] = TextureLib.getLoadedTexture(tileSetName + "/2.png"); map.TileSkin[3] = TextureLib.getLoadedTexture(tileSetName + "/3.png"); map.ElevatorRoomSkin = TextureLib.getLoadedTexture("elevator/0.png"); Thread.Sleep(250); endFlagReached = false; gui = new InGameGUI(this); keyModule = new LevelKeyModule(); particleSet = new ParticleSet(); Thread.Sleep(250); entityList = new List <Entity>(); acidSpitters = new List <MutantAcidSpitter>(); coinPool = new Coin[coinPoolSize]; freeCoinIndex = 0; for (int i = 0; i < coinPoolSize; i++) { coinPool[i] = new Coin(this, new Vector2(-100, -100)); entityList.Add(coinPool[i]); } Thread.Sleep(250); populateRooms(nodeMap, currentSeed); Thread.Sleep(250); for (int i = 0; i < entityList.Count; i++) { if (entityList[i] is Player && ((Player)entityList[i]).Index == InputDevice2.PPG_Player.Player_1) { cameraFocus = entityList[i]; } } fadeOutTime = 0.0f; elapsedLevelTime = 0.0f; elapsedCoinAmount = 0; player1Dead = false; end_flag_placed = false; BackGroundAudio.playSong("RPG Game", true); BackGroundAudio.changeVolume(1.0f); state = LoadingState.LevelRunning; }
public override void update(GameTime currentTime) { double delta = currentTime.ElapsedGameTime.Milliseconds; /* * if (Keyboard.GetState().IsKeyDown(Keys.Space)) * { * parentWorld.Particles.pushGib(CenterPoint); * } */ if (index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Health <= 0.0f : GameCampaign.Player2_Health <= 0.0f) { if (!parentWorld.Player1Dead) { BackGroundAudio.stopAllSongs(); AudioLib.playSoundEffect("missionFailed"); death = true; parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); animation_time = 0; switch (Game1.rand.Next() % 3) { case 0: current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die"); break; case 1: current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die2"); break; default: current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die3"); break; } } animation_time += currentTime.ElapsedGameTime.Milliseconds / 1000f; current_skeleton.Animation.Apply(current_skeleton.Skeleton, animation_time, false); death = true; parentWorld.Player1Dead = true; velocity = Vector2.Zero; return; } //update the world map if you've visited a new room int currentNodeX = (int)((CenterPoint.X / GlobalGameConstants.TileSize.X) / GlobalGameConstants.TilesPerRoomWide); int currentNodeY = (int)((CenterPoint.Y / GlobalGameConstants.TileSize.Y) / GlobalGameConstants.TilesPerRoomHigh); if (currentNodeX >= 0 && currentNodeX < parentWorld.NodeMap.GetLength(0) && currentNodeY >= 0 && currentNodeY < parentWorld.NodeMap.GetLength(1)) { parentWorld.NodeMap[currentNodeX, currentNodeY].visited = true; } //knocked back if (disable_movement == true) { disable_movement_time += currentTime.ElapsedGameTime.Milliseconds; if (disable_movement_time > 300) { velocity = Vector2.Zero; disable_movement = false; disable_movement_time = 0; } if (Player_Right_Item != null) { Player_Right_Item.daemonupdate(this, currentTime, parentWorld); } if (Player_Left_Item != null) { Player_Left_Item.daemonupdate(this, currentTime, parentWorld); } } else { if (state == playerState.Item1) { if (Player_Right_Item == null) { state = playerState.Moving; } else { Player_Right_Item.update(this, currentTime, parentWorld); } if (Player_Left_Item != null) { Player_Left_Item.daemonupdate(this, currentTime, parentWorld); } } else if (state == playerState.Item2) { if (Player_Left_Item == null) { state = playerState.Moving; } else { Player_Left_Item.update(this, currentTime, parentWorld); } if (Player_Right_Item != null) { Player_Right_Item.daemonupdate(this, currentTime, parentWorld); } } else if (state == playerState.Moving) { loopAnimation = true; if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UseItem1)) { state = playerState.Item1; } if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UseItem2)) { state = playerState.Item2; } if (disable_movement == false) { if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.RightDirection)) { velocity.X = playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Right; } else if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.LeftDirection)) { velocity.X = -playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Left; } else { velocity.X = 0.0f; } if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UpDirection)) { velocity.Y = -playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Up; } else if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.DownDirection)) { velocity.Y = playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Down; } else { velocity.Y = 0.0f; } GlobalGameConstants.Direction analogDirection = InputDevice2.PlayerAnalogStickDirection(index); direction_facing = (analogDirection != GlobalGameConstants.Direction.NoDirection) ? analogDirection : direction_facing; switch (direction_facing) { case GlobalGameConstants.Direction.Down: current_skeleton = walk_down; current_skeleton.Skeleton.FlipX = false; break; case GlobalGameConstants.Direction.Up: current_skeleton = walk_up; current_skeleton.Skeleton.FlipX = false; break; case GlobalGameConstants.Direction.Left: current_skeleton = walk_left; current_skeleton.Skeleton.FlipX = true; break; case GlobalGameConstants.Direction.Right: current_skeleton = walk_right; current_skeleton.Skeleton.FlipX = false; break; } //if player stands still then animation returns to idle if (velocity.X == 0.0f && velocity.Y == 0.0f) { current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("idle"); } else { current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("run"); } } bool itemTouched = false; //Check to see if player has encountered a pickup item for (int i = 0; i < parentWorld.EntityList.Count; i++) { if (parentWorld.EntityList[i] == this) { continue; } if (parentWorld.EntityList[i] is Pickup) { if (hitTest(parentWorld.EntityList[i])) { itemTouched = true; if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem1) && !item1_switch_button_down) { item1_switch_button_down = true; } else if (!InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem1) && item1_switch_button_down) { item1_switch_button_down = false; Player_Right_Item = ((Pickup)parentWorld.EntityList[i]).assignItem(Player_Right_Item, currentTime); if (index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Right_Item = Player_Right_Item.ItemType(); } else if (index == InputDevice2.PPG_Player.Player_2) { GameCampaign.Player2_Item_1 = Player_Right_Item.ItemType(); } setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left); setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right); } if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem2) && !item2_switch_button_down) { item2_switch_button_down = true; } else if (!InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem2) && item2_switch_button_down) { item2_switch_button_down = false; Player_Left_Item = ((Pickup)parentWorld.EntityList[i]).assignItem(Player_Left_Item, currentTime); if (index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Left_Item = Player_Left_Item.ItemType(); } else if (index == InputDevice2.PPG_Player.Player_2) { GameCampaign.Player2_Item_2 = Player_Left_Item.ItemType(); } setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left); setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right); } } } } if (!itemTouched && (item1_switch_button_down || item2_switch_button_down)) { item1_switch_button_down = false; item2_switch_button_down = false; } if (Player_Right_Item != null) { Player_Right_Item.daemonupdate(this, currentTime, parentWorld); } if (Player_Left_Item != null) { Player_Left_Item.daemonupdate(this, currentTime, parentWorld); } } } Vector2 pos = new Vector2(position.X, position.Y); Vector2 nextStep = new Vector2(position.X + velocity.X, position.Y + velocity.Y); Vector2 finalPos = parentWorld.Map.reloactePosition(pos, nextStep, dimensions); position = finalPos; animation_time += currentTime.ElapsedGameTime.Milliseconds / 1000f; current_skeleton.Animation.Apply(current_skeleton.Skeleton, animation_time, loopAnimation); }
protected override void doUpdate(GameTime currentTime) { button_pressed_timer += currentTime.ElapsedGameTime.Milliseconds; fade += currentTime.ElapsedGameTime.Milliseconds; if (screen == titleScreens.menuScreen || screen == titleScreens.playScreen) { fade_duration = max_fade_menu_timer; } else { fade_duration = max_fade_timer; } switch (screen) { case titleScreens.introScreen: if (fade > max_fade_timer) { fade = 0.0f; fade_state = (FadeState)(((int)fade_state + 1) % 3); if (fade_state == FadeState.stay) { fade = 0.0f; screen = titleScreens.menuScreen; } } break; /**************************************************************************************************************************/ case titleScreens.logoScreen: if (fade > fade_duration) { fade = 0.0f; fade_state = (FadeState)(((int)fade_state + 1) % 3); if (fade_state == FadeState.fadeIn) { fade = 0.0f; screen = titleScreens.menuScreen; } else if (fade_state == FadeState.stay) { fade = 0.0f; fade_duration = logo_stay_timer; } else if (fade_state == FadeState.fadeOut) { fade = 0.0f; fade_duration = max_fade_timer; } } break; /**************************************************************************************************************************/ case titleScreens.menuScreen: if (!music_playing) { BackGroundAudio.playSong("Menu", true); music_playing = true; } if (Game1.videoPlayer.State == Microsoft.Xna.Framework.Media.MediaState.Stopped) { Game1.videoPlayer.IsLooped = true; Game1.videoPlayer.Play(Game1.titleScreenVideo); } if (fade > max_fade_menu_timer) { fade = 0.0f; fade_state = FadeState.stay; if (fade_state == FadeState.fadeIn) { fade = 0.0f; screen = titleScreens.menuScreen; } } if (storageDevicePrompted) { if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad) { if (!down_pressed) { button_pressed_timer = 0.0f; } down_pressed = true; } if ((down_pressed && !(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad)) || (down_pressed && (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad) && button_pressed_timer > max_button_pressed_timer)) { down_pressed = false; button_pressed_timer = 0.0f; menu_item_selected++; AudioLib.playSoundEffect(menuBlipSound); if (menu_item_selected >= menu_list.Count()) { menu_item_selected = menu_item_selected % menu_list.Count(); } else if (menu_item_selected < 0) { menu_item_selected += menu_list.Count(); } } if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad) { if (!up_pressed) { button_pressed_timer = 0.0f; } up_pressed = true; } if ((up_pressed && !(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad)) || (up_pressed && (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad) && button_pressed_timer > max_button_pressed_timer)) { up_pressed = false; button_pressed_timer = 0.0f; menu_item_selected--; AudioLib.playSoundEffect(menuBlipSound); if (menu_item_selected >= menu_list.Count()) { menu_item_selected = menu_item_selected % menu_list.Count(); } else if (menu_item_selected < 0) { menu_item_selected += menu_list.Count(); } } if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad) { confirm_pressed = true; whoPressedConfirm = InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm); } else if (confirm_pressed) { confirm_pressed = false; switch (menu_list[menu_item_selected].text) { case "START": screen = titleScreens.playScreen; fade_state = FadeState.fadeOut; fade = 0.0f; break; case "OPTIONS": InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, whoPressedConfirm); screen = titleScreens.optionScreen; fade_state = FadeState.fadeOut; fade = 0.0f; break; case "QUIT": Game1.exitGame = true; break; } } for (int i = 0; i < menu_list.Count(); i++) { if (i == menu_item_selected) { menu_list[menu_item_selected].selected = true; } else { menu_list[i].selected = false; } menu_list[i].update(currentTime); } } else { if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad) { confirm_pressed = true; whoPressedConfirm = InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm); } else if (confirm_pressed) { confirm_pressed = false; SaveGameModule.selectStorageDevice((PlayerIndex)whoPressedConfirm); SaveGameModule.loadGame(); storageDevicePrompted = true; } } break; /*****************************************************************************************************/ default: if (fade > max_fade_menu_timer) { isComplete = true; BackGroundAudio.stopAllSongs(); Game1.videoPlayer.Stop(); } break; } }