Throw start
This commit is contained in:
parent
2657ca3d20
commit
c428a0e96f
41
Assets/Scripts/MinionThrower.cs
Normal file
41
Assets/Scripts/MinionThrower.cs
Normal file
@ -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<MinionBar>();
|
||||
}
|
||||
|
||||
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<Vector2>().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);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/MinionThrower.cs.meta
Normal file
11
Assets/Scripts/MinionThrower.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56c3e06ea5db48a40a7f55e72291cb0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user