diff --git a/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Enemies/Target.png b/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Enemies/Target.png new file mode 100644 index 00000000..52780f2c Binary files /dev/null and b/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Enemies/Target.png differ diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/Interfaces/ICollider.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/Interfaces/ICollider.cs new file mode 100644 index 00000000..deac14e6 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/Interfaces/ICollider.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces +{ + public interface ICollider + { + void onCollision(object other); + + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/EnemyManager.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/EnemyManager.cs new file mode 100644 index 00000000..5ef578b6 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/EnemyManager.cs @@ -0,0 +1,72 @@ +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.SSCEnemies +{ + public class EnemyManager + { + public List enemies; + private List garbageCollection; + + /// + /// Constructor. + /// + public EnemyManager() + { + this.enemies = new List(); + this.garbageCollection = new List(); + } + + /// + /// Adds an enemy to the game. + /// + /// + public void addEnemy(SSCEnemy enemy) + { + this.enemies.Add(enemy); + } + /// + /// Removes an enemy from the game. + /// + /// + public void removeEnemy(SSCEnemy enemy) + { + this.garbageCollection.Add(enemy); + } + + /// + /// Update all enemies. + /// + /// + public void update(GameTime time) + { + foreach(SSCEnemy enemy in this.garbageCollection) + { + this.enemies.Remove(enemy); + } + foreach(SSCEnemy enemy in this.enemies) + { + enemy.update(time); + if (enemy.shouldDie) this.removeEnemy(enemy); + } + } + + /// + /// Draw all enemies to the screen. + /// + /// + public void draw(SpriteBatch b) + { + foreach (SSCEnemy enemy in this.enemies) + { + enemy.draw(b); + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/SSCE_Target.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/SSCE_Target.cs new file mode 100644 index 00000000..7a5f2fa2 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/SSCE_Target.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles; +using StardustCore.Animations; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies +{ + public class SSCE_Target:SSCEnemies.SSCEnemy + { + + private bool targetHit; + + public SSCE_Target():base() + { + + } + + public SSCE_Target(AnimatedSprite Sprite, int MoveSpeed, int MaxHealth, Vector2 HitBoxDimensions,float Scale):base(Sprite,MoveSpeed,MaxHealth,HitBoxDimensions,Scale) + { + + } + + public override void die() + { + this.playDeathAnimation(); + } + + public void playDeathAnimation() + { + this.sprite.animation.playAnimationOnce("Die"); + this.targetHit = true; + } + + public override void update(GameTime time) + { + base.update(time); + + if(this.sprite.animation.currentAnimationName=="None" && this.targetHit) + { + this.shouldDie = true; + } + } + + public override void onCollision(SSCProjectile other) + { + if (other is SSCProjectiles.SSCProjectile) + { + this.CurrentHealth -= other.damage; + this.die(); + } + } + + + public static void Spawn_SSCE_Target(Vector2 Position,Color Color) + { + SSCE_Target target = new SSCE_Target(new AnimatedSprite("TargetPractice", Position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Enemies", "Target"), new Animation(0, 0, 16, 16), new Dictionary>() { + { "None",new List(){ + new Animation(0,0,16,16) + } }, + {"Die",new List() + { + new Animation(0,0,16,16,20), + new Animation(16,0,16,16,20), + new Animation(32,0,16,16,20) + } + } + + },"None"), Color), 0, 1, new Vector2(16,16),4f); + SeasideScramble.self.enemies.addEnemy(target); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/SSCEnemy.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/SSCEnemy.cs new file mode 100644 index 00000000..c392f502 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCEnemies/SSCEnemy.cs @@ -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; +using Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces; +using StardustCore.Animations; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies +{ + public class SSCEnemy : ISSCLivingEntity + { + public float MovementSpeed { get; set; } + public int CurrentHealth { get; set; } + public int MaxHealth { get; set; } + public Rectangle HitBox { get; set; } + + public AnimatedSprite sprite; + public bool shouldDie; + public float scale; + + public SSCStatusEffects.StatusEffectManager statusEffects; + + public Vector2 Position + { + get + { + return this.sprite.position; + } + } + + public SSCEnemy() + { + + } + + public SSCEnemy(AnimatedSprite Sprite,int MoveSpeed, int MaxHealth,Vector2 hitBoxDimensions,float Scale) + { + this.sprite = Sprite; + this.MovementSpeed = MoveSpeed; + this.MaxHealth = MaxHealth; + this.HitBox = new Rectangle((int)this.sprite.position.X, (int)this.sprite.position.Y, (int)(hitBoxDimensions.X * Scale),(int)(hitBoxDimensions.Y * Scale)); + this.CurrentHealth = MaxHealth; + this.scale = Scale; + this.statusEffects = new SSCStatusEffects.StatusEffectManager(this); + } + + public virtual void update(GameTime time) + { + + } + public virtual void draw(SpriteBatch b) + { + this.sprite.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, this.Position), this.scale,0f); + } + + public virtual void draw(SpriteBatch b, Vector2 Position, float Scale) + { + this.sprite.draw(b,Position, Scale, 0f); + } + + public virtual void die() + { + + } + + public virtual void onCollision(SSCProjectiles.SSCProjectile other) + { + + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs index a3eea28e..4e44a3e5 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/CharacterSelectScreen.cs @@ -468,8 +468,12 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus 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)); + //p.statusEffects.addStatusEffect(SE_Burn.SpawnBurnEffect(new Vector2(p.HUD.xPositionOnScreen,p.HUD.yPositionOnScreen),10*1000,1000,1.00d,1)); } + + 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); } /// diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs index cd316a4c..24b56872 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs @@ -13,11 +13,8 @@ using Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces; namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { - public class SSCPlayer:ISSCLivingEntity + public class SSCPlayer : ISSCLivingEntity { - //TODO: Add movement speed variable - //TODO: Add in health - //TODO: Add in player HUD public AnimationManager characterSpriteController; public bool flipSprite; public SSCEnums.FacingDirection facingDirection; @@ -55,10 +52,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } } - public float MovementSpeed { get => this.movementSpeed; set => this.movementSpeed=value; } - public int CurrentHealth { get => this.currentHealth; set => this.currentHealth=value; } - public int MaxHealth { get => this.maxHealth; set => this.maxHealth=value; } - public Rectangle HitBox { get => this.hitBox; set => this.hitBox=value; } + public float MovementSpeed { get => this.movementSpeed; set => this.movementSpeed = value; } + public int CurrentHealth { get => this.currentHealth; set => this.currentHealth = value; } + public int MaxHealth { get => this.maxHealth; set => this.maxHealth = value; } + public Rectangle HitBox { get => this.hitBox; set => this.hitBox = value; } public SSCPlayer(SSCEnums.PlayerID PlayerID) { @@ -148,7 +145,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } this.mouseSensitivity = new Vector2(3f, 3f); - this.gun=new SSCGuns.SSCGun(new StardustCore.Animations.AnimatedSprite("MyFirstGun",this.position,new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns","BasicGun"),new Animation(0,0,16,16)),Color.White), SeasideScramble.self.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300),10,1000,3000); + this.gun = new SSCGuns.SSCGun(new StardustCore.Animations.AnimatedSprite("MyFirstGun", this.position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns", "BasicGun"), new Animation(0, 0, 16, 16)), Color.White), SeasideScramble.self.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300), 10, 1000, 3000); this.hitBox = new Rectangle((int)this.position.X, (int)this.position.Y, 64, 64); @@ -211,7 +208,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame 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)); - this.gun.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position),2f); + this.gun.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), 2f); } public void drawMouse(SpriteBatch b) { @@ -220,7 +217,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame public void drawHUD(SpriteBatch b) { this.HUD.draw(b); - this.statusEffects.draw(b,4f); + this.statusEffects.draw(b, 4f); } /// @@ -347,7 +344,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { if (state.ThumbSticks.Right.X != 0 || state.ThumbSticks.Right.Y != 0) { - this.moveMouseCursor(new Vector2(state.ThumbSticks.Right.X,state.ThumbSticks.Right.Y*-1)); + this.moveMouseCursor(new Vector2(state.ThumbSticks.Right.X, state.ThumbSticks.Right.Y * -1)); this.showMouseCursor = true; } } @@ -361,15 +358,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(direction.X * this.mouseSensitivity.X, direction.Y * this.mouseSensitivity.Y))) { - this.mouseCursor.position += new Vector2(direction.X*this.mouseSensitivity.X,direction.Y*this.mouseSensitivity.Y); + this.mouseCursor.position += new Vector2(direction.X * this.mouseSensitivity.X, direction.Y * this.mouseSensitivity.Y); } - else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(direction.X*this.mouseSensitivity.X, 0))) + else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(direction.X * this.mouseSensitivity.X, 0))) { this.mouseCursor.position += new Vector2(direction.X * this.mouseSensitivity.X, 0); } - else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(0, direction.Y*this.mouseSensitivity.Y))) + else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(0, direction.Y * this.mouseSensitivity.Y))) { - this.mouseCursor.position += new Vector2(0, direction.Y*this.mouseSensitivity.Y); + this.mouseCursor.position += new Vector2(0, direction.Y * this.mouseSensitivity.Y); } } @@ -393,7 +390,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame Vector2 pos = this.mouseCursor.position - SeasideScramble.GlobalToLocal(this.position); return pos; } - + /// /// Checks when the player presses a key on the keyboard. @@ -525,13 +522,14 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame //SeasideScramble.self.projectiles.spawnDefaultProjectile(this, this.position, direction, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300); this.gun.tryToShoot(this.position, direction); - + } public void takeDamage(int amount) { this.currentHealth -= amount; - if (this.currentHealth < 0) { + if (this.currentHealth < 0) + { this.currentHealth = 0; } } @@ -546,5 +544,33 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame this.currentHealth = this.maxHealth; } + public void onCollision(SSCProjectiles.SSCProjectile projectile) + { + + if (projectile is SSCProjectiles.SSCProjectile) + { + + if (projectile.hasOwner()) + { + if (projectile.owner == this) + { + //ModCore.log("Can't get hit by own projectile."); + return; + } + /*if projectile.owner is player and friendly fire is off do nothing. + * + * + */ + } + ModCore.log("Big oof. Player hit by projectile."); + this.CurrentHealth -= projectile.damage; + this.statusEffects.addStatusEffect(projectile.effect); + } + } + public void onCollision(SSCEnemies.SSCEnemy enemy) + { + + } + } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs index 512daf2f..0cadbe70 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs @@ -56,11 +56,13 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles } } + public SSCStatusEffects.StatusEffect effect; + public SSCProjectile() { } - public SSCProjectile(object Owner,AnimatedSprite Sprite,Rectangle HitBox ,Vector2 Position,Vector2 Direction, float Speed, int LifeSpan ,float Scale,int damage) + public SSCProjectile(object Owner,AnimatedSprite Sprite,Rectangle HitBox ,Vector2 Position,Vector2 Direction, float Speed, int LifeSpan ,float Scale,int damage,SSCStatusEffects.StatusEffect Effect=null) { this.sprite = Sprite; this.hitBox = HitBox; @@ -72,6 +74,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles this.currentLifeSpan = LifeSpan; this.owner = Owner; this.damage = damage; + this.effect = Effect; } /// @@ -142,14 +145,18 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles return this.hitBox.Intersects(rec); } + /// + /// What happens to this projectile when it collides with something. + /// public virtual void collisionLogic() { - //Do something I guess. + //Do something I guess like play an animation. this.die(); } public virtual void onCollision(object other) { + //Move this if to the player class.???? if(other is SSCPlayer) { if (this.hasOwner()) @@ -159,10 +166,14 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles //ModCore.log("Can't get hit by own projectile."); return; } + /*if projectile.owner is player and friendly fire is off do nothing. + * + * + */ } ModCore.log("Big oof. Player hit by projectile."); - this.collisionLogic(); } + this.collisionLogic(); } /// diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs index f9429e4a..ecb3a106 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs @@ -48,6 +48,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles if (p.collidesWith(player.hitBox)) { p.onCollision(player); + player.onCollision(p); + } + } + foreach(SSCEnemies.SSCEnemy enemy in SeasideScramble.self.enemies.enemies) + { + if (p.collidesWith(enemy.HitBox)) + { + p.onCollision(enemy); //What happens to the projectile. + enemy.onCollision(p); //What happens to the entity. } } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/StatusEffectManager.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/StatusEffectManager.cs index 86d1e7bd..7dffa32f 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/StatusEffectManager.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/StatusEffectManager.cs @@ -11,8 +11,7 @@ using StardewValley; namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCStatusEffects { /// - /// TODO: Maybe figure out a way to add immunity/resistences/weaknesses later??? - /// Add in a reference to the owner of this and have the manager apply effects to entities. + /// TODO: Have it so that this determines where to draw the status effects. /// public class StatusEffectManager { @@ -55,7 +54,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCStatusEffects /// public void addStatusEffect(StatusEffect effect, bool ignoreEffectChance = false) { - + if (effect == null) return; if (ignoreEffectChance == false) { double rng = this.random.NextDouble(); diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs index cb393103..5dae7b0f 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs @@ -50,6 +50,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame public Vector2 oldMousePosition; public SSCProjectiles.SSCProjectileManager projectiles; + public SSCEnemies.EnemyManager enemies; public SSCFonts.SSCFont gameFont; @@ -79,6 +80,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame this.oldMousePosition = new Vector2(Game1.getMousePosition().X, Game1.getMousePosition().Y); this.gameFont = new SSCFonts.SSCFont(new SSCFonts.SSCFontCharacterSheet()); + this.enemies = new SSCEnemies.EnemyManager(); } public SSCPlayer getPlayer(SSCEnums.PlayerID id) @@ -97,20 +99,21 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame 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")); - - TextureManager UIManager = new TextureManager("SSCUI"); UIManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "UI")); TextureManager projectileManager = new TextureManager("Projectiles"); projectileManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Projectiles")); TextureManager gunManager = new TextureManager("Guns"); gunManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Guns")); + TextureManager enemies = new TextureManager("Enemies"); + enemies.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Enemies")); this.textureUtils.addTextureManager(playerManager); this.textureUtils.addTextureManager(mapTextureManager); this.textureUtils.addTextureManager(UIManager); this.textureUtils.addTextureManager(projectileManager); this.textureUtils.addTextureManager(gunManager); + this.textureUtils.addTextureManager(enemies); } private void LoadMaps() @@ -180,6 +183,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame p.drawMouse(b); } } + this.enemies.draw(b); this.menuManager.drawAll(b); @@ -349,6 +353,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame GamePadState state = this.getGamepadState((PlayerIndex)i); this.receiveGamepadInput(state,(SSCEnums.PlayerID)i); } + if (this.quitGame) @@ -372,6 +377,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame { player.update(time); } + this.enemies.update(time); } else { diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 6d3484f1..ce293b21 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -65,10 +65,14 @@ + + + + @@ -141,6 +145,9 @@ PreserveNewest + + Always + Always diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index 7f19e4c6..2ec98bc8 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -18,6 +18,7 @@ namespace StardustCore.Animations public Animation defaultDrawFrame; public Animation currentAnimation; public bool enabled; + public bool loopAnimation; public string animationDataString; @@ -95,12 +96,20 @@ namespace StardustCore.Animations } } - /// Get the next animation in the list of animations. + /// Get the next animation frame in the list of animations. public void getNextAnimation() { this.currentAnimationListIndex++; if (this.currentAnimationListIndex == this.currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. - this.currentAnimationListIndex = 0; + if (this.loopAnimation) + { + this.currentAnimationListIndex = 0; + } + else + { + this.playDefaultAnimation(); + return; + } //Get the next animation from the list and reset it's counter to the starting frame value. this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; @@ -137,9 +146,13 @@ namespace StardustCore.Animations } } - /// Gets the animation from the dictionary of all animations available. + /// + /// Plays the animation for the animation manager. + /// /// + /// /// + /// public bool playAnimation(string AnimationName,bool overrideSameAnimation=false,int StartingFrame = 0) { if (this.animations.TryGetValue(AnimationName, out List dummyList)) @@ -154,6 +167,7 @@ namespace StardustCore.Animations this.currentAnimation = this.currentAnimationList[StartingFrame]; this.currentAnimationName = AnimationName; this.currentAnimation.startAnimation(); + this.loopAnimation = true; return true; } else @@ -172,6 +186,56 @@ namespace StardustCore.Animations } } + /// + /// Plays the animation for the animation manager only once. + /// + /// + /// + /// + /// + public bool playAnimationOnce(string AnimationName, bool overrideSameAnimation = false, int StartingFrame = 0) + { + if (this.animations.TryGetValue(AnimationName, out List dummyList)) + { + if (overrideSameAnimation == false) + { + if (this.currentAnimationName == AnimationName) return true; + } + if (dummyList.Count != 0 || StartingFrame >= dummyList.Count) + { + this.currentAnimationList = dummyList; + this.currentAnimation = this.currentAnimationList[StartingFrame]; + this.currentAnimationName = AnimationName; + this.currentAnimation.startAnimation(); + this.loopAnimation = false; + return true; + } + else + { + if (dummyList.Count == 0) + ModCore.ModMonitor.Log("Error: Current animation " + AnimationName + " has no animation frames associated with it."); + if (dummyList.Count > dummyList.Count) + ModCore.ModMonitor.Log("Error: Animation frame " + StartingFrame + " is outside the range of provided animations. Which has a maximum count of " + dummyList.Count); + return false; + } + } + else + { + ModCore.ModMonitor.Log("Error setting animation: " + AnimationName + " animation does not exist in list of available animations. Did you make sure to add it in?"); + return false; + } + } + + /// + /// Plays the default animation. + /// + public void playDefaultAnimation() + { + this.currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + this.currentAnimationListIndex = 0; + } + /// Sets the animation manager to an on state, meaning that this animation will update on the draw frame. public void enableAnimation() {