mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-24 02:20:58 +00:00
Génération des astéroiride vers les players.
This commit is contained in:
parent
106f953436
commit
9b705e5044
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,13 @@ 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 () {
|
||||
void Start ()
|
||||
{
|
||||
|
||||
if (GenerationVersLesjoueurs) NextSpawnTime = 3 * NextSpawnTime;
|
||||
this.SetTimer(NextSpawnTime, SpawnAsteroidEvent);
|
||||
this.StartTimer();
|
||||
}
|
||||
@ -21,14 +25,33 @@ public class AsteroidSpawner : TimerFunctionsClass
|
||||
|
||||
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<PlanetManager>();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
//Cooldown untill next random spawn
|
||||
SetTimer(NextSpawnTime, SpawnAsteroidEvent);
|
||||
|
||||
@ -137,7 +137,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;
|
||||
}
|
||||
|
||||
@ -181,9 +181,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);
|
||||
}
|
||||
|
||||
@ -68,10 +68,10 @@ public class testRotate : MonoBehaviour {
|
||||
// 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;
|
||||
// var player = GameObject.Find("CubePlayer").gameObject;
|
||||
|
||||
//player.transform.position = Vector3.Lerp(player.transform.position, new Vector3(x, y, 0 ), Time.deltaTime);
|
||||
player.transform.position = Vector3.Lerp(player.transform.position,
|
||||
planet.GetPlanetCoordinatesFromPlayerXY(theta, 0f), Time.fixedDeltaTime);
|
||||
// player.transform.position = Vector3.Lerp(player.transform.position,
|
||||
// planet.GetPlanetCoordinatesFromPlayerXY(theta, 0f), Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,48 +127,7 @@ MonoBehaviour:
|
||||
textTime:
|
||||
NextSpawnTime: 1
|
||||
AsteroidPrefab: {fileID: 160026, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
--- !u!1001 &240262242
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 8.22
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 1.36
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494682, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
GenerationVersLesjoueurs: 1
|
||||
--- !u!1 &437600384
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -264,25 +223,6 @@ MonoBehaviour:
|
||||
CartierMaxRatio: 2
|
||||
CartierStepSize: 0.25
|
||||
WedgePrefab: {fileID: 170328, guid: 0b78da08dfa398840862539a74cc2377, type: 2}
|
||||
--- !u!1 &475725347 stripped
|
||||
GameObject:
|
||||
m_PrefabParentObject: {fileID: 160026, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
|
||||
m_PrefabInternal: {fileID: 240262242}
|
||||
--- !u!54 &475725353
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 475725347}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &638371353
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -383,7 +323,7 @@ GameObject:
|
||||
- 114: {fileID: 1250089535}
|
||||
m_Layer: 0
|
||||
m_Name: CubePlayer
|
||||
m_TagString: Untagged
|
||||
m_TagString: Player
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user