private void Die(string _sourceID)
{
isDead = true;
Player sourcePlayer = GameManager.GetPlayer(_sourceID);
if (sourcePlayer != null)
{
sourcePlayer.kills++;
GameManager.instance.onPlayerKilledCallback.Invoke(username, sourcePlayer.username);
}
deaths++;
//Disable components
for (int i = 0; i < disableOnDeath.Length; i++)
{
disableOnDeath[i].enabled = false;
}
//Disable GameObjects
for (int i = 0; i < disableGameObjectsOnDeath.Length; i++)
{
disableGameObjectsOnDeath[i].SetActive(false);
}
//Disable the collider
Collider _col = GetComponent<Collider>();
if (_col != null)
_col.enabled = false;
//Spawn a death effect
GameObject _gfxIns = (GameObject)Instantiate(deathEffect, transform.position, Quaternion.identity);
Destroy(_gfxIns, 3f);
//Switch cameras
if (isLocalPlayer)
{
GameManager.instance.SetSceneCameraActive(true);
GetComponent<PlayerSetup>().playerUIInstance.SetActive(false);
}
Debug.Log(transform.name + " is DEAD!");
StartCoroutine(Respawn());
}