Conflicts:
	Assets/Scripts/Astronaut.cs
	Assets/Scripts/PlanetManager.cs
This commit is contained in:
RosimInc 2016-04-09 13:18:18 -04:00
commit 74982f9f63
10 changed files with 277 additions and 54 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View File

@ -0,0 +1,57 @@
fileFormatVersion: 2
guid: 8d3ba69018238ee4f9629282ea7d9fcf
timeCreated: 1460214709
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

View File

@ -0,0 +1,57 @@
fileFormatVersion: 2
guid: 7443ae7f877013a42941481b83fee96b
timeCreated: 1460214707
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -145,7 +145,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ab270b0cb2475114ab8eb45661af0df1, type: 3} m_Script: {fileID: 11500000, guid: ab270b0cb2475114ab8eb45661af0df1, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
PlayerNumber: 1 PlayerNumber: 0
--- !u!114 &11491252 --- !u!114 &11491252
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -158,8 +158,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
aspi: {fileID: 0} aspi: {fileID: 0}
WalkAnimSpeed: 0 WalkAnimSpeed: 4
WalkAnimAngle: 0 WalkAnimAngle: 15
EjectSpinSpeed: 80 EjectSpinSpeed: 80
DustParticlesEmitter: {fileID: 138982, guid: 6233079c5a9a756458811f283fdca112, type: 2} DustParticlesEmitter: {fileID: 138982, guid: 6233079c5a9a756458811f283fdca112, type: 2}
--- !u!114 &11494368 --- !u!114 &11494368

View File

@ -106,6 +106,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c11fa6fea03561044843359e6d9d23a6, type: 3} m_Script: {fileID: 11500000, guid: c11fa6fea03561044843359e6d9d23a6, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
CriticalMin: 0.2
CriticalMax: 0.9
--- !u!114 &11401780 --- !u!114 &11401780
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -139,6 +141,8 @@ MonoBehaviour:
CartierMinRatio: 0.75 CartierMinRatio: 0.75
CartierMaxRatio: 1.25 CartierMaxRatio: 1.25
CartierStepSize: 0.25 CartierStepSize: 0.25
CartierWaitBeforeRaise: 0.6
balanceValue: 0
WedgePrefab: {fileID: 170328, guid: 0b78da08dfa398840862539a74cc2377, type: 2} WedgePrefab: {fileID: 170328, guid: 0b78da08dfa398840862539a74cc2377, type: 2}
--- !u!135 &13593906 --- !u!135 &13593906
SphereCollider: SphereCollider:

View File

@ -56,11 +56,10 @@ public class Astronaut : MonoBehaviour {
SpriteDash.gameObject.SetActive(false); SpriteDash.gameObject.SetActive(false);
}*/ }*/
/*if (_state == AstronautState.Walking) if (State == AstronautState.Walking)
{ {
//StartCoroutine(WalkingStance()); _astronautAnimator.Walk(walkRight);
_astronautAnimator.Walk(); }
}*/
} }
} }
@ -68,6 +67,7 @@ public class Astronaut : MonoBehaviour {
private float height = 0; private float height = 0;
private float vSpeed = 0; private float vSpeed = 0;
private bool grounded = false; private bool grounded = false;
private bool walkRight = false;
private float walkTime = 0; private float walkTime = 0;
private int nextStep = 1; private int nextStep = 1;
@ -127,6 +127,7 @@ public class Astronaut : MonoBehaviour {
private float Repeat(float num, float limit) private float Repeat(float num, float limit)
{ {
//This is a modulus
return Mathf.Repeat(num + limit, limit); return Mathf.Repeat(num + limit, limit);
} }
@ -200,17 +201,28 @@ public class Astronaut : MonoBehaviour {
public void Move(float x, float y) public void Move(float x, float y)
{ {
float playerX, playerY;
PlanetUtilities.Spheric2Cartesian(theta - 108, height, out playerX, out playerY);
Vector3 pos = new Vector3(playerX, playerY);
Vector3 dirV = Vector3.Cross(pos, Vector3.forward).normalized;
float proj = Vector3.Dot(new Vector3(x, y, 0), dirV);
float move = proj;
if (State >= AstronautState.Ejecting ) if (State >= AstronautState.Ejecting )
return; return;
if (State < AstronautState.Jumping) if (State < AstronautState.Jumping)
{ {
if (Mathf.Approximately(x, 0)) if (Mathf.Approximately(move, 0))
{ {
State = AstronautState.Idle; State = AstronautState.Idle;
} }
else else
{ {
walkRight = move > 0;
State = AstronautState.Walking; State = AstronautState.Walking;
walkTime = 0f; walkTime = 0f;
} }
@ -218,17 +230,16 @@ public class Astronaut : MonoBehaviour {
if (State < AstronautState.Dashing) if (State < AstronautState.Dashing)
{ {
if (-0.2 < x && x < 0.2) return; if (-0.2 < move && move < 0.2) return;
//Debug.Log(x + " " + Speed + " " + height);
float movement = PlanetUtilities.GetDisplacementAngle(Speed * -x, height) * Time.deltaTime; float movement = PlanetUtilities.GetDisplacementAngle(Speed * -move, height) * Time.deltaTime;
//Debug.Log("Moving! - " + height);
//Debug.Log("Daaa - " + movement); float newTheta = Repeat(theta + movement, 360);
float newTheta = (360 + theta + movement) % 360; // angle positif
float newHeight = GetGroundRadius(newTheta); float newHeight = GetGroundRadius(newTheta);
if (newHeight > height) if (newHeight > height)
{ {
Debug.Log("Blocked by wall"); //Debug.Log("Blocked by wall");
return; // Blocked by wall return; // Blocked by wall
} }
@ -239,15 +250,10 @@ public class Astronaut : MonoBehaviour {
//TODO arreter mouvement lateral //TODO arreter mouvement lateral
State=AstronautState.Idle; State=AstronautState.Idle;
} }
} }
public void Jump() public void Jump()
{ {
Debug.Log("Jump!");
if (State == AstronautState.Jumping) if (State == AstronautState.Jumping)
{ {
Dash(); Dash();
@ -260,9 +266,10 @@ public class Astronaut : MonoBehaviour {
else if (State >= AstronautState.Ejecting) else if (State >= AstronautState.Ejecting)
return; return;
if (!grounded) return;
_astronautAnimator.Jump(); // deja dans le property get/set _astronautAnimator.Jump(); // deja dans le property get/set
if (!grounded) return;
vSpeed = JumpSpeed; vSpeed = JumpSpeed;
grounded = false; grounded = false;
State = AstronautState.Jumping; State = AstronautState.Jumping;
@ -308,7 +315,14 @@ public class Astronaut : MonoBehaviour {
if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString())) if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString()))
{ {
Debug.Log("Clicked the button with an image"); Debug.Log("Clicked the button with an image");
Eject(); //_astronautAnimator.Walk();
//Eject();
} }
/* if (GUI.Button(new Rect(60, 10, 150, 50), "Stop"))
{
Debug.Log("Clicked the button with an image");
_astronautAnimator.StopWalk();
//Eject();
}*/
} }
} }

View File

@ -39,9 +39,10 @@ public class AstronautAnimator : MonoBehaviour {
aspi.SpriteDash.gameObject.SetActive(false); aspi.SpriteDash.gameObject.SetActive(false);
} }
public void Walk() public void Walk(bool right)
{ {
StartCoroutine(Rotate()); Debug.Log("Walking!");
StartCoroutine(Rotate(right? -1 : 1));
} }
public void Eject() public void Eject()
@ -58,9 +59,9 @@ public class AstronautAnimator : MonoBehaviour {
} }
} }
IEnumerator Rotate() IEnumerator Rotate(float side)
{ {
for (float i = 0.5f; i < 2.5f; i+= Time.deltaTime*WalkAnimSpeed) for (float i = 0.5f; i < 1.5f; i+= Time.deltaTime*WalkAnimSpeed)
{ {
/*int roundDown = 10; /*int roundDown = 10;
//0.5, 1.5 et 2.5 //0.5, 1.5 et 2.5
@ -70,15 +71,18 @@ public class AstronautAnimator : MonoBehaviour {
aspi.SpriteWalk.flipX = !aspi.SpriteWalk.flipX; aspi.SpriteWalk.flipX = !aspi.SpriteWalk.flipX;
}*/ }*/
float position = Mathf.PingPong(i, 1f); float position = Mathf.PingPong(i, 1f);
transform.rotation = Quaternion.Euler(0, 0, (position - 0.5f) * WalkAnimAngle * 2); transform.localRotation = Quaternion.Euler(0, 0, side * (position - 0.5f) * WalkAnimAngle * 2);
yield return null; yield return null;
} }
if (aspi.State == Astronaut.AstronautState.Walking) if (aspi.State == Astronaut.AstronautState.Walking)
{ {
StartCoroutine(Rotate()); Debug.Log("Walking again");
StartCoroutine(Rotate(-side));
} }
yield return null; else
Debug.Log("Walking stop");
//yield return null;
} }
public void EmitDustParticules() public void EmitDustParticules()

