diff --git a/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Maps/ShootingGallery.tbin b/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Maps/ShootingGallery.tbin new file mode 100644 index 00000000..e104a28f Binary files /dev/null and b/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Maps/ShootingGallery.tbin differ diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEntities/Generic/SignPost.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEntities/Generic/SignPost.cs new file mode 100644 index 00000000..70003522 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEntities/Generic/SignPost.cs @@ -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); + } + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScrambleMap.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs similarity index 67% rename from GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScrambleMap.cs rename to GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs index a45bd563..e6159450 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScrambleMap.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs @@ -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() + { + + } + /// /// Loads a map from a tbin file from the mod's asset folder. /// @@ -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); } + /// + /// Checks to see if a given position is inside the map. + /// + /// + /// A boolean representing if the point is inside the map. + 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() { diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/ShootingGallery.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/ShootingGallery.cs new file mode 100644 index 00000000..c89d110d --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/ShootingGallery.cs @@ -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 score; + + public static int highScore; + + public ShootingGallery():base() + { + + } + + public ShootingGallery(Map m) : base(m) + { + this.score = new Dictionary(); + 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; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs index f515b13e..f948ea57 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs @@ -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 /// 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) { diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs index 43b7694b..aee031f2 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs @@ -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; + } + /// /// Checks for player movement. /// diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs index eb5278c8..4a6d7821 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs @@ -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 /// public class SeasideScramble : StardewValley.Minigames.IMinigame @@ -135,10 +138,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { this.SeasideScrambleMaps = new Dictionary(); 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"]; } /// diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 059e261a..2b860e24 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -69,7 +69,8 @@ - + + @@ -81,6 +82,7 @@ + @@ -131,6 +133,9 @@ + + Always + Always