Des explosions, partout !

This commit is contained in:
Jean-Sébastien Gervais 2016-04-08 23:19:00 -04:00
parent 653cd7aecc
commit b3dfa5d641
6 changed files with 156 additions and 92 deletions

View File

@ -7,10 +7,10 @@ Material:
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_Name: M_ExplosionParticle m_Name: M_ExplosionParticle
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: m_ShaderKeywords:
m_LightmapFlags: 5 m_LightmapFlags: 5
m_CustomRenderQueue: -1 m_CustomRenderQueue: 3000
stringTagMap: {} stringTagMap: {}
m_SavedProperties: m_SavedProperties:
serializedVersion: 2 serializedVersion: 2
@ -19,7 +19,7 @@ Material:
first: first:
name: _MainTex name: _MainTex
second: second:
m_Texture: {fileID: 0} m_Texture: {fileID: 2800000, guid: 29eb5cb075e0c1344981ff1e034e6b65, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
data: data:
@ -127,6 +127,10 @@ Material:
first: first:
name: _Metallic name: _Metallic
second: 0 second: 0
data:
first:
name: _InvFade
second: 1
m_Colors: m_Colors:
data: data:
first: first:
@ -136,3 +140,7 @@ Material:
first: first:
name: _Color name: _Color
second: {r: 1, g: 1, b: 1, a: 1} second: {r: 1, g: 1, b: 1, a: 1}
data:
first:
name: _TintColor
second: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}

View File

@ -106,6 +106,11 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
speed: 1 speed: 1
step: 0 step: 0
rotationSpeed: 1
rotationDirection: 1
RandomRotationSpeed: 1
CrashFlamesEmitter: {fileID: 120238, guid: 1a5b0b5645fa6104087fd9f96b6104b9, type: 2}
TrailFlamesEmitter: {fileID: 0}
--- !u!135 &13502558 --- !u!135 &13502558
SphereCollider: SphereCollider:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

View File

@ -74,7 +74,7 @@ ParticleSystem:
minMaxState: 0 minMaxState: 0
speed: 1 speed: 1
randomSeed: 0 randomSeed: 0
looping: 1 looping: 0
prewarm: 0 prewarm: 0
playOnAwake: 1 playOnAwake: 1
moveWithTransform: 1 moveWithTransform: 1

View File

@ -61,10 +61,19 @@ public class Asteroid : MonoBehaviour
if (CrashFlamesEmitter) if (CrashFlamesEmitter)
{ {
//Instantiate(CrashFlamesEmitter, this.transform.position, this.transform.forward); var crashPosition = this.transform.position;
//crashPosition.z = 1.15f;
var asteroidTheta = Mathf.Atan2(this.transform.position.y, this.transform.position.x);
var angleImpact = (360.0f + (((asteroidTheta * 180)) / Mathf.PI)) % 360; ///TODO : a changer pour p.theta
var emitter = (GameObject)Instantiate(CrashFlamesEmitter, crashPosition, Quaternion.identity);
//fix du prefab, il point à l'inverse de la caméra, ramenner avec rotation 90 deg en y
//et donner l'angle d'impact inverse en z (vers l'extérieur de la planete)
emitter.transform.Rotate(0,90.0f,angleImpact);
emitter.GetComponent<ParticleSystem>().Play(true);
} }
Destroy(this.gameObject); Destroy(this.gameObject);
} }
} }

View File

