From c7633a2a041b9a1658174886ff35029034a4038d Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 24 Jul 2019 17:24:36 -0700 Subject: [PATCH] Added in a gun manager for easier assignment of guns. Also added in heatwave a gun that spawns fire like crazy. --- .../Graphics/Projectiles/Fire.png | Bin 0 -> 223 bytes .../SeasideScrambleMinigame/SSCGuns/SSCGun.cs | 12 ++++- .../SSCGuns/SSCGunManager.cs | 48 ++++++++++++++++++ .../SSCGuns/SSCGun_HeatWave.cs | 39 ++++++++++++++ .../SSCMaps/SeasideScrambleMap.cs | 3 +- .../SeasideScrambleMinigame/SSCPlayer.cs | 20 +++++++- .../SSCProjectiles/SSCProjectile.cs | 7 ++- .../SSCProjectiles/SSCProjectileManager.cs | 15 ++++++ .../SSCProjectiles/SSC_FireProjectile.cs | 29 +++++++++++ .../SeasideScramble.cs | 4 +- GeneralMods/Revitalize/Revitalize.csproj | 48 ++++++++++-------- 11 files changed, 199 insertions(+), 26 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Projectiles/Fire.png create mode 100644 GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGunManager.cs create mode 100644 GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun_HeatWave.cs create mode 100644 GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_FireProjectile.cs diff --git a/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Projectiles/Fire.png b/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Projectiles/Fire.png new file mode 100644 index 0000000000000000000000000000000000000000..0d2bf2ba727f64bbca723e0e5d1067455f164ddb GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^LO?9Q!3HFy+4N(8)G|*O#}JF&Z_%`~HB!8II8N2SDJ6gX)0@w$hVECesC&45qs}#=4n` zZ>%}?P-y8%_l;RQrgI0f2j4$j@Wnnf_K3#e0}YRqc&0z`aCo7qzhM`TSlAVA>P5x=4Hx=+ZRnus9&mtlWPvnO`^OLh|XxTbi>4!{4d1WK8?b*yw0-zopr0CL|=-2eap literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun.cs index f2a6a32a..60e730ab 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun.cs @@ -23,7 +23,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCGuns /// /// The projectile this gun uses. /// - private SSCProjectile _projectile; + public SSCProjectile _projectile; /// /// The sprite for the gun. /// @@ -101,6 +101,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCGuns } } + public SSCGun() + { + + } + /// /// Constructor. /// @@ -251,5 +256,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCGuns { return this.hasAmmo && this.remainingFiringDelay <= 0 && this.isReloading == false; //Could remove the isReloding condition and do guns like revolvers. } + + public virtual SSCGun getCopy() + { + return new SSCGun(new AnimatedSprite(this.sprite.name, this.Position, new AnimationManager(this.sprite.animation.objectTexture, this.sprite.animation.defaultDrawFrame, this.sprite.animation.animations, this.sprite.animation.currentAnimationName), this.sprite.color), this._projectile, this.maxAmmo, this.firingDelay, this.reloadSpeed, this.consumesXAmmoPerShot); + } } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGunManager.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGunManager.cs new file mode 100644 index 00000000..de9e5131 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGunManager.cs @@ -0,0 +1,48 @@ +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.SSCStatusEffects; +using StardustCore.Animations; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCGuns +{ + public class SSCGunManager + { + + public Dictionary guns; + + public SSCGunManager() + { + this.guns = new Dictionary(); + + this.guns.Add("Default", new SSCGuns.SSCGun(new StardustCore.Animations.AnimatedSprite("MyFirstGun", Vector2.Zero, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns", "BasicGun"), new Animation(0, 0, 16, 16)), Color.White), SeasideScramble.self.entities.projectiles.getDefaultProjectile(this, Vector2.Zero, Vector2.Zero, 4f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300), 10, 1000, 3000)); + this.guns.Add("HeatWave", new SSCGuns.SSCGun_HeatWave(new StardustCore.Animations.AnimatedSprite("HeatWave", Vector2.Zero, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns", "BasicGun"), new Animation(0, 0, 18, 16)), Color.Red), SeasideScramble.self.entities.projectiles.getFireProjectile(this, Vector2.Zero, Vector2.Zero, 1.5f, new Rectangle(0, 0, 18, 16), Color.White, 3f, 3, SE_Burn.SpawnBurnEffect(Vector2.Zero, 3 * 1000, 1000, 1.00d, 2),150), 20, 200, 5000)); + } + + /// + /// Gets a gun from the list of made guns. + /// + /// + /// + public SSCGun getGun(string name) + { + if (this.guns.ContainsKey(name)) + { + return this.guns[name].getCopy(); + } + else + { + return null; + } + } + + public SSCGun getDefaultGun() + { + return this.getGun("Default"); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun_HeatWave.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun_HeatWave.cs new file mode 100644 index 00000000..fa69d8d5 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCGuns/SSCGun_HeatWave.cs @@ -0,0 +1,39 @@ +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.SSCGuns +{ + public class SSCGun_HeatWave:SSCGun + { + + public SSCGun_HeatWave(AnimatedSprite Sprite, SSCProjectile Projectile, int MaxAmmo, double FiringRate, double ReloadSpeed, int ConsumesXAmmo = 1):base(Sprite,Projectile,MaxAmmo,FiringRate,ReloadSpeed,ConsumesXAmmo) + { + } + + public override void tryToShoot(Vector2 Position, Vector2 Direction) + { + if (this.hasAmmo == false) + { + this.startReload(); + return; + } + if (this.canShoot()) + { + this.shoot(Position, Direction); + StardewValley.Game1.playSound("fireball"); + //StardewValley.Game1.playSound("Cowboy_gunshot"); + } + } + + public override SSCGun getCopy() + { + return new SSCGun_HeatWave(new AnimatedSprite(this.sprite.name, this.Position, new AnimationManager(this.sprite.animation.objectTexture, this.sprite.animation.defaultDrawFrame, this.sprite.animation.animations, this.sprite.animation.currentAnimationName), this.sprite.color), this._projectile, this.maxAmmo, this.firingDelay, this.reloadSpeed, this.consumesXAmmoPerShot); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs index e6159450..7d92aac7 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMaps/SeasideScrambleMap.cs @@ -20,7 +20,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame /// /// TODO: /// Force maps to all have the same layers as SDV maps so we can draw different things on a map. - /// + /// Add player respawn timer in to shooting gallery mode. + /// Reduce player Max HP to 10? /// /* * Back: Terrain, water, and basic features (like permanent paths). diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs index 6e6eddb7..eca0bd79 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs @@ -216,7 +216,8 @@ 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.entities.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 4f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300), 10, 1000, 3000); + this.getNewGun(SeasideScramble.self.guns.getGun("HeatWave")); //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.entities.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 4f, 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); @@ -243,6 +244,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame this.statusEffects = new SSCStatusEffects.StatusEffectManager(this); } + + /// /// Sets the color for the player. /// @@ -308,6 +311,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame if (this.currentHealth < 0) this.currentHealth = 0; this.gun.update(Time); + this.updateGunPosition(); this.HUD.update(Time); this.statusEffects.update(Time); @@ -694,5 +698,19 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } + public void getNewGun(SSCGuns.SSCGun gun) + { + this.gun = gun; + //this.gun.Projectile.position = this.position; + this.gun.Position = this.position; + this.gun.Projectile.owner = this; + } + + public void updateGunPosition() + { + this.gun.Projectile.position = this.position; + this.gun.Position = this.position; + } + } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs index 2388fd28..7cbf0113 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs @@ -47,6 +47,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles set { this.sprite.position = value; + this.hitBox.X =(int) this.sprite.position.X; + this.hitBox.Y = (int)this.sprite.position.Y; } } /// @@ -142,6 +144,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles { if (this.currentLifeSpan <= 0) { + //ModCore.log("Lifespan is over!"); this.die(); } else @@ -201,6 +204,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles { if (this.hasOwner()) { + //ModCore.log("Has an owner!"); if (this.owner == other) { //ModCore.log("Can't get hit by own projectile."); @@ -214,6 +218,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles } } } + //ModCore.log("COllision!!!!"); this.collisionLogic(); } @@ -234,7 +239,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles public virtual void spawnClone(Vector2 position,Vector2 direction) { //AnimatedSprite newSprite = new AnimatedSprite(this.sprite.name, position, new AnimationManager(this.sprite.animation.objectTexture.Copy(), this.sprite.animation.defaultDrawFrame), this.color); - SSCProjectile basic = new SSCProjectile(this.owner, new AnimatedSprite("DefaultProjectile", position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Basic"), new Animation(0, 0, 4, 4)), this.color), new Rectangle(this.hitBox.X,this.hitBox.Y,this.hitBox.Width,this.hitBox.Height), position, direction, this.speed, this.maxLifeSpan, this.scale,this.damage); + SSCProjectile basic = new SSCProjectile(this.owner, new AnimatedSprite("DefaultProjectile", position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Basic"), new Animation(0, 0, 4, 4)), this.color), new Rectangle(this.hitBox.X,this.hitBox.Y,this.hitBox.Width,this.hitBox.Height), position, direction, this.speed, this.maxLifeSpan, this.scale,this.damage,this.effect); SeasideScramble.self.entities.projectiles.addProjectile(basic); } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs index 68876a93..8ac0d926 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using StardustCore.Animations; namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles { @@ -64,6 +65,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles Vector2 mapSize = SeasideScramble.self.currentMap.getPixelSize(); if (p.position.X > mapSize.X * 2 || p.position.X < -mapSize.X || p.position.Y > mapSize.Y * 2 || p.position.Y < -mapSize.Y) { + //ModCore.log("Clean up projectile. Position is: " + p.position); this.deleteProjectile(p); } } @@ -95,6 +97,19 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles return basic; } + public void spawnFireProjectile(object Owner, Vector2 Position, Vector2 Direction, float Speed, Rectangle HitBox, Color Color, float Scale,int Damage,SSCStatusEffects.SE_Burn BurnEffect ,int LifeSpan = 300) + { + + SSC_FireProjectile basic = new SSC_FireProjectile(Owner, new AnimatedSprite("FireProjectile", Position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Fire"), new Animation(0, 0, 4, 4)), Color), new Rectangle(HitBox.X, HitBox.Y, HitBox.Width, HitBox.Height), Position, Direction, Speed, LifeSpan, Scale, Damage, BurnEffect); + this.addProjectile(basic); + } + public SSCProjectile getFireProjectile(object Owner, Vector2 Position, Vector2 Direction, float Speed, Rectangle HitBox, Color Color, float Scale,int Damage, SSCStatusEffects.SE_Burn BurnEffect, int LifeSpan = 150) + { + + SSC_FireProjectile basic = new SSC_FireProjectile(Owner, new AnimatedSprite("FireProjectile", Position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Fire"), new Animation(0, 0, 4, 4)), Color), new Rectangle(HitBox.X, HitBox.Y, HitBox.Width, HitBox.Height), Position, Direction, Speed, LifeSpan, Scale, Damage,BurnEffect); + return basic; + } + #endregion } } diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_FireProjectile.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_FireProjectile.cs new file mode 100644 index 00000000..c0c0adb4 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_FireProjectile.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using StardustCore.Animations; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles +{ + public class SSC_FireProjectile: SSCProjectile + { + public SSC_FireProjectile() + { + + } + public SSC_FireProjectile(object Owner, AnimatedSprite Sprite, Rectangle HitBox, Vector2 Position, Vector2 Direction, float Speed, int LifeSpan, float Scale, int damage, SSCStatusEffects.StatusEffect Effect = null):base(Owner,Sprite,HitBox,Position,Direction,Speed,LifeSpan,Scale,damage,Effect) + { + } + + + public override void spawnClone(Vector2 position, Vector2 direction) + { + //AnimatedSprite newSprite = new AnimatedSprite(this.sprite.name, position, new AnimationManager(this.sprite.animation.objectTexture.Copy(), this.sprite.animation.defaultDrawFrame), this.color); + SSC_FireProjectile basic = new SSC_FireProjectile(this.owner, new AnimatedSprite("FireProjectile", position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Fire"), new Animation(0, 0, 18, 16)), this.color), new Rectangle((int)this.position.X, (int)this.position.Y, this.hitBox.Width, this.hitBox.Height), position, direction, this.speed, this.maxLifeSpan, this.scale, this.damage,this.effect); + SeasideScramble.self.entities.projectiles.addProjectile(basic); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs index 20f95184..70b9d4b3 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SeasideScramble.cs @@ -62,6 +62,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame public Vector2 oldMousePosition; public SSCEntities.SSCEntityManager entities; + public SSCGuns.SSCGunManager guns; public SSCFonts.SSCFont gameFont; @@ -111,6 +112,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.guns = new SSCGuns.SSCGunManager(); } public SSCPlayer getPlayer(SSCEnums.PlayerID id) @@ -254,7 +256,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } if(Mode== SSCEnums.SSCGameMode.ShootingGallery) { - this.friendlyFireEnabled = false; + this.friendlyFireEnabled = true; } if(Mode== SSCEnums.SSCGameMode.PVP) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index fc230ca5..1fba26aa 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -71,6 +71,8 @@ + + @@ -92,6 +94,7 @@ + @@ -177,68 +180,71 @@ Always + + PreserveNewest + - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest - Always + PreserveNewest Always