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.
 
 
 
 
 
 

51 lines
1.4 KiB

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;
}
}