using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using UnityEngine;
using System;

public class CommandModule : Module {
	private float launchDistance;
	private List<Tuple<float, float>> landingPattern;

	public CommandModule(JObject json) : base(json) {
		launchDistance = (float)json["launchDistance"];

		landingPattern = new List<Tuple<float, float>>();
		foreach (JObject element in json["landingPattern"]) {

			landingPattern.Add(new Tuple<float, float>((float)element["distance"], (float)element["altitude"]));
		}

		sprite = Resources.Load("Sprites/Modules/Commands/" + getUniqueName(), typeof(Sprite)) as Sprite;
	}

	public float getLaunchDistance() {
		return launchDistance;
	}

	public List<Tuple<float, float>> getLandingPattern() {
		return landingPattern;
	}

	public static CommandModule[] loadModules(string[] filenames) {
		Array.Sort(filenames);
		CommandModule[] array = new CommandModule[filenames.Length];

		for (int i = 0; i < filenames.Length; i++) {
			array[i] = new CommandModule(jsonFromFile(filenames[i]));
		}

		return array;
	}

	override public bool canBeDisabled() {
		return false;
	}

	override public void updateClasses() {
	}

	override public ModuleData getData(int parent, float angleOffset, Vector position) {
		return new CommandModuleData (parent, this, position);
	}
}

public class CommandModuleData : ModuleData{
	public CommandModuleData(int parent, Module template, Vector position) : base(parent, template, position) {
	}
}