Added in some blinking text and the simple title screen.

This commit is contained in:
JoshuaNavarro 2019-07-17 16:26:37 -07:00
parent a75503637d
commit 02e6bd7e49
10 changed files with 253 additions and 70 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -27,6 +27,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
this.viewport.Location = new xTile.Dimensions.Location((int)position.X - (int)(SeasideScramble.self.camera.viewport.Width / 2), (int)position.Y - (int)(SeasideScramble.self.camera.viewport.Height / 2));
}
public Rectangle getXNARect()
{
return new Rectangle(this.viewport.X, this.viewport.Y, this.viewport.Width, this.viewport.Height);
}
public void update(GameTime time)
{

View File

@ -0,0 +1,75 @@
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;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
{
public class TitleScreen: StardustCore.UIUtilities.IClickableMenuExtended
{
StardustCore.UIUtilities.Texture2DExtended background;
StardustCore.UIUtilities.MenuComponents.BlinkingText menuText;
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);
}
public TitleScreen(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);
}
public override void receiveLeftClick(int x, int y, bool playSound = true)
{
//Start the game!
}
public override bool readyToClose()
{
//When menu is closed!
return false;
}
public override void update(GameTime time)
{
this.menuText.update(time);
}
public override void draw(SpriteBatch b)
{
b.GraphicsDevice.Clear(Color.Black);
this.drawTitleBackground(b);
this.drawTitleText(b);
this.drawMouse(b);
}
public void drawTitleBackground(SpriteBatch b)
{
b.Draw(this.background.texture,new Vector2(this.xPositionOnScreen,this.yPositionOnScreen),SeasideScramble.self.camera.getXNARect() ,Color.White);
//this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, Color.Black);
}
public void drawTitleText(SpriteBatch b)
{
Vector2 offset=StardewValley.Game1.dialogueFont.MeasureString(this.menuText.displayText);
this.menuText.draw(b, StardewValley.Game1.dialogueFont, new Vector2((this.width / 2) - (offset.X / 2), this.height / 2), Color.White);
}
}
}

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using StardustCore.Animations;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
public class SSCPlayer
@ -17,6 +18,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public SSCEnums.FacingDirection facingDirection;
public Microsoft.Xna.Framework.Vector2 position;
public bool isMoving;
public Color playerColor;
public const int junimoWalkingAnimationSpeed = 10;
@ -91,6 +93,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
},"Idle_F",0,true);
}
public void setColor(Color color)
{
this.playerColor = color;
}
public void playAnimation(string name)
{
this.characterSpriteController.setAnimation(name);
@ -98,7 +105,7 @@ 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), Color.White, 4f, this.flipSprite == true ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (this.position.Y) / 10000f));
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));
}
public void update(GameTime Time)
@ -179,8 +186,70 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
ModCore.log(this.position);
}
public void receiveKeyPress(Microsoft.Xna.Framework.Input.Keys k)
{
this.checkForMovementInput(k);
}
public void receiveKeyRelease(Keys K)
{
//throw new NotImplementedException();
if (K == Keys.A)
{
ModCore.log("A released for Seaside Scramble!");
this.isMoving = false;
}
if (K == Keys.W)
{
ModCore.log("W pressed for Seaside Scramble!");
this.isMoving = false;
}
if (K == Keys.S)
{
ModCore.log("S pressed for Seaside Scramble!");
this.isMoving = false;
}
if (K == Keys.D)
{
ModCore.log("D pressed for Seaside Scramble!");
this.isMoving = false;
}
}
/// <summary>
/// Checks for player movement.
/// </summary>
/// <param name="K"></param>
private void checkForMovementInput(Keys K)
{
if (SeasideScramble.self.isMenuUp) return;
//Microsoft.Xna.Framework.Input.GamePadState state = this.getGamepadState(PlayerIndex.One);
if (K == Keys.A)
{
ModCore.log("A pressed for player");
this.movePlayer(SSCEnums.FacingDirection.Left);
}
if (K == Keys.W)
{
ModCore.log("W pressed for player!");
this.movePlayer(SSCEnums.FacingDirection.Up);
}
if (K == Keys.S)
{
ModCore.log("S pressed for player!");
this.movePlayer(SSCEnums.FacingDirection.Down);
}
if (K == Keys.D)
{
ModCore.log("D pressed for player!");
this.movePlayer(SSCEnums.FacingDirection.Right);
}
}
}
}

