Skip to content

Commit

Permalink
Added building explosion effect. Fixes #64
Browse files Browse the repository at this point in the history
  • Loading branch information
brainwipe committed Aug 18, 2018
1 parent c556eb4 commit a070328
Show file tree
Hide file tree
Showing 8 changed files with 23,447 additions and 340 deletions.
4,787 changes: 4,714 additions & 73 deletions Assets/Resources/Buildings/boiler-medium.prefab

Large diffs are not rendered by default.

4,644 changes: 4,642 additions & 2 deletions Assets/Resources/Buildings/bridge-standard.prefab

Large diffs are not rendered by default.

4,644 changes: 4,642 additions & 2 deletions Assets/Resources/Buildings/house-small-one.prefab

Large diffs are not rendered by default.

4,648 changes: 4,644 additions & 4 deletions Assets/Resources/Buildings/store-small.prefab

Large diffs are not rendered by default.

4,914 changes: 4,777 additions & 137 deletions Assets/Resources/Buildings/weapon-cannon.prefab

Large diffs are not rendered by default.

126 changes: 15 additions & 111 deletions Assets/Resources/Shaders/Building.ShaderGraph

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions Assets/Scripts/Builder/Buildings/Boiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@

public class Boiler : MonoBehaviour
{
public ParticleSystem smoke;
Building building;
ParticleSystem particles;
FlyingPhysics flyingPhysics;
IFly parent;

void Start ()
{
particles = GetComponentInChildren<ParticleSystem>();
flyingPhysics = GetComponentInParent<FlyingPhysics>();
parent = GetComponentInParent<IFly>();
building = GetComponent<Building>();

var emitter = particles.emission;
emitter.enabled = !building.InMenu;
var smokeEmitter = smoke.emission;
smokeEmitter.enabled = !building.InMenu;
}

void FixedUpdate()
Expand All @@ -27,14 +26,14 @@ void FixedUpdate()
return;
}

var main = particles.main;
var emitter = particles.emission;
var smokeMain = smoke.main;
var smokeEmitter = smoke.emission;

main.startSpeed = Maths.Rescale(6, 10, 0, 1, Mathf.Abs(parent.CommandThrust));
emitter.rateOverTime = Maths.Rescale(0.3f, 12, 0, 1f, Mathf.Abs(parent.CommandThrust));
smokeMain.startSpeed = Maths.Rescale(6, 10, 0, 1, Mathf.Abs(parent.CommandThrust));
smokeEmitter.rateOverTime = Maths.Rescale(0.3f, 12, 0, 1f, Mathf.Abs(parent.CommandThrust));

var windEffect = flyingPhysics.CycloneForce * 0.002f;
var forceOverLifetime = particles.forceOverLifetime;
var forceOverLifetime = smoke.forceOverLifetime;
forceOverLifetime.x = windEffect.x;
forceOverLifetime.y = windEffect.y;
forceOverLifetime.z = windEffect.z;
Expand Down
7 changes: 5 additions & 2 deletions Assets/Scripts/Builder/Buildings/Building.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Building : MonoBehaviour, IAmBuilding, ITakeDamage, IHaveAbilities
public static string BuildingTag = "Building";
public string Id;
public IAmAShip owner;
public ParticleSystem DeathExplosion;
Renderer[] highlightTargets;
Rigidbody rigidBody;

Expand Down Expand Up @@ -208,10 +209,12 @@ public void Damage(float amount)
}

Health -= amount;
SetShaderFloat("Vector1_89360613", Health/MaxHealth);
if (Health < 1)
{
Remove();
DeathExplosion.Play();
DeathExplosion.gameObject.transform.parent = null;
Destroy(DeathExplosion.gameObject, DeathExplosion.main.duration);
Destroy(gameObject, DeathExplosion.main.duration / 2f);
}
}

Expand Down

0 comments on commit a070328

Please sign in to comment.