Conflicts:
	Assets/Scripts/PlanetManager.cs
This commit is contained in:
RosimInc 2016-04-09 10:32:43 -04:00
commit da216027d2
24 changed files with 3985 additions and 193 deletions

View File

@ -0,0 +1,146 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: M_ExplosionParticle
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: 3000
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 29eb5cb075e0c1344981ff1e034e6b65, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _SrcBlend
second: 1
data:
first:
name: _DstBlend
second: 0
data:
first:
name: _Cutoff
second: 0.5
data:
first:
name: _Parallax
second: 0.02
data:
first:
name: _ZWrite
second: 1
data:
first:
name: _Glossiness
second: 0.5
data:
first:
name: _BumpScale
second: 1
data:
first:
name: _OcclusionStrength
second: 1
data:
first:
name: _DetailNormalMapScale
second: 1
data:
first:
name: _UVSec
second: 0
data:
first:
name: _Mode
second: 0
data:
first:
name: _Metallic
second: 0
data:
first:
name: _InvFade
second: 1
m_Colors:
data:
first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
data:
first:
name: _Color
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

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c7d0e59685de7d7449e84875524fa9c2
timeCreated: 1460164692
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -0,0 +1,57 @@
fileFormatVersion: 2
guid: 29eb5cb075e0c1344981ff1e034e6b65
timeCreated: 1460164629
licenseType: Free
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

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

View File

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

View File

@ -54,7 +54,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 160026}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 8.22, y: 1.36, z: 0}
m_LocalPosition: {x: 8.22, y: 2.74, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 404170}
@ -106,6 +106,11 @@ MonoBehaviour:
m_EditorClassIdentifier:
speed: 1
step: 0
rotationSpeed: 1
rotationDirection: 1
RandomRotationSpeed: 1
CrashFlamesEmitter: {fileID: 120238, guid: 1a5b0b5645fa6104087fd9f96b6104b9, type: 2}
TrailFlamesEmitter: {fileID: 0}
--- !u!135 &13502558
SphereCollider:
m_ObjectHideFlags: 1

View File

@ -54,7 +54,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 160026}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 8.22, y: 1.36, z: 0}
m_LocalPosition: {x: 8.22, y: -0.12, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 404170}
@ -106,6 +106,11 @@ MonoBehaviour:
m_EditorClassIdentifier:
speed: 1
step: 0
rotationSpeed: 1
rotationDirection: 1
RandomRotationSpeed: 1
CrashFlamesEmitter: {fileID: 120238, guid: 1a5b0b5645fa6104087fd9f96b6104b9, type: 2}
TrailFlamesEmitter: {fileID: 0}
--- !u!135 &13502558
SphereCollider:
m_ObjectHideFlags: 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6233079c5a9a756458811f283fdca112
timeCreated: 1460171282
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1a5b0b5645fa6104087fd9f96b6104b9
timeCreated: 1460164322
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,6 +10,10 @@ public class Asteroid : MonoBehaviour
public float rotationDirection = 1.0f;
public bool RandomRotationSpeed = true;
public GameObject CrashFlamesEmitter; //Emitter on impact
public GameObject TrailFlamesEmitter; // trailing smoke
// Use this for initialization
public void Start()
{
@ -17,7 +21,7 @@ public class Asteroid : MonoBehaviour
center = new Vector3(0, 0);
if (RandomRotationSpeed)
rotationSpeed = 10 * UnityEngine.Random.Range(0.25f, 5f);
rotationSpeed = 10 * UnityEngine.Random.Range(0.25f, 5f);
rotationDirection = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f)) * 2 - 1);
@ -54,6 +58,24 @@ public class Asteroid : MonoBehaviour
{
var pmgr = FindObjectOfType<PlanetManager>();
pmgr.PushWedge(otherCol.gameObject.transform.parent.eulerAngles.z);
if (CrashFlamesEmitter)
{
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;
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.transform.localRotation = Quaternion.Euler(0, 180.0f, angleImpact);
emitter.GetComponent<ParticleSystem>().Play(true);
}
Destroy(this.gameObject);
}
}

View File

