From 9ab33bba3887e3bdee02046f47db9873a75cc4b9 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 24 Jul 2019 18:37:43 -0700 Subject: [PATCH] Added in the icicle gun! --- .../Graphics/Projectiles/Icicle.png | Bin 0 -> 334 bytes .../Graphics/UI/StatusEffects/Freeze.png | Bin 0 -> 320 bytes .../SSCGuns/SSCGunManager.cs | 1 + .../SeasideScrambleMinigame/SSCPlayer.cs | 2 +- .../SSCProjectiles/SSCProjectile.cs | 7 +- .../SSCProjectiles/SSCProjectileManager.cs | 13 +++ .../SSCProjectiles/SSC_IcicleProjectile.cs | 41 +++++++++ .../SSCStatusEffects/SE_Freeze.cs | 46 +++++++++++ .../Framework/Utilities/RotationUtilities.cs | 78 ++++++++++++++++++ GeneralMods/Revitalize/Revitalize.csproj | 6 ++ .../StardustCore/Animations/AnimatedSprite.cs | 5 ++ .../Animations/AnimationManager.cs | 28 +++++++ 12 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Projectiles/Icicle.png create mode 100644 GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/UI/StatusEffects/Freeze.png create mode 100644 GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_IcicleProjectile.cs create mode 100644 GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/SE_Freeze.cs create mode 100644 GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs diff --git a/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Projectiles/Icicle.png b/GeneralMods/Revitalize/Content/Minigames/SeasideScramble/Graphics/Projectiles/Icicle.png new file mode 100644 index 0000000000000000000000000000000000000000..3f355af416cb9e5d83998b107cc69474bebd6987 GIT binary patch literal 334 zcmV-U0kQsxP)4-aOVNK5eg!>b1Mppn}Sd)wrIzNPK{~W z;M*iKdGqE?5(EjuDG?Yj8zIWEPzk+muqP`%C-wXF(LNp?_U%bleC~CFy-x5)U^YUW zFKSM|6Gd{q--)96qULaSqOa48gA7Xa!yzImAIQX{>2Cl4z_~2rglx`pG2+{e z(5afh#i@X*s-i0Jk|&mqkXNjO@e=JyX_ptP diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs index eca0bd79..2e029175 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs @@ -216,7 +216,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } this.mouseSensitivity = new Vector2(3f, 3f); - 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.getNewGun(SeasideScramble.self.guns.getGun("Icicle")); //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); diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs index 7cbf0113..5e8dcf1a 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectile.cs @@ -95,6 +95,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles /// public SSCStatusEffects.StatusEffect effect; + public bool pierces; + /// /// Constructor. /// @@ -191,7 +193,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles public virtual void collisionLogic() { //Do something I guess like play an animation. - this.die(); + if (this.pierces == false) + { + this.die(); + } } /// diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs index 8ac0d926..c9b4c83a 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSCProjectileManager.cs @@ -97,6 +97,19 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles return basic; } + public void spawnIcicleProjectile(object Owner, Vector2 Position, Vector2 Direction, float Speed, Rectangle HitBox, Color Color, float Scale,int Damage ,int LifeSpan = 300) + { + + SSC_IcicleProjectile basic = new SSC_IcicleProjectile(Owner, new StardustCore.Animations.AnimatedSprite("Icicle", Position, new StardustCore.Animations.AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Icicle"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color), HitBox, Position, Direction, Speed, LifeSpan, Scale, Damage); + this.addProjectile(basic); + } + public SSC_IcicleProjectile getIcicleProjectile(object Owner, Vector2 Position, Vector2 Direction, float Speed, Rectangle HitBox, Color Color, float Scale,int Damage ,int LifeSpan = 300) + { + + SSC_IcicleProjectile basic = new SSC_IcicleProjectile(Owner, new StardustCore.Animations.AnimatedSprite("Icicle", Position, new StardustCore.Animations.AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Icicle"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color), HitBox, Position, Direction, Speed, LifeSpan, Scale, Damage); + 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) { diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_IcicleProjectile.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_IcicleProjectile.cs new file mode 100644 index 00000000..dcba99ec --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCProjectiles/SSC_IcicleProjectile.cs @@ -0,0 +1,41 @@ +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.Utilities; +using StardustCore.Animations; + +namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles +{ + public class SSC_IcicleProjectile:SSCProjectile + { + public float rotation; + + public SSC_IcicleProjectile() + { + + } + public SSC_IcicleProjectile(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) + { + this.pierces = true; + + } + + + 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_IcicleProjectile basic = new SSC_IcicleProjectile(this.owner, new AnimatedSprite("IcicleProjectile", position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Icicle"), new Animation(0, 0, 16, 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); + basic.rotation = RotationUtilities.getRotationFromVector(direction); + SeasideScramble.self.entities.projectiles.addProjectile(basic); + } + + public override void draw(SpriteBatch b) + { + this.sprite.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, this.position), this.scale,this.rotation ,0.5f); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/SE_Freeze.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/SE_Freeze.cs new file mode 100644 index 00000000..a552503e --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCStatusEffects/SE_Freeze.cs @@ -0,0 +1,46 @@ +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.SSCStatusEffects +{ + public class SE_Freeze:SSCStatusEffects.StatusEffect + { + + public SE_Freeze() + { + + } + + /// + /// Constructor. + /// + /// + /// The number of milliseconds the effect lasts. + /// How many milliseconds pass between the effect triggering. + /// The chance this effect has to trigger. Value between 0-1.0 + /// Can this status effect stack? + public SE_Freeze(StardustCore.Animations.AnimatedSprite Sprite, double Duration, double Frequency, double ChanceToAfflict, bool CanStack, bool ResetsSameTimers) : base(Sprite, Duration, Frequency, ChanceToAfflict, CanStack, ResetsSameTimers) + { + } + + /// + /// Spawn a new burn status effect with the given paramaters. + /// + /// The position to draw the effect. + /// The duration of the effect in milliseconds. + /// The freuency in milliseconds between triggers. + /// The chance to be afflicted. + /// The damage it does per trigger. + /// + public static SE_Freeze SpawnFreezeEffect(Vector2 position, double Duration, double Frequency, double Chance) + { + return new SE_Freeze(new StardustCore.Animations.AnimatedSprite("Freeze", position, new StardustCore.Animations.AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("SSCUI", "Freeze"), new Animation(0, 0, 16, 16)), Color.White), Duration, Frequency, Chance, false, false); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs new file mode 100644 index 00000000..fb6b60e0 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; + +namespace Revitalize.Framework.Utilities +{ + public class RotationUtilities + { + public static float get90Degrees() + { + float angle = (float)Math.PI * .5f; + return angle; + } + + public static float get180Degrees() + { + float angle = (float)Math.PI; + return angle; + } + + public static float get270Degrees() + { + float angle = (float)Math.PI * (1.5f); + return angle; + } + + public static float get360Degrees() + { + return 0; + } + + /// + /// Gets a rotation from the degrees passed in. + /// + /// + /// + public static float getRotationFromDegrees(int degrees) + { + float amount = degrees / 180; + float angle = (float)Math.PI * (amount); + return angle; + } + + /// + /// Gets an angle from a passed in vector. + /// + /// + /// + public static float getAngleFromVector(Vector2 vec) + { + Vector2 zero = new Vector2(1,0); + vec = vec.UnitVector(); + float dot=Vector2.Dot(zero, vec); + float len1 = vec.Length(); + float len2 = zero.Length(); + float lenTotal = len1 * len2; + float cosAngle = dot / lenTotal; + + float angle = (float)((Math.Acos(cosAngle)*180)/Math.PI); + return angle; + + } + + /// + /// Gets a rotation amount for xna based off the unit circle. + /// + /// + /// + public static float getRotationFromVector(Vector2 vec) + { + return getRotationFromDegrees((int)Math.Round(getAngleFromVector(vec))); + } + + } +} diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 1fba26aa..dcdba1aa 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -95,7 +95,9 @@ + + @@ -125,6 +127,7 @@ + @@ -183,6 +186,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs index 0c57ea44..952e9009 100644 --- a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs +++ b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs @@ -95,6 +95,11 @@ namespace StardustCore.Animations this.animation.draw(b, position, this.color, scale, SpriteEffects.None, depth); } + public virtual void draw(SpriteBatch b, Vector2 position, float scale,float rotation ,float depth) + { + this.animation.draw(b, position, this.color, scale, rotation,SpriteEffects.None, depth); + } + /// /// Draws the sprite to the screen. /// diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index e147ed12..b0222568 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -383,6 +383,20 @@ namespace StardustCore.Animations } } + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, float scale,float Rotation ,SpriteEffects flipped, float depth) + { + b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, Rotation, Vector2.Zero, scale, flipped, depth); + try + { + this.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + /// /// Draws the animated texture to the screen. /// @@ -406,6 +420,20 @@ namespace StardustCore.Animations } } + public void draw(SpriteBatch b, Vector2 Position, Color drawColor, Vector2 scale, float Rotation,SpriteEffects flipped, float depth) + { + b.Draw(this.objectTexture.texture, Position, this.currentAnimation.sourceRectangle, drawColor, Rotation, Vector2.Zero, scale, flipped, depth); + try + { + this.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + public Texture2DExtended getExtendedTexture() { return this.objectTexture;