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 6319800..3f758a7 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 @@ -456,6 +461,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 @@ -846,16 +933,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 @@ -913,16 +1000,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 @@ -1189,13 +1276,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 4237cd2..f3e5a81 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -822,5 +822,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 233e23c..951aed3 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,13 +48,13 @@ 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(); - gameFlowManager.stateChanged += OnGameFlowStateChanged; } void OnDestroy() => gameFlowManager.stateChanged -= OnGameFlowStateChanged; @@ -70,12 +76,7 @@ public class PlayerMovement : MonoBehaviour { } void OnDrawGizmos() => currentState?.OnDrawGizmos(); - - void OnGameFlowStateChanged(BaseState oldState, BaseState newState) { - if (newState is GameFlowManager.DeadFlowState) - SwitchState(new DeadMovementState(this)); - } - + #endregion #region Flip @@ -98,16 +99,28 @@ 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); + + if (newState is GameFlowManager.DeadFlowState) + SwitchState(new DeadMovementState(this)); + } #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; } @@ -118,10 +131,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)); } @@ -155,7 +167,7 @@ public class PlayerMovement : MonoBehaviour { newState.EnterState(); } - abstract class BaseStatePlayerMovement : BaseState { + public abstract class BaseStatePlayerMovement : BaseState { protected PlayerMovement playerMovement; public BaseStatePlayerMovement(PlayerMovement playerMovement) { @@ -267,7 +279,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(); @@ -275,12 +290,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 0000000..b3d93d7 Binary files /dev/null and b/Assets/Sprites/circle.png differ 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 - - -