@ -0,0 +1,72 @@
using UnityEngine;
using System.Collections;
public class Asteroid : MonoBehaviour
{
Vector3 center;
public float speed;
public float step;
public float rotationSpeed = 1.0f;
public float rotationDirection = 1.0f;
public bool RandomRotationSpeed = true;
public GameObject CrashFlamesEmitter; //Emitter on impact
public GameObject TrailFlamesEmitter; // trailing smoke
// Use this for initialization
public void Start()
{
speed = Random.Range(1.8F, 3F);
center = new Vector3(0, 0);
if (RandomRotationSpeed)
rotationSpeed = 10 * UnityEngine.Random.Range(0.25f, 5f);
rotationDirection = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f)) * 2 - 1);
}
// Update is called once per frame
public void Update () {
MoveObject(center);
}
public void MoveObject(Vector3 center)
{
step = speed * Time.deltaTime;
this.transform.position = Vector3.MoveTowards(transform.position, center, step);
this.transform.Rotate(new Vector3(0, 0, 1.0f), rotationDirection * rotationSpeed * Time.deltaTime);
}
//collider must be set as "isTrigger" in unity for this method to work
public void OnTriggerEnter(Collider otherCol)
{
if (otherCol.gameObject.tag == "Player")
{
///Stun the player
otherCol.gameObject.GetComponent<Astronaut>().Stun();
}
if (otherCol.gameObject.tag == "Wedge")
{
var pmgr = FindObjectOfType<PlanetManager>();
pmgr.PushWedge(otherCol.gameObject.transform.parent.eulerAngles.z);
if (CrashFlamesEmitter)
{
Instantiate(CrashFlamesEmitter, this.transform.position, this.transform.forward);
}
Destroy(this.gameObject);
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 190ea851aec618c4797f7963dd7d386d
timeCreated: 1460169373
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,86 +1,86 @@
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class AsteroidSpawner : TimerFunctionsClass
{
public float NextSpawnTime = 1.0f;
public GameObject AsteroidPrefab1;
public GameObject AsteroidPrefab2;
public GameObject AsteroidPrefab3;
public GameObject AsteroidPrefab4;
private List<GameObject> AsteroidPrefabTypes = new List<GameObject>();
public bool GenerationVersLesjoueurs = false; //random lorsque false;
// Use this for initialization
public void Start ()
{
if (!AsteroidPrefab1 || !AsteroidPrefab2 || !AsteroidPrefab3 || !AsteroidPrefab4)
{
Destroy(this.gameObject);
print("WARNING un type d'asteroide n'est pas defini dans les prefab. Vérifier l'objet avec un component AsteroidSpawner");
return;
}
AsteroidPrefabTypes.Add(AsteroidPrefab1);
AsteroidPrefabTypes.Add(AsteroidPrefab2);
AsteroidPrefabTypes.Add(AsteroidPrefab3);
AsteroidPrefabTypes.Add(AsteroidPrefab4);
if (GenerationVersLesjoueurs) NextSpawnTime = 3 * NextSpawnTime;
this.SetTimer(NextSpawnTime, SpawnAsteroidEvent);
this.StartTimer();
}
// Update is called once per frame
public void Update () {
base.Update();
}
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);
//0-3
var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f)));
//instantiate as child of AsteroidSpawner
var a = Instantiate(AsteroidPrefabTypes[AsteroidType], 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);
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class AsteroidSpawner : TimerFunctionsClass
{
public float NextSpawnTime = 1.0f;
public GameObject AsteroidPrefab1;
public GameObject AsteroidPrefab2;
public GameObject AsteroidPrefab3;
public GameObject AsteroidPrefab4;
private List<GameObject> AsteroidPrefabTypes = new List<GameObject>();
public bool GenerationVersLesjoueurs = false; //random lorsque false;
// Use this for initialization
public void Start ()
{
if (!AsteroidPrefab1 || !AsteroidPrefab2 || !AsteroidPrefab3 || !AsteroidPrefab4)
{
Destroy(this.gameObject);
print("WARNING un type d'asteroide n'est pas defini dans les prefab. Vérifier l'objet avec un component AsteroidSpawner");
return;
}
AsteroidPrefabTypes.Add(AsteroidPrefab1);
AsteroidPrefabTypes.Add(AsteroidPrefab2);
AsteroidPrefabTypes.Add(AsteroidPrefab3);
AsteroidPrefabTypes.Add(AsteroidPrefab4);
if (GenerationVersLesjoueurs) NextSpawnTime = 3 * NextSpawnTime;
this.SetTimer(NextSpawnTime, SpawnAsteroidEvent);
this.StartTimer();
}
// Update is called once per frame
public void Update () {
base.Update();
}
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);
//0-3
var AsteroidType = Mathf.RoundToInt(Mathf.Floor(UnityEngine.Random.Range(0f, 3.999f)));
//instantiate as child of AsteroidSpawner
var a = Instantiate(AsteroidPrefabTypes[AsteroidType], 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);
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);
Instantiate(AsteroidPrefabTypes[AsteroidType],
direction*planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)),
Quaternion.identity);
}
}
//Cooldown untill next random spawn
SetTimer(NextSpawnTime, SpawnAsteroidEvent);
StartTimer();
}
}
float direction = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f)) * 2 - 1);
Instantiate(AsteroidPrefabTypes[AsteroidType],
direction*planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)),
Quaternion.identity);
}
}
//Cooldown untill next random spawn
SetTimer(NextSpawnTime, SpawnAsteroidEvent);
StartTimer();
}
}

