|
|
- 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(1.0f);
- 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;
- }
- }
|