Ejemplo n.º 1
0
        private AHMapMarker CreateMapMarkerRelay(Vessel relay)
        {
            double realSignal = relays [relay].endRelaySignalStrength;            //AHUtil.GetREALSignal (relay.Connection.ControlPath);
            double range      = AHUtil.GetDistanceAt0
                                    (AHUtil.GetRange(vesselPower, relays [relay].endRelayPower));
            AHMapMarker marker = new GameObject().AddComponent <AHMapMarker> ();

            marker.SetUp(range, vessel, relay.mapObject.trf, false, realSignal);


            return(marker);
        }
Ejemplo n.º 2
0
        private void CreateMarkers()
        {
            listMarkers = new Dictionary <string, Dictionary <string, List <GameObject> > > ();

            foreach (KeyValuePair <string, Dictionary <string, string> > vesselPairInfo in listShipTransmitter)
            {
//				Debug.Log ("[AH] creating marker for vessel : " + vesselPairInfo.Value ["name"]);

                listMarkers.Add(vesselPairInfo.Key, new Dictionary <string, List <GameObject> > ());

                double      vesselPower, maxRange, realSignal;
                Vessel      transmiter;
                bool        editorShip;
                bool        isHome;
                Transform   relay;
                AHMapMarker marker;

                vesselPower = AHUtil.TruePower(Double.Parse(vesselPairInfo.Value ["powerTotal"]));
                if ((vesselPairInfo.Value ["type"] == "VAB") || (vesselPairInfo.Value ["type"] == "SPH"))
                {
                    transmiter = null;
                    editorShip = true;
                }
                else
                {
                    transmiter = FlightGlobals.Vessels.Find(v => v.id.ToString() == vesselPairInfo.Key);
                    editorShip = false;
                }
//				Debug.Log ("[AH] vessel power computed");

                // Active Connection :
                if (vesselPairInfo.Value ["connectedTo"] == "")
                {
                    // the active connection is to the DSN or isn't set
                    maxRange   = AHUtil.GetRange(vesselPower, dsnPower);
                    realSignal = 1d;
                    isHome     = true;
                    relay      = Planetarium.fetch.Home.MapObject.trf;
                }
                else
                {
                    // active connection going trough a relay
                    maxRange   = AHUtil.GetRange(vesselPower, AHUtil.TruePower(Double.Parse(listShipRelay [vesselPairInfo.Value ["connectedTo"]] ["powerRelay"])));
                    realSignal = Double.Parse(listShipRelay [vesselPairInfo.Value ["connectedTo"]] ["realSignal"]);
                    isHome     = false;
                    relay      = FlightGlobals.Vessels.Find(v => v.id.ToString() == vesselPairInfo.Value ["connectedTo"]).mapObject.trf;
                }
                maxRange = AHUtil.GetDistanceAt0(maxRange);
                listMarkers [vesselPairInfo.Key].Add("ACTIVE", new List <GameObject> ());
                listMarkers [vesselPairInfo.Key] ["ACTIVE"].Add(new GameObject());
                marker = listMarkers [vesselPairInfo.Key] ["ACTIVE"] [0].AddComponent <AHMapMarker> ();
                marker.SetUp(maxRange, transmiter, relay, isHome, realSignal, editorShip);
//				Debug.Log ("[AH] active connection done");

                // DSN Connection :
                maxRange   = AHUtil.GetRange(vesselPower, dsnPower);
                maxRange   = AHUtil.GetDistanceAt0(maxRange);
                realSignal = 1d;
                isHome     = true;
                relay      = Planetarium.fetch.Home.MapObject.trf;

                listMarkers [vesselPairInfo.Key].Add("DSN", new List <GameObject> ());
                listMarkers [vesselPairInfo.Key] ["DSN"].Add(new GameObject());
                marker = listMarkers [vesselPairInfo.Key] ["DSN"] [0].AddComponent <AHMapMarker> ();
                marker.SetUp(maxRange, transmiter, relay, isHome, realSignal, editorShip);
//				Debug.Log ("[AH] dsn connection done");

                // Relay(s) Connection :
                List <GameObject> listRelayMarkers = new List <GameObject> ();
                foreach (KeyValuePair <string, Dictionary <string, string> > relayPairInfo in listShipRelay)
                {
                    if (relayPairInfo.Key == vesselPairInfo.Key)
                    {
                        continue;
                    }
                    maxRange   = AHUtil.GetRange(vesselPower, AHUtil.TruePower(Double.Parse(relayPairInfo.Value ["powerRelay"])));
                    maxRange   = AHUtil.GetDistanceAt0(maxRange);
                    realSignal = Double.Parse(relayPairInfo.Value ["realSignal"]);
                    isHome     = false;
                    relay      = FlightGlobals.Vessels.Find(v => v.id.ToString() == relayPairInfo.Key).mapObject.trf;

                    listRelayMarkers.Add(new GameObject());
                    marker = listRelayMarkers [listRelayMarkers.Count - 1].AddComponent <AHMapMarker> ();
                    marker.SetUp(maxRange, transmiter, relay, isHome, realSignal, editorShip);
                }
                listMarkers [vesselPairInfo.Key].Add("RELAY", listRelayMarkers);
//				Debug.Log ("[AH] relays connections done");
            }
        }