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.

59 lines
1.5 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerController : MonoBehaviour {
  5. private static bool isLocked = false;
  6. public float power;
  7. public float radius;
  8. public float time;
  9. public GameObject waveRing;
  10. // Update is called once per frame
  11. void Update () {
  12. if (Input.GetButtonDown("Fire1") && !isLocked) {
  13. Debug.Log("Click");
  14. RaycastHit hit;
  15. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  16. LayerMask rayMask = (1 << 4);
  17. Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
  18. if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
  19. Vector3 pos = hit.point;
  20. pos.y += 1;
  21. Quaternion rot = Quaternion.Euler(-90, 0, 0);
  22. if (waveRing != null)
  23. Destroy(Instantiate(waveRing, pos, rot),4);
  24. WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
  25. Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
  26. Debug.Log("I hit: " + hit.transform.name);
  27. if (waterScript != null)
  28. waterScript.CreateWave(hit.point, radius, power);
  29. }
  30. }
  31. }
  32. /// <summary>
  33. /// if true stops player from being able to click on water
  34. /// </summary>
  35. /// <param name="input"></param>
  36. public static void lockControls(bool input) {
  37. isLocked = input;
  38. }
  39. }