From 01bdce2e81826d16edb48fc8900806f3c1c982ad Mon Sep 17 00:00:00 2001 From: Jason Durand 01 Date: Mon, 4 Apr 2022 01:15:02 -0400 Subject: [PATCH] Removed joystick min strength + can throw far --- Assets/Prefabs/Arena.prefab | 44 +++++------ Assets/Prefabs/Vampire.prefab | 117 ++++++++++++++++++++++++++---- Assets/Scenes/SampleScene.unity | 8 ++ Assets/Scripts/MinionThrower.cs | 34 +++++---- Assets/Scripts/Player Stats.asset | 2 + Assets/Scripts/PlayerMovement.cs | 61 +++++++++++++--- Assets/Scripts/PlayerStats.cs | 6 ++ Assets/Scripts/SafeZone.cs | 4 +- Assets/Sprites/circle.png | Bin 0 -> 5258 bytes Assets/Sprites/circle.png.meta | 96 ++++++++++++++++++++++++ ProjectSettings/TagManager.asset | 2 +- 11 files changed, 311 insertions(+), 63 deletions(-) create mode 100644 Assets/Sprites/circle.png create mode 100644 Assets/Sprites/circle.png.meta diff --git a/Assets/Prefabs/Arena.prefab b/Assets/Prefabs/Arena.prefab index 625a0da..add4095 100644 --- a/Assets/Prefabs/Arena.prefab +++ b/Assets/Prefabs/Arena.prefab @@ -60055,7 +60055,7 @@ GameObject: - component: {fileID: 1994381339193144958} - component: {fileID: 26567729814863427} - component: {fileID: 5943935829488333714} - m_Layer: 0 + m_Layer: 7 m_Name: Square (11) m_TagString: Untagged m_Icon: {fileID: 0} @@ -60164,7 +60164,7 @@ GameObject: - component: {fileID: 6927794195753177506} - component: {fileID: 2695343595345999118} - component: {fileID: 8007263816575186116} - m_Layer: 0 + m_Layer: 7 m_Name: Square (10) m_TagString: Untagged m_Icon: {fileID: 0} @@ -60273,7 +60273,7 @@ GameObject: - component: {fileID: 7342882877614581494} - component: {fileID: 5975861706535240330} - component: {fileID: 6383716948073999631} - m_Layer: 0 + m_Layer: 7 m_Name: Square (14) m_TagString: Untagged m_Icon: {fileID: 0} @@ -60382,7 +60382,7 @@ GameObject: - component: {fileID: 5720071058300721486} - component: {fileID: 3548056512256710470} - component: {fileID: 4107455760370628743} - m_Layer: 0 + m_Layer: 7 m_Name: Square (13) m_TagString: Untagged m_Icon: {fileID: 0} @@ -60735,7 +60735,7 @@ GameObject: - component: {fileID: 7218311171828710683} - component: {fileID: 4704818391558166293} - component: {fileID: 7034268950782540506} - m_Layer: 0 + m_Layer: 7 m_Name: Square (12) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61021,7 +61021,7 @@ GameObject: - component: {fileID: 9196727423869592231} - component: {fileID: 9196727423869592230} - component: {fileID: 1892012422} - m_Layer: 0 + m_Layer: 7 m_Name: Square (4) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61130,7 +61130,7 @@ GameObject: - component: {fileID: 9196727423885834081} - component: {fileID: 9196727423885834080} - component: {fileID: 2010907716} - m_Layer: 0 + m_Layer: 7 m_Name: Square (5) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61239,7 +61239,7 @@ GameObject: - component: {fileID: 9196727424183148083} - component: {fileID: 9196727424183148082} - component: {fileID: 1167420690} - m_Layer: 0 + m_Layer: 7 m_Name: Square (1) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61348,7 +61348,7 @@ GameObject: - component: {fileID: 9196727424492844842} - component: {fileID: 9196727424492844841} - component: {fileID: 737133579} - m_Layer: 0 + m_Layer: 7 m_Name: Square (8) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61457,7 +61457,7 @@ GameObject: - component: {fileID: 9196727424680933870} - component: {fileID: 9196727424680933869} - component: {fileID: 656526031} - m_Layer: 0 + m_Layer: 7 m_Name: Square m_TagString: Untagged m_Icon: {fileID: 0} @@ -61693,7 +61693,7 @@ GameObject: - component: {fileID: 9196727425065881106} - component: {fileID: 9196727425065881105} - component: {fileID: 137887027} - m_Layer: 0 + m_Layer: 7 m_Name: Square (9) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61802,7 +61802,7 @@ GameObject: - component: {fileID: 9196727425066418761} - component: {fileID: 9196727425066418760} - component: {fileID: 138391916} - m_Layer: 0 + m_Layer: 7 m_Name: Square (7) m_TagString: Untagged m_Icon: {fileID: 0} @@ -61911,7 +61911,7 @@ GameObject: - component: {fileID: 9196727425080706352} - component: {fileID: 9196727425080706359} - component: {fileID: 253081109} - m_Layer: 0 + m_Layer: 7 m_Name: Square (3) m_TagString: Untagged m_Icon: {fileID: 0} @@ -62020,7 +62020,7 @@ GameObject: - component: {fileID: 9196727425130084006} - component: {fileID: 9196727425130084005} - component: {fileID: 233457031} - m_Layer: 0 + m_Layer: 7 m_Name: Square (6) m_TagString: Untagged m_Icon: {fileID: 0} @@ -62129,7 +62129,7 @@ GameObject: - component: {fileID: 9196727425386152783} - component: {fileID: 9196727425386152782} - component: {fileID: 489615470} - m_Layer: 0 + m_Layer: 7 m_Name: Square (2) m_TagString: Untagged m_Icon: {fileID: 0} @@ -62368,23 +62368,23 @@ MonoBehaviour: m_EditorClassIdentifier: gameFlowManager: {fileID: 1359990806} spawners: - - position: {x: -10, y: 10} + - position: {x: -9.65, y: 14} direction: {x: 0, y: -1} - - position: {x: 10, y: 10} + - position: {x: 9.65, y: 14} direction: {x: 0, y: -1} - - position: {x: -17.75, y: 0} + - position: {x: -19, y: 0} direction: {x: 1, y: 0} - - position: {x: 17.75, y: 0} + - position: {x: 19, y: 0} direction: {x: -1, y: 0} - - position: {x: -10, y: -10} + - position: {x: -9.65, y: -12} direction: {x: 0, y: 1} - - position: {x: 10, y: -10} + - position: {x: 9.65, y: -12} direction: {x: 0, y: 1} stats: {fileID: 11400000, guid: fe319ad8c9a37b84e8b45268c913d54c, type: 2} + k__BackingField: {fileID: 793317230} lightGladiator: {fileID: 2004725698506461419, guid: f75821098c495cb43a0bff5d9ef0a671, type: 3} regularGladiator: {fileID: 2004725698506461419, guid: f75821098c495cb43a0bff5d9ef0a671, type: 3} heavyGladiator: {fileID: 1373848176550804357, guid: 99423d7c9a753554e87e6bb7e555018b, type: 3} - k__BackingField: {fileID: 793317230} k__BackingField: {fileID: 1787272690} k__BackingField: {fileID: 1550580935} currWaveSize: 0 diff --git a/Assets/Prefabs/Vampire.prefab b/Assets/Prefabs/Vampire.prefab index 9311899..40152cf 100644 --- a/Assets/Prefabs/Vampire.prefab +++ b/Assets/Prefabs/Vampire.prefab @@ -40,6 +40,7 @@ Transform: - {fileID: 8877496746214907228} - {fileID: 1931588020511749739} - {fileID: 903222670005920393} + - {fileID: 585682799304407530} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -66,6 +67,10 @@ MonoBehaviour: landSounds: - {fileID: 8300000, guid: 1376bbb24def5184393e893817fe41ca, type: 3} soundManager: {fileID: 0} + landingTarget: {fileID: 585682799304407530} + wallMask: + serializedVersion: 2 + m_Bits: 128 --- !u!114 &3126145803593047825 MonoBehaviour: m_ObjectHideFlags: 0 @@ -455,6 +460,88 @@ Transform: m_Father: {fileID: 1214567908930553594} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &5249541758665302985 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 585682799304407530} + - component: {fileID: 4262967924235676538} + m_Layer: 0 + m_Name: Landing Target + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &585682799304407530 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5249541758665302985} + 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: 1214567908930553594} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &4262967924235676538 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5249541758665302985} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 7b9b6b84ce70c0a4db57bd01f54dc89e, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &5933636161494595212 GameObject: m_ObjectHideFlags: 0 @@ -845,16 +932,16 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} ---- !u!4 &3632678902316393644 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 70347360213241984, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} - m_PrefabInstance: {fileID: 3643467873725871148} - m_PrefabAsset: {fileID: 0} --- !u!82 &8033357406949758492 stripped AudioSource: m_CorrespondingSourceObject: {fileID: 6767790137851257392, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} m_PrefabInstance: {fileID: 3643467873725871148} m_PrefabAsset: {fileID: 0} +--- !u!4 &3632678902316393644 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 70347360213241984, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} + m_PrefabInstance: {fileID: 3643467873725871148} + m_PrefabAsset: {fileID: 0} --- !u!1001 &4504372482479179597 PrefabInstance: m_ObjectHideFlags: 0 @@ -912,16 +999,16 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} ---- !u!82 &7164870411903264125 stripped -AudioSource: - m_CorrespondingSourceObject: {fileID: 6767790137851257392, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} - m_PrefabInstance: {fileID: 4504372482479179597} - m_PrefabAsset: {fileID: 0} --- !u!4 &4502282848150149069 stripped Transform: m_CorrespondingSourceObject: {fileID: 70347360213241984, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} m_PrefabInstance: {fileID: 4504372482479179597} m_PrefabAsset: {fileID: 0} +--- !u!82 &7164870411903264125 stripped +AudioSource: + m_CorrespondingSourceObject: {fileID: 6767790137851257392, guid: 8929857cf558a9b40a30682dc94048ad, type: 3} + m_PrefabInstance: {fileID: 4504372482479179597} + m_PrefabAsset: {fileID: 0} --- !u!1001 &6988628843130902527 PrefabInstance: m_ObjectHideFlags: 0 @@ -1188,13 +1275,13 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 78e4227a7fbb82040b8d8138dad79b1d, type: 3} ---- !u!198 &5815394732050939499 stripped -ParticleSystem: - m_CorrespondingSourceObject: {fileID: 3450778120571403492, guid: 78e4227a7fbb82040b8d8138dad79b1d, type: 3} - m_PrefabInstance: {fileID: 9176030194975883919} - m_PrefabAsset: {fileID: 0} --- !u!4 &8877496746214907228 stripped Transform: m_CorrespondingSourceObject: {fileID: 316653409112989651, guid: 78e4227a7fbb82040b8d8138dad79b1d, type: 3} m_PrefabInstance: {fileID: 9176030194975883919} m_PrefabAsset: {fileID: 0} +--- !u!198 &5815394732050939499 stripped +ParticleSystem: + m_CorrespondingSourceObject: {fileID: 3450778120571403492, guid: 78e4227a7fbb82040b8d8138dad79b1d, type: 3} + m_PrefabInstance: {fileID: 9176030194975883919} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index e4fa940..9752dfb 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -814,5 +814,13 @@ PrefabInstance: propertyPath: gameFlowManager value: objectReference: {fileID: 171858601} + - target: {fileID: 4262967924235676538, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} + propertyPath: m_Color.a + value: 0.5019608 + objectReference: {fileID: 0} + - target: {fileID: 5249541758665302985, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} diff --git a/Assets/Scripts/MinionThrower.cs b/Assets/Scripts/MinionThrower.cs index 76fc4c7..171f935 100644 --- a/Assets/Scripts/MinionThrower.cs +++ b/Assets/Scripts/MinionThrower.cs @@ -15,7 +15,8 @@ public class MinionThrower : MonoBehaviour { public GameObject aimArrow = null!; bool isInThrowMode; - Vector2 throwDirection; + Vector2 throwInput; + Vector2 lastThrowInput; MinionBar minionBar = null!; VampireEntity vampireEntity = null!; PlayerMovement movement = null!; @@ -27,6 +28,7 @@ public class MinionThrower : MonoBehaviour { movement = GetComponent(); minionBar = FindObjectOfType(); aimArrow.SetActive(false); + lastThrowInput = Vector3.up; } void Start() { @@ -50,25 +52,32 @@ public class MinionThrower : MonoBehaviour { if (context.performed) { isInThrowMode = true; aimArrow.SetActive(true); - } else if (context.canceled && throwDirection.magnitude >= playerStats.MinJoystickValueForThrowing) { + } else if (context.canceled) { PerformThrow(); isInThrowMode = false; aimArrow.SetActive(false); } + + if (movement.currentState is PlayerMovement.ImmobileMovementState immobileMovementState) + immobileMovementState.isThrowing = isInThrowMode; } public void AimThrow(InputAction.CallbackContext context) { if (!gameFlowManager.CanDoAction) return; - throwDirection = context.ReadValue(); - if (throwDirection.sqrMagnitude > 1f) - throwDirection.Normalize(); + throwInput = context.ReadValue(); + if (throwInput != Vector2.zero) { + if (throwInput.sqrMagnitude > 1f) + throwInput.Normalize(); + + lastThrowInput = throwInput; + } if (vampireEntity.playerMovement.facingRight) { - aimArrow.transform.rotation = Quaternion.FromToRotation(Vector2.right, throwDirection); + aimArrow.transform.rotation = Quaternion.FromToRotation(Vector2.right, lastThrowInput); } else { - aimArrow.transform.rotation = Quaternion.FromToRotation(Vector2.left, throwDirection); + aimArrow.transform.rotation = Quaternion.FromToRotation(Vector2.left, lastThrowInput); } } @@ -81,7 +90,8 @@ public class MinionThrower : MonoBehaviour { if (minionHealthCost >= vampireEntity.Health) { return; } - vampireEntity.TakeDamage(minionHealthCost, vampireEntity, intentional: true); + if (!movement.IsInSafeZone) + vampireEntity.TakeDamage(minionHealthCost, vampireEntity, intentional: true); currentCooldownTimer = playerStats.currentInitialCooldown; @@ -90,16 +100,14 @@ public class MinionThrower : MonoBehaviour { var newMinion = Instantiate(minionBar.GetCurrentMinion().gameObject, arena.minionParent) .GetComponent(); newMinion.arena = arena; - if (throwDirection == Vector2.zero) - Debug.LogWarning("Throwing with a null throwDirection."); - Vector2 normalizedDirection = throwDirection.normalized; + Vector2 normalizedDirection = lastThrowInput.normalized; newMinion.transform.position = transform.position + (Vector3)normalizedDirection; newMinion.direction = normalizedDirection; newMinion.gameFlowManager = vampireEntity.gameFlowManager; - if (movement.GetSafeZoneIfImmobile() is { } safeZone) { + if (movement.currentState is PlayerMovement.ImmobileMovementState immobileMovementState) { newMinion.thrownFromSafeZone = true; - newMinion.thrownTargetPosition = safeZone.GetOutsidePosition(normalizedDirection); + newMinion.thrownTargetPosition = immobileMovementState.exitPosition; } } diff --git a/Assets/Scripts/Player Stats.asset b/Assets/Scripts/Player Stats.asset index f4897ab..369e2bd 100644 --- a/Assets/Scripts/Player Stats.asset +++ b/Assets/Scripts/Player Stats.asset @@ -17,3 +17,5 @@ MonoBehaviour: bloodLossRate: 2 k__BackingField: 0.4 currentInitialCooldown: 0.5 + k__BackingField: 1.26 + k__BackingField: 10 diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index 9168fc4..85ca5e0 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -16,7 +16,8 @@ public class PlayerMovement : MonoBehaviour { Rigidbody2D rb = null!; Vector2 moveDirection; - BaseState currentState = null!; + Vector2 lastMoveDirection; + public BaseState currentState { get; private set; } = null!; SafeZone? safeZone; VampireEntity vampireEntity = null!; Animator animator = null!; @@ -28,6 +29,11 @@ public class PlayerMovement : MonoBehaviour { [SerializeField] AudioSource landSource = null!; [SerializeField] AudioClip[] landSounds = null!; [HideInInspector] public SoundManager soundManager = null!; + [SerializeField] [Required] + Transform landingTarget = null!; + + [SerializeField] + LayerMask wallMask; bool lastJumpButton; @@ -42,10 +48,11 @@ public class PlayerMovement : MonoBehaviour { currentState = new ImmobileMovementState(this); soundManager = FindObjectOfType(); screenShaker = FindObjectOfType(); - + lastMoveDirection = Vector2.up; } void Start() { + gameFlowManager.stateChanged += OnGameFlowStateChanged; globalCamera.SetActive(true); currentState.EnterState(); } @@ -67,6 +74,8 @@ public class PlayerMovement : MonoBehaviour { } void OnDrawGizmos() => currentState?.OnDrawGizmos(); + + void OnDestroy() => gameFlowManager.stateChanged -= OnGameFlowStateChanged; #endregion @@ -90,16 +99,25 @@ public class PlayerMovement : MonoBehaviour { public SafeZone? GetSafeZoneIfImmobile() { return currentState is ImmobileMovementState ? safeZone : null; } + + void OnGameFlowStateChanged(BaseState oldState, BaseState newState) { + if (currentState is ImmobileMovementState && newState is GameFlowManager.GameplayFlowState) + landingTarget.gameObject.SetActive(true); + } #region Inputs public void OnMove(InputAction.CallbackContext ctx) { if (gameFlowManager.CanDoAction) { moveDirection = ctx.ReadValue(); - if (moveDirection.sqrMagnitude > 1.0f) - moveDirection.Normalize(); + if (moveDirection != Vector2.zero) { + if (moveDirection.sqrMagnitude > 1.0f) + moveDirection.Normalize(); + + lastMoveDirection = moveDirection; + } FlipAccordingToInput(); - }else //TODO Should set to zero via event or callback + } else //TODO Should set to zero via event or callback moveDirection = Vector2.zero; } @@ -110,10 +128,9 @@ public class PlayerMovement : MonoBehaviour { if (!gameFlowManager.CanDoAction || safeZone == null) return; - if (IsInSafeZone) { - if (moveDirection.magnitude >= safeZone.Stats.MinJumpJoystickValue) - SwitchState(new ExitSafeZoneMovementState(this, safeZone, moveDirection)); - } else if (currentState is NormalMovementState) //TODO if (AngleBetween(moveDirection, toSafeZone) < 90) + if (IsInSafeZone) + SwitchState(new ExitSafeZoneMovementState(this, safeZone, lastMoveDirection.normalized)); + else if (currentState is NormalMovementState) //TODO if (AngleBetween(moveDirection, toSafeZone) < 90) SwitchState(new EnterSafeZoneMovementState(this, safeZone)); } @@ -147,7 +164,7 @@ public class PlayerMovement : MonoBehaviour { newState.EnterState(); } - abstract class BaseStatePlayerMovement : BaseState { + public abstract class BaseStatePlayerMovement : BaseState { protected PlayerMovement playerMovement; public BaseStatePlayerMovement(PlayerMovement playerMovement) { @@ -258,7 +275,10 @@ public class PlayerMovement : MonoBehaviour { protected override float ModifyLerpTime(float t) => safeZone.Stats.JumpSpeedCurve.Evaluate(t); } - class ImmobileMovementState : BaseStatePlayerMovement { + public class ImmobileMovementState : BaseStatePlayerMovement { + public Vector3 exitPosition; + public bool isThrowing; + public ImmobileMovementState(PlayerMovement playerMovement) : base(playerMovement) {} public override void EnterState() { base.EnterState(); @@ -266,12 +286,31 @@ public class PlayerMovement : MonoBehaviour { playerMovement.globalCamera.SetActive(true); if (!playerMovement.rb.isKinematic) Debug.LogWarning("Rigidbody should probably be kinematic when immobile (when in safe zone)."); + + playerMovement.landingTarget.gameObject.SetActive(playerMovement.gameFlowManager.CurrentState is GameFlowManager.GameplayFlowState); } public override void LeaveState() { base.LeaveState(); playerMovement.globalCamera.SetActive(false); + playerMovement.landingTarget.gameObject.SetActive(false); + } + + public override BaseState? UpdateState() { + //safeZone can't be null here + float outsideDistance = playerMovement.safeZone == null ? 0f : playerMovement.safeZone.OutsideDistance; + float distance = outsideDistance + playerMovement.lastMoveDirection.magnitude * playerMovement.stats.MaxThrowDistance; + RaycastHit2D hit = Physics2D.Raycast(playerMovement.transform.position, playerMovement.lastMoveDirection, distance, playerMovement.wallMask); + + if (hit.collider == null) + exitPosition = (Vector3)playerMovement.lastMoveDirection.normalized * distance; + else + exitPosition = (Vector3)playerMovement.lastMoveDirection.normalized * distance * hit.fraction + (Vector3)hit.normal * playerMovement.stats.WallOffset; + + playerMovement.landingTarget.position = isThrowing ? exitPosition : playerMovement.safeZone.GetOutsidePosition(playerMovement.lastMoveDirection); + + return null; } #if UNITY_EDITOR diff --git a/Assets/Scripts/PlayerStats.cs b/Assets/Scripts/PlayerStats.cs index ae891cf..9cf242d 100644 --- a/Assets/Scripts/PlayerStats.cs +++ b/Assets/Scripts/PlayerStats.cs @@ -16,4 +16,10 @@ public class PlayerStats : ScriptableObject { [field: SerializeField] [field: Min(0f)] public float currentInitialCooldown = 0.5f; + + [field: SerializeField] [field: Min(0f)] + public float WallOffset { get; private set; } = 0.5f; + + [field: SerializeField] [field: Min(0f)] + public float MaxThrowDistance { get; private set; } = 10f; } \ No newline at end of file diff --git a/Assets/Scripts/SafeZone.cs b/Assets/Scripts/SafeZone.cs index 7870b56..f5201c9 100644 --- a/Assets/Scripts/SafeZone.cs +++ b/Assets/Scripts/SafeZone.cs @@ -8,8 +8,10 @@ public class SafeZone : MonoBehaviour { [SerializeField] Collider2D moatCollider; [SerializeField] RectTransform canvas; + public float OutsideDistance => moatCollider.bounds.extents.x + Stats.JumpOffset; + public Vector3 GetOutsidePosition(Vector2 direction) { - return transform.position + (moatCollider.bounds.extents.x + Stats.JumpOffset) * (Vector3)direction; + return transform.position + OutsideDistance * (Vector3)direction; } public Vector3 GetMoatExtents(){ diff --git a/Assets/Sprites/circle.png b/Assets/Sprites/circle.png new file mode 100644 index 0000000000000000000000000000000000000000..b3d93d77236b1338438d6e2d1823d887a4da101a GIT binary patch literal 5258 zcmY*dbyO5gv|noJZfS#DN@|G(mquU-6_#!mrAtC-mXHuW6r>TPq?V9WQpy$9m1e1> zyHP;m;rE^M-g$q_+;i{TI5TJF&b_~QLzosd#VrZ|06?vyt!{inaeoIH@Md0)T7Gat z2z-sTQ~}k)oEtX`F#@U&1psPaQ(oAS-0 zNt-&9&Mw84QsW*`Y;-igG=rwLp|-Z*fVNll7UcKQugmK>-~6Ks#kKRUp|d$w2<9lq zcXsbAApb~DHXiD|H}~aFiV}me`!wMTx?e9Q)h@b?L)(ek2E{=uYx%ZKrzFkFnR>g^ z^Y(y&DFxtg1N)$Cy#Od=##q6`V?Er|&J=Vx{jdS7h z1xrpj2uYCxw(C@`Lxei{k60(HXZX+)%+nuxn?c@!*h>Ni-;RP%ij1|$MkZ^n{UK`v z^tZtexD8OwCn^H0<$hHN#$|3ItRh4g;BNl91{4) zV?}2Ow*_;O9h7USw)rjEXcqz}O6SSsIU>^BwGI`wGdEao zvu>N@g?}M0ZIiw%vH$p7R^F`iCDn_HRWawc!$5&0ze}_P>}8w>{*b^zq2!6t+xpD3 zn_$A{$l+h&U@nAIMF9mODs4yeP}q$M*5?hAD(_@h*7O8jB}4l=I=RDT-rM9%;u%Pa z;8~d?t8MRlYG+gy{5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`p5JR_CJzp_Kv<$u&}^|IA%h zh=Hvz3>s>c2#Aj!$f7;oEdYP(dydia7$2l{Q=d2}JhaPql5_Ja((1l!#W%)=nr!x# zz4y>l5#p@fj-kD&#ei`$;nc1y+ElkTd;QY7Po4X`d&*roqEn})y@X|>6(qlWcNiQW&*ud`IGa${H)@cf zzfdpLW|vBif}!h}ch9_U8B{cy}wR7tnZJ>>Hz#9O#c z2JIE8~lMKeZjhaWz9ENN{2*c`_8)?*u(@A=oLca?~MC73SlKLby-e~0f35P@_ zPep0YtY%>VVKpg5+?H1hWv(5>oS5goc4MEkE!n@}v7up0A#r+7ds}2CDPXH>^N!rb zdojiPcjW|8mIt2b_l!rA5P#7Z;s3TZuZ2#Gohu!11q-KJ8No_(=KIAfAK%f~1zEH- z5i|`7K7f!g@!HI#28aI$=8S!+G;tebBeK@G0CW;PStdjd-Z}I!$N|NOug*JVFtR@g zIxH3eO*9s8GkyI56ohjV;!K+ABFriw!uDXwUE?R1RW0vaK{mxnQ$UekIUVXftjT-p z`HnU6pei*a;7Bm19)+=UJE?x4-jwo-;+qR4!xgXh`GpQ!ZpEG?)@o7_C1<1=P%_V? zo;o}ZfEp>iyu|z@aVj!@gc zus1eX@6>buNw$)`v#q&Aqe;RmVv7r|w(@_`hx)?pU2nn&2jNEehcl1$eXSVLDN?*c z%VWG7^{U^t_3pb+zVl^!MclIGk-ej@tT9H##&Zi@D0cW_kRD_iWh+<&UuaHuzXmsge8z)<=ASZOKxG) z8_K0x!&@fW)5qTcUEMjaVf|)9{kBx6PL_))vUzosVCv+U5F&?lrT}4y=Z_pUhsPzo zRDpmR7PjvVNtgC+Z?g&zCH0*M`6o>SQ$S!&sujkWhh4yNJ)DzLR`m9x(ADO6=wP&v p%1CV%dBT<#{}2sLjDGeN?crNfL@ELP;SGKW(9wXYSF74a{tth?IFJAU literal 0 HcmV?d00001 diff --git a/Assets/Sprites/circle.png.meta b/Assets/Sprites/circle.png.meta new file mode 100644 index 0000000..edbd3c2 --- /dev/null +++ b/Assets/Sprites/circle.png.meta @@ -0,0 +1,96 @@ +fileFormatVersion: 2 +guid: 7b9b6b84ce70c0a4db57bd01f54dc89e +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 02df679..83cec21 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -14,7 +14,7 @@ TagManager: - Water - UI - Safezone - - + - ArenaWall - - -