Example #1
0
    private void AddToScreen(CDTIPlane plane)
    {
        if (plane == null)
        {
            return;
        }
        GameObject toAdd;

        if (aircraftHidden.Count > 0)
        {
            toAdd = aircraftHidden[0];
            aircraftHidden.Remove(toAdd);
        }
        else
        {
            toAdd = Instantiate(aircraftBuilder) as GameObject;
        }


        toAdd.GetComponent <SpriteRenderer>().sprite = getCorrectSprite(plane);
        toAdd.GetComponent <Transform>().position    = figurePositon(plane);
        toAdd.GetComponent <Transform>().rotation    = figureRotation(plane);
        if (plane != null && plane.Position.X != 0 || plane.Position.Y != 0 || plane.Position.Z != 0)
        {
            toAdd.GetComponent <Aircraft>().addText(plane);
        }


        logger("added to screed " + plane.Id);
        aircraft.Add(toAdd);
        //throw new NotImplementedException();
    }
Example #2
0
 public void addText(CDTIPlane plane)
 {
     text = new GameObject();
     text.AddComponent <TextMesh>();
     text.transform.SetParent(transform);
     Instantiate(text);
     text.GetComponent <TextMesh>().fontSize  = 60;
     text.GetComponent <TextMesh>().fontStyle = FontStyle.Normal;
     text.GetComponent <TextMesh>().text      = "" + plane.Position.Z;
     text.transform.localScale = new Vector3(.05f, .05f, 1);
     text.transform.position   = transform.position + new Vector3(.2f, .2f, 0);
 }
Example #3
0
    public void testPostion()
    {
        CDTIPlane plane = new CDTIPlane();

        plane.Position = new Vector(5, 5, 0);
        NetworkInput toTest = new NetworkInput();

        Assert.That(1.25 == toTest.figurePositon(plane).x, "got: " + toTest.figurePositon(plane).x);
        Assert.That(1.25 == toTest.figurePositon(plane).y, "got: " + toTest.figurePositon(plane).y);
        toTest.zoomIn();
        Assert.That(1.5625 == toTest.figurePositon(plane).x, "got: " + toTest.figurePositon(plane).x);
        Assert.That(1.5625 == toTest.figurePositon(plane).y, "got: " + toTest.figurePositon(plane).y);
        toTest.zoomOut();
        toTest.zoomOut();
        Assert.That(1.041667 == toTest.figurePositon(plane).x, "got: " + toTest.figurePositon(plane).x);
        Assert.That(1.041667 == toTest.figurePositon(plane).y, "got: " + toTest.figurePositon(plane).y);
    }
Example #4
0
        private static CDTIPlane buildPlanes(double px, double py, double pz, double vx, double vy, double vz, string id)
        {
            CDTIPlane toReturn = new CDTIPlane();
            Vector    v        = new Vector();
            Vector    p        = new Vector();

            p.N = (float)px;
            p.E = (float)py;
            p.D = (float)pz;
            v.N = (float)vx;
            v.E = (float)vy;
            v.D = (float)vz;
            toReturn.Position = p;
            toReturn.Velocity = v;
            toReturn.Id       = id;
            return(toReturn);
        }
Example #5
0
    public Quaternion figureRotation(CDTIPlane plane)
    {
        try
        {
            float theta = 0;

            theta = (float)(Math.Atan2(plane.Velocity.Y, plane.Velocity.X) * 180 / 3.14 - 90);
            print(theta);
            if (plane.Velocity.X == 0 && plane.Velocity.Y == 0)
            {
                theta = 0;
            }
            return(Quaternion.AngleAxis(theta, new Vector3(0, 0, 1)));
        }
        catch (Exception)
        {
            return(Quaternion.AngleAxis(0, new Vector3(0, 0, 1)));
        }
    }
Example #6
0
    public Vector3 figurePositon(CDTIPlane plane)
    {
        Vector3 positon;

        if (plane == null)
        {
            positon.x = pos.X / maxRange * 5;
            positon.y = pos.Y / maxRange * 5;
            positon.z = 0;

            return(positon);
        }


        positon.x = plane.Position.X / maxRange * 5;
        positon.y = plane.Position.Y / maxRange * 5;
        positon.z = 0;

        //add writing for the elevation later
        return(positon);
        // throw new NotImplementedException();
    }
Example #7
0
    public void testRotation()
    {
        CDTIPlane plane = new CDTIPlane();

        plane.Velocity = new Vector(1, 0, 0);
        NetworkInput toTest = new NetworkInput();

        Assert.That(Quaternion.AngleAxis(-90, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(1, 1, 0);
        Assert.That(Quaternion.AngleAxis(-45, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(0, 1, 0);
        Assert.That(Quaternion.AngleAxis(0, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(-1, 1, 0);
        Assert.That(Quaternion.AngleAxis(45, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(-1, 0, 0);
        Assert.That(Quaternion.AngleAxis(90, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(-1, -1, 0);
        Assert.That(Quaternion.AngleAxis(135, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(0, -1, 0);
        Assert.That(Quaternion.AngleAxis(180, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
        plane.Velocity = new Vector(1, -1, 0);
        Assert.That(Quaternion.AngleAxis(225, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane)));
    }
Example #8
0
    private Sprite getCorrectSprite(CDTIPlane plane)
    {
        if (plane == null)
        {
            return(airTrafficDirectional);
        }

        switch (plane.severity)
        {
        case (CDTIPlane.Severity.PROXIMATE):
            if (plane.Velocity.X == 0 && plane.Velocity.Y == 0)
            {
                return(proximateTrafficNonDirectional);
            }
            else
            {
                return(proximateTrafficDirectional);
            }

        case (CDTIPlane.Severity.TRAFFIC):
            return(trafficAdvisoryDirectional);

        case (CDTIPlane.Severity.RESOLUTION):
            return(resolutionAdvisoryDirectional);

        default:
            if (plane.Velocity.X == 0 && plane.Velocity.Y == 0)
            {
                return(airTrafficNonDirectional);
            }
            else
            {
                return(airTrafficDirectional);
            }
        }
    }
Example #9
0
 private void setUpText(GameObject toAdd, CDTIPlane plane)
 {
     throw new NotImplementedException();
 }