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.

61 lines
1.4 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerController : MonoBehaviour {
  5. public bool isLocked = false;
  6. public float power;
  7. public float radius;
  8. public float time;
  9. public GameObject waveRing;
  10. void Start() {
  11. NotificationServer.register("show GameUI", showGameUI);
  12. NotificationServer.register("hide GameUI", hideGameUI);
  13. }
  14. // Update is called once per frame
  15. void Update () {
  16. if (Input.GetButtonDown("Fire1") && !isLocked) {
  17. Debug.Log("Click");
  18. RaycastHit hit;
  19. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  20. LayerMask rayMask = (1 << 4);
  21. Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
  22. if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
  23. WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
  24. Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
  25. Debug.Log("I hit: " + hit.transform.name);
  26. if (waterScript != null)
  27. waterScript.CreateWave(hit.point, radius, power);
  28. }
  29. }
  30. }
  31. private void showGameUI() {
  32. Debug.Log("UI open");
  33. isLocked = false;
  34. }
  35. private void hideGameUI() {
  36. Debug.Log("UI close");
  37. isLocked = true;
  38. }
  39. }