<commit_before>﻿using UnityEngine;
using System.Collections;

public class GetInput : MonoBehaviour {
	public bool usingPhone = false;
	private string horizontal;
	private string vertical;

	// Use this for initialization
	void Start () {
		//this.
		//var sw = new StreamWriter(Application.dataPath + "/Scripts/WriteToFile.txt", false);
		//sw.Write(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t\n")); 
		//print("initializing " + this);
		string[] name = this.ToString().Split(' ');
		if (name[0] != "Kart")
		{
			Debug.Log(name[0]);
			throw new System.Exception("Movement script attached to non Kart object");
		}
		switch (name[1])
		{
		case "1":
			horizontal = "Horizontal";
			vertical = "Vertical";
			break;
		case "2":
			horizontal = "Horizontal2";
			vertical = "Vertical2";
			break;
		case "3":
			horizontal = "Horizontal3";
			vertical = "Vertical3";
			break;
		case "4":
			horizontal = "Horizontal4";
			vertical = "Vertical4";
			break;
		}
	}
	
	// Update is called once per frame
	void Update () {
	}

	public float getTurnInput(){
		Vector3 Udp = Vector3.zero;
		if (!usingPhone) {
			if (Input.GetKey(KeyCode.RightArrow)){
				return 1;
			}
			if (Input.GetKey(KeyCode.LeftArrow)){
				return -1;
			}
			return Input.GetAxis (horizontal);
		}
		else
		{
			Udp = GetComponent<UDPReceive>().getLatestUDPPacket();
			float turnInput = Udp.x;
			if (Mathf.Abs(turnInput) < .2)
				return 0;
			return turnInput;
		}
	}

	public int getForwardInput(){
		Vector3 Udp = Vector3.zero;
		int forwardInput;
		if (!usingPhone)
		{
			if (Input.GetAxis(vertical) > 0)
				forwardInput = 1;
			else if (Input.GetAxis(vertical) < 0)
				forwardInput = -1;
			else if (Input.GetKey (KeyCode.UpArrow)) {
				return 1;
			}
			else if (Input.GetKey (KeyCode.DownArrow)) {
				return -1;
			} 
			else
				forwardInput = 0;
		}
		else
		{
			float z = Udp.z;
			if (z < -.25)
				forwardInput = 1;
			else if (z > 0)
				forwardInput = -1;
			else
				forwardInput = 0;
		}
		return forwardInput;
	}

}<commit_msg>updated input script to allow for multiple user keyboard input<commit_after>﻿using UnityEngine;
using System.Collections;

public class GetInput : MonoBehaviour {
	public bool usingPhone = false;
	private string horizontal;
	private string vertical;
	private KeyCode left;
	private KeyCode right;
	private KeyCode up;
	private KeyCode down;

	// Use this for initialization
	void Start () {
		//this.
		//var sw = new StreamWriter(Application.dataPath + "/Scripts/WriteToFile.txt", false);
		//sw.Write(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t\n")); 
		//print("initializing " + this);
		string[] name = this.ToString().Split(' ');
		if (name[0] != "Kart")
		{
			Debug.Log(name[0]);
			throw new System.Exception("Movement script attached to non Kart object");
		}
		switch (name[1])
		{
		case "1":
			horizontal = "Horizontal";
			vertical = "Vertical";
			left = KeyCode.LeftArrow;
			right = KeyCode.RightArrow;
			up = KeyCode.UpArrow;
			down = KeyCode.DownArrow;
			break;
		case "2":
			horizontal = "Horizontal2";
			vertical = "Vertical2";
			left = KeyCode.A;
			right = KeyCode.D;
			up = KeyCode.W;
			down = KeyCode.S;
			break;
		case "3":
			horizontal = "Horizontal3";
			vertical = "Vertical3";
			break;
		case "4":
			horizontal = "Horizontal4";
			vertical = "Vertical4";
			break;
		}
	}
	
	// Update is called once per frame
	void Update () {
	}

	public float getTurnInput(){
		Vector3 Udp = Vector3.zero;
		if (!usingPhone) {
			if (Input.GetKey(right)){
				return 1;
			}
			if (Input.GetKey(left)){
				return -1;
			}
			return Input.GetAxis (horizontal);
		}
		else
		{
			Udp = GetComponent<UDPReceive>().getLatestUDPPacket();
			float turnInput = Udp.x;
			if (Mathf.Abs(turnInput) < .2)
				return 0;
			return turnInput;
		}
	}

	public int getForwardInput(){
		Vector3 Udp = Vector3.zero;
		int forwardInput;
		if (!usingPhone)
		{
			if (Input.GetAxis(vertical) > 0)
				forwardInput = 1;
			else if (Input.GetAxis(vertical) < 0)
				forwardInput = -1;
			else if (Input.GetKey (up)) {
				return 1;
			}
			else if (Input.GetKey (down)) {
				return -1;
			} 
			else
				forwardInput = 0;
		}
		else
		{
			float z = Udp.z;
			if (z < -.25)
				forwardInput = 1;
			else if (z > 0)
				forwardInput = -1;
			else
				forwardInput = 0;
		}
		return forwardInput;
	}

}
{'fraction_non_alphanumeric': 0.14236191356598105, 'fraction_numerical': 0.018026346198289807, 'mean_word_length': 2.8711985688729875, 'pattern_counts': {'":': 8, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7478459', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1536, 'n_words': 389}