View File

@ -14,6 +14,7 @@ public class PlanetManager : MonoBehaviour
public float CartierMinRatio = 0.4f; public float CartierMinRatio = 0.4f;
public float CartierMaxRatio = 2.0f; public float CartierMaxRatio = 2.0f;
public float CartierStepSize = 0.25f; public float CartierStepSize = 0.25f;
public float CartierWaitBeforeRaise = 2f;
public float balanceValue; public float balanceValue;
private float disbalance = 0f; private float disbalance = 0f;
public GameObject WedgePrefab = null; public GameObject WedgePrefab = null;
@ -88,7 +89,7 @@ public class PlanetManager : MonoBehaviour
{ {
w.offset = 1.0f; w.offset = 1.0f;
} }
else if (w.offset > 1.0f) else if (w.offset > 1.0f && Time.time >= w.timeSinceLastPushedBack + CartierWaitBeforeRaise)
{ {
if (!CartierResetRatioSpeedRandomize) if (!CartierResetRatioSpeedRandomize)
{ {
@ -96,10 +97,10 @@ public class PlanetManager : MonoBehaviour
} }
else else
{ {
w.offset -= 0.005f*CartierResetRatioSpeedFactor * UnityEngine.Random.Range(-0.5f, 2f); w.offset -= 0.005f*CartierResetRatioSpeedFactor * UnityEngine.Random.Range(-0.5f, 1.8f);
} }
} }
else if (w.offset < 1.0f) else if ((w.offset < 1.0f) && Time.time >= w.timeSincePushedToMinimum + CartierWaitBeforeRaise )
{ {
if (!CartierResetRatioSpeedRandomize) if (!CartierResetRatioSpeedRandomize)
{ {
@ -121,9 +122,18 @@ public class PlanetManager : MonoBehaviour
var index = GetWedgeIndex(thetaPlayerX); var index = GetWedgeIndex(thetaPlayerX);
var w = wedges[index]; var w = wedges[index];
var difference = CartierStepSize;
var wOffsetBefore = w.offset;
w.offset = w.offset - CartierStepSize; w.offset = w.offset - CartierStepSize;
if (w.offset < CartierMinRatio) if (w.offset <= CartierMinRatio)
{
difference -= CartierMinRatio - w.offset; //enlever du push pour la plateforme qui va faire pousser dans le sens opposé
w.timeSincePushedToMinimum = Time.time;
w.offset = CartierMinRatio; w.offset = CartierMinRatio;
}
w.sprite.transform.localScale = new Vector3(w.offset, w.offset, 1); w.sprite.transform.localScale = new Vector3(w.offset, w.offset, 1);
@ -132,7 +142,12 @@ public class PlanetManager : MonoBehaviour
var indexOppose = GetWedgeOpposé(index); var indexOppose = GetWedgeOpposé(index);
var v = wedges[indexOppose]; var v = wedges[indexOppose];
v.offset = v.offset + CartierStepSize; // if (Time.time >= v.timeSincePushedToMinimum + CartierWaitBeforeRaise) // résultats étranges ;)
// if (wOffsetBefore >= 0.9f)
// {
if (v.offset < CartierMaxRatio) v.timeSinceLastPushedBack = Time.time;
v.offset = v.offset + difference; //CartierStepSize; //diférentiel au lieu du step size
if (v.offset >= CartierMaxRatio) if (v.offset >= CartierMaxRatio)
{ {
v.offset = CartierMaxRatio; v.offset = CartierMaxRatio;
@ -147,12 +162,13 @@ public class PlanetManager : MonoBehaviour
p.Eject(); p.Eject();
} }
} }
} }
v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1);
// }
// call fill gauge after every hit. // call fill gauge after every hit.
var earthQuakeGauge = FindObjectOfType<Earthquake>(); var earthQuakeGauge = FindObjectOfType<Earthquake>();
@ -301,7 +317,7 @@ public class PlanetManager : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public Wedge GetWedgeFromTheta(float thetaPlayerX) public Wedge GetWedgeFromTheta(float thetaPlayerX)
{ {
return wedges[GetWedgeIndex((thetaPlayerX) % 360)]; return wedges[GetWedgeIndex((360 + thetaPlayerX) % 360)];
} }
/// <summary> /// <summary>
@ -312,7 +328,8 @@ public class PlanetManager : MonoBehaviour
public float offset = 1.0f; //valeurs entre minRatio et maxRatio; < 1 étant renfoncé, 1 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 tMin = 0; //theta min et theta max : angle thetat de début et fin du cartier;
public float tMax = 0; public float tMax = 0;
public float timeSincePushedToMinimum = 0.0f;
public float timeSinceLastPushedBack = 0.0f;
public GameObject sprite; //sprite et collider 2D public GameObject sprite; //sprite et collider 2D
public GameObject gameObject; //wedge prefab avec collider public GameObject gameObject; //wedge prefab avec collider
} }

