fixed shooting rockets when dead
This commit is contained in:
parent
80217db197
commit
b01c146481
6 changed files with 55 additions and 6 deletions
|
@ -6,7 +6,7 @@ public class Explosion : MonoBehaviour {
|
||||||
|
|
||||||
public PlayerController player;
|
public PlayerController player;
|
||||||
private float MAX_PLAYER_DIST = 3.0f;
|
private float MAX_PLAYER_DIST = 3.0f;
|
||||||
private float EXPLOSION_FORCE = 10.0f;
|
private float EXPLOSION_FORCE = 15.0f;
|
||||||
|
|
||||||
void Start () {
|
void Start () {
|
||||||
Vector3 playerPos = player.transform.position;
|
Vector3 playerPos = player.transform.position;
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class LevelController : MonoBehaviour {
|
||||||
{
|
{
|
||||||
if (wonLevel)
|
if (wonLevel)
|
||||||
return;
|
return;
|
||||||
|
PlayerController.GetController().KillPlayer();
|
||||||
winText.text = "TRY AGAIN!";
|
winText.text = "TRY AGAIN!";
|
||||||
StartCoroutine(DelayLoadLevel(SceneManager.GetActiveScene().name, 2.0f));
|
StartCoroutine(DelayLoadLevel(SceneManager.GetActiveScene().name, 2.0f));
|
||||||
}
|
}
|
||||||
|
@ -50,8 +51,10 @@ public class LevelController : MonoBehaviour {
|
||||||
GameObject start = GameObject.FindGameObjectWithTag ("Start");
|
GameObject start = GameObject.FindGameObjectWithTag ("Start");
|
||||||
player.transform.position = start.transform.position;
|
player.transform.position = start.transform.position;
|
||||||
winText.text = "";
|
winText.text = "";
|
||||||
|
PlayerController.GetController().RevivePlayer();
|
||||||
} else {
|
} else {
|
||||||
SceneManager.LoadScene (levelName);
|
levelController = null;
|
||||||
|
SceneManager.LoadScene (levelName);
|
||||||
}
|
}
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,44 @@ public class PlayerController : MonoBehaviour {
|
||||||
public GameObject rocketPrefab;
|
public GameObject rocketPrefab;
|
||||||
private float reloadTime = 0.25f;
|
private float reloadTime = 0.25f;
|
||||||
private bool reloading = false;
|
private bool reloading = false;
|
||||||
|
private static PlayerController controller;
|
||||||
// Update is called once per frame
|
private bool alive = true;
|
||||||
void Update () {
|
|
||||||
|
|
||||||
|
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
|
/*// Basic jumping
|
||||||
if (Input.GetKeyDown (KeyCode.Space)) {
|
if (Input.GetKeyDown (KeyCode.Space)) {
|
||||||
GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, jumpPower);
|
GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, jumpPower);
|
||||||
|
|
9
Game 1/Assets/Sprites.meta
Normal file
9
Game 1/Assets/Sprites.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1884be5a55d87e54689bff928b40ee6d
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1504642159
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -374,6 +374,9 @@ PlayerSettings:
|
||||||
switchUdpSendBufferSize: 9
|
switchUdpSendBufferSize: 9
|
||||||
switchUdpReceiveBufferSize: 42
|
switchUdpReceiveBufferSize: 42
|
||||||
switchSocketBufferEfficiency: 4
|
switchSocketBufferEfficiency: 4
|
||||||
|
switchSocketInitializeEnabled: 1
|
||||||
|
switchNetworkInterfaceManagerInitializeEnabled: 1
|
||||||
|
switchPlayerConnectionEnabled: 1
|
||||||
ps4NPAgeRating: 12
|
ps4NPAgeRating: 12
|
||||||
ps4NPTitleSecret:
|
ps4NPTitleSecret:
|
||||||
ps4NPTrophyPackPath:
|
ps4NPTrophyPackPath:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
m_EditorVersion: 2017.1.0f3
|
m_EditorVersion: 2017.1.1f1
|
||||||
|
|
Reference in a new issue