using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class Air : ActiveBlock
|
|
{
|
|
public float fallingAnimationTime = 1.0f;
|
|
public float fallingDistance = 10.0f;
|
|
public bool burnAfterReading = true;
|
|
|
|
int DeleteCount = 2;
|
|
|
|
public override int GetInitative()
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
|
|
{
|
|
player.stuck = true;
|
|
player.respawnNeeded = true;
|
|
|
|
//Very hacky, but it solved a weird bug where falling off the left-hand-side of the track didn't kill you, it just got you stuck down there forever
|
|
//You have to leave the camera's sight in order to die from falling
|
|
yield return StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * fallingDistance,Character.Animation.Hit, fallingAnimationTime));
|
|
yield return StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 100, Character.Animation.Hit, 0.01f));
|
|
|
|
player.transform.localScale = Vector3.one;
|
|
}
|
|
|
|
public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
|
|
{
|
|
isFinished = true;
|
|
|
|
if (burnAfterReading)
|
|
{
|
|
DeleteCount--;
|
|
if (DeleteCount == 0)
|
|
Destroy(gameObject);
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
private IEnumerator LerpScale(Transform target, Vector3 endScale, float time)
|
|
{
|
|
Vector3 startScale = target.localScale;
|
|
float elapsedTime = 0;
|
|
|
|
while(elapsedTime < time)
|
|
{
|
|
target.localScale = Vector3.Slerp(startScale, endScale, (elapsedTime / time));
|
|
yield return new WaitForEndOfFrame();
|
|
elapsedTime += Time.deltaTime;
|
|
}
|
|
target.localScale = endScale;
|
|
}
|
|
}
|