﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour {

	Masken _masken;

	public KeyCode rightKey = KeyCode.RightArrow; 
	public KeyCode leftKey = KeyCode.LeftArrow; 
	public KeyCode upKey = KeyCode.UpArrow; 
	public KeyCode downKey = KeyCode.DownArrow;

	private Vector2 _vector = Vector2.zero;

	// Use this for initialization
	private void Start () {
		_masken = GetComponent<Masken> ();
	}

	private bool _vertical = true;
	private bool _horizontal = true;
	
	// Update is called once per frame
	private void Update () {

		if (Input.GetKey (rightKey) && _horizontal) {
			_horizontal = false;
			_vertical = true;
			_vector = Vector2.right;
		} else if (Input.GetKey (upKey) && _vertical) {
			_horizontal = true;
			_vertical = false;
			_vector = Vector2.up;
		} else if (Input.GetKey (downKey) && _vertical) {
			_horizontal = true;
			_vertical = false;
			_vector = -Vector2.up;
		} else if (Input.GetKey (leftKey) && _horizontal) {
			_horizontal = false;
			_vertical = true;
			_vector = -Vector2.right;
		}
		_masken.SetMovementVector(_vector / 3f);
	}
}