@ -1,86 +1,86 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
public class AsteroidSpawner : TimerFunctionsClass public class AsteroidSpawner : TimerFunctionsClass
{ {
public float NextSpawnTime = 1.0f; public float NextSpawnTime = 1.0f;
public GameObject AsteroidPrefab1; public GameObject AsteroidPrefab1;
public GameObject AsteroidPrefab2; public GameObject AsteroidPrefab2;
public GameObject AsteroidPrefab3; public GameObject AsteroidPrefab3;
public GameObject AsteroidPrefab4; public GameObject AsteroidPrefab4;
private List<GameObject> AsteroidPrefabTypes = new List<GameObject>(); private List<GameObject> AsteroidPrefabTypes = new List<GameObject>();
public bool GenerationVersLesjoueurs = false; //random lorsque false; public bool GenerationVersLesjoueurs = false; //random lorsque false;
// Use this for initialization // Use this for initialization
public void Start () public void Start ()
{ {
if (!AsteroidPrefab1 || !AsteroidPrefab2 || !AsteroidPrefab3 || !AsteroidPrefab4) if (!AsteroidPrefab1 || !AsteroidPrefab2 || !AsteroidPrefab3 || !AsteroidPrefab4)
{ {
Destroy(this.gameObject); Destroy(this.gameObject);
print("WARNING un type d'asteroide n'est pas defini dans les prefab. Vérifier l'objet avec un component AsteroidSpawner"); print("WARNING un type d'asteroide n'est pas defini dans les prefab. Vérifier l'objet avec un component AsteroidSpawner");
return; return;
} }
AsteroidPrefabTypes.Add(AsteroidPrefab1); AsteroidPrefabTypes.Add(AsteroidPrefab1);
AsteroidPrefabTypes.Add(AsteroidPrefab2); AsteroidPrefabTypes.Add(AsteroidPrefab2);
AsteroidPrefabTypes.Add(AsteroidPrefab3); AsteroidPrefabTypes.Add(AsteroidPrefab3);
AsteroidPrefabTypes.Add(AsteroidPrefab4); AsteroidPrefabTypes.Add(AsteroidPrefab4);
if (GenerationVersLesjoueurs) NextSpawnTime = 3 * NextSpawnTime; if (GenerationVersLesjoueurs) NextSpawnTime = 3 * NextSpawnTime;
this.SetTimer(NextSpawnTime, SpawnAsteroidEvent); this.SetTimer(NextSpawnTime, SpawnAsteroidEvent);
this.StartTimer(); this.StartTimer();
} }
// Update is called once per frame // Update is called once per frame
public void Update () { public void Update () {
base.Update(); base.Update();
} }
public void SpawnAsteroidEvent() public void SpawnAsteroidEvent()
{ {
if (!GenerationVersLesjoueurs) if (!GenerationVersLesjoueurs)
{ {
// Random entre 10 et 20, * 1 ou -1 // 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 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); var y = UnityEngine.Random.Range(10.0f, 20.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1);
//0-3 //0-3
var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f))); var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f)));
//instantiate as child of AsteroidSpawner //instantiate as child of AsteroidSpawner
var a = Instantiate(AsteroidPrefabTypes[AsteroidType], new Vector3(x, y, 0.0f), Quaternion.identity); var a = Instantiate(AsteroidPrefabTypes[AsteroidType], new Vector3(x, y, 0.0f), Quaternion.identity);
//a.tranform.parent = this.transform; //a.tranform.parent = this.transform;
} }
else else
{ {
var players = GameObject.FindGameObjectsWithTag("Player"); var players = GameObject.FindGameObjectsWithTag("Player");
var planet = FindObjectOfType<PlanetManager>(); var planet = FindObjectOfType<PlanetManager>();
foreach (var p in players) foreach (var p in players)
{ {
var playerTheta = Mathf.Atan2(p.transform.position.y, p.transform.position.x); 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 var angle = ( 360.0f + (((playerTheta * 180)) / Mathf.PI)) % 360; ///TODO : a changer pour p.theta
print("angle:" + angle); //print("angle:" + angle);
var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f))); var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f)));
float direction = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f)) * 2 - 1); float direction = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f)) * 2 - 1);
Instantiate(AsteroidPrefabTypes[AsteroidType], Instantiate(AsteroidPrefabTypes[AsteroidType],
direction*planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)), direction*planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)),
Quaternion.identity); Quaternion.identity);
} }
} }
//Cooldown untill next random spawn //Cooldown untill next random spawn
SetTimer(NextSpawnTime, SpawnAsteroidEvent); SetTimer(NextSpawnTime, SpawnAsteroidEvent);
StartTimer(); StartTimer();
} }
} }

View File

@ -104,6 +104,48 @@ MonoBehaviour:
WalkAnimSpeed: 0 WalkAnimSpeed: 0
WalkAnimAngle: 0 WalkAnimAngle: 0
EjectSpinSpeed: 0 EjectSpinSpeed: 0
--- !u!1001 &595727044
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: 6
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
m_IsPrefabParent: 0
--- !u!114 &1027139440 stripped --- !u!114 &1027139440 stripped
MonoBehaviour: MonoBehaviour:
m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1, m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1,