using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MovementScript : MonoBehaviour
{
    public Direction dir;
    float speed = 10;
    PoweredObject power;

    public GameObject vehicle;
    public Vector3 offset;
    // Use this for initialization
    void Start()
    {
        power = GetComponent<PoweredObject>();
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = vehicle.transform.position + offset;
        if (dir == Direction.BACKWARDS)
        {
            if (/*Input.GetKey(KeyCode.A) &&*/ power.GetPower() > 0)
            {
                vehicle.GetComponent<Rigidbody2D>().MovePosition(vehicle.transform.position + (Vector3.left * speed * power.GetPower() * Time.deltaTime));
            }
        }
        if (dir == Direction.FORWARDS)
        {
            if (/*Input.GetKey(KeyCode.D) &&*/ power.GetPower() > 0)
            {
                vehicle.GetComponent<Rigidbody2D>().MovePosition(vehicle.transform.position + (Vector3.right * speed * power.GetPower() * Time.deltaTime));
            }
        }
    }
}
[System.Serializable]
public enum Direction
{
    FORWARDS,
    BACKWARDS
}
