2019-09-17 15:43:40 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class InputManager : MonoBehaviour
|
|
|
|
|
{
|
2019-09-17 18:52:55 +02:00
|
|
|
|
|
|
|
|
|
private AbstractCharacter _character;
|
2019-09-17 15:43:40 +02:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
2019-09-17 18:52:55 +02:00
|
|
|
|
_character = GetComponentInParent<AbstractCharacter>();
|
2019-09-17 15:43:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2019-09-17 18:52:55 +02:00
|
|
|
|
//
|
|
|
|
|
// Manage movement inputs
|
|
|
|
|
//
|
|
|
|
|
var movementDirection = Vector2.zero;
|
|
|
|
|
|
|
|
|
|
movementDirection += Input.GetAxis("Horizontal") * Vector2.right;
|
|
|
|
|
movementDirection += Input.GetAxis("Vertical") * Vector2.up;
|
2019-09-17 15:43:40 +02:00
|
|
|
|
|
2019-09-17 18:52:55 +02:00
|
|
|
|
_character.Move(movementDirection);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Manage action inputs
|
|
|
|
|
//
|
|
|
|
|
if (Input.GetButton("Fire1"))
|
|
|
|
|
{
|
|
|
|
|
_character.Shoot();
|
|
|
|
|
}
|
2019-09-17 15:43:40 +02:00
|
|
|
|
}
|
|
|
|
|
}
|