using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class CrushingBoulder : ActiveBlock { public int countdowntimer; public TextMeshPro counter; int countdown; public override int GetInitative() { return 3; } private void Start() { countdown = countdowntimer; } 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(5); 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; } }