public LevelSelectState() { //GameCampaign.levelMap = new LevelData[6, 3]; wireframe = TextureLib.getLoadedTexture("shipWireframe.png"); PresentationParameters pp = AnimationLib.GraphicsDevice.PresentationParameters; textureScreen = new RenderTarget2D(AnimationLib.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, AnimationLib.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24); halfTextureScreen = new RenderTarget2D(AnimationLib.GraphicsDevice, pp.BackBufferWidth / 2, pp.BackBufferHeight / 2, false, AnimationLib.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24); quarterTextureScreen = new RenderTarget2D(AnimationLib.GraphicsDevice, pp.BackBufferWidth / 4, pp.BackBufferHeight / 4, false, AnimationLib.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24); sb2 = new SpriteBatch(AnimationLib.GraphicsDevice); /* * for (int i = 0; i < GameCampaign.levelMap.GetLength(0); i++) * { * for (int j = 0; j < GameCampaign.levelMap.GetLength(1); j++) * { * GameCampaign.levelMap[i, j] = new LevelData(Game1.rand.NextDouble(), Game1.rand.NextDouble(), Game1.rand.NextDouble(), Game1.rand.NextDouble()); * } * } * * GameCampaign.levelMap[0, 0].visible = false; * GameCampaign.levelMap[0, 2].visible = false; * GameCampaign.levelMap[GameCampaign.levelMap.GetLength(0) - 1, 0].visible = false; * GameCampaign.levelMap[GameCampaign.levelMap.GetLength(0) - 1, 2].visible = false; */ selectedLevelX = GameCampaign.PlayerLevelProgress + 1; selectedLevelY = GameCampaign.PlayerFloorHeight; cursorPosition = new Vector2(((GameCampaign.PlayerLevelProgress * 128) + drawMapTestOffset.X), ((GameCampaign.PlayerFloorHeight * 96) + drawMapTestOffset.Y)); cursorAnimationTime = 0; state = LevelSelectStateState.AnimateIn; openingSoundMade = false; }
protected override void doUpdate(Microsoft.Xna.Framework.GameTime currentTime) { CampaignLobbyState.lineOffset += (currentTime.ElapsedGameTime.Milliseconds * lineMoveSpeed); if (CampaignLobbyState.lineOffset > 16.0f) { CampaignLobbyState.lineOffset -= 16.0f; } if (!openingSoundMade) { AudioLib.playSoundEffect("monitorOpening"); openingSoundMade = true; } if (state == LevelSelectStateState.AnimateIn && cursorAnimationTime > 500f) { state = LevelSelectStateState.Idle; } if (state == LevelSelectStateState.Idle) { if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && !downPressed) { downPressed = true; } else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && downPressed) { downPressed = false; if (selectedLevelY < GameCampaign.levelMap.GetLength(1) - 1 && GameCampaign.levelMap[selectedLevelX, selectedLevelY + 1].visible && selectedLevelY - GameCampaign.PlayerFloorHeight < 1) { selectedLevelY++; AudioLib.playSoundEffect(menuBlipSound); } } if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && !upPressed) { upPressed = true; } else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && upPressed) { upPressed = false; if (selectedLevelY > 0 && GameCampaign.levelMap[selectedLevelX, selectedLevelY - 1].visible && selectedLevelY - GameCampaign.PlayerFloorHeight > -1) { selectedLevelY--; AudioLib.playSoundEffect(menuBlipSound); } } selectedLevelX = GameCampaign.PlayerLevelProgress + 1; if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm) && !confirmPressed) { confirmPressed = true; } else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm) && confirmPressed) { confirmPressed = false; GameCampaign.CurrentAlienRate = GameCampaign.levelMap[selectedLevelX, selectedLevelY].alienRates; GameCampaign.CurrentGuardRate = GameCampaign.levelMap[selectedLevelX, selectedLevelY].guardRates; GameCampaign.CurrentPrisonerRate = GameCampaign.levelMap[selectedLevelX, selectedLevelY].prisonerRates; GameCampaign.currentContract = GameCampaign.levelMap[selectedLevelX, selectedLevelY].contract; GameCampaign.PlayerLevelProgress = GameCampaign.PlayerLevelProgress + 1; GameCampaign.PlayerFloorHeight = selectedLevelY; GameCampaign.floorProgress[GameCampaign.PlayerLevelProgress] = GameCampaign.PlayerFloorHeight; state = LevelSelectStateState.AnimateOut; isComplete = true; } } double cursorDir = Math.Atan2(((selectedLevelY * 96) + drawMapTestOffset.Y) - cursorPosition.Y, ((selectedLevelX * 128) + drawMapTestOffset.X) - cursorPosition.X); cursorPosition += currentTime.ElapsedGameTime.Milliseconds * cursorVelocity * new Vector2((float)(Math.Cos(cursorDir)), (float)(Math.Sin(cursorDir))); if (Vector2.Distance(cursorPosition, new Vector2(((selectedLevelX * 128) + drawMapTestOffset.X), ((selectedLevelY * 96) + drawMapTestOffset.Y))) < 10f) { cursorPosition = new Vector2(((selectedLevelX * 128) + drawMapTestOffset.X), ((selectedLevelY * 96) + drawMapTestOffset.Y)); } cursorAnimationTime += currentTime.ElapsedGameTime.Milliseconds; }