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.3 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Air : ActiveBlock
  5. {
  6. public override int GetInitative()
  7. {
  8. return -1;
  9. }
  10. public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
  11. {
  12. player.stuck = true;
  13. player.respawnNeeded = true;
  14. StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 10,Character.Animation.Hit, 1));
  15. StartCoroutine(LerpScale(player.transform, Vector3.zero, 1));
  16. yield return new WaitForSeconds(1);
  17. player.gameObject.SetActive(false);
  18. player.transform.localScale = Vector3.one;
  19. isFinished = true;
  20. }
  21. public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
  22. {
  23. isFinished = true;
  24. Destroy(gameObject);
  25. yield break;
  26. }
  27. private IEnumerator LerpScale(Transform target, Vector3 endScale, float time)
  28. {
  29. Vector3 startScale = target.localScale;
  30. float elapsedTime = 0;
  31. while(elapsedTime < time)
  32. {
  33. target.localScale = Vector3.Slerp(startScale, endScale, (elapsedTime / time));
  34. yield return new WaitForEndOfFrame();
  35. elapsedTime += Time.deltaTime;
  36. }
  37. target.localScale = endScale;
  38. }
  39. }