Skip to content

Commit

Permalink
Alpha Version. Ready for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceJZ committed Feb 2, 2018
1 parent 553ece2 commit a8b8fa3
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 69 deletions.
15 changes: 10 additions & 5 deletions Highsight_Game_Jam_1/Engine/Explode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Highsight_Game_Jam_1
class Explode : GameComponent
{
List<ExplodeParticle> Particles;
Model Cube;
Camera TheCamera;
Vector3 TheColor = Vector3.One;
Vector3 TheEmissiveColor = Vector3.Zero;
Expand All @@ -37,7 +36,7 @@ public override void Initialize()

public void LoadContent()
{
Cube = Helper.LoadModel("Core/Cube");

}

public void BeginRun()
Expand All @@ -64,6 +63,12 @@ public override void Update(GameTime gameTime)
base.Update(gameTime);
}

public void Setup(Vector3 color, Vector3 lightcolor)
{
TheColor = color;
TheEmissiveColor = lightcolor;
}

public void Spawn(Vector3 position, float radius, int minCount, float speed,
float scale, float life)
{
Expand All @@ -76,9 +81,7 @@ public void Spawn(Vector3 position, float radius, int minCount, float speed,

for (int i = 0; i < more; i++)
{
Particles.Add(new ExplodeParticle(Game, TheCamera, Cube));
Particles.Last().DefuseColor = TheColor;
Particles.Last().EmissiveColor = TheEmissiveColor;
Particles.Add(new ExplodeParticle(Game, TheCamera));
}
}

Expand All @@ -88,6 +91,8 @@ public void Spawn(Vector3 position, float radius, int minCount, float speed,
Helper.RandomMinMax(-radius, radius), 0);

particle.Spawn(position, speed, scale, life);
particle.DefuseColor = TheColor;
particle.EmissiveColor = TheEmissiveColor;
}
}

Expand Down
6 changes: 3 additions & 3 deletions Highsight_Game_Jam_1/Engine/ExplodeParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace Highsight_Game_Jam_1
{
class ExplodeParticle : ModelEntity
class ExplodeParticle : Cube
{
Timer LifeTimer;

public ExplodeParticle(Game game, Camera camera, Model model) : base(game, camera, model)
public ExplodeParticle(Game game, Camera camera) : base(game, camera)
{
LifeTimer = new Timer(game);
}
Expand All @@ -34,7 +34,7 @@ public void Spawn(Vector3 position, float velocity, float scaleRange, float maxL
base.Spawn(position);

Velocity = ThePO.RandomVelocity(velocity);
Scale = Helper.RandomMinMax(0.5f + scaleRange, 1.5f + scaleRange);
Scale = Helper.RandomMinMax(scaleRange, 1.5f * scaleRange);
LifeTimer.Reset(Helper.RandomMinMax(0.1f, maxLife));
}
}
Expand Down
24 changes: 8 additions & 16 deletions Highsight_Game_Jam_1/Engine/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ public class Timer : GameComponent
private float TheSeconds;
private float TheAmount;

public float Seconds
{
get { return TheSeconds; }
}
public float Seconds { get => TheSeconds; }
public float TimeLeft { get => TheAmount - TheSeconds; }
public bool Elapsed { get => (TheSeconds > TheAmount); }

public float Amount
{
Expand All @@ -23,14 +22,6 @@ public float Amount
}
}

public bool Elapsed
{
get
{
return (TheSeconds > TheAmount);
}
}

public Timer(Game game) : base(game)
{
Game.Components.Add(this);
Expand All @@ -52,8 +43,10 @@ public override void Update(GameTime gameTime)
{
base.Update(gameTime);

if (!Elapsed)
TheSeconds += (float)gameTime.ElapsedGameTime.TotalSeconds;
TheSeconds += (float)gameTime.ElapsedGameTime.TotalSeconds;

if (Elapsed)
Enabled = false;
}

public void Reset()
Expand All @@ -64,8 +57,7 @@ public void Reset()

public void Reset(float time)
{
TheAmount = time;
Reset();
Amount = time;
}
}
}
13 changes: 10 additions & 3 deletions Highsight_Game_Jam_1/Entities/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ class Enemy : ModelEntity
#region Fields
GameLogic LogicRef;
Swirl TheSwirl;
Explode TheExplosion;
Timer ArmTimer;
SoundEffect ExplodeSound;
SoundEffect AlertSound;
bool AlertSounded;
#endregion
#region Properties

public Swirl SwirlRef { get => TheSwirl; }
#endregion
#region Constructor
public Enemy(Game game, Camera camera, GameLogic gameLogic) : base(game, camera)
{
LogicRef = gameLogic;
TheSwirl = new Swirl(game, camera, gameLogic);
TheExplosion = new Explode(game, camera);
ArmTimer = new Timer(game, Helper.RandomMinMax(4, 20));
}
#endregion
Expand All @@ -48,7 +50,6 @@ protected override void LoadContent()

public override void BeginRun()
{

base.BeginRun();
Reset();
}
Expand All @@ -60,7 +61,7 @@ public override void Update(GameTime gameTime)

if (LogicRef.CurrentMode == GameState.InPlay)
{
if (ArmTimer.Amount - ArmTimer.Seconds < 2f && !AlertSounded)
if (ArmTimer.TimeLeft < 2f && !AlertSounded)
{
AlertSounded = true;
AlertSound.Play();
Expand All @@ -82,12 +83,18 @@ public void Reset()
DefuseColor = new Vector3(0.5f, 0.1f, 0.8f);
TheSwirl.Enabled = false;
ResetSwirlTimer();
TheExplosion.Setup(new Vector3(0.8f, 0.1f, 0.4f), new Vector3(0.3f, 0, 0f));
}

public void Explode()
{
TheExplosion.Spawn(Position, 2, 150, 25, 0.3f, 4);
ExplodeSound.Play();
LogicRef.AddPoints(1000);
Reset();
LogicRef.ShieldRef.Reset();
LogicRef.PlayerRef.Reset();
LogicRef.DestroyerRef.Reset();
}

public void EndGame()
Expand Down
13 changes: 12 additions & 1 deletion Highsight_Game_Jam_1/Entities/Missile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,25 @@ void CheckCollusion()
}
}

