mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-24 02:20:58 +00:00
Réactivé boom naturel. PlanetManager vérifie combien de player restants
This commit is contained in:
parent
6b5e27bd97
commit
53bf519590
@ -43,25 +43,37 @@ public class AsteroidSpawner : TimerFunctionsClass
|
|||||||
|
|
||||||
public void SpawnAsteroidEvent()
|
public void SpawnAsteroidEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var planet = FindObjectOfType<PlanetManager>();
|
||||||
|
|
||||||
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(30.0f, 40.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1);
|
//var x = UnityEngine.Random.Range(30.0f, 40.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1);
|
||||||
var y = UnityEngine.Random.Range(20.0f, 30.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1);
|
//var y = UnityEngine.Random.Range(20.0f, 30.0f)*(Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1);
|
||||||
|
|
||||||
|
|
||||||
|
var angleRandom = UnityEngine.Random.Range(0, 359.9f);
|
||||||
|
|
||||||
|
|
||||||
//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);
|
||||||
|
|
||||||
|
Instantiate(AsteroidPrefabTypes[AsteroidType],
|
||||||
|
planet.GetPlanetCoordinatesFromPlayerXY(angleRandom, UnityEngine.Random.Range(15f, 25f)),
|
||||||
|
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>();
|
|
||||||
foreach (var p in players)
|
foreach (var p in players)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class Earthquake : MonoBehaviour {
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
public void Update () {
|
public void Update () {
|
||||||
|
|
||||||
if(!isExploding) return;
|
if(isExploding) return;
|
||||||
|
|
||||||
float disbalance = pmgr.GetDisbalance();
|
float disbalance = pmgr.GetDisbalance();
|
||||||
float val = Mathf.Clamp((disbalance-CriticalMin) / (CriticalMax-CriticalMin),0,1);
|
float val = Mathf.Clamp((disbalance-CriticalMin) / (CriticalMax-CriticalMin),0,1);
|
||||||
@ -38,7 +38,7 @@ public class Earthquake : MonoBehaviour {
|
|||||||
|
|
||||||
core.color = new Color(1f, 1f - val, 1f - val);
|
core.color = new Color(1f, 1f - val, 1f - val);
|
||||||
|
|
||||||
if (val2 >= 1f)
|
if (val2 >= CriticalMax + 0.05f)
|
||||||
{
|
{
|
||||||
EarthquakeBoom();
|
EarthquakeBoom();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
public class PlanetManager : MonoBehaviour
|
public class PlanetManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public int _NbActivePlayersRemaining = 0;
|
||||||
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 float CartierResetRatioSpeedFactor = 0.23f; //Entre 0.05 et 1 ou plus on aime que ca restore lentement, randomnly
|
||||||
@ -115,6 +116,30 @@ public class PlanetManager : MonoBehaviour
|
|||||||
w.sprite.transform.localScale = new Vector3(w.offset, w.offset,1.0f);
|
w.sprite.transform.localScale = new Vector3(w.offset, w.offset,1.0f);
|
||||||
}
|
}
|
||||||
//TODO_SR For each player
|
//TODO_SR For each player
|
||||||
|
VerifierPlayersActif();
|
||||||
|
|
||||||
|
if (_NbActivePlayersRemaining <= 1)
|
||||||
|
{
|
||||||
|
//TODO Call WorldManger.EndGame ou whatever
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void VerifierPlayersActif()
|
||||||
|
{
|
||||||
|
|
||||||
|
int nbJoueursTrouves = 0;
|
||||||
|
var players = GameObject.FindGameObjectsWithTag("Player");
|
||||||
|
|
||||||
|
foreach (var p in players)
|
||||||
|
{
|
||||||
|
if (p.GetComponent<Astronaut>().State < Astronaut.AstronautState.Ejecting)
|
||||||
|
{
|
||||||
|
nbJoueursTrouves++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_NbActivePlayersRemaining = nbJoueursTrouves;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PushWedge(float thetaPlayerX)
|
public void PushWedge(float thetaPlayerX)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user