using UnityEngine;
using System.Collections;

public class RangeCircle : MonoBehaviour {

	static RangeCircle booster;
	static RangeCircle turret;
	Transform target;

	// Use this for initialization
	void Start () {
		if(gameObject.name.Contains("Turret"))
			turret = this;
		if(gameObject.name.Contains("Booster"))
			booster = this;
	}
	
	// Update is called once per frame
	void Update () {
		if(target == null) {
			TurnOff();
			return;
		}

		transform.position = target.position + new Vector3(0, 0, -0.1f);
	}

	public static void LockTo( Transform t, float radius, bool isBooster) {
		if(isBooster) {
			booster.target = t;
			booster.transform.localScale = new Vector3( radius, radius, 1);
			booster.gameObject.SetActive(true);
		}
		else {
			turret.target = t;
			turret.transform.localScale = new Vector3( radius, radius, 1);
			turret.gameObject.SetActive(true);
		}
	}

	public static void TurnOff() {
		booster.gameObject.SetActive(false);
		turret.gameObject.SetActive(false);
	}
}
