From e755120ef079b7ec8ad782086d5016346e3a1590 Mon Sep 17 00:00:00 2001 From: RosimInc Date: Fri, 8 Apr 2016 19:53:04 -0400 Subject: [PATCH 1/5] player movement - dash & eject --- Assets/Scripts/Astronaut.cs | 29 ++++++++++++++++++++++++++++- Assets/Test/SR_Player2.unity | 8 ++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 12cd512..e78687b 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -18,6 +18,8 @@ public class Astronaut : MonoBehaviour { public float JumpSpeed; public float Gravity; public float Speed; + public float EjectSpeed; + public float DashSpeed; public PlanetManager planet; @@ -106,15 +108,27 @@ public class Astronaut : MonoBehaviour { if (!grounded) { height += vSpeed * delta; - vSpeed -= Gravity * delta; + if (State != AstronautState.Ejecting) + vSpeed -= Gravity * delta; + else + vSpeed *= 0.98f; } float radius = GetGroundRadius(); if (grounded = (height <= radius)) { + if (State == AstronautState.Dashing) + { + planet.PushWedge(Repeat(theta,360)); + State = AstronautState.Idle; + //TODO_SR Create dash impact here + } + height = radius; if (State == AstronautState.Jumping) State = AstronautState.Idle; + + vSpeed = 0f; } UpdatePosition(); @@ -208,12 +222,25 @@ public class Astronaut : MonoBehaviour { { if (_state >= AstronautState.Ejecting) return; + + State = AstronautState.Dashing; + vSpeed = -DashSpeed; + } + + public void Eject() + { + State = AstronautState.Ejecting; + vSpeed = EjectSpeed; + grounded = false; } public void OnGUI() { if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString())) + { Debug.Log("Clicked the button with an image"); + Eject(); + } } /*IEnumerator WalkingStance() diff --git a/Assets/Test/SR_Player2.unity b/Assets/Test/SR_Player2.unity index 2007a20..cf24f80 100644 --- a/Assets/Test/SR_Player2.unity +++ b/Assets/Test/SR_Player2.unity @@ -572,6 +572,14 @@ Prefab: propertyPath: Width value: 0.4 objectReference: {fileID: 0} + - target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: EjectSpeed + value: 15 + objectReference: {fileID: 0} + - target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: DashSpeed + value: 12 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0 From 6f39d6f841557ef070d8803aad890064a710911e Mon Sep 17 00:00:00 2001 From: Sophie Date: Fri, 8 Apr 2016 20:37:16 -0400 Subject: [PATCH 2/5] character animation - idle, walk, dash, spin --- Assets/Scripts/Astronaut.cs | 67 +++++--- Assets/Scripts/AstronautAnimator.cs | 75 +++++++++ Assets/Scripts/AstronautAnimator.cs.meta | 12 ++ Assets/Scripts/AstronautController2.cs | 70 ++++++++ Assets/Scripts/AstronautController2.cs.meta | 12 ++ Assets/Scripts/PlanetManager.cs | 2 +- Assets/_Scenes/sophieScene.unity | 177 ++++++++++++++++---- 7 files changed, 363 insertions(+), 52 deletions(-) create mode 100644 Assets/Scripts/AstronautAnimator.cs create mode 100644 Assets/Scripts/AstronautAnimator.cs.meta create mode 100644 Assets/Scripts/AstronautController2.cs create mode 100644 Assets/Scripts/AstronautController2.cs.meta diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 44e3a47..ce07482 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -1,22 +1,24 @@ using UnityEngine; -using System.Collections; +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 StepTime; public float JumpSpeed; private AstronautState _state; - private AstronautState State + public AstronautState State { get { @@ -30,19 +32,20 @@ public class Astronaut : MonoBehaviour { if (oldState == _state) return; if (oldState == AstronautState.Dashing) - { - SpriteWalk.SetActive(false); - SpriteDash.SetActive(true); + { + SpriteWalk.gameObject.SetActive(true); + SpriteDash.gameObject.SetActive(false); } 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(); } } } @@ -53,8 +56,11 @@ public class Astronaut : MonoBehaviour { private float walkTime = 0; private int nextStep = 1; - // Use this for initialization - void Start () { + // Use this for initialization + void Start() + { + _astronautAnimator = GetComponent(); + _astronautAnimator.aspi = this; State = AstronautState.Idle; } @@ -115,6 +121,7 @@ public class Astronaut : MonoBehaviour { { if (_state >= AstronautState.Ejecting) return; + _astronautAnimator.Jump(); } public void Dash() @@ -125,10 +132,32 @@ public class Astronaut : MonoBehaviour { public void OnGUI() { - if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString())) - Debug.Log("Clicked the button with an image"); - } + if (GUI.Button(new Rect(10, 10, 150, 50), "Jump")) + { + Debug.Log("Clicked the button with an image"); + _astronautAnimator.Jump(); + } + if (GUI.Button(new Rect(10, 70, 150, 50), "Land")) + { + Debug.Log("Clicked the 2nd button"); + _astronautAnimator.Land(); + } + + if (GUI.Button(new Rect(10, 130, 150, 50), "Walk")) + { + Debug.Log("Clicked the 3rd button"); + State = AstronautState.Walking; + _astronautAnimator.Walk(); + } + + if (GUI.Button(new Rect(10, 190, 150, 50), "Eject")) + { + Debug.Log("Clicked the 4th button"); + _astronautAnimator.Eject(); + } + } + /* IEnumerator WalkingStance() { Debug.Log("walking stance"); @@ -137,7 +166,7 @@ public class Astronaut : MonoBehaviour { { Vector3 rotation = transform.rotation.eulerAngles; rotation.z = Mathf.Sin(walkTime*Mathf.PI)*50; - print("rotation " + rotation); + //print("rotation " + rotation); transform.rotation = Quaternion.Euler(rotation); yield return null; } @@ -147,5 +176,5 @@ public class Astronaut : MonoBehaviour { { StartCoroutine("WalkingStance"); } - } + }*/ } diff --git a/Assets/Scripts/AstronautAnimator.cs b/Assets/Scripts/AstronautAnimator.cs new file mode 100644 index 0000000..4699bd6 --- /dev/null +++ b/Assets/Scripts/AstronautAnimator.cs @@ -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; + } +} diff --git a/Assets/Scripts/AstronautAnimator.cs.meta b/Assets/Scripts/AstronautAnimator.cs.meta new file mode 100644 index 0000000..dc6173f --- /dev/null +++ b/Assets/Scripts/AstronautAnimator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 77462b2431858f84b9bc2d055c2f4d45 +timeCreated: 1460135550 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AstronautController2.cs b/Assets/Scripts/AstronautController2.cs new file mode 100644 index 0000000..5de5d5f --- /dev/null +++ b/Assets/Scripts/AstronautController2.cs @@ -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(); + } + + 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(); + } + } +} + diff --git a/Assets/Scripts/AstronautController2.cs.meta b/Assets/Scripts/AstronautController2.cs.meta new file mode 100644 index 0000000..2dadbdf --- /dev/null +++ b/Assets/Scripts/AstronautController2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d7792093ffcd687448b5875a8ce0cc32 +timeCreated: 1460133633 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 68671b2..6298910 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -12,7 +12,7 @@ public class PlanetManager : MonoBehaviour public bool CartierResetRatioSpeedRandomize = true; public float CartierMinRatio = 0.4f; public float CartierMaxRatio = 2.0f; - public float CartierStepSize = 0.25; + public float CartierStepSize = 0.25f; public GameObject WedgePrefab = null; public List wedges = new List(); diff --git a/Assets/_Scenes/sophieScene.unity b/Assets/_Scenes/sophieScene.unity index 9480a93..6750b83 100644 --- a/Assets/_Scenes/sophieScene.unity +++ b/Assets/_Scenes/sophieScene.unity @@ -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 From ddf091d6103c8d3f18c631e8ec89b3d73524b617 Mon Sep 17 00:00:00 2001 From: RosimInc Date: Fri, 8 Apr 2016 21:58:50 -0400 Subject: [PATCH 3/5] fixed asteroid spawn opposite of player --- Assets/Prefabs/Astronaut.prefab | 21 ++++++++++++++++++--- Assets/Scripts/Asteroid.cs | 12 +++++------- Assets/Scripts/AsteroidSpawner.cs | 7 ++++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Assets/Prefabs/Astronaut.prefab b/Assets/Prefabs/Astronaut.prefab index dd5900a..6bbf479 100644 --- a/Assets/Prefabs/Astronaut.prefab +++ b/Assets/Prefabs/Astronaut.prefab @@ -57,8 +57,9 @@ GameObject: - 4: {fileID: 403646} - 114: {fileID: 11494368} - 114: {fileID: 11434752} - - 54: {fileID: 5402556} - 136: {fileID: 13683032} + - 54: {fileID: 5462614} + - 136: {fileID: 13672180} m_Layer: 0 m_Name: Character m_TagString: Player @@ -117,7 +118,7 @@ Transform: - {fileID: 403646} m_Father: {fileID: 0} m_RootOrder: 0 ---- !u!54 &5402556 +--- !u!54 &5462614 Rigidbody: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -130,7 +131,7 @@ Rigidbody: m_UseGravity: 0 m_IsKinematic: 0 m_Interpolate: 0 - m_Constraints: 0 + m_Constraints: 120 m_CollisionDetection: 0 --- !u!114 &11434752 MonoBehaviour: @@ -164,7 +165,21 @@ MonoBehaviour: JumpSpeed: 5 Gravity: 15 Speed: 5 + EjectSpeed: 20 planet: {fileID: 0} +--- !u!136 &13672180 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 170392} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.77 + m_Height: 3.37 + m_Direction: 1 + m_Center: {x: -0.03, y: 0.35, z: 0} --- !u!136 &13683032 CapsuleCollider: m_ObjectHideFlags: 1 diff --git a/Assets/Scripts/Asteroid.cs b/Assets/Scripts/Asteroid.cs index ad160d6..d890389 100644 --- a/Assets/Scripts/Asteroid.cs +++ b/Assets/Scripts/Asteroid.cs @@ -14,15 +14,13 @@ public class Asteroid : MonoBehaviour public void Start() { speed = Random.Range(1.8F, 3F); - // print(speed); 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); - + 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 diff --git a/Assets/Scripts/AsteroidSpawner.cs b/Assets/Scripts/AsteroidSpawner.cs index 567a2f7..7d6d89e 100644 --- a/Assets/Scripts/AsteroidSpawner.cs +++ b/Assets/Scripts/AsteroidSpawner.cs @@ -68,10 +68,11 @@ public class AsteroidSpawner : TimerFunctionsClass 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))); - + 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], - planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)), + direction*planet.GetPlanetCoordinatesFromPlayerXY(angle, UnityEngine.Random.Range(10f,15f)), Quaternion.identity); } From 8d80c2fbdcd6efea1a6896f0f4dcfac693cdf772 Mon Sep 17 00:00:00 2001 From: Sophie Date: Fri, 8 Apr 2016 22:02:02 -0400 Subject: [PATCH 4/5] Corrected merge errors --- Assets/Scripts/Astronaut.cs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index dbd40ca..75db2fc 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -71,11 +71,12 @@ public class Astronaut : MonoBehaviour { _astronautAnimator = GetComponent(); _astronautAnimator.aspi = this; State = AstronautState.Idle; + if (!planet) { - p if (!planet) - {e(); + planet = FindObjectOfType(); } + State = AstronautState.Idle; //Debug.Log(planet.GetPlanetRadius(0)); theta = 0; @@ -232,11 +233,11 @@ public class Astronaut : MonoBehaviour { public void Dash() { - iS(Time.time < DashTime + lastDashTime) + if (Time.time < DashTime + lastDashTime) return; - if (_state >= AstronautState.Ejecting) - return; + if (State >= AstronautState.Ejecting) + return; lastDashTime = Time.time; planet.PushWedge(this.theta); @@ -272,14 +273,5 @@ public class Astronaut : MonoBehaviour { State = AstronautState.Walking; _astronautAnimator.Walk(); } - - if (GUI.Button(new Rect(10, 190, 150, 50), "Eject")) - { - Debug.Lif(State == AstronautState.Walking) - { StartCoroutine("WalkingStance"); - } - { - StartCoroutine("WalkingStance"); - } - }*/ + } } From 72b4975ab1d080a69c8595eb292844298e9307d8 Mon Sep 17 00:00:00 2001 From: Sophie Date: Fri, 8 Apr 2016 22:26:21 -0400 Subject: [PATCH 5/5] All merges accepted --- Assets/Scripts/Astronaut.cs | 5 +++++ Assets/_Scenes/Main.unity | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 45dda95..89de1c7 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -228,9 +228,13 @@ public class Astronaut : MonoBehaviour { public void Jump() { + Debug.Log("Jump!"); + if (State >= AstronautState.Ejecting) return; + _astronautAnimator.Jump(); + if (State == AstronautState.Jumping) { Dash(); @@ -238,6 +242,7 @@ public class Astronaut : MonoBehaviour { return; } + if (!grounded) return; vSpeed = JumpSpeed; grounded = false; diff --git a/Assets/_Scenes/Main.unity b/Assets/_Scenes/Main.unity index 650a3fa..7133947 100644 --- a/Assets/_Scenes/Main.unity +++ b/Assets/_Scenes/Main.unity @@ -85,6 +85,31 @@ 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 &431637410 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, + type: 2} + m_PrefabInternal: {fileID: 1660116367} + m_Script: {fileID: 11500000, guid: 8c32c40e0b8e5eb47bb7a91068af09ca, type: 3} +--- !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: 431637410} + WalkAnimSpeed: 3 + WalkAnimAngle: 20 + EjectSpinSpeed: 5 --- !u!114 &1027139440 stripped MonoBehaviour: m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1, @@ -138,6 +163,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 +327,10 @@ Prefab: propertyPath: m_Radius value: 0.76 objectReference: {fileID: 0} + - target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: SpriteWalk + value: + objectReference: {fileID: 1106066633} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0