using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Debug class for controlling a character with keyboard input
|
|
/// </summary>
|
|
public class KeyboardInput : MonoBehaviour
|
|
{
|
|
|
|
#region Inspector Fields
|
|
[SerializeField]
|
|
[Tooltip("Character to move")]
|
|
private Character character;
|
|
|
|
public float characterSpeed;
|
|
#endregion Unity Functions
|
|
|
|
#region Unity Functions
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (character == null)
|
|
return;
|
|
|
|
if (Input.GetKeyDown(KeyCode.LeftArrow))
|
|
{
|
|
StartCoroutine(character.RotateInDirection(Direction.Left,90, Character.Animation.Jump, characterSpeed));
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.RightArrow))
|
|
{
|
|
StartCoroutine(character.RotateInDirection(Direction.Right, 90, Character.Animation.Jump, characterSpeed));
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.UpArrow))
|
|
{
|
|
float outTime;
|
|
Move move = (Move)ScriptableObject.CreateInstance(typeof(Move));
|
|
StartCoroutine(move.Run(character, characterSpeed));
|
|
Destroy(move);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
float outTime;
|
|
Jump jump = (Jump)ScriptableObject.CreateInstance(typeof(Jump));
|
|
StartCoroutine(jump.Run(character, characterSpeed));
|
|
Destroy(jump);
|
|
}
|
|
}
|
|
|
|
//if character is empty check on object for it
|
|
private void OnValidate()
|
|
{
|
|
if (character == null)
|
|
character = GetComponent<Character>();
|
|
}
|
|
|
|
#endregion Unity Functions
|
|
}
|