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.
 
 
 
 
 
 

52 lines
1.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeWithCrystals : ActiveBlock
{
public GameObject crystals;
public override int GetInitative()
{
return 3;
}
public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
{
StartCoroutine(GrowCoroutine());
yield return new WaitForSeconds(0.5f);
StartCoroutine(ShrinkCoroutine());
isFinished = true;
//yield break;
}
IEnumerator GrowCoroutine()
{
float elapsedTime = 0;
Vector3 startPosition = crystals.transform.position;
Vector3 endPosition = new Vector3(crystals.transform.position.x, crystals.transform.position.y + 1.0f, crystals.transform.position.z);
float time = 0.8f;
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
crystals.transform.position = endPosition;
}
IEnumerator ShrinkCoroutine()
{
float elapsedTime = 0;
Vector3 startPosition = crystals.transform.position;
Vector3 endPosition = new Vector3(crystals.transform.position.x, crystals.transform.position.y - 1.0f, crystals.transform.position.z);
float time = 0.8f;
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
crystals.transform.position = endPosition;
}
}