diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 37ced3d..f9df79b 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -8,9 +8,11 @@ public class PlanetManager : MonoBehaviour 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 + public bool CartierResetRatioSpeedRandomize = true; + public float CartierMinRatio = 0.4f; + public float CartierMaxRatio = 2.0f; public GameObject WedgePrefab = null; - public List wedges = new List(); @@ -49,7 +51,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(-0.5f, 2f); + } + } + else if (w.offset < 1.0f) + { + if (!CartierResetRatioSpeedRandomize) + { + w.offset += 0.005f*CartierResetRatioSpeedFactor; + } + else + { + w.offset += 0.005f*CartierResetRatioSpeedFactor*UnityEngine.Random.Range(0f, 3f); + } + } + w.sprite.transform.localScale = new Vector3(w.offset, w.offset,0.0f); } } @@ -60,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; @@ -71,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