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.

56 lines
1.4 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Air : ActiveBlock
  5. {
  6. int DeleteCount = 2;
  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. player.respawnNeeded = true;
  15. StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 10,Character.Animation.Hit, 1));
  16. yield return StartCoroutine(LerpScale(player.transform, Vector3.zero, 1));
  17. //player.gameObject.SetActive(false);
  18. Debug.Log("Set player scale to one");
  19. player.transform.localScale = Vector3.one;
  20. isFinished = true;
  21. }
  22. public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
  23. {
  24. isFinished = true;
  25. DeleteCount--;
  26. if (DeleteCount == 0)
  27. Destroy(gameObject);
  28. yield break;
  29. }
  30. private IEnumerator LerpScale(Transform target, Vector3 endScale, float time)
  31. {
  32. Vector3 startScale = target.localScale;
  33. float elapsedTime = 0;
  34. while(elapsedTime < time)
  35. {
  36. target.localScale = Vector3.Slerp(startScale, endScale, (elapsedTime / time));
  37. yield return new WaitForEndOfFrame();
  38. elapsedTime += Time.deltaTime;
  39. }
  40. target.localScale = endScale;
  41. }
  42. }