diff --git a/Assets/Resources/Shapes/Ship.png.meta b/Assets/Resources/Shapes/Ship.png.meta index 69eb08f..157dd08 100644 --- a/Assets/Resources/Shapes/Ship.png.meta +++ b/Assets/Resources/Shapes/Ship.png.meta @@ -72,7 +72,7 @@ TextureImporter: platformSettings: - serializedVersion: 4 buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 + maxTextureSize: 1024 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 diff --git a/Assets/Scenes/LevelScene.unity b/Assets/Scenes/LevelScene.unity index d24e94a..ca5e2a5 100644 --- a/Assets/Scenes/LevelScene.unity +++ b/Assets/Scenes/LevelScene.unity @@ -381,6 +381,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: playerObject: {fileID: 1267397455} + normalMinYFollow: 2 + shipMinYFollow: 6 --- !u!1 &521952199 GameObject: m_ObjectHideFlags: 0 @@ -565,13 +567,13 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 725779773} serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: 0.96696675, w: 0.25490257} - m_LocalPosition: {x: 0.19, y: -0.64, z: -10} + m_LocalRotation: {x: -0, y: -0, z: 0.9750753, w: 0.2218744} + m_LocalPosition: {x: 0, y: -0.52, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1267397458} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 150.464} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 154.362} --- !u!199 &725779775 ParticleSystemRenderer: serializedVersion: 6 @@ -657,8 +659,8 @@ ParticleSystem: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 725779773} serializedVersion: 8 - lengthInSec: 5 - simulationSpeed: 1 + lengthInSec: 1 + simulationSpeed: 1.3 stopAction: 0 cullingMode: 0 ringBufferMode: 0 @@ -732,7 +734,7 @@ ParticleSystem: startLifetime: serializedVersion: 2 minMaxState: 0 - scalar: 5 + scalar: 0.5 minScalar: 5 maxCurve: serializedVersion: 2 @@ -785,7 +787,7 @@ ParticleSystem: startSpeed: serializedVersion: 2 minMaxState: 0 - scalar: 20 + scalar: 5 minScalar: 5 maxCurve: serializedVersion: 2 @@ -872,8 +874,8 @@ ParticleSystem: m_NumAlphaKeys: 2 minGradient: serializedVersion: 2 - key0: {r: 0.6528301, g: 0.6320044, b: 0.4865432, a: 1} - key1: {r: 0.82641506, g: 0.73513323, b: 0, a: 1} + key0: {r: 0.6906728, g: 0.81325835, b: 0.8415094, a: 1} + key1: {r: 0, g: 0.5758081, b: 0.827451, a: 1} key2: {r: 0, g: 0, b: 0, a: 0} key3: {r: 0, g: 0, b: 0, a: 0} key4: {r: 0, g: 0, b: 0, a: 0} @@ -1280,15 +1282,15 @@ ParticleSystem: ShapeModule: serializedVersion: 6 enabled: 1 - type: 4 + type: 0 angle: 20 length: 5 boxThickness: {x: 0, y: 0, z: 0} - radiusThickness: 1 + radiusThickness: 0 donutRadius: 0.2 - m_Position: {x: 0, y: 0, z: 0} - m_Rotation: {x: 0, y: 0, z: 0} - m_Scale: {x: 1, y: 1, z: 1} + m_Position: {x: -0.000021252421, y: 0.000042931977, z: 0} + m_Rotation: {x: -0, y: 0, z: 0.6191988} + m_Scale: {x: 0.99999994, y: 0.99999994, z: 1} placementMode: 0 m_MeshMaterialIndex: 0 m_MeshNormalOffset: 0 @@ -1367,7 +1369,7 @@ ParticleSystem: sphericalDirectionAmount: 0 randomPositionAmount: 0 radius: - value: 5 + value: 1 mode: 0 spread: 0 speed: diff --git a/Assets/Scripts/GameMode/ShipGameMode.cs b/Assets/Scripts/GameMode/ShipGameMode.cs index dba3589..ece7857 100644 --- a/Assets/Scripts/GameMode/ShipGameMode.cs +++ b/Assets/Scripts/GameMode/ShipGameMode.cs @@ -6,34 +6,51 @@ public class ShipGameMode : IGameMode private const float HorizontalSpeed = 8.6f; private const float JumpForce = 26.6581f; private const KeyCode JumpKey = KeyCode.Space; - private const float UpperAngle = 45f; private const float LowerAngle = -45f; - private const float RotationLerpSpeed = 5f; + private const float RotationTransitionDuration = 0.5f; public void Update(Player player) { player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed, player.RigidBody.linearVelocity.y); - if (player.HasStarted && Input.GetKey(JumpKey)) + bool jumpPressed = Input.GetKey(JumpKey); + + if (player.HasStarted && jumpPressed) { Jump(player); + + if (Input.GetKeyDown(JumpKey)) + { + player.Transform.rotation = Quaternion.Euler(0, 0, UpperAngle); + } + else + { + player.Transform.rotation = Quaternion.Euler(0, 0, UpperAngle); + } + } + else + { + float currentAngle = GetCurrentZAngle(player); + + float t = Mathf.Clamp01(Time.deltaTime / RotationTransitionDuration); + float interpolationFactor = Mathf.Sin(t * (Mathf.PI / 2)); + float newAngle = Mathf.Lerp(currentAngle, LowerAngle, interpolationFactor); + player.Transform.rotation = Quaternion.Euler(0, 0, newAngle); } - float targetAngle = Input.GetKey(JumpKey) ? UpperAngle : LowerAngle; - float currentAngle = player.Transform.rotation.eulerAngles.z; - if (currentAngle > 180f) - currentAngle -= 360f; - float newAngle = Mathf.Lerp(currentAngle, targetAngle, RotationLerpSpeed * Time.deltaTime); - player.Transform.rotation = Quaternion.Euler(0, 0, newAngle); - - UpdateParticlePositionAndRotation(player); + if (player.Particle.gameObject.activeSelf) + { + player.Particle.gameObject.SetActive(false); + } } - private void UpdateParticlePositionAndRotation(Player player) + private float GetCurrentZAngle(Player player) { - player.Particle.transform.position = player.Transform.position + new Vector3(-0.19f, -0.64f, -10); - player.Particle.transform.rotation = Quaternion.Euler(0, 0, 150.464f); + float angle = player.Transform.rotation.eulerAngles.z; + if (angle > 180f) + angle -= 360f; + return angle; } private void Jump(Player player) @@ -56,7 +73,7 @@ public class ShipGameMode : IGameMode return; } - float currentAngle = player.Transform.rotation.eulerAngles.z; + float currentAngle = GetCurrentZAngle(player); float shortestAngle = Mathf.DeltaAngle(currentAngle, 0); player.Transform.rotation = Quaternion.RotateTowards(player.Transform.rotation, Quaternion.Euler(0, 0, 0), Mathf.Abs(shortestAngle)); } diff --git a/Assets/Scripts/PlayerCamera.cs b/Assets/Scripts/PlayerCamera.cs index 870f927..b0fe43c 100644 --- a/Assets/Scripts/PlayerCamera.cs +++ b/Assets/Scripts/PlayerCamera.cs @@ -3,7 +3,8 @@ using UnityEngine; public class PlayerCamera : MonoBehaviour { public GameObject playerObject; - public const float MIN_Y_FOLLOW = 2.0f; + public float normalMinYFollow = 2.0f; + public float shipMinYFollow = 6.0f; private float initialY; private void Start() @@ -13,9 +14,16 @@ public class PlayerCamera : MonoBehaviour private void Update() { - float targetY = initialY; + Player player = playerObject.GetComponent(); - if (playerObject.transform.position.y > MIN_Y_FOLLOW) + float minYFollow = normalMinYFollow; + if (player.CurrentGameMode is ShipGameMode) + { + minYFollow = shipMinYFollow; + } + + float targetY = initialY; + if (playerObject.transform.position.y > minYFollow) { targetY = playerObject.transform.position.y; }