2017-05-07 18:48:56 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2017-05-08 21:59:35 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Controls the player character. Shouldn't exist on the server, and only one
|
|
|
|
|
/// should exist per client (the character that client is controlling).
|
|
|
|
|
/// </summary>
|
2017-05-07 18:48:56 +02:00
|
|
|
|
public class PlayerController : MonoBehaviour {
|
2017-05-08 21:59:35 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The character this controller should control.
|
|
|
|
|
/// </summary>
|
2017-05-07 21:44:35 +02:00
|
|
|
|
public Character Character;
|
2017-05-07 18:48:56 +02:00
|
|
|
|
|
2017-05-08 01:29:12 +02:00
|
|
|
|
private void Update() {
|
|
|
|
|
if (!Term.IsVisible()) {
|
|
|
|
|
// Handle inputs
|
|
|
|
|
Vector3 Move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
|
|
|
|
|
if (Move.sqrMagnitude != 0) {
|
|
|
|
|
Character.Move(transform.TransformDirection(Move));
|
|
|
|
|
} else if (Character.Moving()) {
|
|
|
|
|
Character.Stop();
|
|
|
|
|
}
|
2017-05-07 21:53:01 +02:00
|
|
|
|
} else if (Character.Moving()) {
|
2017-05-08 01:29:12 +02:00
|
|
|
|
// The debug console is open, stop the player.
|
2017-05-07 21:53:01 +02:00
|
|
|
|
Character.Stop();
|
|
|
|
|
}
|
2017-05-07 21:44:35 +02:00
|
|
|
|
}
|
2017-05-07 18:48:56 +02:00
|
|
|
|
}
|