mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-24 02:20:58 +00:00
Applied earthquake
This commit is contained in:
parent
db6a7e1fe9
commit
c1582a88a1
@ -74,7 +74,7 @@ ParticleSystem:
|
||||
minMaxState: 0
|
||||
speed: 1
|
||||
randomSeed: 0
|
||||
looping: 1
|
||||
looping: 0
|
||||
prewarm: 0
|
||||
playOnAwake: 1
|
||||
moveWithTransform: 1
|
||||
|
||||
@ -14,8 +14,8 @@ public class Astronaut : MonoBehaviour {
|
||||
public SpriteRenderer SpriteWalk;
|
||||
public GameObject SpriteDash;
|
||||
|
||||
public float Width;
|
||||
public float Height;
|
||||
public float SpriteWidth;
|
||||
public float SpriteHeight;
|
||||
public float DashTime = 0.4f; //Temps de l'animation et rate limiting
|
||||
private float lastDashTime = 0f;
|
||||
public float StepTime;
|
||||
@ -66,6 +66,10 @@ public class Astronaut : MonoBehaviour {
|
||||
|
||||
private float theta = 0;
|
||||
private float height = 0;
|
||||
public float Height
|
||||
{
|
||||
get { return height; }
|
||||
}
|
||||
private float vSpeed = 0;
|
||||
private bool grounded = false;
|
||||
private bool walkRight = false;
|
||||
@ -105,7 +109,7 @@ public class Astronaut : MonoBehaviour {
|
||||
private void UpdatePosition()
|
||||
{
|
||||
//float heightAtPos = planet.GetPlanetRadius(theta);
|
||||
transform.localPosition = new Vector3(0, height + Height / 2, 0);
|
||||
transform.localPosition = new Vector3(0, height + SpriteHeight / 2, 0);
|
||||
Rotator.transform.localRotation = Quaternion.Euler(0, 0, theta - 108);
|
||||
}
|
||||
|
||||
@ -116,7 +120,7 @@ public class Astronaut : MonoBehaviour {
|
||||
|
||||
private float GetGroundRadius(float theta)
|
||||
{
|
||||
float displacement = PlanetUtilities.GetDisplacementAngle(Width / 2, height);
|
||||
float displacement = PlanetUtilities.GetDisplacementAngle(SpriteWidth / 2, height);
|
||||
float radius1 = planet.GetPlanetRadius(Repeat(theta + displacement, 360));
|
||||
float radius2 = planet.GetPlanetRadius(Repeat(theta - displacement, 360));
|
||||
//float x1, y1, x2, y2;
|
||||
|
||||
@ -6,26 +6,30 @@ public class Earthquake : MonoBehaviour {
|
||||
|
||||
public float CriticalMin;
|
||||
public float CriticalMax;
|
||||
//public float testValue;
|
||||
public float ExplosionTime;
|
||||
public GameObject ExplosionParticle;
|
||||
private const float WaveSpeed = 1f;
|
||||
private const float WaveOffset = 1.3f;
|
||||
|
||||
//public float gaugeLevel;
|
||||
//public int gaugeMax=100;
|
||||
private SpriteRenderer core;
|
||||
PlanetManager pmgr;
|
||||
|
||||
bool isExploding;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
public void Start()
|
||||
{
|
||||
isExploding = false;
|
||||
pmgr = FindObjectOfType<PlanetManager>();
|
||||
//gaugeLevel = 0;
|
||||
core = this.GetComponent<SpriteRenderer>();
|
||||
//InvokeRepeating("FillGauge", 1, 1F);
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public void Update () {
|
||||
|
||||
if(!isExploding) return;
|
||||
|
||||
float disbalance = pmgr.GetDisbalance();
|
||||
float val = Mathf.Clamp((disbalance-CriticalMin) / (CriticalMax-CriticalMin),0,1);
|
||||
|
||||
@ -34,47 +38,37 @@ public class Earthquake : MonoBehaviour {
|
||||
|
||||
core.color = new Color(1f, 1f - val, 1f - val);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Actualiser l'affichage de la gauge
|
||||
/// </summary>
|
||||
public void UpdateFixed()
|
||||
if (val2 >= 1f)
|
||||
{
|
||||
EarthquakeBoom();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// à être Appelé à chaque fois qu'on enfonce un plateau, le gage se remplis plus vite. (et par le temps)
|
||||
/// </summary>
|
||||
public void FillGauge()
|
||||
void OnGUI()
|
||||
{
|
||||
|
||||
/*if (gaugeLevel < gaugeMax)
|
||||
if (GUI.Button(new Rect(100, 100, 50, 50), "BOOM"))
|
||||
{
|
||||
gaugeLevel += 1;
|
||||
|
||||
//anim state [0-90] normale, rotation
|
||||
|
||||
//color hue de plus en plus vers le rouge
|
||||
|
||||
//[90-100]
|
||||
//anim avec les ripples
|
||||
|
||||
|
||||
Debug.Log("Clicked the button with an image");
|
||||
EarthquakeBoom();
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
private void EarthquakeBoom()
|
||||
{
|
||||
|
||||
var planet = FindObjectOfType<PlanetManager>();
|
||||
|
||||
planet.CallEarthQuake();
|
||||
|
||||
gaugeLevel = 0;
|
||||
|
||||
}
|
||||
print("gauge is at: " + gaugeLevel);*/
|
||||
isExploding = true;
|
||||
StartCoroutine(Explode());
|
||||
Instantiate(ExplosionParticle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
IEnumerator Explode()
|
||||
{
|
||||
float realPosition;
|
||||
for (float i = 0; i < ExplosionTime; i += Time.deltaTime)
|
||||
{
|
||||
realPosition = WaveSpeed * i + WaveOffset;
|
||||
Debug.Log(realPosition);
|
||||
pmgr.EjectPlayers(realPosition);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,13 +172,19 @@ public class PlanetManager : MonoBehaviour
|
||||
v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// call fill gauge after every hit.
|
||||
var earthQuakeGauge = FindObjectOfType<Earthquake>();
|
||||
earthQuakeGauge.FillGauge();
|
||||
//var earthQuakeGauge = FindObjectOfType<Earthquake>();
|
||||
//earthQuakeGauge.FillGauge();
|
||||
}
|
||||
|
||||
public void EjectPlayers(float range)
|
||||
{
|
||||
Astronaut[] players = FindObjectsOfType<Astronaut>();
|
||||
foreach (Astronaut p in players)
|
||||
{
|
||||
if (p.State < Astronaut.AstronautState.Ejecting && p.Height <= range)
|
||||
p.Eject();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
39
Assets/Test/EarthquakeTest.cs
Normal file
39
Assets/Test/EarthquakeTest.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class EarthquakeTest : MonoBehaviour {
|
||||
|
||||
public GameObject particle;
|
||||
private GameObject obj;
|
||||
|
||||
public float Mod1, Mod2;
|
||||
|
||||
float timeSinceStart = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
timeSinceStart += Time.deltaTime;
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
if(obj!=null)
|
||||
Destroy(obj);
|
||||
obj = (GameObject)Instantiate(particle);
|
||||
timeSinceStart = 0f;
|
||||
}
|
||||
|
||||
if( Input.GetKeyDown(KeyCode.C))
|
||||
{
|
||||
Destroy(obj);
|
||||
obj = null;
|
||||
}
|
||||
|
||||
Debug.DrawLine(Vector3.zero, new Vector3(Mod1 * timeSinceStart + Mod2, 0f, 0f));
|
||||
}
|
||||
}
|
||||
12
Assets/Test/EarthquakeTest.cs.meta
Normal file
12
Assets/Test/EarthquakeTest.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b478dc9d54d60fe4cb0b8a261ec5f65b
|
||||
timeCreated: 1460226796
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -316,6 +316,56 @@ Prefab:
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 158e745881137e04ca2086294f44d74c, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1001 &1166215621
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0.11
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 8
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: SpriteWidth
|
||||
value: 0.4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
propertyPath: SpriteHeight
|
||||
value: 0.3
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1001 &1223268487
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -413,6 +463,14 @@ Prefab:
|
||||
propertyPath: CriticalMax
|
||||
value: 0.9
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11401034, guid: 198e988adacced646a19f757f6237ae1, type: 2}
|
||||
propertyPath: ExplosionTime
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11401034, guid: 198e988adacced646a19f757f6237ae1, type: 2}
|
||||
propertyPath: ExplosionParticle
|
||||
value:
|
||||
objectReference: {fileID: 143434, guid: a63c057a7a113a349b55d0ae61d0c936, type: 2}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 198e988adacced646a19f757f6237ae1, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user