fixed shooting rockets when dead

This commit is contained in:
steven2gleal 2017-09-07 14:21:58 -05:00
parent 80217db197
commit b01c146481
6 changed files with 55 additions and 6 deletions

View file

@ -6,7 +6,7 @@ public class Explosion : MonoBehaviour {
public PlayerController player;
private float MAX_PLAYER_DIST = 3.0f;
private float EXPLOSION_FORCE = 10.0f;
private float EXPLOSION_FORCE = 15.0f;
void Start () {
Vector3 playerPos = player.transform.position;

View file

@ -37,6 +37,7 @@ public class LevelController : MonoBehaviour {
{
if (wonLevel)
return;
PlayerController.GetController().KillPlayer();
winText.text = "TRY AGAIN!";
StartCoroutine(DelayLoadLevel(SceneManager.GetActiveScene().name, 2.0f));
}
@ -50,8 +51,10 @@ public class LevelController : MonoBehaviour {
GameObject start = GameObject.FindGameObjectWithTag ("Start");
player.transform.position = start.transform.position;
winText.text = "";
PlayerController.GetController().RevivePlayer();
} else {
SceneManager.LoadScene (levelName);
levelController = null;
SceneManager.LoadScene (levelName);
}
yield return null;
}

View file

@ -12,10 +12,44 @@ public class PlayerController : MonoBehaviour {
public GameObject rocketPrefab;
private float reloadTime = 0.25f;
private bool reloading = false;
// Update is called once per frame
void Update () {
private static PlayerController controller;
private bool alive = true;
private void Start()
{
if (controller)
{
Debug.LogError("More than one player controller in the scene! Deleting this controller.");
Destroy(this);
}
controller = this;
alive = true;
}
public static PlayerController GetController()
{
if (!controller)
{
Debug.LogError("No player controller currently in the scene.");
return null;
}
return controller;
}
public void KillPlayer()
{
alive = false;
}
public void RevivePlayer()
{
alive = true;
}
// Update is called once per frame
void Update () {
if (!alive)
return;
/*// Basic jumping
if (Input.GetKeyDown (KeyCode.Space)) {
GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, jumpPower);

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1884be5a55d87e54689bff928b40ee6d
folderAsset: yes
timeCreated: 1504642159
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -374,6 +374,9 @@ PlayerSettings:
switchUdpSendBufferSize: 9
switchUdpReceiveBufferSize: 42
switchSocketBufferEfficiency: 4
switchSocketInitializeEnabled: 1
switchNetworkInterfaceManagerInitializeEnabled: 1
switchPlayerConnectionEnabled: 1
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:

View file

@ -1 +1 @@
m_EditorVersion: 2017.1.0f3
m_EditorVersion: 2017.1.1f1