diff --git a/Assets/Prefabs.meta b/Assets/Prefabs.meta index 01edf7c..b4a2cdc 100644 --- a/Assets/Prefabs.meta +++ b/Assets/Prefabs.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: e7cc8537ea5a6bf4b844573c98dc567e +guid: 96533e08f1684a4499d445c8fefb7b3e folderAsset: yes -timeCreated: 1460086265 +timeCreated: 1460093246 licenseType: Free DefaultImporter: userData: diff --git a/Assets/Prefabs/Asteroid.prefab b/Assets/Prefabs/Asteroid.prefab new file mode 100644 index 0000000..f21dc6f Binary files /dev/null and b/Assets/Prefabs/Asteroid.prefab differ diff --git a/Assets/Prefabs/Asteroid.prefab.meta b/Assets/Prefabs/Asteroid.prefab.meta new file mode 100644 index 0000000..0da83ea --- /dev/null +++ b/Assets/Prefabs/Asteroid.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc1a204562630cd40a1dd685b5ed8e6e +timeCreated: 1460093261 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/WedgePrefab.prefab b/Assets/Prefabs/WedgePrefab.prefab index 2aed2fd..b3ff5aa 100644 Binary files a/Assets/Prefabs/WedgePrefab.prefab and b/Assets/Prefabs/WedgePrefab.prefab differ diff --git a/Assets/Scripts.meta b/Assets/Scripts.meta index 14bba09..823506f 100644 --- a/Assets/Scripts.meta +++ b/Assets/Scripts.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: 2a2a40279929a214db32fd8ec2e94b23 +guid: f0123460f54262d43bd494bf9cbc0126 folderAsset: yes -timeCreated: 1460086249 +timeCreated: 1460093246 licenseType: Free DefaultImporter: userData: diff --git a/Assets/Scripts/Asteroid.cs b/Assets/Scripts/Asteroid.cs new file mode 100644 index 0000000..ab18c29 --- /dev/null +++ b/Assets/Scripts/Asteroid.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using System.Collections; + +public class Asteroid : MonoBehaviour +{ + Vector3 center; + public float speed; + public float step; + + // Use this for initialization + void Start () { + center = new Vector3(0, 0); + } + + // Update is called once per frame + void Update () { + MoveObject(center); + + } + + void MoveObject(Vector3 center) + { + step = speed * Time.deltaTime; + this.transform.position = Vector3.MoveTowards(transform.position, center, step); + } +} diff --git a/Assets/Scripts/Asteroid.cs.meta b/Assets/Scripts/Asteroid.cs.meta new file mode 100644 index 0000000..50ef0f8 --- /dev/null +++ b/Assets/Scripts/Asteroid.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 025c26020d5e62f40be0e8a2d063c51b +timeCreated: 1460088774 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 06db24c..c0fdb53 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -23,15 +23,16 @@ public class PlanetManager : MonoBehaviour { float debutAngleTheta = i* TailleCartiersEnDegres; var w = new Wedge() {tMin = debutAngleTheta, tMax = debutAngleTheta + TailleCartiersEnDegres}; - wedges.Add(w); //pushes at end. + //float angle = i * Mathf.PI * 2 / NbCartiers * 360; var wedgePos = GetPlanetCoordinatesFromPlayerXY(debutAngleTheta, 0); wedgePos.x -= 8/ Mathf.PI * Mathf.Cos(debutAngleTheta * Mathf.PI / 180); wedgePos.y -= 8/ Mathf.PI * Mathf.Sin(debutAngleTheta * Mathf.PI / 180); - Instantiate(WedgePrefab, wedgePos, Quaternion.Euler(0, 0, debutAngleTheta)); - - + var obj = Instantiate(WedgePrefab, wedgePos, Quaternion.Euler(0, 0, debutAngleTheta)); + obj.name = "wedge_" + i; + w.sprite = GameObject.Find(obj.name); + wedges.Add(w); //pushes at end. } } @@ -54,6 +55,55 @@ public class PlanetManager : MonoBehaviour } + public void PushWedge(float thetaPlayerX) + { + var index = GetWedgeIndex(thetaPlayerX); + var w = wedges[index]; + + + + w.offset = w.offset - 0.5f; + if (w.offset < -1.0f) + w.offset = -1.0f; + + var angle = w.tMin; //w.tMax - TailleCartiersEnDegres/2; + + var normalPos = GetPlanetCoordinatesFromPlayerXY(angle, 0); + normalPos.x -= 8 / Mathf.PI * Mathf.Cos(angle * Mathf.PI / 180); + normalPos.y -= 8 / Mathf.PI * Mathf.Sin(angle * Mathf.PI / 180); + + var wedgePos = GetPlanetCoordinatesFromPlayerXY(angle, 0); + wedgePos.x -= 8 / Mathf.PI * Mathf.Cos(angle * Mathf.PI / 180) - 50 * w.offset * Mathf.Cos(angle * Mathf.PI / 180); + wedgePos.y -= 8 / Mathf.PI * Mathf.Sin(angle * Mathf.PI / 180) - 50 * w.offset * Mathf.Sin(angle * Mathf.PI / 180); + + + w.sprite.transform.position = Vector3.Lerp(normalPos, wedgePos, Time.deltaTime); + + ///push back l'opposée + var indexOppose = GetWedgeOpposé(index); + var v = wedges[indexOppose]; + + v.offset = v.offset + 0.5f; + if (v.offset > 1.0f) + v.offset = 1.0f; + + angle = v.tMin; //w.tMax - TailleCartiersEnDegres/2; + + normalPos = GetPlanetCoordinatesFromPlayerXY(angle, 0); + normalPos.x -= 8 / Mathf.PI * Mathf.Cos(angle * Mathf.PI / 180); + normalPos.y -= 8 / Mathf.PI * Mathf.Sin(angle * Mathf.PI / 180); + + wedgePos = GetPlanetCoordinatesFromPlayerXY(angle, 0); + wedgePos.x -= 8 / Mathf.PI * Mathf.Cos(angle * Mathf.PI / 180) - 50 * v.offset * Mathf.Cos(angle * Mathf.PI / 180); + wedgePos.y -= 8 / Mathf.PI * Mathf.Sin(angle * Mathf.PI / 180) - 50 * v.offset * Mathf.Sin(angle * Mathf.PI / 180); + + + v.sprite.transform.position = Vector3.Lerp(normalPos, wedgePos, Time.deltaTime); + + + } + + /// /// Radius sphere est scale/2 /// @@ -110,7 +160,7 @@ public class PlanetManager : MonoBehaviour /// public class Wedge { - public float yoffset = 0; //valeurs entre -1 et 1; -1 étant renfoncé, 0 position normale, et 1 vers l'extérieur + public float offset = 0; //valeurs entre -1 et 1; -1 étant renfoncé, 0 position normale, et 1 vers l'extérieur public float tMin = 0; //theta min et theta max : angle thetat de début et fin du cartier; public float tMax = 0; diff --git a/Assets/Scripts/SpawnAsteroids.cs b/Assets/Scripts/SpawnAsteroids.cs new file mode 100644 index 0000000..751e263 --- /dev/null +++ b/Assets/Scripts/SpawnAsteroids.cs @@ -0,0 +1,41 @@ +using UnityEngine; +using System.Collections; + +public class SpawnAsteroids : MonoBehaviour { + + public GameObject myAsteroid; + Vector3 center; + float x; + float y; + float d; + + // Use this for initialization + void Start() + { + center = new Vector3(0, 0); + d = 4; + InvokeRepeating("Spawn", 0, 0.5F); + + } + + // Update is called once per frame + void Update () { + + } + + void Spawn() + { + GameObject instance = Instantiate(myAsteroid); + instance.transform.position = getPositions(); + } + + Vector3 getPositions() + { + float theta = Random.Range(0F, 360F); + x = center.x - Mathf.Sin(theta) * d; + y = center.y - Mathf.Cos(theta) * d; + return new Vector3(x, y); + } + + +} diff --git a/Assets/Scripts/SpawnAsteroids.cs.meta b/Assets/Scripts/SpawnAsteroids.cs.meta new file mode 100644 index 0000000..d0986ca --- /dev/null +++ b/Assets/Scripts/SpawnAsteroids.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 665432c96ca23f140a869ed98ade0dde +timeCreated: 1460092006 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/TimerFunctionsClass.cs b/Assets/Scripts/TimerFunctionsClass.cs new file mode 100644 index 0000000..a95f830 --- /dev/null +++ b/Assets/Scripts/TimerFunctionsClass.cs @@ -0,0 +1,92 @@ + +using UnityEngine; +using System.Collections; + + + +/// +/// +/// +public class TimerFunctionsClass : MonoBehaviour +{ + + public delegate void OnTimerEvent(); //delegate type definition + + private OnTimerEvent CallBackFunction; // the function that is called when the time is up + private float OriginalTimeInterval; // used for resetting + private float TimeLeft; // used for counting down + private bool Active = false; + + protected bool DestroyTimerOnTimeEnds = false; + + public string textTime = ""; + + + public float GetTimeLeft() + { + return TimeLeft; + } + + // setup the timer: how long should the timer wait and which function should it call when the event is triggered + public void SetTimer(float TimeInterval, OnTimerEvent NewCallBackFunction) + { + OriginalTimeInterval = TimeInterval; + TimeLeft = TimeInterval; + CallBackFunction = NewCallBackFunction; + } + + + // actually start the timer: + public void StartTimer() + { + Active = true; + } + + + // I'm not using this, but whatever: + public void StopTimer() + { + Active = false; + } + + + // ohwell + public void ResetTimer() + { + TimeLeft = OriginalTimeInterval; + } + + + public void DestroyTimer() + { + Destroy(this); + } + + + // TimeLeft is decreased by Time.deltaTime every tick, if it hits 0 then the CallBackFunction is called + public void Update() + { + + if (Active) + { + + TimeLeft -= Time.deltaTime; + if (TimeLeft <= 0) + { + CallBackFunction(); + + + //si usage unique + if (DestroyTimerOnTimeEnds) + { + StopTimer(); + DestroyTimer(); + } + + } + } + } + + + +} diff --git a/Assets/Scripts/TimerFunctionsClass.cs.meta b/Assets/Scripts/TimerFunctionsClass.cs.meta new file mode 100644 index 0000000..e2b2cee --- /dev/null +++ b/Assets/Scripts/TimerFunctionsClass.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ba34cb3424d86984e882e8e209276792 +timeCreated: 1460097512 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/testRotate.cs b/Assets/Scripts/testRotate.cs index 6c8155f..4560318 100644 --- a/Assets/Scripts/testRotate.cs +++ b/Assets/Scripts/testRotate.cs @@ -4,15 +4,52 @@ using System.Collections; public class testRotate : MonoBehaviour { + + + public float fireRate = 1.0f; + private float lastShot = 0.0f; + + + void Update() + { + if(Input.GetKeyDown("space") || Input.GetKey("s")) + { + + Fire(); + } + } + + private void Fire() + { + if (Time.time > fireRate + lastShot) + { + 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); + + + } + } + + // Use this for initialization void Start () { } - // Update is called once per frame - void Update () { - - } + + + /// /// Juste pour tester le mouvement du player autour du cercle. @@ -21,18 +58,18 @@ public class testRotate : MonoBehaviour { /// void FixedUpdate() { - var speed = 13.2; - var theta = Time.realtimeSinceStartup * speed % 360.0; // Position X du player = angle theta - var r = 5.0; //sphereradius + var speed = 13.2f; + var theta = Time.realtimeSinceStartup * speed % 360.0f; // Position X du player = angle theta + var r = 4.5f; //sphereradius // XY coordinates - double x = r * Math.Cos(theta * Math.PI / 180); - double y = r * Math.Sin(theta * Math.PI / 180); // + y0 du player + var x = r * Mathf.Cos(theta * Mathf.PI / 180); + var y = r * Mathf.Sin(theta * Mathf.PI / 180); // + y0 du player var player = GameObject.Find("CubePlayer").gameObject; - player.transform.position = Vector3.Lerp(player.transform.position, new Vector3( (float)x, (float)y, 0 ), Time.deltaTime); + player.transform.position = Vector3.Lerp(player.transform.position, new Vector3(x, y, 0 ), Time.deltaTime); } } diff --git a/Assets/Sounds.meta b/Assets/Sounds.meta index 8a769b8..9c1e5fe 100644 --- a/Assets/Sounds.meta +++ b/Assets/Sounds.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: c8a47bc917a8b874eabaca4e75369948 +guid: 043c9d3c0b79fd64b9d82d520495597e folderAsset: yes -timeCreated: 1460086241 +timeCreated: 1460093246 licenseType: Free DefaultImporter: userData: diff --git a/Assets/_Scenes.meta b/Assets/_Scenes.meta index 400ffa7..6e47d4c 100644 --- a/Assets/_Scenes.meta +++ b/Assets/_Scenes.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: 3c5f064c6cc9dad4d942c7175ca62bf8 +guid: eaff437385965f0409ef60dcab46e52a folderAsset: yes -timeCreated: 1460086225 +timeCreated: 1460088152 licenseType: Free DefaultImporter: userData: diff --git a/Assets/_Scenes/planet.unity b/Assets/_Scenes/planet.unity index 10b01e1..bc6ecc9 100644 Binary files a/Assets/_Scenes/planet.unity and b/Assets/_Scenes/planet.unity differ diff --git a/Assets/_Scenes/sophieScene.unity b/Assets/_Scenes/sophieScene.unity new file mode 100644 index 0000000..6729570 Binary files /dev/null and b/Assets/_Scenes/sophieScene.unity differ diff --git a/Assets/_Scenes/sophieScene.unity.meta b/Assets/_Scenes/sophieScene.unity.meta new file mode 100644 index 0000000..425f915 --- /dev/null +++ b/Assets/_Scenes/sophieScene.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ea0c30ed16d86641a0b486375c97c1a +timeCreated: 1460091128 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/m_asteroid.mat b/Assets/m_asteroid.mat new file mode 100644 index 0000000..11969cb Binary files /dev/null and b/Assets/m_asteroid.mat differ diff --git a/Assets/m_asteroid.mat.meta b/Assets/m_asteroid.mat.meta new file mode 100644 index 0000000..1e016b8 --- /dev/null +++ b/Assets/m_asteroid.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 373eeb9894b74ec43b7157c541d7cde8 +timeCreated: 1460088680 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 92dfed6..64d079b 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index c507092..9f9baf1 100644 Binary files a/ProjectSettings/TagManager.asset and b/ProjectSettings/TagManager.asset differ