diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs new file mode 100644 index 00000000..f7fe81d1 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using StardewValley; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus +{ + public class CharacterSelectScreen: IClickableMenuExtended + { + StardustCore.UIUtilities.Texture2DExtended background; + string menuTitle; + + public Color p1DefaultColor = Color.PaleVioletRed; + public Color p2DefaultColor = Color.LightSkyBlue; + public Color p3DefaultColor = Color.LawnGreen; + public Color p4DefaultColor = Color.LightGoldenrodYellow; + + public Vector2 p1DisplayLocation; + + public bool closeMenu; + + public CharacterSelectScreen(int x, int y, int width, int height) : base(x, y, width, height, false) + { + + this.background = SeasideScramble.self.textureUtils.getExtendedTexture("SSCMaps", "TitleScreenBackground"); + this.menuTitle = "Character Selection"; + + this.p1DisplayLocation = this.getRelativePositionToMenu(.1f, .5f); + } + + public CharacterSelectScreen(xTile.Dimensions.Rectangle viewport) : this(0, 0, viewport.Width, viewport.Height) + { + + } + + public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) + { + this.xPositionOnScreen = newBounds.X; + this.yPositionOnScreen = newBounds.Y; + this.width = newBounds.Width; + this.height = newBounds.Height; + base.gameWindowSizeChanged(oldBounds, newBounds); + + this.p1DisplayLocation = this.getRelativePositionToMenu(.1f, .5f); + } + + public override void update(GameTime time) + { + GamePadState p1 = SeasideScramble.self.getGamepadState(PlayerIndex.One); + GamePadState p2 = SeasideScramble.self.getGamepadState(PlayerIndex.Two); + GamePadState p3 = SeasideScramble.self.getGamepadState(PlayerIndex.Three); + GamePadState p4 = SeasideScramble.self.getGamepadState(PlayerIndex.Four); + + if (p1.IsButtonDown(Buttons.A)) + { + this.initializeCharacter(SSCEnums.PlayerID.One); + } + if (p2.IsButtonDown(Buttons.A)) + { + throw new NotImplementedException("Need to support player 2!"); + } + if (p3.IsButtonDown(Buttons.A)) + { + throw new NotImplementedException("Need to support player 3!"); + } + if (p4.IsButtonDown(Buttons.A)) + { + throw new NotImplementedException("Need to support player 4!"); + } + + } + + public void initializeCharacter(SSCEnums.PlayerID player) + { + if (SeasideScramble.self.players.ContainsKey(player)) + { + SeasideScramble.self.players[player] = new SSCPlayer(player); + } + else + { + SeasideScramble.self.players.Add(player, new SSCPlayer(player)); + } + SeasideScramble.self.getPlayer(player).setColor(this.p1DefaultColor); + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + this.initializeCharacter(SSCEnums.PlayerID.One); + } + + public override void receiveKeyPress(Keys key) + { + if(key== Keys.Enter) + { + this.setUpForGameplay(); + this.closeMenu = true; + } + } + + private void setUpForGameplay() + { + + } + + public override bool readyToClose() + { + if (this.closeMenu == true) + { + return true; + } + + return false; + } + + /// + /// Draw everything to the screen. + /// + /// + public override void draw(SpriteBatch b) + { + //Draw background texture. + b.Draw(this.background.texture, new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), SeasideScramble.self.camera.getXNARect(), Color.White); + + Vector2 menuTitlePos = Game1.dialogueFont.MeasureString(this.menuTitle); + b.DrawString(Game1.dialogueFont, this.menuTitle, new Vector2((this.width / 2) - (menuTitlePos.X / 2), this.height / 2),Color.White); + + if (SeasideScramble.self.getPlayer(SSCEnums.PlayerID.One) != null) + { + SeasideScramble.self.getPlayer(SSCEnums.PlayerID.One).draw(b,this.p1DisplayLocation); + } + } + + public override void exitMenu(bool playSound = true) + { + base.exitMenu(playSound); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/TitleScreen.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/TitleScreen.cs index 3c502fbb..8c5f4376 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/TitleScreen.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/TitleScreen.cs @@ -18,7 +18,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus public TitleScreen(int x, int y, int width, int height):base(x,y,width,height,false) { this.background = SeasideScramble.self.textureUtils.getExtendedTexture("SSCMaps", "TitleScreenBackground"); - this.menuText = new StardustCore.UIUtilities.MenuComponents.BlinkingText("Sea Side Scramble: Lite Edition" + System.Environment.NewLine + "Click to start.",1000); + this.menuText = new StardustCore.UIUtilities.MenuComponents.BlinkingText("Sea Side Scramble: Lite Edition" + System.Environment.NewLine + "Click or press A to start.",1000); } public TitleScreen(xTile.Dimensions.Rectangle viewport) : this(0, 0, viewport.Width, viewport.Height) @@ -50,7 +50,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus public override void receiveLeftClick(int x, int y, bool playSound = true) { if (SeasideScramble.self.menuManager.isThisActiveMenu(this) == false) return; - this.closeMenu = true; + SeasideScramble.self.menuManager.addNewMenu(new CharacterSelectScreen(SeasideScramble.self.camera.viewport)); } /// @@ -83,8 +83,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus /// public override void draw(SpriteBatch b) { - - b.GraphicsDevice.Clear(Color.Black); + if (SeasideScramble.self.menuManager.isThisActiveMenu(this) == false) return; this.drawTitleBackground(b); this.drawTitleText(b); this.drawMouse(b); @@ -111,5 +110,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus } + public override void exitMenu(bool playSound = true) + { + base.exitMenu(playSound); + } + } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs index 82b5f9fb..2102fb54 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs @@ -119,7 +119,17 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame /// public void draw(Microsoft.Xna.Framework.Graphics.SpriteBatch b) { - this.characterSpriteController.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport,this.position), this.playerColor, 4f, this.flipSprite == true ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (this.position.Y) / 10000f)); + this.draw(b,this.position); + } + + /// + /// Draws the character to the screen. + /// + /// + /// + public void draw(SpriteBatch b, Vector2 position) + { + this.characterSpriteController.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), this.playerColor, 4f, this.flipSprite == true ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (this.position.Y) / 10000f)); } /// diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs index c3c73adf..64736740 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs @@ -11,6 +11,10 @@ using Revitalize.Framework.Minigame.SeasideScrambleMinigame; using StardustCore.UIUtilities; namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { + /// + /// TODO: Finish character select screen. Ensure that camera snapping doesn't happen until game starts. + /// Also add interface for game entity for camera to consistently have a focus target. + /// public class SeasideScramble : StardewValley.Minigames.IMinigame { @@ -46,9 +50,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame this.quitGame = false; this.players = new Dictionary(); - this.players.Add(SSCEnums.PlayerID.One, new SSCPlayer(SSCEnums.PlayerID.One)); - - this.getPlayer(SSCEnums.PlayerID.One).setColor(Color.PaleVioletRed); + //this.players.Add(SSCEnums.PlayerID.One, new SSCPlayer(SSCEnums.PlayerID.One)); + //this.getPlayer(SSCEnums.PlayerID.One).setColor(Color.PaleVioletRed); this.menuManager = new SSCMenus.SSCMenuManager(); @@ -297,11 +300,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { this.currentMap.update(time); } - foreach(SSCPlayer player in this.players.Values) - { - if(player.playerID== SSCEnums.PlayerID.One) this.camera.centerOnPosition(player.position); - player.update(time); - } + if (this.menuManager.activeMenu != null) { @@ -311,6 +310,14 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame this.menuManager.closeActiveMenu(); } } + else + { + foreach (SSCPlayer player in this.players.Values) + { + if (player.playerID == SSCEnums.PlayerID.One) this.camera.centerOnPosition(player.position); + player.update(time); + } + } return false; //throw new NotImplementedException(); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 0d9745c1..d76ac4f6 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -69,6 +69,7 @@ +