public override void OnDeath()
{
// Run the death animation (if it exists)
if (DeathAnim != null)
{
DeathAnim.Play ();
}
transform.SetParent(null);
if (!FacingRight)
{
Flip ();
}
// Reset the materials to the last checkpoint and respawn the player
for(int i=0; i<currentMats.Length; i++){
currentMats[i] = CheckPointMatsCount[i];
}
//currentMats = CheckPointMatsCount;
if (!activeCheckpoint)
{
Application.LoadLevel(Application.loadedLevel);
}
else
{
GameObject newPlayer = (GameObject)Instantiate(PlayerPrefab, new Vector3(activeCheckpoint.transform.position.x, activeCheckpoint.transform.position.y + 2, 0.0f), Quaternion.identity);
if (PickUpList != null)
{
foreach (GameObject g in PickUpList)
{
g.SetActive(true);
//When there are more than one type of crystal this breaks
}
PickUpList.Clear();
}
if (KilledEnemies != null)
{
foreach (GameObject g in KilledEnemies)
{
g.SetActive(true);
}
KilledEnemies.Clear();
}
// Finish killing the player
Died = true;
newPlayer.name = "Character";
newPlayer.gameObject.GetComponent<CharacterBehavior>().selected = selected;
TimesPlayerDied++;
base.OnDeath();
}
}