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.

51 lines
1.2 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Boulder : HeavyObject
  5. {
  6. public GameObject splash;
  7. public GameObject Explosion;
  8. private int transparentLayer;
  9. void Awake()
  10. {
  11. transparentLayer = LayerMask.NameToLayer("TransparentFX");
  12. }
  13. public override void OnWaterStay(WaterController water,float waveHeight)
  14. {
  15. }
  16. public override void OnWaterExit(WaterController water)
  17. {
  18. }
  19. void OnTriggerEnter(Collider other) {
  20. if (other.gameObject.layer == transparentLayer)
  21. return;
  22. if (other.gameObject.CompareTag("Water"))
  23. {
  24. NotificationServer.notify("play sfx", "rockWater_3:0.8");
  25. Destroy(Instantiate(splash, transform.position,Quaternion.identity), 2.5f);
  26. }
  27. else if (other.gameObject.CompareTag("Player"))
  28. {
  29. NotificationServer.notify("play sfx", "runAground:1");
  30. Destroy(Instantiate(Explosion, transform.position, Quaternion.identity), 6);
  31. PlayerController.instance.takeOneDamage();
  32. }
  33. else
  34. {
  35. NotificationServer.notify("play sfx", "runAground:1");
  36. Destroy(Instantiate(Explosion, transform.position, Quaternion.identity), 6);
  37. }
  38. NotificationServer.notify("BoulderHit", gameObject);
  39. }
  40. }