using System; using System.Collections.Generic; using System.IO; 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 Revitalize.Framework.Minigame.SeasideScrambleMinigame; using StardustCore.UIUtilities; namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { public class SeasideScramble : StardewValley.Minigames.IMinigame { public static SeasideScramble self; SeasideScrambleMap currentMap; public int currentNumberOfPlayers = 0; public const int maxPlayers = 4; public Dictionary SeasideScrambleMaps; public bool quitGame; public SSCTextureUtilities textureUtils; public SSCPlayer player; public SeasideScramble() { self = this; 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(); this.loadStartingMap(); this.quitGame = false; this.player = new SSCPlayer(); } private void LoadTextures() { } private void LoadMaps() { this.SeasideScrambleMaps = new Dictionary(); this.SeasideScrambleMaps.Add("TestRoom",new SeasideScrambleMap(SeasideScrambleMap.LoadMap("TestRoom.tbin").Value)); } private void loadStartingMap() { this.currentMap = this.SeasideScrambleMaps["TestRoom"]; } /// /// What happens when the screen changes size. /// public void changeScreenSize() { //throw new NotImplementedException(); } /// /// Used to update Stardew Valley while this minigame runs. True means SDV updates false means the SDV pauses all update ticks. /// /// public bool doMainGameUpdates() { return false; //throw new NotImplementedException(); } /// /// Draws all game aspects to the screen. /// /// public void draw(SpriteBatch b) { if (this.currentMap!=null){ this.currentMap.draw(b); } b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); if (this.player != null) { this.player.draw(b); } b.End(); } /// /// What happens when the left click is held. /// /// /// public void leftClickHeld(int x, int y) { //throw new NotImplementedException(); } /// /// The id of the minigame??? /// /// public string minigameId() { return "Seaside Scramble Stardew Lite Edition"; //throw new NotImplementedException(); } /// /// Does this override free mous emovements? /// /// public bool overrideFreeMouseMovement() { return false; //throw new NotImplementedException(); } /// /// ??? Undocumended. /// /// public void receiveEventPoke(int data) { //throw new NotImplementedException(); } /// /// What happens when a key is pressed. /// /// public void receiveKeyPress(Keys k) { //throw new NotImplementedException(); this.checkForMovementInput(k); } /// /// Checks for player movement. /// /// 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) { this.quitGame = true; } } private GamePadState getGamepadState(PlayerIndex index) { 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; } } public void receiveLeftClick(int x, int y, bool playSound = true) { //throw new NotImplementedException(); } public void receiveRightClick(int x, int y, bool playSound = true) { //throw new NotImplementedException(); } public void releaseLeftClick(int x, int y) { //throw new NotImplementedException(); } public void releaseRightClick(int x, int y) { //throw new NotImplementedException(); } /// /// Called every update frame. /// /// /// public bool tick(GameTime time) { KeyboardState state = Keyboard.GetState(); foreach (Keys k in state.GetPressedKeys()) { this.receiveKeyPress(k); } if (this.quitGame) { return true; } if (this.currentMap != null) { this.currentMap.update(time); } if (this.player != null) { this.player.update(time); } return false; //throw new NotImplementedException(); } /// /// Called when the minigame is quit upon. /// public void unload() { //throw new NotImplementedException(); ModCore.log("Exit the game!"); } } }