Import 2D Level
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Platformer.Core;
|
||||
using Platformer.Model;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platformer.Gameplay
|
||||
{
|
||||
/// <summary>
|
||||
/// Fired when the player has died.
|
||||
/// </summary>
|
||||
/// <typeparam name="PlayerDeath"></typeparam>
|
||||
public class PlayerDeath : Simulation.Event<PlayerDeath>
|
||||
{
|
||||
PlatformerModel model = Simulation.GetModel<PlatformerModel>();
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
var player = model.player;
|
||||
if (player.health.IsAlive)
|
||||
{
|
||||
player.health.Die();
|
||||
model.virtualCamera.Follow = null;
|
||||
model.virtualCamera.LookAt = null;
|
||||
// player.collider.enabled = false;
|
||||
player.controlEnabled = false;
|
||||
|
||||
if (player.audioSource && player.ouchAudio)
|
||||
player.audioSource.PlayOneShot(player.ouchAudio);
|
||||
player.animator.SetTrigger("hurt");
|
||||
player.animator.SetBool("dead", true);
|
||||
Simulation.Schedule<PlayerSpawn>(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user