View File

@ -1,15 +1,17 @@
using UnityEngine;
using System.Collections;
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AstronautAnimator))]
public class Astronaut : MonoBehaviour {
private enum AstronautState
private AstronautAnimator _astronautAnimator;
public enum AstronautState
{
Idle, Walking, Jumping, Dashing, Ejecting, Dead
}
public GameObject Rotator;
public GameObject SpriteWalk;
public SpriteRenderer SpriteWalk;
public GameObject SpriteDash;
public float Width;
@ -25,7 +27,7 @@ public class Astronaut : MonoBehaviour {
public PlanetManager planet;
private AstronautState _state;
private AstronautState State
public AstronautState State
{
get
{
@ -39,42 +41,59 @@ public class Astronaut : MonoBehaviour {
if (oldState == _state) return;
if (oldState == AstronautState.Dashing)
{
SpriteWalk.SetActive(false);
SpriteDash.SetActive(true);
{
SpriteWalk.gameObject.SetActive(false);
SpriteDash.gameObject.SetActive(true);
}
else
{
SpriteWalk.SetActive(true);
SpriteDash.SetActive(false);
{
SpriteWalk.gameObject.SetActive(true);
SpriteDash.gameObject.SetActive(false);
}
/*if (_state == AstronautState.Walking)
{
StartCoroutine(WalkingStance());
//StartCoroutine(WalkingStance());
_astronautAnimator.Walk();
}*/
}
}
}
private float theta = 0;
private float height = 0;
private float vSpeed = 0;
private float height = 0;
private float vSpeed = 0;
private bool grounded = false;
private float walkTime = 0;
private int nextStep = 1;
private int nextStep = 1;
public float GetTheta()
{
return theta;
}
public bool IsGrounded()
{
return grounded;
}
// Use this for initialization
public void Start () {
void Start()
{
_astronautAnimator = GetComponent<AstronautAnimator>();
_astronautAnimator.aspi = this;
State = AstronautState.Idle;
if (!planet)
{
planet = FindObjectOfType<PlanetManager>();
}
State = AstronautState.Idle;
//Debug.Log(planet.GetPlanetRadius(0));
theta = 0;
height = planet.GetPlanetRadius(theta);
UpdatePosition();
UpdatePosition();
}
private void UpdatePosition()
@ -104,7 +123,7 @@ public class Astronaut : MonoBehaviour {
private float Repeat(float num, float limit)
{
return Mathf.Repeat(num + limit, limit);
}
}
// Update is called once per frame
public void Update () {
@ -133,9 +152,10 @@ public class Astronaut : MonoBehaviour {
if (State == AstronautState.Jumping)
State = AstronautState.Idle;
vSpeed = 0f;
if (State < AstronautState.Ejecting) vSpeed = 0f;
}
UpdatePosition();
//float x, y;
@ -149,8 +169,7 @@ public class Astronaut : MonoBehaviour {
{
walkTime += Time.deltaTime / StepTime;
Vector3 rotation = transform.rotation.eulerAngles;
rotation.z = Mathf.Sin(walkTime * Mathf.PI)*50;
transform.rotation = Quaternion.Euler(rotation);
rotation.z = Mathf.Sin(walkTime * Mathf.PI)*50; transform.rotation = Quaternion.Euler(rotation);
}*/
/*
@ -171,8 +190,8 @@ public class Astronaut : MonoBehaviour {
case AstronautState.Walking:
break;
}
*/
}
*/
}
public void Move(float x, float y)
@ -216,12 +235,18 @@ public class Astronaut : MonoBehaviour {
//TODO arreter mouvement lateral
State=AstronautState.Idle;
}
}
public void Jump()
{
Debug.Log("Jump!");
if (State >= AstronautState.Ejecting)
return;
_astronautAnimator.Jump();
if (State == AstronautState.Jumping)
{
Dash();
@ -229,6 +254,7 @@ public class Astronaut : MonoBehaviour {
return;
}
if (!grounded) return;
vSpeed = JumpSpeed;
grounded = false;
@ -239,10 +265,10 @@ public class Astronaut : MonoBehaviour {
{
if (Time.time < DashTime + lastDashTime)
return;
return;
if (_state >= AstronautState.Ejecting)
return;
if (State >= AstronautState.Ejecting)
return;
lastDashTime = Time.time;
planet.PushWedge(this.theta);
@ -266,8 +292,6 @@ public class Astronaut : MonoBehaviour {
print("Stunned");
}
public void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString()))
@ -276,24 +300,4 @@ public class Astronaut : MonoBehaviour {
Eject();
}
}
/*IEnumerator WalkingStance()
{
Debug.Log("walking stance");
walkTime += Time.deltaTime / StepTime;
while (State <= AstronautState.Walking || walkTime <= 1f)
{
Vector3 rotation = transform.rotation.eulerAngles;
rotation.z = Mathf.Sin(walkTime*Mathf.PI)*50;
// print("rotation " + rotation);
transform.rotation = Quaternion.Euler(rotation);
yield return null;
}
walkTime = 0f;
if(State == AstronautState.Walking)
{
StartCoroutine("WalkingStance");
}
}*/
}
}

View File

@ -0,0 +1,75 @@
using UnityEngine;
using System.Collections;
public class AstronautAnimator : MonoBehaviour {
//init
public Astronaut aspi;
public float WalkAnimSpeed;
public float WalkAnimAngle;
public float EjectSpinSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Jump()
{
aspi.SpriteWalk.gameObject.SetActive(false);
aspi.SpriteDash.gameObject.SetActive(true);
}
public void Land()
{
aspi.SpriteWalk.gameObject.SetActive(true);
aspi.SpriteDash.gameObject.SetActive(false);
}
public void Walk()
{
StartCoroutine(Rotate());
}
public void Eject()
{
StartCoroutine(Spin());
}
IEnumerator Spin()
{
for (float i = 0f; i < 3000f; i += Time.deltaTime * EjectSpinSpeed)
{
transform.rotation = Quaternion.Euler(0, 0, i);
yield return null;
}
}
IEnumerator Rotate()
{
for (float i = 0.5f; i < 2.5f; i+= Time.deltaTime*WalkAnimSpeed)
{
/*int roundDown = 10;
//0.5, 1.5 et 2.5
if (Mathf.Floor(i * roundDown) == roundDown || Mathf.Floor(i * roundDown) == 2 * roundDown)
{
print(i * roundDown + " " + Mathf.Floor(i * roundDown));
aspi.SpriteWalk.flipX = !aspi.SpriteWalk.flipX;
}*/
float position = Mathf.PingPong(i, 1f);
transform.rotation = Quaternion.Euler(0, 0, (position - 0.5f) * WalkAnimAngle * 2);
yield return null;
}
if (aspi.State == Astronaut.AstronautState.Walking)
{
StartCoroutine(Rotate());
}
yield return null;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 77462b2431858f84b9bc2d055c2f4d45
timeCreated: 1460135550
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,70 @@
using UnityEngine;
using System.Collections;
using InputHandler;
[RequireComponent(typeof(Astronaut))]
public class AstronautController2 : MonoBehaviour
{
private Astronaut _astronaut;
public int PlayerNumber;
// Use this for initialization
void Start()
{
InputManager.Instance.PushActiveContext("Gameplay", PlayerNumber);
InputManager.Instance.AddCallback(PlayerNumber, HandlePlayerAxis);
InputManager.Instance.AddCallback(PlayerNumber, HandlePlayerButtons);
_astronaut = GetComponent<Astronaut>();
}
private void HandlePlayerAxis(MappedInput input)
{
if (this == null) return;
// movement
float xValue = 0f;
if (input.Ranges.ContainsKey("MoveLeft"))
{
xValue = -input.Ranges["MoveLeft"];
}
else if (input.Ranges.ContainsKey("MoveRight"))
{
xValue = input.Ranges["MoveRight"];
}
float yValue = 0f;
if (input.Ranges.ContainsKey("MoveUp"))
{
yValue = input.Ranges["MoveUp"];
}
else if (input.Ranges.ContainsKey("MoveDown"))
{
yValue = -input.Ranges["MoveDown"];
}
_astronaut.Move(xValue, yValue);
if (input.Ranges.ContainsKey("Dash"))
{
if (input.Ranges["Dash"] > 0.8f)
_astronaut.Dash();
}
}
private void HandlePlayerButtons(MappedInput input)
{
if (this == null) return;
if (input.Actions.Contains("Jump"))
{
_astronaut.Jump();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d7792093ffcd687448b5875a8ce0cc32
timeCreated: 1460133633
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -36,6 +36,7 @@ public class PlanetManager : MonoBehaviour
var obj = Instantiate(WedgePrefab, new Vector3(0.0f,0.0f, 0.0f), Quaternion.Euler(0, 0, debutAngleTheta));
obj.name = "wedge_" + i;
w.sprite = GameObject.Find(obj.name);
w.gameObject = (GameObject)obj;
wedges.Add(w); //pushes at end.
}
}
@ -116,25 +117,41 @@ public class PlanetManager : MonoBehaviour
w.offset = w.offset - CartierStepSize;
if (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);
//push back l'opposée
var indexOppose = GetWedgeOpposé(index);
var v = wedges[indexOppose];
v.offset = v.offset + CartierStepSize;
if (v.offset > CartierMaxRatio)
if (v.offset >= CartierMaxRatio)
{
v.offset = CartierMaxRatio;
v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1);
// call fill gauge after every hit.
var earthQuakeGauge = FindObjectOfType<Earthquake>();
earthQuakeGauge.Fill4Gauge();
//checker si on éjecte des players
var players = FindObjectsOfType<Astronaut>();
foreach (var p in players)
{
if (v.tMax >= p.GetTheta() && p.GetTheta() >= v.tMin && p.IsGrounded())
{
p.Eject();
}
}
}
v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1);
// call fill gauge after every hit.
var earthQuakeGauge = FindObjectOfType<Earthquake>();
earthQuakeGauge.FillGauge();
}
/// <summary>
/// On a earthquake, everything expands by a step
/// </summary>
@ -155,8 +172,6 @@ public class PlanetManager : MonoBehaviour
// var index = GetWedgeIndex(thetaPlayerX);
// var w = wedges[index];
// w.offset = w.offset - 0.5f;
// if (w.offset < -1.0f)
// w.offset = -1.0f;
@ -171,7 +186,6 @@ public class PlanetManager : MonoBehaviour
// wedgePos.x -= Mathf.Cos(angle * Mathf.PI / 180) - 50 * w.offset * Mathf.Cos(angle * Mathf.PI / 180);
// wedgePos.y -= Mathf.Sin(angle * Mathf.PI / 180) - 50 * w.offset * Mathf.Sin(angle * Mathf.PI / 180);
// w.sprite.transform.position = Vector3.Lerp(normalPos, wedgePos, Time.deltaTime);
// ///push back l'opposée
@ -192,13 +206,10 @@ public class PlanetManager : MonoBehaviour
// wedgePos.x -= Mathf.Cos(angle * Mathf.PI / 180) - 50 * v.offset * Mathf.Cos(angle * Mathf.PI / 180);
// wedgePos.y -= Mathf.Sin(angle * Mathf.PI / 180) - 50 * v.offset * Mathf.Sin(angle * Mathf.PI / 180);
// v.sprite.transform.position = Vector3.Lerp(normalPos, wedgePos, Time.deltaTime);
//}
/// <summary>
/// Radius sphere est scale/2
/// </summary>
@ -217,8 +228,6 @@ public class PlanetManager : MonoBehaviour
var wedge = GetWedgeFromTheta(thetaPlayerX);
return GetPlanetRadius() * wedge.offset;
}
public Vector3 GetPlanetCoordinatesFromPlayerXY(float playerLocalX, float playerLocalY)
{
var theta = playerLocalX;
@ -229,7 +238,6 @@ public class PlanetManager : MonoBehaviour
return new Vector3(x, y, 0);
}
/// <summary>
/// retourn le no de plateforme
/// </summary>
@ -250,7 +258,6 @@ public class PlanetManager : MonoBehaviour
return (wedgeIndex + NbCartiers / 2) % (NbCartiers);
}
/// <summary>
/// retourne l'objet interne
/// </summary>
@ -271,7 +278,6 @@ public class PlanetManager : MonoBehaviour
public float tMax = 0;
public GameObject sprite; //sprite et collider 2D
public GameObject gameObject; //wedge prefab avec collider
}
}

