Made the shooting gallery map and figured out more collisions for the player.

This commit is contained in:
JoshuaNavarro 2019-07-22 23:22:03 -07:00
parent 1838c80ccb
commit 1c8d973a14
8 changed files with 253 additions and 14 deletions

View File

@ -0,0 +1,71 @@
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 Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces;
using StardustCore.Animations;
using StardustCore.UIUtilities.SpriteFonts.Components;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEntities.Generic
{
public class SignPost : ISSCLivingEntity
{
public float MovementSpeed { get; set; }
public int CurrentHealth { get; set; }
public int MaxHealth { get; set; }
public Rectangle HitBox { get; set; }
public AnimatedSprite sprite;
Vector2 position;
public TexturedString displayString;
public Vector2 Position
{
get
{
return this.position;
}
set
{
this.position = value;
Rectangle hitbox = this.HitBox;
hitbox.X = (int)this.position.X;
hitbox.Y = (int)this.position.Y;
}
}
public Color color
{
get
{
return this.sprite.color;
}
set
{
this.sprite.color = value;
}
}
public SignPost(Vector2 Position)
{
this.sprite = new AnimatedSprite("SignPost", Position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Entities", "SignPost"), new Animation(0, 0, 16, 16)), Color.White);
}
public void update(GameTime time)
{
}
public void draw(SpriteBatch b)
{
this.sprite.draw(b);
if (this.displayString != null)
{
this.displayString.draw(b, new Rectangle(0, 0, 16, 16), 0f);
}
}
}
}

View File

@ -12,6 +12,8 @@ using xTile;
using xTile.Dimensions;
using xTile.Display;
using xTile.Layers;
using xTile.ObjectModel;
using xTile.Tiles;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
@ -31,6 +33,8 @@ AlwaysFront: Objects that are always drawn on top of other layers as well as the
{
public xTile.Map map;
public const int TileSize = 64;
public SeasideScrambleMap()
{
@ -42,9 +46,27 @@ AlwaysFront: Objects that are always drawn on top of other layers as well as the
//this.map.LoadTileSheets(Game1.mapDisplayDevice);
}
public Microsoft.Xna.Framework.Rectangle MapBounds
{
get
{
Vector2 size = this.getPixelSize();
return new Microsoft.Xna.Framework.Rectangle(0,0,(int)size.X,(int)size.Y);
}
}
public Vector2 Center
{
get
{
Microsoft.Xna.Framework.Rectangle bounds = this.MapBounds;
return new Vector2(bounds.Width / 2, bounds.Height / 2);
}
}
public virtual void update(GameTime time)
{
this.map.Update(time.TotalGameTime.Ticks);
this.map.Update(time.ElapsedGameTime.Milliseconds);
}
public virtual void draw(SpriteBatch b)
@ -60,6 +82,32 @@ AlwaysFront: Objects that are always drawn on top of other layers as well as the
b.End();
}
public virtual void drawBackLayer()
{
}
public virtual void drawBuildingsLayer()
{
}
public virtual void drawPathsLayer()
{
}
public virtual void drawFrontLayer()
{
}
public virtual void drawAlwaysFrontLayer()
{
}
public virtual void spawnPlayersAtPositions()
{
}
/// <summary>
/// Loads a map from a tbin file from the mod's asset folder.
/// </summary>
@ -95,6 +143,31 @@ AlwaysFront: Objects that are always drawn on top of other layers as well as the
return new Vector2(layer.TileSize.Width * layer.LayerWidth * mapZoomScale, layer.TileSize.Height * layer.LayerWidth * mapZoomScale);
}
/// <summary>
/// Checks to see if a given position is inside the map.
/// </summary>
/// <param name="Position"></param>
/// <returns>A boolean representing if the point is inside the map.</returns>
public bool insideMap(Vector2 Position)
{
return this.MapBounds.Contains((int)Position.X, (int)Position.Y);
}
public bool isObstacleAt(Vector2 position)
{
int tileSize = 1;//16 * 4;
int x = (int)position.X / tileSize;
int y = (int)position.Y / tileSize;
PropertyValue propertyValue = (PropertyValue)null;
Tile t=this.map.GetLayer("Front").PickTile(new Location(x, y), SeasideScramble.self.camera.viewport.Size);
t?.TileIndexProperties.TryGetValue("Obstacle", out propertyValue);
if (propertyValue == null) return false;
else
{
return true;
}
}
public void debugInfo()
{

View File

@ -0,0 +1,55 @@
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 xTile;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMaps
{
public class ShootingGallery: SeasideScrambleMap
{
public Dictionary<SSCEnums.PlayerID, int> score;
public static int highScore;
public ShootingGallery():base()
{
}
public ShootingGallery(Map m) : base(m)
{
this.score = new Dictionary<SSCEnums.PlayerID, int>();
this.score.Add(SSCEnums.PlayerID.One, 0);
this.score.Add(SSCEnums.PlayerID.Two, 0);
this.score.Add(SSCEnums.PlayerID.Three, 0);
this.score.Add(SSCEnums.PlayerID.Four, 0);
}
public override void spawnPlayersAtPositions()
{
foreach(SSCPlayer p in SeasideScramble.self.players.Values)
{
p.position = SeasideScramble.self.currentMap.Center;
}
}
public override void update(GameTime time)
{
base.update(time);
}
public override void draw(SpriteBatch b)
{
base.draw(b);
}
public void addScore(SSCEnums.PlayerID player, int amount)
{
this.score[player] += amount;
}
}
}

View File

@ -116,7 +116,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
//this.animatedSprites.Add("P1NextColor", new StardustCore.Animations.AnimatedSprite("P1NextColor", this.playerDisplayLocations[SSCEnums.PlayerID.One] + new Vector2(64, 200), new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("SSCUI", "nextPageButton"), new Animation(0, 0, 32, 32)), Color.White));
this.oldMousePos =new Vector2( Game1.getMousePosition().X,Game1.getMousePosition().Y);
this.oldMousePos = new Vector2(Game1.getMousePosition().X, Game1.getMousePosition().Y);
}
public CharacterSelectScreen(xTile.Dimensions.Rectangle viewport) : this(0, 0, viewport.Width, viewport.Height)
@ -388,7 +388,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
}
}
public void receiveGamepadLeftClick(SSCEnums.PlayerID player,int x, int y, bool playSound = true)
public void receiveGamepadLeftClick(SSCEnums.PlayerID player, int x, int y, bool playSound = true)
{
if (player == SSCEnums.PlayerID.One)
{
@ -466,13 +466,16 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
/// </summary>
private void setUpForGameplay()
{
foreach(SSCPlayer p in SeasideScramble.self.players.Values)
foreach (SSCPlayer p in SeasideScramble.self.players.Values)
{
p.HUD.displayHUD();
//p.statusEffects.addStatusEffect(SE_Burn.SpawnBurnEffect(new Vector2(p.HUD.xPositionOnScreen,p.HUD.yPositionOnScreen),10*1000,1000,1.00d,1));
}
SeasideScramble.self.entities.addSpawner(new Target_Spawner(new Vector2(-64, 0), new Vector2(1, 0), Color.White, true, 1000, 5000, true, 0.25f, 3f,true));
SeasideScramble.self.entities.addSpawner(new Target_Spawner(new Vector2(SeasideScrambleMap.TileSize*-1, SeasideScrambleMap.TileSize * 4), new Vector2(1, 0), Color.White, true, 1000, 5000, true, 0.25f, 3f, true));
SeasideScramble.self.entities.addSpawner(new Target_Spawner(new Vector2(SeasideScrambleMap.TileSize * 17, SeasideScrambleMap.TileSize * 5), new Vector2(-1, 0), Color.White, true, 1000, 5000, true, 0.25f, 3f, true));
SeasideScramble.self.currentMap.spawnPlayersAtPositions();
//SSCEnemies.SSCE_Target.Spawn_SSCE_Target(new Vector2(100, 100), Color.Blue);
//SSCEnemies.SSCE_Target.Spawn_SSCE_Target(new Vector2(200, 100), Color.Red);
//SSCEnemies.SSCE_Target.Spawn_SSCE_Target(new Vector2(300, 100), Color.Green);
@ -565,12 +568,12 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
if (SeasideScramble.self.currentNumberOfPlayers >= 1)
{
Vector2 finish = Game1.dialogueFont.MeasureString("Press start or enter to start the game.");
b.DrawString(Game1.dialogueFont, "Press start or enter to start the game.", new Vector2((this.width / 2) - (menuTitlePos.X / 2), this.height *.25f), Color.White);
b.DrawString(Game1.dialogueFont, "Press start or enter to start the game.", new Vector2((this.width / 2) - (menuTitlePos.X / 2), this.height * .25f), Color.White);
}
if (SeasideScramble.self.getPlayer(SSCEnums.PlayerID.One) != null)
{
SeasideScramble.self.getPlayer( SSCEnums.PlayerID.One).drawMouse(b);
SeasideScramble.self.getPlayer(SSCEnums.PlayerID.One).drawMouse(b);
}
if (SeasideScramble.self.getPlayer(SSCEnums.PlayerID.Two) != null)
{

View File

@ -464,28 +464,56 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
if (direction == SSCEnums.FacingDirection.Up)
{
this.facingDirection = direction;
this.position += new Vector2(0, -1);
if (this.canMoveHere(direction,new Vector2(0, -1))){
this.position += new Vector2(0, -1);
}
}
if (direction == SSCEnums.FacingDirection.Down)
{
this.facingDirection = direction;
this.position += new Vector2(0, 1);
if (this.canMoveHere(direction,new Vector2(0, 1)))
{
this.position += new Vector2(0, 1);
}
}
if (direction == SSCEnums.FacingDirection.Left)
{
this.facingDirection = direction;
this.position += new Vector2(-1, 0);
if (this.canMoveHere(direction,new Vector2(-1, 0)))
{
this.position += new Vector2(-1, 0);
}
}
if (direction == SSCEnums.FacingDirection.Right)
{
this.facingDirection = direction;
this.position += new Vector2(1, 0);
if (this.canMoveHere(direction,new Vector2(1, 0)))
{
this.position += new Vector2(1, 0);
}
}
this.hitBox.X = (int)this.position.X;
this.hitBox.Y = (int)this.position.Y;
//ModCore.log(this.position);
}
public bool canMoveHere(SSCEnums.FacingDirection Direction,Vector2 offset)
{
Vector2 combo = this.position + offset;
if(Direction== SSCEnums.FacingDirection.Right)
{
combo.X += this.hitBox.Width;
}
if(Direction== SSCEnums.FacingDirection.Down)
{
combo.Y += this.hitBox.Height;
}
if (SeasideScramble.self.currentMap.insideMap(combo) == false) return false;
if (SeasideScramble.self.currentMap.isObstacleAt(combo)) return false;
return true;
}
/// <summary>
/// Checks for player movement.
/// </summary>

View File

@ -24,7 +24,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
/// -Fix positioning of status effects on player HUD
/// -Add effect on player for a more visual representation of status effects.
///
/// -Make shooting gallary map.
/// -Make shooting gallary game mode
/// -Make shooting gallery map wider.
/// -Add in score system for shooting gallery mode.
///
/// -Make More guns
/// </summary>
public class SeasideScramble : StardewValley.Minigames.IMinigame
@ -135,10 +138,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
this.SeasideScrambleMaps = new Dictionary<string, SeasideScrambleMap>();
this.SeasideScrambleMaps.Add("TestRoom", new SeasideScrambleMap(SeasideScrambleMap.LoadMap("TestRoom.tbin").Value));
this.SeasideScrambleMaps.Add("ShootingGallery", new SSCMaps.ShootingGallery(SeasideScrambleMap.LoadMap("ShootingGallery.tbin").Value));
}
private void loadStartingMap()
{
this.currentMap = this.SeasideScrambleMaps["TestRoom"];
this.currentMap = this.SeasideScrambleMaps["ShootingGallery"];
}
/// <summary>

View File

@ -69,7 +69,8 @@
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISpawner.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISSCLivingEntity.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScramble.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScrambleMap.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEntities\Generic\SignPost.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCMaps\SeasideScrambleMap.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCCamera.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\EnemyManager.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\KillZone.cs" />
@ -81,6 +82,7 @@
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCFonts\SSCFontCharacterSheet.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCFonts\SSCFont.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCGuns\SSCGun.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCMaps\ShootingGallery.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCMenus\CharacterSelectScreen.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCMenus\HUD\CharacterHUD.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCMenus\SSCMenuManager.cs" />
@ -131,6 +133,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Content\Minigames\SeasideScramble\Maps\ShootingGallery.tbin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\Minigames\SeasideScramble\Maps\TestRoom.tbin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>