diff --git a/Assets/Scripts/MinionThrower.cs b/Assets/Scripts/MinionThrower.cs new file mode 100644 index 0000000..5b7372e --- /dev/null +++ b/Assets/Scripts/MinionThrower.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.InputSystem; + +public class MinionThrower : MonoBehaviour { + + public GameObject placeholderMinionPrefab; + + public GameObject aimArrow; + + bool isInThrowMode; + Vector2 throwDirection = Vector2.right; + MinionBar minionBar; + + void Awake() { + minionBar = FindObjectOfType(); + } + + public void ToggleThrowMode(InputAction.CallbackContext context) { + if(context.performed) { + isInThrowMode = true; + } else if(context.canceled) { + PerformThrow(); + isInThrowMode = false; + } + } + + public void AimThrow(InputAction.CallbackContext context) { + throwDirection = context.ReadValue().normalized; + } + + void PerformThrow() { + if(!isInThrowMode) { + return; + } + Object currentMinion = minionBar.GetCurrentMinion(); + GameObject newMinion = Instantiate(placeholderMinionPrefab, transform.position + new Vector3(throwDirection.x, throwDirection.y, 0f) * 1f, Quaternion.identity); + } + +} diff --git a/Assets/Scripts/MinionThrower.cs.meta b/Assets/Scripts/MinionThrower.cs.meta new file mode 100644 index 0000000..08cae21 --- /dev/null +++ b/Assets/Scripts/MinionThrower.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 56c3e06ea5db48a40a7f55e72291cb0d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: