//needs to be public to use the method in onclick() method
    public void TransmitInstructions(PlaneTrasponder tarPlane) // add the cleared ILS???
    {
        bool b_float = true;

        Debug.Log("Transmitted instructions!");

        foreach (InputField text in ControlInputFieldsArr) // checks ig there are any letters in the input fields
        {
            foreach (char c in text.text)
            {
                if (char.IsLetter(c))
                {
                    b_float = false; Debug.Log(b_float); break;
                }
            }
        }

        if (b_float)
        {
            if (ControlInputFieldsArr[0].text.Length > 0)
            {
                tarPlane.expectedSpeedInKTS = float.Parse(ControlInputFieldsArr[0].text);
            }
            if (ControlInputFieldsArr[1].text.Length > 0)
            {
                tarPlane.expectedHeading = float.Parse(ControlInputFieldsArr[1].text);
            }
            if (ControlInputFieldsArr[2].text.Length > 0)
            {
                tarPlane.expectedAltitude = float.Parse(ControlInputFieldsArr[2].text);
            }
        }

        ClearInputFields();
    }
 private void DisplayInfo(PlaneTrasponder tarPlane)
 {
     InfoCallsign.text = "Callsing: " + tarPlane.planeName;
     InfoSpeed.text    = "Speed: " + Mathf.Round(tarPlane.expectedSpeedInKTS).ToString() + " " + "KTS";
     InfoHeading.text  = "Heading: " + Mathf.Round(tarPlane.expectedHeading).ToString() + " " + "DEG";
     InfoAltitude.text = "Altitude: " + Mathf.Round(tarPlane.expectedAltitude).ToString() + " " + "FT";
     RunwayToLand.text = " " + tarPlane.runwayToLand.ToString();
 }
Ejemplo n.º 3
0
 private void ResetLandedPlane(PlaneTrasponder landingPlane) // work on delition
 {
     landingPlane.transform.position = transform.position;
     landingPlane.curSpeedInKTS      = 0;
     landingPlane.expectedSpeedInKTS = 0;
     landingPlane.curAltitude        = 0;
     landingPlane.expectedAltitude   = 0;
     landingPlane.gameObject.SetActive(false);
 }
Ejemplo n.º 4
0
 // ADD THE ELEMINATION AFTER LANDING // ADD DETECTIONXXX
 void Start()
 {
     b_withinAngleLimits  = false;
     interceptPoint       = interceptionPointGO.transform.position;
     glideSlopeRadiusDist = Vector3.Distance(transform.position, interceptPoint);
     landingPlane         = null;
     ATCInterface         = ATCinterfaceGO.GetComponent <AirplaneMovementInterface>();
     spawner = FindObjectOfType <PlaneSpawner>();
 }
Ejemplo n.º 5
0
 private void RemoveLandingPlaneFromILS(PlaneTrasponder planeToDelete)
 {
     if (planeToDelete == landingPlane)
     {
         landingPlane = null;
     }
     if (planeToDelete == secondLandingPlane)
     {
         secondLandingPlane = null;
     }
 }
Ejemplo n.º 6
0
 private void RemoveLandedPlaneFromApproachPlaneList(PlaneTrasponder landingPlane)  // try to remove from the approach Plane List!!!!!! w/o having reference exception
 {
     foreach (PlaneTrasponder plane in spawner.approachPlaneList)
     {
         if (plane == landingPlane)
         {
             spawner.approachPlaneList.Remove(plane);
             spawner.landedPlaneList.Add(plane);
             break;
         }
     }
 }
Ejemplo n.º 7
0
    private void Localiser(PlaneTrasponder landingPlane)
    {
        Quaternion tarRot = Quaternion.LookRotation(interceptPoint - landingPlane.transform.position);

        landingPlane.expectedHeading = tarRot.eulerAngles.y;

        float distanceFromInterceptPoint = Vector3.Distance(landingPlane.transform.position, interceptPoint); // This is called after intercepting intercept point

        if (distanceFromInterceptPoint < .5 || landingPlane.b_onGS == true)
        {
            landingPlane.expectedHeading = localiserHeading;
        }
    }
