diff --git a/Assets/Prefabs/Asteroid.prefab b/Assets/Prefabs/Asteroid.prefab index d28abf7..5849238 100644 --- a/Assets/Prefabs/Asteroid.prefab +++ b/Assets/Prefabs/Asteroid.prefab @@ -9,9 +9,9 @@ GameObject: m_Component: - 4: {fileID: 494682} - 33: {fileID: 3335396} - - 135: {fileID: 13519402} - 23: {fileID: 2317388} - 114: {fileID: 11437858} + - 135: {fileID: 13502558} m_Layer: 0 m_Name: Asteroid m_TagString: Asteroid @@ -26,7 +26,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 160026} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3.51, y: 1.36, z: 0} + m_LocalPosition: {x: 8.22, y: 1.36, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -77,14 +77,14 @@ MonoBehaviour: m_EditorClassIdentifier: speed: 1 step: 0 ---- !u!135 &13519402 +--- !u!135 &13502558 SphereCollider: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 160026} m_Material: {fileID: 0} - m_IsTrigger: 0 + m_IsTrigger: 1 m_Enabled: 1 serializedVersion: 2 m_Radius: 0.5 diff --git a/Assets/Prefabs/WedgePrefab00.prefab b/Assets/Prefabs/WedgePrefab00.prefab index f46b5df..73389f1 100644 --- a/Assets/Prefabs/WedgePrefab00.prefab +++ b/Assets/Prefabs/WedgePrefab00.prefab @@ -9,9 +9,11 @@ GameObject: m_Component: - 4: {fileID: 427432} - 212: {fileID: 21228928} + - 135: {fileID: 13583406} + - 54: {fileID: 5455998} m_Layer: 0 m_Name: WedgePrefab - m_TagString: Untagged + m_TagString: Wedge m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -56,6 +58,33 @@ Transform: m_Children: [] m_Father: {fileID: 411762} m_RootOrder: 0 +--- !u!54 &5455998 +Rigidbody: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 152938} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 0 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 +--- !u!135 &13583406 +SphereCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 152938} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 2 + m_Center: {x: 0, y: 0, z: 0} --- !u!212 &21228928 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/Scripts/Asteroid.cs b/Assets/Scripts/Asteroid.cs index 23cb82d..56875e8 100644 --- a/Assets/Scripts/Asteroid.cs +++ b/Assets/Scripts/Asteroid.cs @@ -10,8 +10,8 @@ public class Asteroid : MonoBehaviour // Use this for initialization void Start() { - speed = Random.Range(0.1F, 2F); - print(speed); + speed = Random.Range(0.9F, 3F); + // print(speed); center = new Vector3(0, 0); } @@ -26,4 +26,22 @@ public class Asteroid : MonoBehaviour step = speed * Time.deltaTime; this.transform.position = Vector3.MoveTowards(transform.position, center, step); } + + //collider must be set as "isTrigger" in unity for this method to work + public void OnTriggerEnter(Collider otherCol) + { + + + if (otherCol.gameObject.tag == "Player") + { + //Stun the player + } + if (otherCol.gameObject.tag == "Wedge") + { + var pmgr = FindObjectOfType(); + pmgr.PushWedge(otherCol.gameObject.transform.parent.eulerAngles.z); + Destroy(this.gameObject); + } + } + } diff --git a/Assets/Scripts/AsteroidSpawner.cs b/Assets/Scripts/AsteroidSpawner.cs new file mode 100644 index 0000000..821fb83 --- /dev/null +++ b/Assets/Scripts/AsteroidSpawner.cs @@ -0,0 +1,60 @@ +using UnityEngine; +using System.Collections; +using System; + +public class AsteroidSpawner : TimerFunctionsClass +{ + + public float NextSpawnTime = 1.0f; + public GameObject AsteroidPrefab; + public bool GenerationVersLesjoueurs = true; //random lorsque false; + + // Use this for initialization + void Start () + { + + if (GenerationVersLesjoueurs) NextSpawnTime = 3 * NextSpawnTime; + this.SetTimer(NextSpawnTime, SpawnAsteroidEvent); + this.StartTimer(); + } + + // Update is called once per frame + void Update () { + base.Update(); + } + + public void SpawnAsteroidEvent() + { + if (!GenerationVersLesjoueurs) + { + // Random entre 10 et 20, * 1 ou -1 + var x = UnityEngine.Random.Range(10.0f, 20.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); + var y = UnityEngine.Random.Range(10.0f, 20.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); + + //instantiate as child of AsteroidSpawner + var a = Instantiate(AsteroidPrefab, new Vector3(x, y, 0.0f), Quaternion.identity); + //a.tranform.parent = this.transform; + + } + else + { + var players = GameObject.FindGameObjectsWithTag("Player"); + var planet = FindObjectOfType(); + foreach (var p in players) + { + var playerTheta = Mathf.Atan2(p.transform.position.y, p.transform.position.x); + var angle = ( 360.0f + (((playerTheta * 180)) / Mathf.PI)) % 360; ///TODO : a changer pour p.theta + print("angle:" + angle); + Instantiate(AsteroidPrefab, planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)), Quaternion.identity); + } + + } + + + + + //Cooldown untill next random spawn + SetTimer(NextSpawnTime, SpawnAsteroidEvent); + StartTimer(); + } +} diff --git a/Assets/Scripts/AsteroidSpawner.cs.meta b/Assets/Scripts/AsteroidSpawner.cs.meta new file mode 100644 index 0000000..29c31c5 --- /dev/null +++ b/Assets/Scripts/AsteroidSpawner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43c82cd8902191d49b45cf914b13e97c +timeCreated: 1460125980 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 026fa9d..1943e78 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -225,7 +225,7 @@ public class Astronaut : MonoBehaviour { { Vector3 rotation = transform.rotation.eulerAngles; rotation.z = Mathf.Sin(walkTime*Mathf.PI)*50; - print("rotation " + rotation); + // print("rotation " + rotation); transform.rotation = Quaternion.Euler(rotation); yield return null; } diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 2b80cc8..9bf9861 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -12,6 +12,7 @@ public class PlanetManager : MonoBehaviour public bool CartierResetRatioSpeedRandomize = true; public float CartierMinRatio = 0.4f; public float CartierMaxRatio = 2.0f; + public float CartierStepSize = 0.25f; public GameObject WedgePrefab = null; public List wedges = new List(); @@ -75,7 +76,7 @@ public class PlanetManager : MonoBehaviour } } - w.sprite.transform.localScale = new Vector3(w.offset, w.offset,0.0f); + w.sprite.transform.localScale = new Vector3(w.offset, w.offset,1.0f); } //TODO_SR For each player } @@ -85,7 +86,7 @@ public class PlanetManager : MonoBehaviour var index = GetWedgeIndex(thetaPlayerX); var w = wedges[index]; - w.offset = w.offset - 0.25f; + w.offset = w.offset - CartierStepSize; if (w.offset < CartierMinRatio) w.offset = 0.5f; @@ -96,7 +97,7 @@ public class PlanetManager : MonoBehaviour var indexOppose = GetWedgeOpposé(index); var v = wedges[indexOppose]; - v.offset = v.offset + 0.25f; + v.offset = v.offset + CartierStepSize; if (v.offset > CartierMaxRatio) v.offset = 1.5f; @@ -176,9 +177,9 @@ public class PlanetManager : MonoBehaviour public Vector3 GetPlanetCoordinatesFromPlayerXY(float playerLocalX, float playerLocalY) { var theta = playerLocalX; - var wedgeRadius = GetPlanetRadius(playerLocalX); + var wedgeRadius = GetPlanetRadius(playerLocalX) + playerLocalY; var x = wedgeRadius * Mathf.Cos(theta * Mathf.PI / 180); - var y = wedgeRadius * Mathf.Sin(theta * Mathf.PI / 180) + playerLocalY; + var y = wedgeRadius * Mathf.Sin(theta * Mathf.PI / 180) ; return new Vector3(x, y, 0); } @@ -220,7 +221,7 @@ public class PlanetManager : MonoBehaviour /// public class Wedge { - public float offset = 1.0f; //valeurs entre -1 et 1; -1 étant renfoncé, 0 position normale, et 1 vers l'extérieur + public float offset = 1.0f; //valeurs entre minRatio et maxRatio; < 1 étant renfoncé, 1 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/_Scenes/planet.unity b/Assets/_Scenes/planet.unity index db41455..a382705 100644 --- a/Assets/_Scenes/planet.unity +++ b/Assets/_Scenes/planet.unity @@ -85,6 +85,49 @@ NavMeshSettings: cellSize: 0.16666667 manualCellSize: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &150247454 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 150247455} + - 114: {fileID: 150247456} + m_Layer: 0 + m_Name: AsteroidSpawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &150247455 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 150247454} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 +--- !u!114 &150247456 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 150247454} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 43c82cd8902191d49b45cf914b13e97c, type: 3} + m_Name: + m_EditorClassIdentifier: + textTime: + NextSpawnTime: 1 + AsteroidPrefab: {fileID: 160026, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2} + GenerationVersLesjoueurs: 1 --- !u!1 &437600384 GameObject: m_ObjectHideFlags: 0 @@ -103,7 +146,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!23 &437600385 MeshRenderer: m_ObjectHideFlags: 0 @@ -174,7 +217,12 @@ MonoBehaviour: m_EditorClassIdentifier: NbCartiers: 10 TailleCartiersEnDegres: 0 - WedgePrefab: {fileID: 186656, guid: 901b80ca01ac0de4ca89de7f82c3709f, type: 2} + CartierResetRatioSpeedFactor: 0.23 + CartierResetRatioSpeedRandomize: 1 + CartierMinRatio: 0.4 + CartierMaxRatio: 2 + CartierStepSize: 0.25 + WedgePrefab: {fileID: 170328, guid: 0b78da08dfa398840862539a74cc2377, type: 2} --- !u!1 &638371353 GameObject: m_ObjectHideFlags: 0 @@ -273,11 +321,9 @@ GameObject: - 65: {fileID: 1250089530} - 23: {fileID: 1250089529} - 114: {fileID: 1250089535} - - 114: {fileID: 1250089534} - - 114: {fileID: 1250089533} m_Layer: 0 m_Name: CubePlayer - m_TagString: Untagged + m_TagString: Player m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -339,28 +385,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 ---- !u!114 &1250089533 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1250089528} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 7dea5240387606044ad82f94c4235e31, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!114 &1250089534 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1250089528} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ab91e6d9b759ad545b023f33788c97ba, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!114 &1250089535 MonoBehaviour: m_ObjectHideFlags: 0 @@ -372,4 +396,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ac56b6226ed50a742a676cbfae403f88, type: 3} m_Name: m_EditorClassIdentifier: - fireRate: 1 + fireRate: 0.2 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 8f98569..793cb0a 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -4,7 +4,7 @@ TagManager: serializedVersion: 2 tags: - - Asteroid + - Wedge layers: - Default - TransparentFX