Pink/Assets/Scripts/Events/PlayerDeath.cs

28 lines
700 B
C#
Raw Normal View History

using Pink.Environment;
2020-10-01 18:11:43 +01:00
using UnityEngine;
2020-10-01 18:11:43 +01:00
using static Pink.Environment.Simulation;
namespace Pink.Events
{
2020-10-01 18:11:43 +01:00
class PlayerDeath : Simulation.Event<PlayerDeath>
{
EnvironmentModel state = Simulation.GetModel<EnvironmentModel>();
public override void Execute()
{
2020-10-01 18:11:43 +01:00
if (!state.player.health.IsAlive)
{
2020-10-01 18:11:43 +01:00
Debug.Log("Player Died");
state.player.controlAllowed = false;
2020-10-01 18:11:43 +01:00
state.player.collider2d.enabled = false;
state.virtualCamera.m_Follow = null;
state.virtualCamera.m_LookAt = null;
2020-10-01 18:11:43 +01:00
Schedule<PlayerSpawn>(2);
}
}
}
}