Ejemplo n.º 8
0
    private void GlideSlope(PlaneTrasponder landingPlane, float dist, float alt)
    {
        float curSpeed = landingPlane.curSpeedInKTS = 150;

        landingPlane.expectedSpeedInKTS = 150;
        float time             = dist / curSpeed;
        float descentRateInFPM = alt / time / 60;

        if (landingPlane.curAltitude > 10)
        {
            landingPlane.curAltitude     -= descentRateInFPM / 3000; // per iteration check if accurate to runway threshold
            landingPlane.expectedAltitude = landingPlane.curAltitude;
        }
    }
 private void DisplayControlCurrentInfo(PlaneTrasponder tarPlane)
 {
     ControlSpeed.text    = Mathf.Round(tarPlane.curSpeedInKTS).ToString() + "\r\n" + "Exptd " + Mathf.Round(tarPlane.expectedSpeedInKTS).ToString() + " " + "KTS";
     ControlHeading.text  = Mathf.Round(tarPlane.curHeading).ToString() + "\r\n" + "Exptd " + Mathf.Round(tarPlane.expectedHeading).ToString() + " " + "DEG";
     ControlAltitude.text = Mathf.Round(tarPlane.curAltitude).ToString() + "\r\n" + "Exptd " + Mathf.Round(tarPlane.expectedAltitude).ToString() + " " + "FT";
     if (tarPlane.b_onLOC)
     {
         ILSGauge.text = "ON ILS";
     }
     else
     {
         ILSGauge.text = "OFF ILS";
     }
 }
Ejemplo n.º 10
0
    private void ClearDistanceAlarm(PlaneTrasponder plane, PlaneTrasponder otherPlane)
    {
        MeshRenderer firstPlaneMeshRend  = plane.gameObject.GetComponent <MeshRenderer>();
        MeshRenderer secondPlaneMeshRend = otherPlane.gameObject.GetComponent <MeshRenderer>();

        firstPlaneMeshRend.material  = defaultMat;
        secondPlaneMeshRend.material = defaultMat;

        firstPlaneMeshRend.GetComponentInChildren <Text>().color  = Color.white;
        secondPlaneMeshRend.GetComponentInChildren <Text>().color = Color.white;

        firstPlaneMeshRend.GetComponent <LineRenderer>().startColor = Color.white;
        firstPlaneMeshRend.GetComponent <LineRenderer>().endColor   = Color.white;


        alertInfo.text = " ";
    }
Ejemplo n.º 11
0
    private void DistanceAlarm(PlaneTrasponder plane, PlaneTrasponder otherPlane, float dist)
    {
        MeshRenderer firstPlaneMeshRend  = plane.gameObject.GetComponent <MeshRenderer>();
        MeshRenderer secondPlaneMeshRend = otherPlane.gameObject.GetComponent <MeshRenderer>();

        firstPlaneMeshRend.material  = alarmMat;
        secondPlaneMeshRend.material = alarmMat;

        firstPlaneMeshRend.GetComponentInChildren <Text>().color  = Color.red;
        secondPlaneMeshRend.GetComponentInChildren <Text>().color = Color.red;

        firstPlaneMeshRend.GetComponent <LineRenderer>().startColor = Color.red;
        firstPlaneMeshRend.GetComponent <LineRenderer>().endColor   = Color.red;

        alertTitle.text = "Alert System";
        alertInfo.text  = plane.name + " " + otherPlane.name + "\r\n" + "Traffic Alert less than" + " " + Mathf.Round(dist).ToString() + " " + "miles";
    }
    private void SelectPlane() // selects plane with Raycast
    {
        if (Input.GetMouseButtonDown(1))
        {
            Ray       ray        = Camera.main.ScreenPointToRay(Input.mousePosition);
            LayerMask planeLayer = 1 << 8;

            if (Physics.Raycast(ray, out target, Mathf.Infinity, planeLayer))
            {
                targetPlaneGO      = target.collider.gameObject;
                tarPlaneTrasponder = targetPlaneGO.GetComponent <PlaneTrasponder>();
                tarPlaneIcon       = targetPlaneGO.GetComponent <MeshRenderer>();

                // this changes the color of the icon of the plane
                SetSelectedColor(tarPlaneIcon);

                selectedPlanesList.Add(targetPlaneGO);

                if (selectedPlanesList.Count > 1)
                {
                    if (selectedPlanesList[0] != selectedPlanesList[1])
                    {
                        ResetDefaultColor(selectedPlanesList[0].GetComponent <MeshRenderer>());
                        SetSelectedColor(selectedPlanesList[1].GetComponent <MeshRenderer>());
                        ClearInputFields();
                    }
                    selectedPlanesList.RemoveAt(0);
                }
            }

            else if (selectedPlanesList != null && selectedPlanesList[0] != targetPlaneGO) //
            {
                ClearInfo();
                ClearControlCurrentInfo();
                ResetDefaultColor(tarPlaneIcon); // check default color
                ClearTarPlaneTrasponders();
                ClearInputFields();
            }
        }
    }