View File

@ -22,7 +22,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public Dictionary<string, SeasideScrambleMap> SeasideScrambleMaps;
public bool quitGame;
public Vector2 topLeftScreenCoordinate;
public SSCTextureUtilities textureUtils;
@ -32,19 +32,23 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public SSCCamera camera;
public IClickableMenuExtended activeMenu;
public bool isMenuUp
{
get
{
return this.activeMenu != null;
}
}
public SeasideScramble()
{
self = this;
this.camera = new SSCCamera();
//this.viewport = new xTile.Dimensions.Rectangle(StardewValley.Game1.viewport);
this.topLeftScreenCoordinate= new Vector2((float)(this.camera.viewport.Width / 2 - 384), (float)(this.camera.viewport.Height / 2 - 384));
this.topLeftScreenCoordinate = new Vector2((float)(this.camera.viewport.Width / 2 - 384), (float)(this.camera.viewport.Height / 2 - 384));
this.textureUtils = new SSCTextureUtilities();
TextureManager playerManager = new TextureManager("SSCPlayer");
playerManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Player"));
this.textureUtils.addTextureManager(playerManager);
this.LoadTextures();
this.LoadMaps();
@ -52,17 +56,26 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
this.quitGame = false;
this.player = new SSCPlayer();
this.player.setColor(Color.Red);
this.activeMenu = new SSCMenus.TitleScreen(this.camera.viewport);
}
private void LoadTextures()
{
this.textureUtils = new SSCTextureUtilities();
TextureManager playerManager = new TextureManager("SSCPlayer");
playerManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Player"));
TextureManager mapTextureManager = new TextureManager("SSCMaps");
mapTextureManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Maps", "Backgrounds"));
this.textureUtils.addTextureManager(playerManager);
this.textureUtils.addTextureManager(mapTextureManager);
}
private void LoadMaps()
{
this.SeasideScrambleMaps = new Dictionary<string, SeasideScrambleMap>();
this.SeasideScrambleMaps.Add("TestRoom",new SeasideScrambleMap(SeasideScrambleMap.LoadMap("TestRoom.tbin").Value));
this.SeasideScrambleMaps.Add("TestRoom", new SeasideScrambleMap(SeasideScrambleMap.LoadMap("TestRoom.tbin").Value));
}
private void loadStartingMap()
{
@ -99,7 +112,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
/// <param name="b"></param>
public void draw(SpriteBatch b)
{
if (this.currentMap!=null){
if (this.currentMap != null)
{
this.currentMap.draw(b);
}
b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
@ -107,6 +121,12 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
this.player.draw(b);
}
if (this.activeMenu != null)
{
this.activeMenu.draw(b);
}
b.End();
}
@ -156,72 +176,23 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public void receiveKeyPress(Keys k)
{
//throw new NotImplementedException();
this.checkForMovementInput(k);
}
/// <summary>
/// Checks for player movement.
/// </summary>
/// <param name="K"></param>
private void checkForMovementInput(Keys K)
{
Microsoft.Xna.Framework.Input.GamePadState state = this.getGamepadState(PlayerIndex.One);
if(K== Keys.A)
{
ModCore.log("A pressed for Seaside Scramble!");
this.player.movePlayer(SSCEnums.FacingDirection.Left);
}
if (K == Keys.W)
{
ModCore.log("W pressed for Seaside Scramble!");
this.player.movePlayer(SSCEnums.FacingDirection.Up);
}
if(K== Keys.S)
{
ModCore.log("S pressed for Seaside Scramble!");
this.player.movePlayer(SSCEnums.FacingDirection.Down);
}
if(K== Keys.D)
{
ModCore.log("D pressed for Seaside Scramble!");
this.player.movePlayer(SSCEnums.FacingDirection.Right);
}
if(K== Keys.Escape)
if (k == Keys.Escape)
{
this.quitGame = true;
}
this.player.receiveKeyPress(k);
}
private GamePadState getGamepadState(PlayerIndex index)
{
return Microsoft.Xna.Framework.Input.GamePad.GetState(PlayerIndex.One);
return Microsoft.Xna.Framework.Input.GamePad.GetState(PlayerIndex.One);
}
public void receiveKeyRelease(Keys K)
{
//throw new NotImplementedException();
if (K == Keys.A)
{
ModCore.log("A released for Seaside Scramble!");
this.player.isMoving = false;
}
if (K == Keys.W)
{
ModCore.log("W pressed for Seaside Scramble!");
this.player.isMoving = false;
}
if (K == Keys.S)
{
ModCore.log("S pressed for Seaside Scramble!");
this.player.isMoving = false;
}
if (K == Keys.D)
{
ModCore.log("D pressed for Seaside Scramble!");
this.player.isMoving = false;
}
this.player.receiveKeyRelease(K);
}
public void receiveLeftClick(int x, int y, bool playSound = true)
@ -271,11 +242,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
this.player.update(time);
this.camera.centerOnPosition(this.player.position);
}
if (this.activeMenu != null)
{
this.activeMenu.update(time);
}
return false;
//throw new NotImplementedException();
}
/// <summary>
/// Called when the minigame is quit upon.
/// </summary>

