Update Inserted Public Destroy Ship Function
This commit is contained in:
parent
68912e52cd
commit
cc31ce9b38
@ -48,17 +48,7 @@ public class EnemyReturn : Physics2DObject
|
|||||||
}
|
}
|
||||||
if (playerTag == "Bullet")
|
if (playerTag == "Bullet")
|
||||||
{
|
{
|
||||||
if (deathEffect != null)
|
DestroyShip();
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
if (playerTag == "Finish" && hasDroppableObject)
|
if (playerTag == "Finish" && hasDroppableObject)
|
||||||
{
|
{
|
||||||
@ -83,4 +73,18 @@ public class EnemyReturn : Physics2DObject
|
|||||||
this.GetComponent<SpriteRenderer>().sprite = shipWithPasties;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user