View File

@ -132,10 +132,6 @@ Prefab:
propertyPath: m_Name propertyPath: m_Name
value: Astronaut_0 value: Astronaut_0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: PlayerNumber
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0
@ -241,6 +237,64 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 7
--- !u!1 &227879751
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 227879752}
- 212: {fileID: 227879753}
m_Layer: 0
m_Name: Atmosphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &227879752
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 227879751}
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: 1867085522}
m_RootOrder: 1
--- !u!212 &227879753
SpriteRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 227879751}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 0
m_ReflectionProbeUsage: 0
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Sprite: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
--- !u!114 &1027139440 stripped --- !u!114 &1027139440 stripped
MonoBehaviour: MonoBehaviour:
m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1, m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1,
@ -453,6 +507,14 @@ Prefab:
propertyPath: EjectSpinSpeed propertyPath: EjectSpinSpeed
value: 10 value: 10
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 154602, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: PlayerNumber
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0
@ -495,9 +557,17 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 5 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 140218, guid: 8347d06db0c264442891d12282c4a4dd, type: 2}
propertyPath: m_Name
value: Stars behind
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} m_ParentPrefab: {fileID: 100100000, guid: 8347d06db0c264442891d12282c4a4dd, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0
--- !u!4 &1867085522 stripped
Transform:
m_PrefabParentObject: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2}
m_PrefabInternal: {fileID: 1867085521}
--- !u!1 &1945693977 --- !u!1 &1945693977
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0