View File

@ -69,6 +69,7 @@
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScrambleMap.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCCamera.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnums.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCMenus\TitleScreen.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCPlayer.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCTextureUtilities.cs" />
<Compile Include="Framework\Objects\BasicItemInformation.cs" />
@ -130,6 +131,12 @@
<Content Include="Content\Minigames\SeasideScramble\Graphics\Player\Junimo.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Minigames\SeasideScramble\Maps\Backgrounds\TitleScreenBackground.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Minigames\SeasideScramble\Maps\Intro.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Minigames\SeasideScramble\Maps\SSC_Beach.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -93,6 +93,7 @@
<Compile Include="ModConfig.cs" />
<Compile Include="UIUtilities\IClickableMenuExtended.cs" />
<Compile Include="UIUtilities\LayeredTexture.cs" />
<Compile Include="UIUtilities\MenuComponents\BlinkingText.cs" />
<Compile Include="UIUtilities\MenuComponents\CycleButton.cs" />
<Compile Include="UIUtilities\MenuComponents\Delegates\Delegates.cs" />
<Compile Include="UIUtilities\MenuComponents\Delegates\DelegatePairing.cs" />

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardustCore.UIUtilities.MenuComponents
{
public class BlinkingText
{
public string displayText;
public int currentFrame;
public int maxFrames;
public bool drawThis;
public BlinkingText(string text,int existsForXMilliseconds)
{
this.displayText = text;
this.maxFrames = existsForXMilliseconds;
this.currentFrame = existsForXMilliseconds;
}
public void update(Microsoft.Xna.Framework.GameTime time)
{
this.currentFrame -= time.ElapsedGameTime.Milliseconds;
if (this.currentFrame <= 0 && this.currentFrame>=-this.maxFrames)
{
this.drawThis = false;
}
else if(this.currentFrame>0)
{
if (this.currentFrame > 0)
{
this.drawThis = true;
}
}
else if(this.currentFrame<-this.maxFrames)
{
this.currentFrame = this.maxFrames;
}
}
public void draw(Microsoft.Xna.Framework.Graphics.SpriteBatch b, Microsoft.Xna.Framework.Graphics.SpriteFont font, Microsoft.Xna.Framework.Vector2 position, Microsoft.Xna.Framework.Color color)
{
if (this.drawThis)
{
b.DrawString(font, this.displayText, position, color);
}
}
}
}