using UnityEngine;
using System.Collections;

public class TargetController : MonoBehaviour {

	public KeyCode upKey;
	public KeyCode downKey;

	public Vector3 homePosition;
	public Transform rotCenter;

	public bool isRotation;
	public bool horizontal;

	public float angleSpeed;
	public float amount;

	// Use this for initialization
	void Start () {
		homePosition = transform.position;
	}
	
	// Update is called once per frame
	void Update () {
	
		amount = 0.0f;

		if( Input.GetKey(upKey) ) {
			amount = .2f;
		} else if( Input.GetKey(downKey) ) {
			amount = -.2f;
		}

		if( amount != 0.0f ) {
			if(isRotation) {
				transform.RotateAround(rotCenter.transform.position, Vector3.forward, amount * angleSpeed * Time.deltaTime);
			} else {
				if( horizontal ) {
					Rigidbody2D rb2d = GetComponent<Rigidbody2D>();
					Vector3 pos = transform.position;
					rb2d.MovePosition(new Vector2(pos.x + amount, pos.y));
				} else {
					Rigidbody2D rb2d = GetComponent<Rigidbody2D>();
					Vector3 pos = transform.position;
					rb2d.MovePosition(new Vector2(pos.x, pos.y + amount));
					//				transform.Translate(0, amount, 0);
				}
			}
		}

	}
}
