diff options
-rw-r--r-- | Assets/InputActions.inputactions | 35 | ||||
-rw-r--r-- | Assets/Scenes/Jungle.unity | 50 | ||||
-rw-r--r-- | Assets/Scripts/Actors/Actor.cs | 20 | ||||
-rw-r--r-- | Assets/Scripts/Actors/Enemy.cs | 9 | ||||
-rw-r--r-- | Assets/Scripts/Actors/Player.cs | 5 | ||||
-rw-r--r-- | Assets/Scripts/Items/Whip.cs | 5 |
6 files changed, 110 insertions, 14 deletions
diff --git a/Assets/InputActions.inputactions b/Assets/InputActions.inputactions index 5529905..3beb69a 100644 --- a/Assets/InputActions.inputactions +++ b/Assets/InputActions.inputactions @@ -24,13 +24,22 @@ "initialStateCheck": true }, { - "name": "Use", + "name": "Attack", "type": "Button", "id": "18319b32-d662-4d4f-adec-97eab089357c", "expectedControlType": "Button", "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Use", + "type": "Button", + "id": "f3b20a10-e7c5-424c-8b9e-5f3ef85ab330", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -118,7 +127,7 @@ "interactions": "", "processors": "", "groups": "", - "action": "Use", + "action": "Attack", "isComposite": false, "isPartOfComposite": false }, @@ -129,6 +138,28 @@ "interactions": "", "processors": "", "groups": "", + "action": "Attack", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "a1a6551b-7b5b-4059-ac8e-5ef5eca43f00", + "path": "<Mouse>/rightButton", + "interactions": "", + "processors": "", + "groups": "", + "action": "Use", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "a2d7daaf-9572-474d-add1-fd9331a0712f", + "path": "<Keyboard>/r", + "interactions": "", + "processors": "", + "groups": "", "action": "Use", "isComposite": false, "isPartOfComposite": false diff --git a/Assets/Scenes/Jungle.unity b/Assets/Scenes/Jungle.unity index 07c2d04..a7246e7 100644 --- a/Assets/Scenes/Jungle.unity +++ b/Assets/Scenes/Jungle.unity @@ -9825,6 +9825,27 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &565923078 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 8919320861035673885, guid: d1ac05b890e176640a3d9fd9e24cd0c1, type: 3} + m_PrefabInstance: {fileID: 8919320862215231254} + m_PrefabAsset: {fileID: 0} +--- !u!70 &565923085 +CapsuleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 565923078} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0.12936941, y: 0} + m_Size: {x: 0.6162614, y: 1.03125} + m_Direction: 0 --- !u!1001 &579896363 PrefabInstance: m_ObjectHideFlags: 0 @@ -11138,6 +11159,27 @@ Transform: m_CorrespondingSourceObject: {fileID: 5267721061292888517, guid: 47596d04057f55146bb75d8cea49ccdb, type: 3} m_PrefabInstance: {fileID: 814781393} m_PrefabAsset: {fileID: 0} +--- !u!1 &861919835 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4799600927363337844, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3} + m_PrefabInstance: {fileID: 2119287057} + m_PrefabAsset: {fileID: 0} +--- !u!70 &861919842 +CapsuleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 861919835} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0.012937165, y: -0.08984017} + m_Size: {x: 0.58601534, y: 0.82031965} + m_Direction: 0 --- !u!1001 &869826067 PrefabInstance: m_ObjectHideFlags: 0 @@ -325005,6 +325047,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: -849362167687110816, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3} + propertyPath: m_IsTrigger + value: 1 + objectReference: {fileID: 0} - target: {fileID: 199732719703436395, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3} propertyPath: m_RootOrder value: 9 @@ -325523,6 +325569,10 @@ PrefabInstance: value: 0 objectReference: {fileID: 0} - target: {fileID: 8919320861035673882, guid: d1ac05b890e176640a3d9fd9e24cd0c1, type: 3} + propertyPath: m_IsTrigger + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8919320861035673882, guid: d1ac05b890e176640a3d9fd9e24cd0c1, type: 3} propertyPath: m_Points.m_Paths.Array.data[0].Array.size value: 24 objectReference: {fileID: 0} diff --git a/Assets/Scripts/Actors/Actor.cs b/Assets/Scripts/Actors/Actor.cs index f23f3c6..9a4b338 100644 --- a/Assets/Scripts/Actors/Actor.cs +++ b/Assets/Scripts/Actors/Actor.cs @@ -21,7 +21,6 @@ namespace MontanaJohns.Actors protected Animator _animator; protected Transform _transform; - protected Stats stats; protected Active activeItem; protected bool isGrappling; protected Vector2? grapplePoint = null; @@ -30,6 +29,7 @@ namespace MontanaJohns.Actors protected int jumpCount; protected Vector2 acceleration; + public Stats stats; public int health; protected virtual void Awake() @@ -68,7 +68,7 @@ namespace MontanaJohns.Actors _rigidBody.velocity = Vector2.SmoothDamp(_rigidBody.velocity, target, ref acceleration, .05f); _animator.SetBool("moving", Mathf.Abs(_rigidBody.velocity.x) > 1); - if (_rigidBody.velocity.x < -0.001) { + if (_rigidBody.velocity.x < -0.1) { _renderer.flipX = true; for (int i = 0; i < transform.childCount; i++) { var rot = transform.GetChild(i).rotation; @@ -76,7 +76,7 @@ namespace MontanaJohns.Actors transform.GetChild(i).rotation = rot; } } - else if (_rigidBody.velocity.x > 0.001) { + else if (_rigidBody.velocity.x > 0.1) { _renderer.flipX = false; for (int i = 0; i < transform.childCount; i++) { var rot = transform.GetChild(i).rotation; @@ -129,15 +129,23 @@ namespace MontanaJohns.Actors stats = baseStats + items.Select(i => i.stats).Sum(); } + public virtual void Grapple(float xInput, float yInput, Vector2 grapplePoint) + { + Move(xInput); + MoveY(yInput); + } + public virtual void TakeDamage(int damage) { health -= damage; + StartCoroutine(DamageAnimation()); } - public virtual void Grapple(float xInput, float yInput, Vector2 grapplePoint) + IEnumerator DamageAnimation() { - Move(xInput); - MoveY(yInput); + _renderer.color = Color.red; + yield return new WaitForSeconds(0.5f); + _renderer.color = Color.white; } IEnumerator Falling() diff --git a/Assets/Scripts/Actors/Enemy.cs b/Assets/Scripts/Actors/Enemy.cs index 9160e44..5abf7ce 100644 --- a/Assets/Scripts/Actors/Enemy.cs +++ b/Assets/Scripts/Actors/Enemy.cs @@ -24,6 +24,11 @@ namespace MontanaJohns.Actors CheckHealth(); } + protected override void FixedUpdate() + { + // Temp override while missing falling logic/animations + } + void MoveTowardsPlayer() { if (player.transform.position.x < transform.position.x) Move(-stats.speedMultiplier * 0.5f); @@ -37,7 +42,7 @@ namespace MontanaJohns.Actors void Attack() { - if (Mathf.Abs(player.transform.position.x - transform.position.x) <= 5 && Time.time >= nextAttackTime) { + if (Mathf.Abs(player.transform.position.x - transform.position.x) <= 5 && Mathf.Abs(player.transform.position.y - transform.position.y) <= 2 && Time.time >= nextAttackTime) { _animator.SetTrigger("attack"); player.GetComponent<Actor>().TakeDamage(1); nextAttackTime = Time.time + 1f / attackRate; @@ -48,7 +53,7 @@ namespace MontanaJohns.Actors { if (other.gameObject.tag == "Projectile") { - Debug.Log("Enemy: Hit by projectile"); + // TODO update once projectile is made an Active Item TakeDamage(1); Destroy(other.gameObject); } diff --git a/Assets/Scripts/Actors/Player.cs b/Assets/Scripts/Actors/Player.cs index 95ec2ca..8ba1daf 100644 --- a/Assets/Scripts/Actors/Player.cs +++ b/Assets/Scripts/Actors/Player.cs @@ -16,7 +16,7 @@ namespace MontanaJohns.Actors private Camera _camera; private PlayerInput playerInput; - private InputAction use, move, jump; + private InputAction use, move, jump, attack; protected override void Awake() { @@ -25,12 +25,13 @@ namespace MontanaJohns.Actors playerInput = GetComponent<PlayerInput>(); move = playerInput.currentActionMap.FindAction("Move"); jump = playerInput.currentActionMap.FindAction("Jump"); + attack = playerInput.currentActionMap.FindAction("Attack"); use = playerInput.currentActionMap.FindAction("Use"); jump.started += context => Jump(); use.started += context => Use(); - use.started += context => Fire(); + attack.started += context => Fire(); } protected override void Start() diff --git a/Assets/Scripts/Items/Whip.cs b/Assets/Scripts/Items/Whip.cs index 134ea53..cfc7aa9 100644 --- a/Assets/Scripts/Items/Whip.cs +++ b/Assets/Scripts/Items/Whip.cs @@ -46,7 +46,8 @@ namespace MontanaJohns.Items } else { - StartCoroutine(WhipSmack(collisionGameObject, clickLocation)); + // TODO uncomment this later when Projectiles are reworked into an Active Item (commented out for demonstration purposes) + // StartCoroutine(WhipSmack(collisionGameObject, clickLocation)); } } return null; @@ -62,7 +63,7 @@ namespace MontanaJohns.Items private IEnumerator WhipSmack(GameObject collisionGameObject, Vector2 clickLocation) { currentHook = Instantiate(hookNoSwing, clickLocation, Quaternion.identity); - collisionGameObject.GetComponent<Actor>().TakeDamage(player.GetComponent<Stats>().damage); + collisionGameObject.GetComponent<Actor>().TakeDamage(player.GetComponent<Player>().stats.damage); yield return new WaitForSeconds(0.1f); Destroy(currentHook); ropeExists = false; |