Added in kill zones but also just made it so if enemies or projectiles go too far off the map they die. Also finished making spawners for targets and reworked managers to be stored in a single entity manager.
This commit is contained in:
parent
c5e4b5ecdc
commit
1838c80ccb
|
@ -0,0 +1,22 @@
|
|||
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.Interfaces
|
||||
{
|
||||
public interface ISpawner
|
||||
{
|
||||
|
||||
void update(GameTime Time);
|
||||
void draw(SpriteBatch b);
|
||||
bool enabled
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces;
|
||||
|
||||
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
||||
{
|
||||
|
@ -13,6 +14,9 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
public List<SSCEnemy> enemies;
|
||||
private List<SSCEnemy> garbageCollection;
|
||||
|
||||
private List<ISpawner> spawnerGarbageCollection;
|
||||
public List<ISpawner> spawners;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
|
@ -20,6 +24,9 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
{
|
||||
this.enemies = new List<SSCEnemy>();
|
||||
this.garbageCollection = new List<SSCEnemy>();
|
||||
|
||||
this.spawners = new List<ISpawner>();
|
||||
this.spawnerGarbageCollection = new List<ISpawner>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -39,12 +46,31 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
this.garbageCollection.Add(enemy);
|
||||
}
|
||||
|
||||
public void addSpawner(ISpawner spawner)
|
||||
{
|
||||
this.spawners.Add(spawner);
|
||||
}
|
||||
public void removeSpawner(ISpawner spawner)
|
||||
{
|
||||
this.spawnerGarbageCollection.Add(spawner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update all enemies.
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
public void update(GameTime time)
|
||||
{
|
||||
|
||||
foreach(ISpawner spawner in this.spawnerGarbageCollection)
|
||||
{
|
||||
this.spawners.Remove(spawner);
|
||||
}
|
||||
foreach(ISpawner spawner in this.spawners)
|
||||
{
|
||||
spawner.update(time);
|
||||
}
|
||||
|
||||
foreach(SSCEnemy enemy in this.garbageCollection)
|
||||
{
|
||||
this.enemies.Remove(enemy);
|
||||
|
@ -53,7 +79,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
{
|
||||
enemy.update(time);
|
||||
if (enemy.shouldDie) this.removeEnemy(enemy);
|
||||
//Delete enemies that are too far off screen.
|
||||
Vector2 mapSize = SeasideScramble.self.currentMap.getPixelSize();
|
||||
if (enemy.Position.X>mapSize.X*2 || enemy.Position.X<-mapSize.X || enemy.Position.Y>mapSize.Y*2|| enemy.Position.Y < -mapSize.Y)
|
||||
{
|
||||
enemy.shouldDie = true; //Silently remove the enemy from the map.
|
||||
this.removeEnemy(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -66,6 +100,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
{
|
||||
enemy.draw(b);
|
||||
}
|
||||
foreach(ISpawner spawner in this.spawners)
|
||||
{
|
||||
spawner.draw(b);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
||||
{
|
||||
public class KillZone
|
||||
{
|
||||
private Vector2 position;
|
||||
public Rectangle hitBox;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position of the kill zone as well as the position of the kill zone hit box.
|
||||
/// </summary>
|
||||
public Vector2 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.position = value;
|
||||
this.hitBox.X = (int)this.position.X;
|
||||
this.hitBox.Y = (int)this.position.Y;
|
||||
}
|
||||
}
|
||||
|
||||
public KillZone()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public KillZone(Vector2 Position,Rectangle HitBox)
|
||||
{
|
||||
this.hitBox = HitBox;
|
||||
this.Position = Position;
|
||||
}
|
||||
|
||||
public void onCollision(SSCProjectiles.SSCProjectile projectile)
|
||||
{
|
||||
//Do nothing???
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardustCore.Animations;
|
||||
|
||||
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
||||
|
@ -14,14 +15,25 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
|
||||
private bool targetHit;
|
||||
|
||||
public Vector2 direction;
|
||||
public float speed;
|
||||
public Vector2 Velocity
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.direction * this.speed;
|
||||
}
|
||||
}
|
||||
|
||||
public SSCE_Target():base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SSCE_Target(AnimatedSprite Sprite, int MoveSpeed, int MaxHealth, Vector2 HitBoxDimensions,float Scale):base(Sprite,MoveSpeed,MaxHealth,HitBoxDimensions,Scale)
|
||||
public SSCE_Target(AnimatedSprite Sprite, int MoveSpeed, int MaxHealth, Vector2 HitBoxDimensions,float Scale,Vector2 Direction,float Speed):base(Sprite,MoveSpeed,MaxHealth,HitBoxDimensions,Scale)
|
||||
{
|
||||
|
||||
this.direction = Direction;
|
||||
this.speed = Speed;
|
||||
}
|
||||
|
||||
public override void die()
|
||||
|
@ -35,14 +47,28 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
this.targetHit = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the state of the enemy.
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
if(this.sprite.animation.IsAnimationPlaying==false && this.targetHit)
|
||||
{
|
||||
this.shouldDie = true;
|
||||
}
|
||||
this.updateMovement();
|
||||
}
|
||||
|
||||
public override void updateMovement()
|
||||
{
|
||||
this.Position += this.Velocity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What happens when the target collides with a projectile.
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
public override void onCollision(SSCProjectile other)
|
||||
{
|
||||
if (other is SSCProjectiles.SSCProjectile)
|
||||
|
@ -54,6 +80,18 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
|
||||
|
||||
public static void Spawn_SSCE_Target(Vector2 Position,Color Color)
|
||||
{
|
||||
Spawn_SSCE_Target(Position, Color, Vector2.Zero, 0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawn a target enemy with the given paramaters.
|
||||
/// </summary>
|
||||
/// <param name="Position"></param>
|
||||
/// <param name="Color"></param>
|
||||
/// <param name="Direction"></param>
|
||||
/// <param name="Speed"></param>
|
||||
public static void Spawn_SSCE_Target(Vector2 Position, Color Color,Vector2 Direction, float Speed)
|
||||
{
|
||||
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<string, List<Animation>>() {
|
||||
{ "None",new List<Animation>(){
|
||||
|
@ -67,8 +105,8 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
}
|
||||
}
|
||||
|
||||
},"None"), Color), 0, 1, new Vector2(16,16),4f);
|
||||
SeasideScramble.self.enemies.addEnemy(target);
|
||||
}, "None"), Color), 0, 1, new Vector2(16, 16), 4f, Direction.UnitVector(), Speed);
|
||||
SeasideScramble.self.entities.addEnemy(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,14 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
{
|
||||
return this.sprite.position;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.sprite.position = value;
|
||||
Rectangle hit = this.HitBox;
|
||||
hit.X = (int)this.Position.X;
|
||||
hit.Y = (int)this.Position.Y;
|
||||
this.HitBox = hit;
|
||||
}
|
||||
}
|
||||
|
||||
public SSCEnemy()
|
||||
|
@ -71,5 +79,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
|
|||
|
||||
}
|
||||
|
||||
public virtual void updateMovement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
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;
|
||||
|
||||
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies.Spawners
|
||||
{
|
||||
public class Target_Spawner:ISpawner
|
||||
{
|
||||
|
||||
public Vector2 position;
|
||||
/// <summary>
|
||||
/// The max time in milliseconds between spawns.
|
||||
/// </summary>
|
||||
public double maxFrequency;
|
||||
/// <summary>
|
||||
/// The min time in milliseconds between spawns.
|
||||
/// </summary>
|
||||
public double minFrequency;
|
||||
|
||||
/// <summary>
|
||||
/// The time until the next spawn.
|
||||
/// </summary>
|
||||
public double timeUntilNextSpawn;
|
||||
|
||||
/// <summary>
|
||||
/// Randomizes the spawn time between spawns between 0 and this.frequency.
|
||||
/// </summary>
|
||||
public bool randomizeSpawnTimes;
|
||||
|
||||
public Vector2 spawnDirection;
|
||||
|
||||
public Color spawnColor;
|
||||
public bool randomizeColor;
|
||||
/// <summary>
|
||||
/// The max speed a target can travel at.
|
||||
/// </summary>
|
||||
public float maxSpeed;
|
||||
public float minSpeed;
|
||||
|
||||
public bool enabled { get; set; }
|
||||
|
||||
public Target_Spawner()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="Position">The position of the spawner.</param>
|
||||
/// <param name="SpawnDirection">The direction to spawn targets.</param>
|
||||
/// <param name="Color">The default color of targets that are spawned.</param>
|
||||
/// <param name="RandomizeColor">Should the color be randomized every time a target is spawned?</param>
|
||||
/// <param name="MaxFrequency">The max amount of time between spawns.</param>
|
||||
/// <param name="MinFrequency">The min amount of time between spawns.</param>
|
||||
/// <param name="RandomizeSpawnTime">Should the frequency between spawns be randomized?</param>
|
||||
/// <param name="MinSpeed"></param>
|
||||
/// <param name="MaxSpeed"></param>
|
||||
public Target_Spawner(Vector2 Position,Vector2 SpawnDirection ,Color Color,bool RandomizeColor,double MinFrequency,double MaxFrequency,bool RandomizeSpawnTime,float MinSpeed,float MaxSpeed,bool Enabled)
|
||||
{
|
||||
this.position = Position;
|
||||
this.spawnDirection = SpawnDirection;
|
||||
|
||||
this.spawnColor = Color;
|
||||
this.randomizeColor = RandomizeColor;
|
||||
|
||||
this.minFrequency = MinFrequency;
|
||||
this.maxFrequency = MaxFrequency;
|
||||
this.randomizeSpawnTimes = RandomizeSpawnTime;
|
||||
this.setNextSpawnTime();
|
||||
|
||||
this.minSpeed = MinSpeed;
|
||||
this.maxSpeed = MaxSpeed;
|
||||
this.enabled = Enabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the time until the next spawn.
|
||||
/// </summary>
|
||||
private void setNextSpawnTime()
|
||||
{
|
||||
if (this.randomizeSpawnTimes)
|
||||
{
|
||||
this.timeUntilNextSpawn = SeasideScramble.self.random.NextDouble() * this.maxFrequency;
|
||||
if (this.timeUntilNextSpawn < this.minFrequency) this.timeUntilNextSpawn = this.minFrequency;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.timeUntilNextSpawn = this.maxFrequency;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the logic of the spawner.
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
public void update(GameTime time)
|
||||
{
|
||||
if (this.enabled == false) return;
|
||||
this.timeUntilNextSpawn -= time.ElapsedGameTime.Milliseconds;
|
||||
if (this.timeUntilNextSpawn <= 0)
|
||||
{
|
||||
this.spawn(this.position, this.spawnDirection, this.randomizeColor ? this.getRandomColor() : this.spawnColor, (float)this.getRandomSpeed());
|
||||
this.setNextSpawnTime();
|
||||
}
|
||||
}
|
||||
public void draw(SpriteBatch b)
|
||||
{
|
||||
//Do I really want to draw a spawner???
|
||||
}
|
||||
|
||||
|
||||
public void turnOn()
|
||||
{
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public void turnOff()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a random color for the spawned target.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Color getRandomColor()
|
||||
{
|
||||
int red = (int)(SeasideScramble.self.random.NextDouble() * 255);
|
||||
int green = (int)(SeasideScramble.self.random.NextDouble() * 255);
|
||||
int blue = (int)(SeasideScramble.self.random.NextDouble() * 255);
|
||||
Color c = new Color(red, green, blue);
|
||||
return c;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a random speed for the newly spawned target.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private double getRandomSpeed()
|
||||
{
|
||||
double speed = this.maxSpeed * SeasideScramble.self.random.NextDouble();
|
||||
if (speed < this.minSpeed) speed = this.minSpeed;
|
||||
return speed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns a target at this position and sends it a specific direction.
|
||||
/// </summary>
|
||||
/// <param name="Direction"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <param name="Speed"></param>
|
||||
public void spawn(SSCEnums.FacingDirection Direction,Color color, float Speed)
|
||||
{
|
||||
if(Direction== SSCEnums.FacingDirection.Down)
|
||||
{
|
||||
this.spawnDown(this.position, color, Speed);
|
||||
}
|
||||
if (Direction == SSCEnums.FacingDirection.Up)
|
||||
{
|
||||
this.spawnUp(this.position, color, Speed);
|
||||
}
|
||||
if (Direction == SSCEnums.FacingDirection.Right)
|
||||
{
|
||||
this.spawnRight(this.position, color, Speed);
|
||||
}
|
||||
if (Direction == SSCEnums.FacingDirection.Left)
|
||||
{
|
||||
this.spawnLeft(this.position, color, Speed);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn(Vector2 Position,Vector2 Direction,Color Color, float Speed)
|
||||
{
|
||||
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(Position, Color, Direction, Speed);
|
||||
}
|
||||
|
||||
public void spawnStationary(Vector2 Position, Color Color)
|
||||
{
|
||||
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(Position, Color);
|
||||
}
|
||||
|
||||
public void spawnLeft(Vector2 Position, Color Color,float Speed)
|
||||
{
|
||||
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(Position, Color,new Vector2(-1,0),Speed);
|
||||
}
|
||||
public void spawnRight(Vector2 Position, Color Color, float Speed)
|
||||
{
|
||||
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(Position, Color, new Vector2(1, 0), Speed);
|
||||
}
|
||||
public void spawnUp(Vector2 Position, Color Color, float Speed)
|
||||
{
|
||||
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(Position, Color, new Vector2(0, -1), Speed);
|
||||
}
|
||||
public void spawnDown(Vector2 Position, Color Color, float Speed)
|
||||
{
|
||||
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(Position, Color, new Vector2(0, 1), Speed);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
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 Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies;
|
||||
|
||||
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEntities
|
||||
{
|
||||
public class SSCEntityManager
|
||||
{
|
||||
public SSCProjectiles.SSCProjectileManager projectiles;
|
||||
public SSCEnemies.EnemyManager enemies;
|
||||
public List<KillZone> killZones;
|
||||
|
||||
public SSCEntityManager()
|
||||
{
|
||||
this.projectiles = new SSCProjectiles.SSCProjectileManager();
|
||||
this.enemies = new EnemyManager();
|
||||
this.killZones = new List<KillZone>();
|
||||
}
|
||||
|
||||
public void addProjectile(SSCProjectiles.SSCProjectile projectile)
|
||||
{
|
||||
this.projectiles.addProjectile(projectile);
|
||||
}
|
||||
|
||||
public void addEnemy(SSCEnemies.SSCEnemy enemy)
|
||||
{
|
||||
this.enemies.addEnemy(enemy);
|
||||
}
|
||||
|
||||
public void addSpawner(ISpawner spawner)
|
||||
{
|
||||
this.enemies.addSpawner(spawner);
|
||||
}
|
||||
|
||||
public void addKillZone(KillZone zone)
|
||||
{
|
||||
this.killZones.Add(zone);
|
||||
}
|
||||
|
||||
public void update(GameTime time)
|
||||
{
|
||||
this.projectiles.update(time);
|
||||
this.enemies.update(time);
|
||||
}
|
||||
|
||||
public void draw(SpriteBatch b)
|
||||
{
|
||||
this.projectiles.draw(b);
|
||||
this.enemies.draw(b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies.Spawners;
|
||||
using Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCStatusEffects;
|
||||
using StardewValley;
|
||||
using StardustCore.Animations;
|
||||
|
@ -471,8 +472,9 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
|
|||
//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);
|
||||
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));
|
||||
//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);
|
||||
}
|
||||
|
||||
|
|
|
@ -145,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.entities.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);
|
||||
|
||||
|
|
|
@ -118,8 +118,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
|
|||
{
|
||||
//Make projectile manager that handles deleting this projectile.
|
||||
//Make projectile manager have a pool of projectiles????
|
||||
ModCore.log("Projectile has died.");
|
||||
SeasideScramble.self.projectiles.deleteProjectile(this);
|
||||
SeasideScramble.self.entities.projectiles.deleteProjectile(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -194,7 +193,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
|
|||
{
|
||||
//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);
|
||||
SeasideScramble.self.projectiles.addProjectile(basic);
|
||||
SeasideScramble.self.entities.projectiles.addProjectile(basic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
|
|||
player.onCollision(p);
|
||||
}
|
||||
}
|
||||
foreach(SSCEnemies.SSCEnemy enemy in SeasideScramble.self.enemies.enemies)
|
||||
foreach(SSCEnemies.SSCEnemy enemy in SeasideScramble.self.entities.enemies.enemies)
|
||||
{
|
||||
if (p.collidesWith(enemy.HitBox))
|
||||
{
|
||||
|
@ -59,6 +59,13 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
|
|||
enemy.onCollision(p); //What happens to the entity.
|
||||
}
|
||||
}
|
||||
|
||||
//Quietly clean up stray projectiles just incase their timer hasn't ticked out yet.
|
||||
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)
|
||||
{
|
||||
this.deleteProjectile(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,22 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
|
|||
/// -a,d for keyboard
|
||||
/// -dpad for p2-4
|
||||
/// Also add interface for game entity for camera to consistently have a focus target.
|
||||
/// -Make moving target enemies
|
||||
/// -Make a sound effect play when they break
|
||||
/// -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 More guns
|
||||
/// </summary>
|
||||
public class SeasideScramble : StardewValley.Minigames.IMinigame
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A static reference to the game.
|
||||
/// </summary>
|
||||
public static SeasideScramble self;
|
||||
|
||||
SeasideScrambleMap currentMap;
|
||||
public SeasideScrambleMap currentMap;
|
||||
public Dictionary<string, SeasideScrambleMap> SeasideScrambleMaps;
|
||||
|
||||
public int currentNumberOfPlayers
|
||||
|
@ -49,11 +58,18 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
|
|||
|
||||
public Vector2 oldMousePosition;
|
||||
|
||||
public SSCProjectiles.SSCProjectileManager projectiles;
|
||||
public SSCEnemies.EnemyManager enemies;
|
||||
public SSCEntities.SSCEntityManager entities;
|
||||
|
||||
public SSCFonts.SSCFont gameFont;
|
||||
|
||||
public Random random
|
||||
{
|
||||
get
|
||||
{
|
||||
return Game1.random;
|
||||
}
|
||||
}
|
||||
|
||||
public SeasideScramble()
|
||||
{
|
||||
self = this;
|
||||
|
@ -63,7 +79,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
|
|||
|
||||
this.LoadTextures();
|
||||
|
||||
this.projectiles = new SSCProjectiles.SSCProjectileManager();
|
||||
this.entities = new SSCEntities.SSCEntityManager();
|
||||
|
||||
this.LoadMaps();
|
||||
this.loadStartingMap();
|
||||
|
@ -80,7 +96,6 @@ 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)
|
||||
|
@ -183,14 +198,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
|
|||
p.drawMouse(b);
|
||||
}
|
||||
}
|
||||
this.enemies.draw(b);
|
||||
this.entities.draw(b);
|
||||
|
||||
this.menuManager.drawAll(b);
|
||||
|
||||
this.projectiles.draw(b);
|
||||
|
||||
|
||||
|
||||
b.End();
|
||||
}
|
||||
|
||||
|
@ -384,11 +395,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
|
|||
{
|
||||
if (player.playerID == SSCEnums.PlayerID.One) this.camera.centerOnPosition(player.position);
|
||||
player.update(time);
|
||||
this.enemies.update(time);
|
||||
}
|
||||
this.entities.update(time);
|
||||
}
|
||||
|
||||
this.projectiles.update(time);
|
||||
|
||||
|
||||
this.oldMousePosition = new Vector2(Game1.getOldMouseX(), Game1.getOldMouseY());
|
||||
return false;
|
||||
|
|
|
@ -84,5 +84,25 @@ AlwaysFront: Objects that are always drawn on top of other layers as well as the
|
|||
return new KeyValuePair<string, Map>(mapAssetKey, map);
|
||||
}
|
||||
|
||||
public virtual Vector2 getPixelSize()
|
||||
{
|
||||
Layer layer = this.map.GetLayer("Back");
|
||||
return new Vector2(layer.TileSize.Width * (layer.LayerWidth/4f) * 4f, layer.TileSize.Height * (layer.LayerHeight/4f) * 4f);
|
||||
}
|
||||
public virtual Vector2 getPixelSize(float mapZoomScale)
|
||||
{
|
||||
Layer layer = this.map.GetLayer("Back");
|
||||
return new Vector2(layer.TileSize.Width * layer.LayerWidth * mapZoomScale, layer.TileSize.Height * layer.LayerWidth * mapZoomScale);
|
||||
}
|
||||
|
||||
|
||||
public void debugInfo()
|
||||
{
|
||||
Layer layer = this.map.GetLayer("Back");
|
||||
ModCore.log("layer Tile Size: " + new Vector2(layer.TileSize.Width,layer.TileSize.Height));
|
||||
ModCore.log("Layer Width/Height: " + new Vector2(layer.LayerWidth, layer.LayerHeight));
|
||||
ModCore.log("Size multiplier: 4");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ namespace Revitalize.Framework.Utilities
|
|||
/// <returns></returns>
|
||||
public static Vector2 UnitVector(this Vector2 vec)
|
||||
{
|
||||
if (vec == Vector2.Zero) return Vector2.Zero;
|
||||
double mag = Magnitude(vec);
|
||||
if (mag == 0) return Vector2.Zero;
|
||||
return new Vector2((float)(vec.X / mag),(float)(vec.Y / mag));
|
||||
|
||||
}
|
||||
|
|
|
@ -66,13 +66,17 @@
|
|||
<Compile Include="Framework\Illuminate\LightManager.cs" />
|
||||
<Compile Include="Framework\Menus\SimpleItemGrabMenu.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ICollider.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISpawner.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISSCLivingEntity.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScramble.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScrambleMap.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCCamera.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\EnemyManager.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\KillZone.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\Spawners\Target_Spawner.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\SSCEnemy.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\SSCE_Target.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEntities\SSCEntityManager.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnums.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCFonts\SSCFontCharacterSheet.cs" />
|
||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCFonts\SSCFont.cs" />
|
||||
|
|
Loading…
Reference in New Issue