|
@ -3,7 +3,8 @@ using System.Collections.Generic; |
|
|
using UnityEngine; |
|
|
using UnityEngine; |
|
|
|
|
|
|
|
|
public class PlayerController : MonoBehaviour { |
|
|
public class PlayerController : MonoBehaviour { |
|
|
|
|
|
|
|
|
|
|
|
public float cooldownWaveCreate = 0.5f; |
|
|
|
|
|
private float timeOfLastWave; |
|
|
public bool isLocked = false; |
|
|
public bool isLocked = false; |
|
|
|
|
|
|
|
|
public float power; |
|
|
public float power; |
|
@ -11,6 +12,7 @@ public class PlayerController : MonoBehaviour { |
|
|
public float time; |
|
|
public float time; |
|
|
|
|
|
|
|
|
public GameObject waveRing; |
|
|
public GameObject waveRing; |
|
|
|
|
|
public ParticleSystem boatHitParticle; |
|
|
|
|
|
|
|
|
public int life = 3; |
|
|
public int life = 3; |
|
|
public float lastDamageTime = 0; |
|
|
public float lastDamageTime = 0; |
|
@ -37,6 +39,11 @@ public class PlayerController : MonoBehaviour { |
|
|
void Update () { |
|
|
void Update () { |
|
|
|
|
|
|
|
|
if (Input.GetButtonDown("Fire1") && !isLocked) { |
|
|
if (Input.GetButtonDown("Fire1") && !isLocked) { |
|
|
|
|
|
|
|
|
|
|
|
if (cooldownWaveCreate > Time.timeSinceLevelLoad - timeOfLastWave) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
timeOfLastWave = Time.timeSinceLevelLoad; |
|
|
// Debug.Log("Click");
|
|
|
// Debug.Log("Click");
|
|
|
RaycastHit hit; |
|
|
RaycastHit hit; |
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
@ -69,6 +76,9 @@ public class PlayerController : MonoBehaviour { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void takeOneDamage() { |
|
|
public void takeOneDamage() { |
|
|
|
|
|
// NotificationServer.notify("shake camera");
|
|
|
|
|
|
NotificationServer.notify("flash damage"); |
|
|
|
|
|
boatHitParticle.Play(); |
|
|
if (Time.time > lastDamageTime + 2 && life > 0) { |
|
|
if (Time.time > lastDamageTime + 2 && life > 0) { |
|
|
setLife(life - 1); |
|
|
setLife(life - 1); |
|
|
lastDamageTime = Time.time; |
|
|
lastDamageTime = Time.time; |
|
@ -76,7 +86,7 @@ public class PlayerController : MonoBehaviour { |
|
|
{ |
|
|
{ |
|
|
NotificationServer.notify("fade bgm"); |
|
|
NotificationServer.notify("fade bgm"); |
|
|
NotificationServer.notify("play sfx", "shipSpotted:0.5"); |
|
|
NotificationServer.notify("play sfx", "shipSpotted:0.5"); |
|
|
NotificationServer.notify("play sfx", "sinkingShip:0.75"); |
|
|
|
|
|
|
|
|
NotificationServer.notify("play sfx", "sinkingShip_2:0.75"); |
|
|
NotificationServer.notify("show GameOverPanel"); |
|
|
NotificationServer.notify("show GameOverPanel"); |
|
|
NotificationServer.notify("hide GameUI"); |
|
|
NotificationServer.notify("hide GameUI"); |
|
|
} |
|
|
} |
|
|