You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Air : ActiveBlock
{
private List<Character> FallenPlayers = new List<Character>();
public override int GetInitative()
{
return -1;
}
public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
{
player.stuck = true;
FallenPlayers.Add(player);
StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 10,Character.Animation.Hit, 1));
StartCoroutine(LerpScale(player.transform, Vector3.zero, 1));
yield return new WaitForSeconds(1);
player.gameObject.SetActive(false);
player.transform.localScale = Vector3.one;
isFinished = true;
}
public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
{
foreach (Character player in FallenPlayers)
{
player.gameObject.SetActive(true);
player.respawnCharacter(transform.position);
}
FallenPlayers.Clear();
isFinished = true;
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;
}
}