Ejemplo n.º 13
0
    private void ILSCoreLogic(PlaneTrasponder landingPlane)
    {
        if (landingPlane != null)
        {
            if (landingPlane.b_clearedForILS && landingPlane.runwayToLand == runwayName)// add the runway name condition
            {
                landingPlaneDist = Vector3.Distance(transform.position, landingPlane.transform.position);

                Vector3 airplaneDir       = landingPlane.transform.position - transform.position;
                float   airplaneAngleDiff = Vector3.Angle(airplaneDir, transform.forward);

                if (airplaneAngleDiff < localiserMaxAngleDiff)
                {
                    b_withinAngleLimits = true;
                }                                                                              // 45 degree limit
                if (landingPlaneDist <= localiserRadiusDist && b_withinAngleLimits)
                {
                    Localiser(landingPlane);
                    landingPlane.b_onLOC = true;  // display be on ILS on the GUI
                }

                if (landingPlaneDist <= glideSlopeRadiusDist && landingPlane.curAltitude <= glideSlopeAltitude)
                {
                    GlideSlope(landingPlane, glideSlopeRadiusDist, landingPlane.curAltitude);
                    landingPlane.b_onGS = true;
                }

                if (landingPlaneDist <= landedRadius)
                {
                    AddInLandedPlaneList(landingPlane);
                    RemoveLandedPlaneFromApproachPlaneList(landingPlane);
                    ResetLandedPlane(landingPlane);
                    RemoveLandingPlaneFromILS(landingPlane);
                }
            }
        }
    }
 private void ClearTarPlaneTrasponders()
 {
     selectedPlanesList.Clear();
     targetPlaneGO      = null;
     tarPlaneTrasponder = null;
 }
Ejemplo n.º 15
0
 private void AddInLandedPlaneList(PlaneTrasponder landingPlane)
 {
     ATCInterface.landedPlanes.Add(landingPlane);
 }
Ejemplo n.º 16
0
 private void RemoveLandingPlaneFromILS()
 {
     landingPlane = null;
 }
