Update Inserted Public Destroy Ship Function

This commit is contained in:
Philip W 2021-11-14 10:55:11 +00:00
parent 68912e52cd
commit cc31ce9b38

View File

@ -48,17 +48,7 @@ public class EnemyReturn : Physics2DObject
}
if (playerTag == "Bullet")
{
if (deathEffect != null)
{
GameObject newDeathEffect = Instantiate<GameObject>(deathEffect);
newDeathEffect.transform.position = this.transform.position;
}
if (hasDroppableObject)
{
GameObject newDroppedObject = Instantiate<GameObject>(droppedObject);
newDroppedObject.transform.position = new Vector2(Random.Range(0, 2) + this.transform.position.x, Random.Range(0, 2) + this.transform.position.y);
}
Destroy(gameObject);
DestroyShip();
}
if (playerTag == "Finish" && hasDroppableObject)
{
@ -83,4 +73,18 @@ public class EnemyReturn : Physics2DObject
this.GetComponent<SpriteRenderer>().sprite = shipWithPasties;
}
}
public void DestroyShip(bool triggerDeathEffect = true)
{
if (deathEffect != null && triggerDeathEffect)
{
GameObject newDeathEffect = Instantiate<GameObject>(deathEffect);
newDeathEffect.transform.position = this.transform.position;
}
if (hasDroppableObject)
{
GameObject newDroppedObject = Instantiate<GameObject>(droppedObject);
newDroppedObject.transform.position = new Vector2(Random.Range(0, 2) + this.transform.position.x, Random.Range(0, 2) + this.transform.position.y);
}
Destroy(gameObject);
}
}