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.

57 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. }
  21. public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
  22. {
  23. isFinished = true;
  24. DeleteCount--;
  25. if (DeleteCount == 0)
  26. Destroy(gameObject);
  27. yield break;
  28. }
  29. private IEnumerator LerpScale(Transform target, Vector3 endScale, float time)
  30. {
  31. Vector3 startScale = target.localScale;
  32. float elapsedTime = 0;
  33. while(elapsedTime < time)
  34. {
  35. target.localScale = Vector3.Slerp(startScale, endScale, (elapsedTime / time));
  36. yield return new WaitForEndOfFrame();
  37. elapsedTime += Time.deltaTime;
  38. }
  39. target.localScale = endScale;
  40. }
  41. }