using System.Collections;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class CrushingBoulder : ActiveBlock
|
|
{
|
|
int countdowntimer;
|
|
public TextMeshPro counter;
|
|
public int countdown;
|
|
|
|
public override int GetInitative()
|
|
{
|
|
return 3;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
counter.text = countdown.ToString();
|
|
}
|
|
|
|
public override IEnumerator OnEnvironmentTurn(PlayerData[] allPlayers)
|
|
{
|
|
countdown--;
|
|
if (countdown == 0)
|
|
{
|
|
StartCoroutine(FallRaiseCoroutine(-2.0f));
|
|
yield return new WaitForSeconds(1.5f);
|
|
StartCoroutine(FallRaiseCoroutine(2.0f));
|
|
countdown = countdowntimer;
|
|
}
|
|
isFinished = true;
|
|
}
|
|
|
|
IEnumerator FallRaiseCoroutine(float dropDistance)
|
|
{
|
|
float elapsedTime = 0;
|
|
Vector3 startPosition = transform.position;
|
|
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y + dropDistance, 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;
|
|
}
|
|
transform.position = endPosition;
|
|
}
|
|
}
|