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

  1. using System.Collections;
  2. using UnityEngine;
  3. public class Air : ActiveBlock
  4. {
  5. public float fallingAnimationTime = 1.0f;
  6. public float fallingDistance = 10.0f;
  7. public bool burnAfterReading = true;
  8. int DeleteCount = 2;
  9. public override int GetInitative()
  10. {
  11. return -1;
  12. }
  13. public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
  14. {
  15. player.stuck = true;
  16. player.respawnNeeded = true;
  17. //Very hacky, but it solved a weird bug where falling off the left-hand-side of the track didn't kill you, it just got you stuck down there forever
  18. //You have to leave the camera's sight in order to die from falling
  19. yield return StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * fallingDistance,Character.Animation.Hit, fallingAnimationTime));
  20. yield return StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 100, Character.Animation.Hit, 0.01f));
  21. player.transform.localScale = Vector3.one;
  22. }
  23. public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
  24. {
  25. isFinished = true;
  26. if (burnAfterReading)
  27. {
  28. DeleteCount--;
  29. if (DeleteCount == 0)
  30. Destroy(gameObject);
  31. }
  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. }