Ejemplo n.º 17
0
 private void RemoveLandingPlaneFromILS(PlaneTrasponder landingPlane)
 {
     landingPlane = null;
 }
    private void ClearToILS(PlaneTrasponder tarplane)
    {
        if (tarplane.runwayToLand == "27L")
        {
            if (ils27L.landingPlane == null) // only one plane at a time on ILS
            {
                tarplane.b_clearedForILS = true;
                ils27L.landingPlane      = tarplane;
            } // sets the current selected plane to landing plane for ILS
            else if (ils27L.secondLandingPlane == null && tarplane != ils27L.landingPlane)
            {
                tarplane.b_clearedForILS  = true;
                ils27L.secondLandingPlane = tarplane;
            }
        }

        if (tarplane.runwayToLand == "27R")
        {
            if (ils27R.landingPlane == null) // only one plane at a time on ILS
            {
                tarplane.b_clearedForILS = true;
                ils27R.landingPlane      = tarplane;
            } // sets the current selected plane to landing plane for ILS

            else if (ils27R.secondLandingPlane == null && tarplane != ils27R.landingPlane)
            {
                tarplane.b_clearedForILS  = true;
                ils27R.secondLandingPlane = tarplane;
            }
        }

        if (tarplane.runwayToLand == "9L")
        {
            if (ils9L.landingPlane == null) // only one plane at a time on ILS
            {
                tarplane.b_clearedForILS = true;
                ils9L.landingPlane       = tarplane;
            } // sets the current selected plane to landing plane for ILS


            else if (ils9L.secondLandingPlane == null && tarplane != ils9L.landingPlane)
            {
                tarplane.b_clearedForILS = true;
                ils9L.secondLandingPlane = tarplane;
            }
        }

        if (tarplane.runwayToLand == "9R")
        {
            if (ils9R.landingPlane == null) // only one plane at a time on ILS
            {
                tarplane.b_clearedForILS = true;
                ils9R.landingPlane       = tarplane;
            } // sets the current selected plane to landing plane for ILS

            else if (ils9R.secondLandingPlane == null && tarplane != ils9R.landingPlane)
            {
                tarplane.b_clearedForILS = true;
                ils9R.secondLandingPlane = tarplane;
            }
        }
    }
Ejemplo n.º 19
0
    private void SpawnAPlane()
    {
        GameObject planeSpawned;
        Vector3    randomVORPos = RandomVORSpawnPos();

        planeSpawned = Instantiate(planePrefab, randomVORPos, SpawnRotation(randomVORPos)); // abit higher over the VOR and Waypoints

        PlaneTrasponder planeTrans = planeSpawned.GetComponent <PlaneTrasponder>();

        // Randomise Aircraft Type
        planeTrans.aircraftType = RandomiseAircraftType();

        // randomize positions and rotations based on the jetways and the airways used! // check if is not already in the list of approaching planes
        string randomname = RandomisePlaneName();

        foreach (PlaneTrasponder planes in approachPlaneList)  // check if name is already taken
        {
            if (planes.name == randomname)
            {
                b_nameAlreadyTaken = true;
            }
            else
            {
                b_nameAlreadyTaken = false;
            }
        }

        foreach (PlaneTrasponder landedPlane in landedPlaneList)
        {
            if (landedPlane.name == randomname)
            {
                b_nameAlreadyTaken = true;
            }
            else
            {
                b_nameAlreadyTaken = false;
            }
        }

        if (!b_nameAlreadyTaken)
        {
            planeSpawned.name = randomname;
            planeSpawned.GetComponent <PlaneTrasponder>().planeName = randomname;
            approachPlaneList.Add(planeSpawned.GetComponent <PlaneTrasponder>());
            planeCount++;
        }

        // sets preferred runway // also you can eliminate this // add this in different functions
        planeSpawned.GetComponent <PlaneTrasponder>().runwayToLand = SetPlaneLandingRunway();

        if (planeTrans.runwayToLand.Contains("R"))
        {
            rightCount++;
        }
        else if (planeTrans.runwayToLand.Contains("L"))
        {
            leftCount++;
        }

        //sets altitude based on VOR ALTITUTDE
        planeSpawned.GetComponent <PlaneTrasponder>().curAltitude      = SetPlaneAltitudeAtSpawn(randomVORPos);
        planeSpawned.GetComponent <PlaneTrasponder>().expectedAltitude = SetPlaneAltitudeAtSpawn(randomVORPos);
        //Sets default speed 250kts under 10000'
        planeSpawned.GetComponent <PlaneTrasponder>().curSpeedInKTS      = initialSpeedAtSpawn;
        planeSpawned.GetComponent <PlaneTrasponder>().expectedSpeedInKTS = initialSpeedAtSpawn;

        AddToUiInterceptList(planeSpawned.transform);
    }