using UnityEngine;
using System.Collections;

public class TracerControllerBase : MonoBehaviour {

    // wenn Sie diese Checkbox aktivieren, pausiert der
    // Editor nach jeder Drehung, was zum Debuggen praktisch ist
    public bool pauseOnTurns = false;

    public InputHandler inputHandler;

    public float baseVelocity = 5F;

    public Rigidbody snakeHeadPrefab;
    public Transform pointFront;
    public Transform pointBack;
    public Transform rotateBody;

    protected Rigidbody myRigidbody = null;
    protected WallController wallController = null;

    protected void InitComponents() {
        myRigidbody = GetComponent<Rigidbody>();
        wallController = GetComponent<WallController>();
    }

    protected void StartMoving() {
        myRigidbody.velocity = transform.forward * baseVelocity;
        wallController.TracerTurned();
    }

    protected void CheckForTurn(ref float? rotation) {
        if (inputHandler.HasTurnCommand(TurnCommand.Left)) {
            rotation = -90F;
            SendMessage("TracerTurned", TurnCommand.Left);
        } else if (inputHandler.HasTurnCommand(TurnCommand.Right)) {
            rotation = 90F;
            SendMessage("TracerTurned", TurnCommand.Right);
        }
    }

}