View File

@ -85,6 +85,25 @@ NavMeshSettings:
cellSize: 0.16666667
manualCellSize: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &431637404 stripped
GameObject:
m_PrefabParentObject: {fileID: 170392, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_PrefabInternal: {fileID: 1660116367}
--- !u!114 &431637411
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 431637404}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 77462b2431858f84b9bc2d055c2f4d45, type: 3}
m_Name:
m_EditorClassIdentifier:
aspi: {fileID: 0}
WalkAnimSpeed: 0
WalkAnimAngle: 0
EjectSpinSpeed: 0
--- !u!114 &1027139440 stripped
MonoBehaviour:
m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1,
@ -138,6 +157,11 @@ Prefab:
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 158e745881137e04ca2086294f44d74c, type: 2}
m_IsPrefabParent: 0
--- !u!212 &1106066633 stripped
SpriteRenderer:
m_PrefabParentObject: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc,
type: 2}
m_PrefabInternal: {fileID: 1660116367}
--- !u!1001 &1223268487
Prefab:
m_ObjectHideFlags: 0
@ -297,6 +321,14 @@ Prefab:
propertyPath: m_Radius
value: 0.76
objectReference: {fileID: 0}
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: SpriteWalk
value:
objectReference: {fileID: 1106066633}
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: EjectSpeed
value: 50
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_IsPrefabParent: 0

