/// <summary> /// I have died, give XP to player and spawn any death spawns. /// </summary> public virtual void OnDead() { if (GlobalFuncs.DEBUGGING_MESSAGES) { Debug.Log(transform.name + " change state to Dead"); } GlobalFuncs.GiveXPToPlayer(XPToGive); // update player XP bMagicAttacking = false; // ensure no more spells launched bPatrolling = false; // ensure patrol actions stopped StartCoroutine(GlobalFuncs.SpawnAllDelayed(SpawnOnDeath, 0f, NoneSequentialSpawns, transform, null, 0, false, (gameObject.tag == "Enemy" ? SpawnTarget.Friend : SpawnTarget.Enemy))); // trigger all death spawns the the array StartCoroutine(GlobalFuncs.SpawnAllDelayed(SpawnOnBodyRemoval, GlobalFuncs.EnemyDestroyDelay, NoneSequentialSpawns, transform, null, 0, false, (gameObject.tag == "Enemy" ? SpawnTarget.Friend : SpawnTarget.Enemy))); // trigger all death spawns the the array Destroy(gameObject, GlobalFuncs.EnemyDestroyDelay); // remove self when dead after global time limit }