Ejemplo n.º 1
0
    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);
        }
    }