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.

64 lines
1.6 KiB

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