From 78b679ac01bcbc31d1b466c9419310fe42e73d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Fri, 8 Apr 2016 09:13:58 -0400 Subject: [PATCH 1/2] =?UTF-8?q?Restaurer=20les=20plateformes=20=C3=A0=20le?= =?UTF-8?q?ur=20=C3=A9tat=20normal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/PlanetManager.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 37ced3d..7e37f15 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -8,9 +8,9 @@ public class PlanetManager : MonoBehaviour public int NbCartiers = 10; public float TailleCartiersEnDegres = 0; //radian -> valeurs 0 a 360 - + public float CartierResetRatioSpeedFactor = 1.0f; + public bool CartierResetRatioSpeedRandomize = false; public GameObject WedgePrefab = null; - public List wedges = new List(); @@ -49,7 +49,34 @@ public class PlanetManager : MonoBehaviour foreach (var w in wedges) { + if (w.offset <= 1.05f && w.offset >= 0.95f) + { + w.offset = 1.0f; + } + else if (w.offset > 1.0f) + { + if (!CartierResetRatioSpeedRandomize) + { + w.offset -= 0.005f*CartierResetRatioSpeedFactor; + } + else + { + w.offset -= 0.005f*CartierResetRatioSpeedFactor*UnityEngine.Random.Range(0f, 2f); + } + } + else if (w.offset < 1.0f) + { + if (!CartierResetRatioSpeedRandomize) + { + w.offset += 0.005f*CartierResetRatioSpeedFactor; + } + else + { + w.offset += 0.005f*CartierResetRatioSpeedFactor*UnityEngine.Random.Range(0f, 2f); + } + } + w.sprite.transform.localScale = new Vector3(w.offset, w.offset,0.0f); } } From 7cad78c03819b179b0cb771aec97ca90b9864a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Fri, 8 Apr 2016 09:38:11 -0400 Subject: [PATCH 2/2] =?UTF-8?q?Ajout=C3=A9=20des=20valeur=20min=20max=20po?= =?UTF-8?q?ur=20les=20ratios,=20activ=C3=A9=20la=20randomisation=20pour=20?= =?UTF-8?q?le=20reset=20des=20plateformes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/PlanetManager.cs | 14 ++++++++------ Assets/Scripts/testRotate.cs | 15 ++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 7e37f15..f9df79b 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -8,8 +8,10 @@ public class PlanetManager : MonoBehaviour public int NbCartiers = 10; public float TailleCartiersEnDegres = 0; //radian -> valeurs 0 a 360 - public float CartierResetRatioSpeedFactor = 1.0f; - public bool CartierResetRatioSpeedRandomize = false; + public float CartierResetRatioSpeedFactor = 0.23f; //Entre 0.05 et 1 ou plus on aime que ca restore lentement, randomnly + public bool CartierResetRatioSpeedRandomize = true; + public float CartierMinRatio = 0.4f; + public float CartierMaxRatio = 2.0f; public GameObject WedgePrefab = null; public List wedges = new List(); @@ -61,7 +63,7 @@ public class PlanetManager : MonoBehaviour } else { - w.offset -= 0.005f*CartierResetRatioSpeedFactor*UnityEngine.Random.Range(0f, 2f); + w.offset -= 0.005f*CartierResetRatioSpeedFactor * UnityEngine.Random.Range(-0.5f, 2f); } } else if (w.offset < 1.0f) @@ -72,7 +74,7 @@ public class PlanetManager : MonoBehaviour } else { - w.offset += 0.005f*CartierResetRatioSpeedFactor*UnityEngine.Random.Range(0f, 2f); + w.offset += 0.005f*CartierResetRatioSpeedFactor*UnityEngine.Random.Range(0f, 3f); } } @@ -87,7 +89,7 @@ public class PlanetManager : MonoBehaviour var w = wedges[index]; w.offset = w.offset - 0.25f; - if (w.offset < 0.5f) + if (w.offset < CartierMinRatio) w.offset = 0.5f; @@ -98,7 +100,7 @@ public class PlanetManager : MonoBehaviour var v = wedges[indexOppose]; v.offset = v.offset + 0.25f; - if (v.offset > 1.5f) + if (v.offset > CartierMaxRatio) v.offset = 1.5f; v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); diff --git a/Assets/Scripts/testRotate.cs b/Assets/Scripts/testRotate.cs index 55bbf88..34a9c2f 100644 --- a/Assets/Scripts/testRotate.cs +++ b/Assets/Scripts/testRotate.cs @@ -6,15 +6,14 @@ public class testRotate : MonoBehaviour { - public float fireRate = 1.0f; + public float fireRate = 0.2f; private float lastShot = 0.0f; - + private float speed = 33.2f; void Update() { if(Input.GetKeyDown("space") || Input.GetKey("s")) { - Fire(); } } @@ -25,17 +24,15 @@ public class testRotate : MonoBehaviour { { lastShot = Time.time; - var speed = 13.2f; + var theta = Time.realtimeSinceStartup * speed % 360.0f; var pmgr = FindObjectOfType(); pmgr.PushWedge(theta); - - - - var index = pmgr.GetWedgeIndex(theta); + + } @@ -58,7 +55,7 @@ public class testRotate : MonoBehaviour { /// void FixedUpdate() { - var speed = 13.2f; + var theta = Time.realtimeSinceStartup * speed % 360.0f; // Position X du player = angle theta