Browse Source

Ripple is called from ripple Controller

master
Joshua Reason 7 years ago
parent
commit
5ef29da490
2 changed files with 25 additions and 15 deletions
  1. +17
    -15
      IronToad_UnityProject/Assets/Scripts/PlayerController.cs
  2. +8
    -0
      IronToad_UnityProject/Assets/Scripts/WaterController.cs

+ 17
- 15
IronToad_UnityProject/Assets/Scripts/PlayerController.cs View File

@ -4,7 +4,7 @@ using UnityEngine;
public class PlayerController : MonoBehaviour { public class PlayerController : MonoBehaviour {
private static bool isLocked = false;
public bool isLocked = false;
public float power; public float power;
public float radius; public float radius;
@ -12,6 +12,14 @@ public class PlayerController : MonoBehaviour {
public GameObject waveRing; public GameObject waveRing;
void Start() {
NotificationServer.register("show GameUI", showGameUI);
NotificationServer.register("hide GameUI", hideGameUI);
}
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
@ -26,14 +34,6 @@ public class PlayerController : MonoBehaviour {
if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) { if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
Vector3 pos = hit.point;
pos.y += 1;
Quaternion rot = Quaternion.Euler(-90, 0, 0);
if (waveRing != null)
Destroy(Instantiate(waveRing, pos, rot),4);
WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>(); WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1); Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
@ -48,12 +48,14 @@ public class PlayerController : MonoBehaviour {
} }
/// <summary>
/// if true stops player from being able to click on water
/// </summary>
/// <param name="input"></param>
public static void lockControls(bool input) {
isLocked = input;
private void showGameUI() {
Debug.Log("UI open");
isLocked = false;
}
private void hideGameUI() {
Debug.Log("UI close");
isLocked = true;
} }
} }

+ 8
- 0
IronToad_UnityProject/Assets/Scripts/WaterController.cs View File

@ -13,6 +13,7 @@ public class WaterController : MonoBehaviour {
public float waveSpeed = 1; public float waveSpeed = 1;
public float maxWaveHeight = 2; public float maxWaveHeight = 2;
public GameObject rippleEffect;
#region Unity Functions #region Unity Functions
// Use this for initialization // Use this for initialization
@ -43,6 +44,13 @@ public class WaterController : MonoBehaviour {
point.y = transform.position.y; point.y = transform.position.y;
Vector3 pos = point;
pos.y += 1;
Quaternion rot = Quaternion.Euler(-90, 0, 0);
if (rippleEffect != null)
Destroy(Instantiate(rippleEffect, pos, rot), 4);
Collider[] colliders = Physics.OverlapSphere(point, radius); Collider[] colliders = Physics.OverlapSphere(point, radius);
foreach (Collider hit in colliders) { foreach (Collider hit in colliders) {
Debug.Log(hit.name); Debug.Log(hit.name);

Loading…
Cancel
Save