// Use this for initialization void Start() { scanTimer = 0f; layer = 8; team = GetComponent <UnitController> ().team; shipTargets = new List <UnitController> (); fcs = GetComponent <FireControlSystem> (); }
public void AssignTarget(TargetState ts) { var systems = dataLink.GetAllOf <FireControlSystem>(); float distance = float.PositiveInfinity; FireControlSystem optimal = null; foreach (DataLink dl in systems) { FireControlSystem fcs = dl.GetComponent <FireControlSystem>(); if (!fcs.assigned && Vector3.Distance(fcs.transform.position, ts.position) < distance) { optimal = fcs; distance = Vector3.Distance(fcs.transform.position, ts.position); } } if (optimal != null) { //Debug.Log("Assigning Target"); visualise.AddShortData("Action", "Sending Target Order"); assigned++; ts.assigned = true; optimal.EngageTarget(ref ts); } }