Pink/Assets/Scripts/Events/PlayerSpawn.cs

32 lines
886 B
C#
Raw Normal View History

using Pink.Environment;
using Pink.Items;
2020-10-01 18:11:43 +01:00
using static Pink.Environment.Simulation;
using UnityEngine;
2020-10-01 18:11:43 +01:00
namespace Pink.Events
{
public class PlayerSpawn : Simulation.Event<PlayerSpawn>
{
EnvironmentModel state = Simulation.GetModel<EnvironmentModel>();
public override void Execute()
{
state.player.controlAllowed = true;
2020-10-01 18:11:43 +01:00
state.player.collider2d.enabled = true;
state.player.health.Reset();
2020-10-01 18:11:43 +01:00
state.player.controller.Teleport(state.spawnPoint.transform.position);
state.player.animator.SetBool("dead", false);
state.virtualCamera.m_Follow = state.player.transform;
state.virtualCamera.m_LookAt = state.player.transform;
2020-10-01 18:11:43 +01:00
state.hud.Reset();
state.items.ResetItems();
2020-10-01 18:11:43 +01:00
// Schedule<EnableControl>(2f);
}
}
}