diff --git a/Assets/Prefabs/Monster.prefab b/Assets/Prefabs/Monster.prefab index d7a7bfa..93acfb4 100644 --- a/Assets/Prefabs/Monster.prefab +++ b/Assets/Prefabs/Monster.prefab @@ -193,6 +193,8 @@ MonoBehaviour: target: {fileID: 0} halo: {fileID: 160873202674104038} AIStats: {fileID: 11400000, guid: 9d8a9a664d932d0498d5eca7607eeb53, type: 2} + thrownFromSafeZone: 0 + thrownTargetPosition: {x: 0, y: 0, z: 0} --- !u!50 &1427479462206541758 Rigidbody2D: serializedVersion: 4 @@ -206,7 +208,7 @@ Rigidbody2D: m_UseFullKinematicContacts: 0 m_UseAutoMass: 0 m_Mass: 1 - m_LinearDrag: 0 + m_LinearDrag: 1 m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 6200000, guid: 72c8b57001d325c418a78771641a077f, type: 2} diff --git a/Assets/Scenes/JasonScene.unity b/Assets/Scenes/JasonScene.unity index a81fe42..9119a45 100644 --- a/Assets/Scenes/JasonScene.unity +++ b/Assets/Scenes/JasonScene.unity @@ -630,10 +630,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 1214567908930553595, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} - propertyPath: m_SortingOrder - value: 0 - objectReference: {fileID: 0} - target: {fileID: 1967503440015794769, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} propertyPath: gameFlowManager value: diff --git a/Assets/Scripts/AI Stats.asset b/Assets/Scripts/AI Stats.asset index 28ef788..2e890a0 100644 --- a/Assets/Scripts/AI Stats.asset +++ b/Assets/Scripts/AI Stats.asset @@ -51,3 +51,5 @@ MonoBehaviour: m_PostInfinity: 2 m_RotationOrder: 4 k__BackingField: 0.15 + k__BackingField: 2 + throwForce: 5 diff --git a/Assets/Scripts/AIStats.cs b/Assets/Scripts/AIStats.cs index 92e133b..e1d8a44 100644 --- a/Assets/Scripts/AIStats.cs +++ b/Assets/Scripts/AIStats.cs @@ -16,4 +16,10 @@ public class AIStats : ScriptableObject { [field: SerializeField] public float ThrownDurationPerMeter { get; private set; } + + [field: SerializeField] [field: Min(0f)] + public float MinVelocityWhenThrown { get; private set; } = 5f; + + [field: SerializeField] [field: Min(0f)] + public float throwForce = 3f; } \ No newline at end of file diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index c734c34..698053f 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -9,9 +9,6 @@ public class Entity : MonoBehaviour { [Required] public GameFlowManager gameFlowManager = null!; - [field: SerializeField] - [field: Required] - public EntityStats stats { get; private set; } [field: SerializeField] public float Health { get; private set; } [Min(10f)] protected float initialHealth; @@ -48,13 +45,7 @@ public class Entity : MonoBehaviour { protected virtual void Update() { } - protected virtual void FixedUpdate() { - //TODO sqrMagnitude? - if (beingPushed && rb.velocity.magnitude < stats.MinVelocityWhenThrown) { - rb.velocity = Vector2.zero; - beingPushed = false; - } - } + protected virtual void FixedUpdate() {} protected virtual void Attack() { diff --git a/Assets/Scripts/EntityStats.cs b/Assets/Scripts/EntityStats.cs deleted file mode 100644 index 6f841c8..0000000 --- a/Assets/Scripts/EntityStats.cs +++ /dev/null @@ -1,6 +0,0 @@ -using UnityEngine; - -public class EntityStats { - [field: SerializeField] [field: Min(0f)] - public float MinVelocityWhenThrown { get; private set; } = 5f; -} \ No newline at end of file diff --git a/Assets/Scripts/EntityStats.cs.meta b/Assets/Scripts/EntityStats.cs.meta deleted file mode 100644 index 0a1726f..0000000 --- a/Assets/Scripts/EntityStats.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f3b49b8d7dbc43dfbd074996aa811570 -timeCreated: 1648908811 \ No newline at end of file diff --git a/Assets/Scripts/MinionThrower.cs b/Assets/Scripts/MinionThrower.cs index e6dacdc..325f862 100644 --- a/Assets/Scripts/MinionThrower.cs +++ b/Assets/Scripts/MinionThrower.cs @@ -76,7 +76,7 @@ public class MinionThrower : MonoBehaviour { var newMinion = Instantiate(minionBar.GetCurrentMinion().gameObject, transform.position + new Vector3(throwDirection.x, throwDirection.y, 0f) * 1f, Quaternion.identity) .GetComponent(); - if (movement.GetSafeZone() is {} safeZone) { + if (movement.GetSafeZoneIfImmobile() is {} safeZone) { newMinion.thrownFromSafeZone = true; newMinion.thrownTargetPosition = safeZone.GetOutsidePosition(throwDirection); } diff --git a/Assets/Scripts/Monster.cs b/Assets/Scripts/Monster.cs index 0f0568d..5260077 100644 --- a/Assets/Scripts/Monster.cs +++ b/Assets/Scripts/Monster.cs @@ -2,8 +2,8 @@ using UnityEngine; public class Monster : AIEntity { - public bool thrownFromSafeZone; - public Vector3 thrownTargetPosition; + [HideInInspector] public bool thrownFromSafeZone; + [HideInInspector] public Vector3 thrownTargetPosition; // Start is called before the first frame update override protected void Start() @@ -65,17 +65,14 @@ public class Monster : AIEntity { public override void EnterState() { base.EnterState(); - entity.rb.SetEnabled(false); + entity.rb.velocity = entity.direction * entity.AIStats.throwForce; } - public override void LeaveState() { - base.LeaveState(); - entity.rb.SetEnabled(true); - } - - public override BaseState? FixedUpdateState() - => entity.rb.velocity.magnitude < entity.stats.MinVelocityWhenThrown + public override BaseState? FixedUpdateState() { + Debug.Log($"Velocity: {entity.rb.velocity.magnitude}"); + return entity.rb.velocity.magnitude < entity.AIStats.MinVelocityWhenThrown ? new FindTargetState(entity) : null; + } } } diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index eed2519..34ce60a 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -49,8 +49,8 @@ public class PlayerMovement : MonoBehaviour { #endregion - public SafeZone? GetSafeZone() { - return safeZone; + public SafeZone? GetSafeZoneIfImmobile() { + return currentState is ImmobileMovementState ? safeZone : null; } #region Inputs