From 03fc23ed5c62aeb5e0bb5b1f90be4d98e9dfef83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Sat, 9 Apr 2016 16:21:58 -0400 Subject: [PATCH 1/4] =?UTF-8?q?appliqu=C3=A9=20shake=20sur=20Earthquake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Earthquake.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Earthquake.cs b/Assets/Scripts/Earthquake.cs index 1fe03f4..d79a7f0 100644 --- a/Assets/Scripts/Earthquake.cs +++ b/Assets/Scripts/Earthquake.cs @@ -57,7 +57,13 @@ public class Earthquake : MonoBehaviour { { isExploding = true; StartCoroutine(Explode()); - Instantiate(ExplosionParticle); + Instantiate(ExplosionParticle); + var camera = GameObject.Find("Main Camera"); + if (camera) + { + var shaker = camera.GetComponent(); + if (shaker) shaker.shakeTimeAmount = 2.0f; + } } IEnumerator Explode() From 6b5e27bd9700b896da50cb03883cf1a2793cb16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Sat, 9 Apr 2016 16:23:33 -0400 Subject: [PATCH 2/4] repush main --- Assets/_Scenes/Main.unity | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/_Scenes/Main.unity b/Assets/_Scenes/Main.unity index b29dcba..aad96fc 100644 --- a/Assets/_Scenes/Main.unity +++ b/Assets/_Scenes/Main.unity @@ -1091,6 +1091,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 015d8005b8f2f454da584e55b55711f5, type: 3} m_Name: m_EditorClassIdentifier: - shakeTimeAmount: 2 + shakeTimeAmount: 0 shakeAmount: 0.6 decreaseFactor: 1 From f966bf235c1015ccfb41ad332203c03d9df5a7cc Mon Sep 17 00:00:00 2001 From: Sophie Date: Sat, 9 Apr 2016 16:33:57 -0400 Subject: [PATCH 3/4] WorldManager singelton --- Assets/Scripts/WorldManager.cs | 25 +++++++++++++++++++++++++ Assets/Scripts/WorldManager.cs.meta | 12 ++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Assets/Scripts/WorldManager.cs create mode 100644 Assets/Scripts/WorldManager.cs.meta diff --git a/Assets/Scripts/WorldManager.cs b/Assets/Scripts/WorldManager.cs new file mode 100644 index 0000000..ba1ecdc --- /dev/null +++ b/Assets/Scripts/WorldManager.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using System.Collections; + +public class WorldManager : MonoBehaviour { + + private static WorldManager instance = null; + private WorldManager(){} + + // Use this for initialization + public void Awake () { + if (!instance) + { + instance = new WorldManager(); + } + } + + public WorldManager getInstance() { + return instance; + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/Assets/Scripts/WorldManager.cs.meta b/Assets/Scripts/WorldManager.cs.meta new file mode 100644 index 0000000..81bb7ca --- /dev/null +++ b/Assets/Scripts/WorldManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3eaea4cf17643ba42939e209672bc39e +timeCreated: 1460233556 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 53bf519590d10ac7a3a9a94546cfa51876d41d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Sat, 9 Apr 2016 17:02:51 -0400 Subject: [PATCH 4/4] =?UTF-8?q?R=C3=A9activ=C3=A9=20boom=20naturel.=20=20P?= =?UTF-8?q?lanetManager=20v=C3=A9rifie=20combien=20de=20player=20restants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/AsteroidSpawner.cs | 20 ++++++++++++++++---- Assets/Scripts/Earthquake.cs | 4 ++-- Assets/Scripts/PlanetManager.cs | 27 ++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/AsteroidSpawner.cs b/Assets/Scripts/AsteroidSpawner.cs index cb84664..3812775 100644 --- a/Assets/Scripts/AsteroidSpawner.cs +++ b/Assets/Scripts/AsteroidSpawner.cs @@ -43,25 +43,37 @@ public class AsteroidSpawner : TimerFunctionsClass public void SpawnAsteroidEvent() { + + + var planet = FindObjectOfType(); + if (!GenerationVersLesjoueurs) { // Random entre 10 et 20, * 1 ou -1 - var x = UnityEngine.Random.Range(30.0f, 40.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); - var y = UnityEngine.Random.Range(20.0f, 30.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); + //var x = UnityEngine.Random.Range(30.0f, 40.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); + //var y = UnityEngine.Random.Range(20.0f, 30.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); + + + var angleRandom = UnityEngine.Random.Range(0, 359.9f); //0-3 var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f))); //instantiate as child of AsteroidSpawner - var a = Instantiate(AsteroidPrefabTypes[AsteroidType], new Vector3(x, y, 0.0f), Quaternion.identity); + //var a = Instantiate(AsteroidPrefabTypes[AsteroidType], new Vector3(x, y, 0.0f), Quaternion.identity); + + Instantiate(AsteroidPrefabTypes[AsteroidType], + planet.GetPlanetCoordinatesFromPlayerXY(angleRandom, UnityEngine.Random.Range(15f, 25f)), + Quaternion.identity); + //a.tranform.parent = this.transform; } else { var players = GameObject.FindGameObjectsWithTag("Player"); - var planet = FindObjectOfType(); + foreach (var p in players) { diff --git a/Assets/Scripts/Earthquake.cs b/Assets/Scripts/Earthquake.cs index d79a7f0..b07acc3 100644 --- a/Assets/Scripts/Earthquake.cs +++ b/Assets/Scripts/Earthquake.cs @@ -28,7 +28,7 @@ public class Earthquake : MonoBehaviour { // Update is called once per frame public void Update () { - if(!isExploding) return; + if(isExploding) return; float disbalance = pmgr.GetDisbalance(); float val = Mathf.Clamp((disbalance-CriticalMin) / (CriticalMax-CriticalMin),0,1); @@ -38,7 +38,7 @@ public class Earthquake : MonoBehaviour { core.color = new Color(1f, 1f - val, 1f - val); - if (val2 >= 1f) + if (val2 >= CriticalMax + 0.05f) { EarthquakeBoom(); } diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 45cf612..0ed76bc 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; public class PlanetManager : MonoBehaviour { + public int _NbActivePlayersRemaining = 0; public int NbCartiers = 10; public float TailleCartiersEnDegres = 0; //radian -> valeurs 0 a 360 public float CartierResetRatioSpeedFactor = 0.23f; //Entre 0.05 et 1 ou plus on aime que ca restore lentement, randomnly @@ -114,7 +115,31 @@ public class PlanetManager : MonoBehaviour w.sprite.transform.localScale = new Vector3(w.offset, w.offset,1.0f); } - //TODO_SR For each player + //TODO_SR For each player + VerifierPlayersActif(); + + if (_NbActivePlayersRemaining <= 1) + { + //TODO Call WorldManger.EndGame ou whatever + } + + } + + private void VerifierPlayersActif() + { + + int nbJoueursTrouves = 0; + var players = GameObject.FindGameObjectsWithTag("Player"); + + foreach (var p in players) + { + if (p.GetComponent().State < Astronaut.AstronautState.Ejecting) + { + nbJoueursTrouves++; + } + } + + _NbActivePlayersRemaining = nbJoueursTrouves; } public void PushWedge(float thetaPlayerX)