View File

@ -171,6 +171,53 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1001 &160670874
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalPosition.x
value: -0.6692338
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalPosition.y
value: 1.7862048
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalPosition.z
value: -0.045327663
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 11450178, guid: 158e745881137e04ca2086294f44d74c, type: 2}
propertyPath: InputMapperAsset
value:
objectReference: {fileID: 11400000, guid: ba52e0f13249c9e46bb162622e61904f,
type: 2}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 158e745881137e04ca2086294f44d74c, type: 2}
m_IsPrefabParent: 0
--- !u!1 &238389812
GameObject:
m_ObjectHideFlags: 0
@ -231,44 +278,110 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
--- !u!1 &1024275268
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1024275269}
- 114: {fileID: 1024275270}
m_Layer: 0
m_Name: spawnAsteroid
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1024275269
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1024275268}
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: 0}
m_RootOrder: 1
--- !u!114 &1024275270
--- !u!212 &841465700 stripped
SpriteRenderer:
m_PrefabParentObject: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc,
type: 2}
m_PrefabInternal: {fileID: 1660503799}
--- !u!1001 &1660503799
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
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: 2
objectReference: {fileID: 0}
- target: {fileID: 403646, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_LocalScale.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 403646, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_LocalScale.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 403646, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_LocalPosition.y
value: 3.46
objectReference: {fileID: 0}
- target: {fileID: 21257324, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 157058, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_FlipX
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: SpriteWalk
value:
objectReference: {fileID: 841465700}
- target: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_Color.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_Color.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_Color.b
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_IsPrefabParent: 0
--- !u!1 &1660503800 stripped
GameObject:
m_PrefabParentObject: {fileID: 170392, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_PrefabInternal: {fileID: 1660503799}
--- !u!114 &1660503801
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1024275268}
m_GameObject: {fileID: 1660503800}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 665432c96ca23f140a869ed98ade0dde, type: 3}
m_Script: {fileID: 11500000, guid: 77462b2431858f84b9bc2d055c2f4d45, type: 3}
m_Name:
m_EditorClassIdentifier:
myAsteroid: {fileID: 160026, guid: cc1a204562630cd40a1dd685b5ed8e6e, type: 2}
aspi: {fileID: 0}
WalkAnimSpeed: 4
WalkAnimAngle: 20
EjectSpinSpeed: 60