This commit is contained in:
Sophie 2016-04-08 09:43:12 -04:00
commit a112925d97
2 changed files with 39 additions and 13 deletions

View File

@ -8,9 +8,11 @@ public class PlanetManager : MonoBehaviour
public int NbCartiers = 10; public int NbCartiers = 10;
public float TailleCartiersEnDegres = 0; //radian -> valeurs 0 a 360 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 GameObject WedgePrefab = null;
public List<Wedge> wedges = new List<Wedge>(); public List<Wedge> wedges = new List<Wedge>();
@ -49,7 +51,34 @@ public class PlanetManager : MonoBehaviour
foreach (var w in wedges) 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]; var w = wedges[index];
w.offset = w.offset - 0.25f; w.offset = w.offset - 0.25f;
if (w.offset < 0.5f) if (w.offset < CartierMinRatio)
w.offset = 0.5f; w.offset = 0.5f;
@ -71,7 +100,7 @@ public class PlanetManager : MonoBehaviour
var v = wedges[indexOppose]; var v = wedges[indexOppose];
v.offset = v.offset + 0.25f; v.offset = v.offset + 0.25f;
if (v.offset > 1.5f) if (v.offset > CartierMaxRatio)
v.offset = 1.5f; v.offset = 1.5f;
v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1);

View File

@ -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 lastShot = 0.0f;
private float speed = 33.2f;
void Update() void Update()
{ {
if(Input.GetKeyDown("space") || Input.GetKey("s")) if(Input.GetKeyDown("space") || Input.GetKey("s"))
{ {
Fire(); Fire();
} }
} }
@ -25,17 +24,15 @@ public class testRotate : MonoBehaviour {
{ {
lastShot = Time.time; lastShot = Time.time;
var speed = 13.2f;
var theta = Time.realtimeSinceStartup * speed % 360.0f; var theta = Time.realtimeSinceStartup * speed % 360.0f;
var pmgr = FindObjectOfType<PlanetManager>(); var pmgr = FindObjectOfType<PlanetManager>();
pmgr.PushWedge(theta); pmgr.PushWedge(theta);
var index = pmgr.GetWedgeIndex(theta);
} }
@ -58,7 +55,7 @@ public class testRotate : MonoBehaviour {
/// </summary> /// </summary>
void FixedUpdate() void FixedUpdate()
{ {
var speed = 13.2f;
var theta = Time.realtimeSinceStartup * speed % 360.0f; // Position X du player = angle theta var theta = Time.realtimeSinceStartup * speed % 360.0f; // Position X du player = angle theta