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.
 
 
 
 
 
 

56 lines
1.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Air : ActiveBlock
{
int DeleteCount = 2;
public override int GetInitative()
{
return -1;
}
public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
{
player.stuck = true;
player.respawnNeeded = true;
StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 10,Character.Animation.Hit, 1));
yield return StartCoroutine(LerpScale(player.transform, Vector3.zero, 1));
//player.gameObject.SetActive(false);
Debug.Log("Set player scale to one");
player.transform.localScale = Vector3.one;
isFinished = true;
}
public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
{
isFinished = true;
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;
}
}