if (LogicRef.EnemyRef.Enabled)
if (Sphere.Intersects(LogicRef.EnemyRef.SwirlRef.Sphere))
{
Enabled = false;
LogicRef.EnemyRef.SwirlRef.HitByMissile();
return;
}

if (LogicRef.EnemyRef.Enabled && !LogicRef.EnemyRef.SwirlRef.Enabled)
{
if (Sphere.Intersects(LogicRef.EnemyRef.Sphere))
{
Enabled = false;
LogicRef.EnemyRef.Explode();
return;
}
}

if (Position.X > 120)
Enabled = false;
}
}
}
10 changes: 7 additions & 3 deletions Highsight_Game_Jam_1/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ class Player : ModelEntity
GameLogic LogicRef;
Shot TheShot;
Missile TheMissile;
Explode TheExplosion;
Timer InZoneTimer;
Timer FlapSoundTimer;
Timer IdleSoundTimer;
SoundEffect ExplodeSound;
SoundEffect FlapSound;
SoundEffect IdleSound;
SoundEffect FireSound;
SoundEffect FireMissileSound;
Timer InZoneTimer;
SoundEffect InZoneSound;
Timer FlapSoundTimer;
Timer IdleSoundTimer;
KeyboardState OldKeyState;
float MovementSpeed = 50;
int PlayAreaHeight = 83;
Expand All @@ -39,6 +40,7 @@ public Player(Game game, Camera camera, GameLogic gameLogic) : base(game, camera
LogicRef = gameLogic;
TheShot = new Shot(game, camera, gameLogic);
TheMissile = new Missile(game, camera, gameLogic);
TheExplosion = new Explode(game, camera);
FlapSoundTimer = new Timer(game);
IdleSoundTimer = new Timer(game);
InZoneTimer = new Timer(game);
Expand Down Expand Up @@ -103,11 +105,13 @@ public bool MissileCollusion()
public void Reset()
{
TheMissile.Enabled = false;
TheExplosion.Setup(new Vector3(0.6f, 0.1f, 0.8f), new Vector3(0f, 0, 0.3f));
Spawn(new Vector3(-100, 0, 0));
}

public void Explode()
{
TheExplosion.Spawn(Position, 2, 100, 20, 0.25f, 3);
ExplodeSound.Play();
Reset();
}
Expand Down
49 changes: 41 additions & 8 deletions Highsight_Game_Jam_1/Entities/Shield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Highsight_Game_Jam_1
class Shield : PositionedObject
{
List<Cube> TheBlocks = new List<Cube>();
List<Explode> TheExplosions = new List<Explode>();
Camera CameraRef;
GameLogic LogicRef;
SoundEffect BlockHitSound;
Expand Down Expand Up @@ -62,22 +63,29 @@ public void Reset()

public bool CheckColusion(ModelEntity otherEntity)
{
if (DidEntityCollide(otherEntity) == null)
ModelEntity block = DidEntityCollide(otherEntity);

if (block == null)
return false;

MakeExplosion(block.PO.WorldPosition + block.Position);
BlockHitSound.Play();
LogicRef.AddPoints(69);
DidEntityCollide(otherEntity).Enabled = false;
block.Enabled = false;
otherEntity.Enabled = false;
return true;
}

public bool CheckEating()
{
if (DidEntityCollide(LogicRef.PlayerRef) == null)
ModelEntity block = DidEntityCollide(LogicRef.PlayerRef);

if (block == null)
return false;

ModelEntity block = DidEntityCollide(LogicRef.PlayerRef);
LogicRef.PlayerRef.Velocity =
VelocityFromVectorsZ(LogicRef.PlayerRef.Position,
block.Position, 120);

if (Helper.RandomMinMax(0, 10) == 10)
{
Expand All @@ -87,13 +95,38 @@ public bool CheckEating()
return true;
}

LogicRef.PlayerRef.Velocity =
VelocityFromVectorsZ(LogicRef.PlayerRef.Position,
block.Position, 120);

return false;
}

void MakeExplosion(Vector3 position)
{
foreach (Explode boom in TheExplosions)
{
if (!boom.Enabled)
{
SetExplode(boom, position);
return;
}
}

TheExplosions.Add(new Explode(Game, CameraRef));
SetExplode(TheExplosions.Last(), position);
}

void SetExplode(Explode boom, Vector3 position)
{
float rad = Helper.RandomMinMax(0.1f, 1);
int mc = Helper.RandomMinMax(6, 10);
float speed = Helper.RandomMinMax(10, 50);
Vector3 color = new Vector3(Helper.RandomMinMax(0.1f, 1),
Helper.RandomMinMax(0.1f, 1), Helper.RandomMinMax(0.1f, 1));
Vector3 lightcolor = new Vector3(Helper.RandomMinMax(0.01f, 0.2f),
Helper.RandomMinMax(0.01f, 0.1f), Helper.RandomMinMax(0.01f, 0.2f));

boom.Setup(color, lightcolor);
boom.Spawn(position, rad, mc, speed, 0.1f, 2);
}

ModelEntity DidEntityCollide(ModelEntity otherEntity)
{
foreach (ModelEntity block in TheBlocks)
Expand Down
Loading

0 comments on commit a8b8fa3

Please sign in to comment.