Пример #1
0
    public Vector3 PhysicalPositionToWorldPosition(Vector3 physical_position)
    {
        Satellite root_satellite         = Root.GetComponent <Satellite>();
        Satellite focused_satellite      = FocusedObject.GetComponent <Satellite>();
        Satellite last_focused_satellite = last_focused_object.GetComponent <Satellite>();

        if (focused_satellite == null ||
            last_focused_satellite == null ||
            root_satellite == null)
        {
            throw new System.NotImplementedException();
        }

        Vector3 compressed_position =
            GetCompressedPosition(focused_satellite, physical_position);

        if (TransitionMoment < 1)
        {
            compressed_position = compressed_position.Lerped(
                GetCompressedPosition(last_focused_satellite, physical_position),
                1 - TransitionMoment);
        }

        compressed_position = compressed_position.Lerped(
            GetCompressedPosition(root_satellite, physical_position),
            0.5f);

        return(ObjectsContainer.TransformPoint(compressed_position * PixelRadius));
    }
Пример #2
0
    private void HandleAsteroidSplitExplosion()
    {
        float blastRadius = mass * 2f;
        float blastForce  = 40f * mass;

        Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, blastRadius);

        foreach (Collider2D col in hitColliders)
        {
            Vector3 pos     = col.transform.position;
            Vector2 impulse = pos - transform.position;

            impulse /= impulse.magnitude;
            impulse *= blastForce;

            float percent = (blastRadius - Vector3.Distance(pos, transform.position)) / blastRadius;

            if (col.tag == "Ship")
            {
                ShipScript ship = col.GetComponent <ShipScript>();
                ship.TakeHit(impulse / 2 * percent, pos);
                ship.ApplyDamage(1.0f * mass * percent, 0.0f);
            }
            else if (col.tag == "Satellite" || col.tag == "sAsteroid" && col.gameObject != gameObject)
            {
                //Rigidbody2D roidRb = col.GetComponent<Rigidbody2D>();
                //roidRb.AddForce( impulse * percent, ForceMode2D.Impulse );
                Satellite sat = col.GetComponent <Satellite>();
                sat.ApplyDamage(0, impulse * 2 * percent, pos, false);
            }
        }
    }
Пример #3
0
        public List <Satellite> GetSatellites(string LanuchYaer)
        {
            string predicateValues = "/class/tle_latest/LAUNCH_YEAR/=" + LanuchYaer + "/orderby/INTLDES asc/metadata/false";
            string request         = uriBase + requestController + requestAction + predicateValues;

            // Create new WebClient object to communicate with the service
            using (var client = new WebClientEx())
            {
                if (Auth(client))
                {
                    var response4           = client.DownloadData(request);
                    var stringData          = (System.Text.Encoding.Default.GetString(response4)).Split('\n');
                    List <Satellite> result = new List <Satellite>();
                    for (Int32 i = 0; i < stringData.Length - 1; i += 3)
                    {
                        Tle       tle = new Tle(stringData[i], stringData[i + 1], stringData[i + 2]);
                        Satellite sat = new Satellite(tle);
                        result.Add(sat);
                        OnProgress(new ProgressEventArgs(i, stringData.Length - 1));
                    }
                    return(result);
                }
                else
                {
                    throw new NoAuthException();
                }
            }
        }
Пример #4
0
    protected virtual void Update()
    {
        if (!Application.isPlaying)
        {
            Motion.Primary = transform.parent.GetComponentInParent <Satellite>();

            int sibling_index = transform.GetSiblingIndex();
            if (sibling_index > 0)
            {
                Satellite sibling =
                    transform.parent.GetChild(sibling_index - 1)
                    .GetComponent <Satellite>();

                if (sibling.Motion.Periapsis > Motion.Periapsis)
                {
                    transform.SetAsFirstSibling();
                }
            }
        }

        if (Motion.Periapsis > Motion.Apoapsis)
        {
            Utility.Swap(ref Motion.Periapsis, ref Motion.Apoapsis);
        }

        if (gameObject.name != Name)
        {
            gameObject.name = Name;
        }
    }
Пример #5
0
 public void DeselectObject()
 {
     selectedSomething = false;
     satellite.ColorOverlay();
     satellite.downwardSpeed = 0.0f;
     satellite = null;
 }
Пример #6
0
        private void ReadSatellites(ZipFile zip)
        {
            byte[] data = ReadFileContent(zip, "SatDataBase.dat");
            if (data == null || data.Length < 4)
            {
                return;
            }

            this.SatDatabaseVersion = System.BitConverter.ToInt32(data, 0);
            SatelliteMapping satMapping = new SatelliteMapping(data, 4);
            int count = data.Length / this.c.dvbsSatelliteLength;

            for (int i = 0; i < count; i++)
            {
                if (satMapping.MagicMarker == 'U')
                {
                    string location = string.Format("{0}.{1}{2}",
                                                    satMapping.Longitude / 10, satMapping.Longitude % 10, satMapping.IsEast ? "E" : "W");

                    Satellite satellite = new Satellite(satMapping.SatelliteNr);
                    satellite.Name            = satMapping.Name;
                    satellite.OrbitalPosition = location;
                    this.DataRoot.Satellites.Add(satMapping.SatelliteNr, satellite);
                }
                else if (satMapping.MagicMarker != 'E')
                {
                    throw new FileLoadException("Unknown SatDataBase.dat format");
                }

                satMapping.BaseOffset += this.c.dvbsSatelliteLength;
            }
        }
Пример #7
0
        public SatChannel(int slot, SignalSource presetList, DataMapping data, DataRoot dataRoot, FavoritesIndexMode sortedFavorites, IDictionary <int, string> providerNames) :
            base(data, sortedFavorites)
        {
            this.InitCommonData(slot, SignalSource.DvbS | presetList, data);
            if (!this.InUse)
            {
                this.IsDeleted = true;
                return;
            }

            this.InitDvbData(data, providerNames);

            int         transponderIndex = data.GetWord(_TransponderIndex);
            Transponder transponder      = dataRoot.Transponder.TryGet(transponderIndex);

            if (transponder == null)
            {
                var list = dataRoot.GetChannelList(this.SignalSource | SignalSource.Tv);
                dataRoot.Warnings.AppendFormat("{0} channel record #{1} (Pr# {2} \"{3}\") contains invalid transponder index {4}\r\n",
                                               list.ShortCaption, slot, this.OldProgramNr, this.Name, transponderIndex);
                return;
            }

            Satellite sat = transponder.Satellite;

            this.Satellite            = sat.Name;
            this.SatPosition          = sat.OrbitalPosition;
            this.Polarity             = transponder.Polarity;
            this.SymbolRate           = transponder.SymbolRate;
            this.FreqInMhz            = transponder.FrequencyInMhz;
            this.ChannelOrTransponder = "";
        }
    private SatelliteStats CalculateStats(Satellite satellite)
    {
        List <DamageResistance> resists = new List <DamageResistance>();

        foreach (DamageResistance baseResist in satellite.BaseStats.DamageResistances)
        {
            foreach (DamageResistance resistPerLevel in satellite.StatIncreasePerLevel.DamageResistances)
            {
                if (resistPerLevel.Type == baseResist.Type)
                {
                    float resistValue = Mathf.Clamp(baseResist.Percentage + (resistPerLevel.Percentage * (satellite.Level - 1f)), 0f, 100f);
                    resists.Add(new DamageResistance()
                    {
                        Percentage = resistValue,
                        Type       = baseResist.Type
                    });
                    break;
                }
            }
        }

        return(new SatelliteStats()
        {
            PrimaryMagnitude = satellite.BaseStats.PrimaryMagnitude + (satellite.StatIncreasePerLevel.PrimaryMagnitude * (satellite.Level - 1f)),
            SecondaryMagnitude = satellite.BaseStats.SecondaryMagnitude + (satellite.StatIncreasePerLevel.SecondaryMagnitude * (satellite.Level - 1f)),
            Reach = satellite.BaseStats.Reach + (satellite.StatIncreasePerLevel.Reach * (satellite.Level - 1f)),
            DamageResistances = resists
        });
    }
Пример #9
0
        public List <Satellite> GetSatellites(string[] Norad)
        {
            string predicateValues = "/class/tle_latest/ORDINAL/1/NORAD_CAT_ID/" + string.Join(",", Norad) + "/orderby/NORAD_CAT_ID%20ASC/format/3le";
            string request         = uriBase + requestController + requestAction + predicateValues;

            // Create new WebClient object to communicate with the service
            using (var client = new WebClientEx())
            {
                if (Auth(client))
                {
                    var response4           = client.DownloadData(request);
                    var stringData          = (System.Text.Encoding.Default.GetString(response4)).Split('\n');
                    List <Satellite> result = new List <Satellite>();
                    for (Int32 i = 0; i < stringData.Length - 1; i += 3)
                    {
                        Tle       tle = new Tle(stringData[i], stringData[i + 1], stringData[i + 2]);
                        Satellite sat = new Satellite(tle);
                        result.Add(sat);
                        OnProgress(new ProgressEventArgs(i, stringData.Length - 1));
                    }
                    return(result);
                }
                else
                {
                    throw new NoAuthException();
                }
            }
        }
Пример #10
0
        public IActionResult TopSecretSplit(string name, SatelliteForm satellite)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string           cookieData = GetCookie("message");
            List <Satellite> data       = new List <Satellite>();

            if (!string.IsNullOrEmpty(cookieData))
            {
                data = JsonSerializer.Deserialize <List <Satellite> >(cookieData);
            }

            List <Satellite> tempData        = new List <Satellite>();
            Satellite        currentSatelite = new Satellite()
            {
                Name     = name,
                Distance = satellite.Distance,
                Message  = satellite.Message
            };

            tempData.Add(currentSatelite);

            if (!Communications.ValidateSateliteInfo(tempData))
            {
                return(BadRequest("The information is incomplete!!"));
            }

            var FinalList = data.Union(tempData).ToList();

            if (FinalList.Count <= Communications.GetSatellites().Count())
            {
                SetCookie("message", JsonSerializer.Serialize(FinalList), 0.5);
                return(BadRequest("Need more information"));
            }
            else
            {
                Point finalPosition = Communications.GetLocation(FinalList);

                if (finalPosition == null)
                {
                    return(BadRequest("Ops Somethig go wrong!!"));
                }

                var reponse = new
                {
                    position = new
                    {
                        x = finalPosition.PositionX,
                        y = finalPosition.PositionY
                    },
                    message = Communications.GetMessage(FinalList)
                };
                DeleteCookie("message");
                return(Ok(reponse));
            }
        }
Пример #11
0
    public static void Main(string[] args)
    {
        int tests = int.Parse(Console.ReadLine());

        while (tests-- > 0)
        {
            int         n   = int.Parse(Console.ReadLine());
            Satellite[] sat = new Satellite[n];
            for (int i = 0; i < n; i++)
            {
                string[] parts = Console.ReadLine().Split();
                sat[i] = new Satellite(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]));
            }
            Array.Sort(sat);

            // Find all distinct x values (at most n)
            SortedList <int, int> sxs = new SortedList <int, int>();
            for (int i = 0; i < n; i++)
            {
                if (!sxs.ContainsKey(sat[i].x1))
                {
                    sxs.Add(sat[i].x1, 0);
                }
                if (!sxs.ContainsKey(sat[i].x2))
                {
                    sxs.Add(sat[i].x2, 0);
                }
            }
            int[] xs = sxs.Keys.ToArray();

            // For each block of x[i] to x[i+1]
            long ans = 0;
            for (int i = 0; i < xs.Length - 1; i++)
            {
                // Count in y direction
                int from = 0;
                int to   = 0;
                for (int j = 0; j < n; j++)
                {
                    if (sat[j].x1 > xs[i] || sat[j].x2 < xs[i + 1])
                    {
                        continue;
                    }
                    if (sat[j].y1 > to)
                    {
                        ans += (long)(to - from) * (long)(xs[i + 1] - xs[i]);
                        from = sat[j].y1;
                        to   = sat[j].y2;
                    }
                    else
                    {
                        to = Math.Max(to, sat[j].y2);
                    }
                }
                ans += (long)(to - from) * (long)(xs[i + 1] - xs[i]);
            }
            Console.WriteLine(ans);
        }
    }
    IEnumerator LoadDebris()
    {
        spaceCraft   = GameObject.Find("SpaceCraft");
        attribute    = spaceCraft.GetComponent <attributeDefiner>();
        Loading.text = "Downloading Game Debris Data";
        yield return(new WaitForSeconds(1));

        string jsonURL  = @"https://worldwind.arc.nasa.gov/spacebirds/data/TLE.json";
        WWW    download = new WWW(jsonURL);

        while (!download.isDone)
        {
            Progress.fillAmount = download.progress;
            float prog = download.progress * 100;
            ProgressText.text = "" + (int)prog + "%";

            yield return(null);
        }

        yield return(download);

        List <Debris> debrisData = JsonConvert.DeserializeObject <List <Debris> >(download.text);

        Loading.text = "Loading Game Debris.";


        foreach (var item in debrisData)
        {
            if (item.OBJECT_TYPE == "DEBRIS")
            {
                Tle        tle    = new Tle(item.OBJECT_ID, item.TLE_LINE1, item.TLE_LINE2);
                Satellite  sat    = new Satellite(tle);
                List <Eci> coords = new List <Eci>();

                Eci eci = sat.PositionEci(900);

                Vector3 pos = new Vector3((float)eci.Position.X, (float)eci.Position.Y, (float)eci.Position.Z);
                Debug.Log(pos);
                float decider = Random.value;

                if (decider <= 0.33)
                {
                    DebrisGenerator(bolt, pos);
                }
                else if (decider > 0.33 && decider <= 0.66)
                {
                    DebrisGenerator(nut, pos);
                }
                else
                {
                    DebrisGenerator(sheet, pos);
                }
            }
        }
        yield return(new WaitForSeconds(1));

        LoadingScreen.SetActive(false);
        attribute.IsLoading = false;
    }
Пример #13
0
        public bool checkOffset(int index, Satellite _satellite, Offset _cameraOffset)
        {
            var    gene        = Chromosome[_satellite.Id].OrderBy(x => x.Turn).ToList()[index];
            double w_latitude  = Math.Abs(_cameraOffset.deltaLat - gene.CameraPosition.deltaLat) / Math.Abs((double)_cameraOffset.turn - (double)gene.CameraPosition.turn);
            double w_longitude = Math.Abs(_cameraOffset.deltaLong - gene.CameraPosition.deltaLong) / Math.Abs((double)_cameraOffset.turn - (double)gene.CameraPosition.turn);

            return(w_latitude <= (double)_satellite.W && w_longitude <= (double)_satellite.W);
        }
Пример #14
0
 void Start()
 {
     sat                 = Object.FindObjectOfType <Satellite> ();
     cb                  = button.colors;
     cb.normalColor      = Color.blue;
     cb.highlightedColor = Color.blue;
     cb.disabledColor    = Color.blue;
 }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     scanButton.onClick.AddListener(OnScanClick);
     travelButton.onClick.AddListener(OnTravelClick);
     sat          = UnityEngine.Object.FindObjectOfType <Satellite> ();
     audioManager = UnityEngine.Object.FindObjectOfType <AudioManager>();
     rings        = UnityEngine.Object.FindObjectOfType <Rings> ();
 }
Пример #16
0
 private void TryClearLastSatellite()
 {
     if (_lastSatellite != null)
     {
         _lastSatellite.OnGettingSignalEnd();
         _lastSatellite = null;
     }
 }
Пример #17
0
        public static Satellite ConvertSatellite(ProgressionMap map, Satellite oldSatellite)
        {
            Satellite newSatellite = new Satellite(oldSatellite.Name);

            newSatellite.Properties = oldSatellite.Properties;
            map.Add(newSatellite);
            return(newSatellite);
        }
Пример #18
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a ISDB satellite frequency.
 /// </summary>
 /// <param name="satellite">The satellite to tune to.</param>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(Satellite satellite, ISDBSatelliteFrequency frequency)
 {
     this.frequency     = frequency;
     this.satellite     = satellite;
     symbolRate         = frequency.SymbolRate;
     fec                = frequency.FEC;
     signalPolarization = frequency.Polarization;
 }
Пример #19
0
 private void Remove(Satellite satellite)
 {
     if (!this.satellites.Contains(satellite))
     {
         throw new ArgumentException("Satellite not found");
     }
     this.satellites.Remove(satellite);
 }
Пример #20
0
        /// <summary>
        /// Creates a GPSV sentence instance from the specified parameters describing the location and signal strength of GPS satellites
        /// </summary>
        /// <param name="totalMessageCount"></param>
        /// <param name="currentMessageNumber"></param>
        /// <param name="satellitesInView"></param>
        /// <param name="satellites"></param>
        public GpgsvSentence(int totalMessageCount, int currentMessageNumber,
                             int satellitesInView, IList <Satellite> satellites)
        {
            _totalMessageCount    = totalMessageCount;
            _currentMessageNumber = currentMessageNumber;
            _satellitesInView     = satellitesInView;
            _satellites           = satellites;

            // Build a sentence
            StringBuilder builder = new StringBuilder(128);

            // Append the command word
            builder.Append("$GPGSV");

            // Append a comma
            builder.Append(',');

            // Total message count
            builder.Append(_totalMessageCount);

            // Append a comma
            builder.Append(',');

            // Current message number
            builder.Append(_currentMessageNumber);

            // Append a comma
            builder.Append(',');

            // Satellites in view
            builder.Append(_satellitesInView);

            #region Satellite information

            int count = _satellites.Count;
            for (int index = 0; index < count; index++)
            {
                Satellite satellite = _satellites[index];

                // Serialize this satellite
                builder.Append(",");
                builder.Append(satellite.PseudorandomNumber.ToString("0#", NmeaCultureInfo));
                builder.Append(",");
                builder.Append(satellite.Elevation.ToString("dd", NmeaCultureInfo));
                builder.Append(",");
                builder.Append(satellite.Azimuth.ToString("ddd", NmeaCultureInfo));
                builder.Append(",");
                builder.Append(satellite.SignalToNoiseRatio.Value.ToString("0#", NmeaCultureInfo));
            }

            #endregion

            // Set this object's sentence
            SetSentence(builder.ToString());

            // Finally, append the checksum
            AppendChecksum();
        }
Пример #21
0
        /// <summary>
        /// Adds a GPGSV sentence, and parses it.
        /// </summary>
        /// <param name="nmeaSentence">NMEA string</param>
        /// <returns>Returns true if this is the last message in GSV nmea sentences</returns>
        public bool AddSentence(string nmeaSentence)
        {
            bool lastmsg = false;

            try
            {
                //Split into an array of strings.
                string[] split = nmeaSentence.Split(',');

                int satsInView = 0;
                int.TryParse(split[3], out satsInView);

                int msgCount = 0;
                int.TryParse(split[1], out msgCount); //Number of GPGSV messages

                int msgno = 0;
                int.TryParse(split[2], out msgno); //Current messagenumber

                if (msgCount < msgno || msgno < 1) //check for invalid data (could be zero if parse failed)
                {
                    return(false);
                }

                if (msgno == 1)
                {
                    _satellites.Clear(); //First message. Let's clear the satellite list
                    _firstMessageParsed = true;
                }
                else if (!_firstMessageParsed) //If we haven't received the first GSV message, return
                {
                    return(false);
                }

                lastmsg = (msgCount == msgno); //Is this the last GSV message in the GSV messages?
                int satsInMsg;
                if (!lastmsg)
                {
                    satsInMsg = 4; //If this isn't the last message, the message will hold info for 4 satellites
                }
                else
                {
                    satsInMsg = satsInView - 4 * (msgno - 1); //calculate number of satellites in last message
                }
                for (int i = 0; i < satsInMsg; i++)
                {
                    Satellite sat = new Satellite
                    {
                        PRN       = split[i * 4 + 4],
                        Elevation = Convert.ToByte(split[i * 4 + 5]),
                        Azimuth   = Convert.ToInt16(split[i * 4 + 6]),
                        SNR       = Convert.ToByte(split[i * 4 + 7])
                    };
                    _satellites.Add(sat);
                }
            }
            catch { }
            return(lastmsg);
        }
Пример #22
0
 public SatelliteRecipe(List <CraftingModule.ItemRecipeData> NewIIn, List <CraftingModule.RecipeResourceData> NewRIn, Satellite O)
 {
     ItemInput          = NewIIn;
     ResourceInput      = NewRIn;
     Output             = O;
     CreatesByProducts  = false;
     ItemByProducts     = null;
     ResourceByProducts = null;
 }
Пример #23
0
    // Use this for initialization
    void Start()
    {
        this._tle           = new Tle("sat", TLE1, TLE2);
        this._satellite     = new Satellite(_tle);
        this._site          = new Site(Lat, Long, Altitude);
        this._detailsCanvas = this.transform.Find("detailsCanvas").gameObject;

        mainLabel.text = SatelliteName;
    }
Пример #24
0
        /// <summary>
        /// Set the message from the help requests received by a satellite
        /// </summary>
        /// <param name="satellite"></param>
        /// <returns></returns>
        public void SetReceivedMessage(Satellite satellite)
        {
            if (satellite == null)
            {
                throw new ArgumentNullException(nameof(satellite));
            }

            _satelliteRepository.SetReceivedMessage(satellite);
        }
Пример #25
0
 public void Add(Satellite satellite)
 {
     if (this.satellites.Contains(satellite))
     {
         throw new ArgumentException("The satellite is already contained in the list.");
     }
     this.satellites.Add(satellite);
     this.length = this.length + 1;
 }
Пример #26
0
        public void PartOne()
        {
            var input = Helpers.FileHelper.ParseFile(InputFile);

            var satellite = new Satellite(input);
            int count     = satellite.CountMatchingMessages(RuleIndex);

            Assert.IsTrue(count == 203);
        }
Пример #27
0
        public void Test_KnownMessages_WithFuckery()
        {
            var input = Helpers.FileHelper.ParseFile(TestHelper.GetTestFile(this, "Test2"));

            var satellite = new Satellite(input, isPartTwo: true);
            int count     = satellite.CountMatchingMessages(RuleIndex, isPartTwo: true);

            Assert.IsTrue(count == 12);
        }
Пример #28
0
        public void Test_KnownMessages()
        {
            var input = Helpers.FileHelper.ParseFile(TestFile);

            var satellite = new Satellite(input);
            int count     = satellite.CountMatchingMessages(RuleIndex);

            Assert.IsTrue(count == 2);
        }
Пример #29
0
        // /////////////////////////////////////////////////////////////////////
        static void Main(string[] args)
        {
            // Sample code to test the SGP4 and SDP4 implementation. The test
            // TLEs come from the NORAD document "Space Track Report No. 3".

            // Test SGP4
            string str1 = "SGP4 Test";
            string str2 = "1 88888U          80275.98708465  .00073094  13844-3  66816-4 0     8";
            string str3 = "2 88888  72.8435 115.9689 0086731  52.6988 110.5714 16.05824518   105";

            Tle tle1 = new Tle(str1, str2, str3);

            PrintPosVel(tle1);

            Console.WriteLine();

            // Test SDP4
            str1 = "SDP4 Test";
            str2 = "1 11801U          80230.29629788  .01431103  00000-0  14311-1       8";
            str3 = "2 11801  46.7916 230.4354 7318036  47.4722  10.4117  2.28537848     6";

            Tle tle2 = new Tle(str1, str2, str3);

            PrintPosVel(tle2);

            Console.WriteLine("\nExample output:");

            // Example: Define a location on the earth, then determine the look-angle
            // to the SDP4 satellite defined above.

            // Create an orbit object using the SDP4 TLE object.
            Satellite satSDP4 = new Satellite(tle2);

            // Get the location of the satellite from the Orbit object. The
            // earth-centered inertial information is placed into eciSDP4.
            // Here we ask for the location of the satellite 90 minutes after
            // the TLE epoch.
            EciTime eciSDP4 = satSDP4.PositionEci(90.0);

            // Now create a site object. Site objects represent a location on the
            // surface of the earth. Here we arbitrarily select a point on the
            // equator.
            Site siteEquator = new Site(0.0, -100.0, 0); // 0.00 N, 100.00 W, 0 km altitude

            // Now get the "look angle" from the site to the satellite.
            // Note that the ECI object "eciSDP4" has a time associated
            // with the coordinates it contains; this is the time at which
            // the look angle is valid.
            Topo topoLook = siteEquator.GetLookAngle(eciSDP4);

            // Print out the results. Note that the Azimuth and Elevation are
            // stored in the CoordTopo object as radians. Here we convert
            // to degrees using Rad2Deg()
            Console.Write("AZ: {0:f3}  EL: {1:f3}\n",
                          topoLook.AzimuthDeg,
                          topoLook.ElevationDeg);
        }
Пример #30
0
 public void SatPlaced(Satellite satPlaced)
 {
     if (satPlaced == satelliteType)
     {
         placeComplete = true;
         string objectiveUpdate = $"1/1 {actionVerb[1]} <color=#FFC63B>{satelliteType.DisplayName}</color>";
         UIRootModule.UIRoot.GetScreen <GameHUD>().objectivePanel.UpdateObjective(1, objectiveUpdate);
     }
 }
    // Use this for initialization
    void Start ()
    {
        // 2pac
        //1 39481U 13075A   16067.38270921 -.00000212  00000-0  00000+0 0  9998
        //2 39481   0.0109 109.7942 0001540 210.2578 256.0601  1.00271837  8203

        Tupac = new Satellite("Tupac Reference", epochYear, epochDay, inclination, rightAscensionOfTheAscendingNode, eccentricity, argumentOfPeriapsis, meanAnomaly, meanMotion);
        Vector3 position = TLEtoVec3.Convert(Tupac, DateTime.UtcNow , 1, 100000);
        myTupacPrefab = Instantiate(tupacPrefab, position, Quaternion.identity) as GameObject;

    }
    public static Vector3 Convert(Satellite tleData, DateTime timeOfReading, int accuracy = 1, float inverseScale = 1f)
    {
        int epochYear = tleData.EpochYear;
        float epochDay = tleData.EpochDay;
        float inclination = tleData.Inclination;
        float rightAscensionOfAscendingNode = tleData.RightAscensionOfTheAscendingNode;
        float eccentricity = tleData.Eccentricity;
        float arguementOfPeriapsis = tleData.ArgumentOfPeriapsis;
        float meanAnomaly = tleData.MeanAnomaly;
        float meanMotion = tleData.MeanMotion;

        meanAnomaly = AdvanceMeanAnomaly(epochYear, epochDay, meanAnomaly, meanMotion, timeOfReading);

        Vector2 elipticalCoordinates = ElipticalCoordinates(eccentricity, meanAnomaly, meanMotion, accuracy);

        Vector3 position = new Vector3(elipticalCoordinates.y, 0f, elipticalCoordinates.x);

        position = ApplyRotation(position, inclination, rightAscensionOfAscendingNode, arguementOfPeriapsis);

        return position * (1f / inverseScale);
    }
 public virtual void addSatellite(Satellite s)
 {
     this.sysPlanets.Add(s);
 }
Пример #34
0
        public void ProcessGPGSV(string data)
        {
            //parses the GPGSV stream to extract satellite information

            string[] fields = Regex.Split(data,",");

            uint totalNumberOfMessages = Convert.ToUInt32(fields[0]);

            //make sure the data is OK. valid range is 1..8 channels
            if ((totalNumberOfMessages > 8) || (totalNumberOfMessages <= 0))
                return;

            GPGSV.TotalNumberOfMessages = totalNumberOfMessages;

            //message number
            int nMessageNumber = Convert.ToInt32(fields[1]);

            //make sure it is 0..9...is there an inconsistency? 8/9?
            if ((nMessageNumber > 9) || (nMessageNumber < 0))
                return;

            //sats in view
            GPGSV.SatellitesInView  = Convert.ToInt32(fields[2]);

            //for(int iSat = 0; iSat < GPGSV.SatellitesInView; iSat++)
            for (int iSat = 0; iSat < 4; iSat++)
            {
                Satellite sat = new Satellite();

                sat.Id = Convert.ToInt32(fields[3+iSat*4]);
                sat.Elevation = Convert.ToInt32(fields[4+iSat*4]);
                sat.Azimuth = Convert.ToInt32(fields[5+iSat*4]);
                sat.SignalQuality = Convert.ToInt32(fields[6+iSat*4]);
                sat.Used = IsSatelliteUsed(sat.Id);

                GPGSV.Satellites.Add(sat);
            }
            GPGSV.Count ++;
        }
 private void FillPositions()
 {
     orbitPositions = new Vector3[conicSegments];
     for(int i = 0; i < conicSegments; i++)
     {
         float anomaly = (i * 2f * Mathf.PI) / (conicSegments);
         int tleYear = DateTime.UtcNow.Year % 100;
         float tleDay = DateTime.UtcNow.DayOfYear + ((float)DateTime.UtcNow.TimeOfDay.TotalSeconds / 86164f);
         Satellite sat = new Satellite("Test", tleYear, tleDay, inclination, rightAscensionOfAscendingNode, eccentricity, arguementOfPeriapsis, anomaly, meanMotion);
         orbitPositions[i] = TLEtoVec3.Convert(sat, DateTime.UtcNow, accuracy, inversePositionScale);
     }
 }
Пример #36
0
 public void addSatellite(string name, Vector3 position, float radius, Material material, float spinSpeed)
 {
     Satellite s = new Satellite(name, position, radius, material, spinSpeed, this);
     this.satellites.Add(s);
 }
        /// <summary>
        /// Updates a satellite for tidal lock
        /// </summary>
        /// <param name="s">The satelite </param>
        /// <param name="ourBag">Our dice object</param>
        public static void updateTidalLock(Satellite s, Dice ourBag)
        {
            int atmDesc = s.getAtmCategory();

            if (atmDesc == Satellite.ATM_PRES_NONE || atmDesc == Satellite.ATM_PRES_TRACE)
            {
                s.updateAtmPres(0.00);
                s.hydCoverage = 0.0;
                s.dayFaceMod = 1.2;
                s.nightFaceMod = .1;
            }

            if (atmDesc == Satellite.ATM_PRES_VERYTHIN)
            {
                s.updateAtmPres(0.01);
                s.hydCoverage = 0.0;
                s.dayFaceMod = 1.2;
                s.nightFaceMod = .1;
            }

            if (atmDesc == Satellite.ATM_PRES_THIN)
            {
                s.updateAtmPres(ourBag.rollRange(.01, .49));

                s.hydCoverage = s.hydCoverage - .5;
                if (s.hydCoverage < 0) s.hydCoverage = 0.0;

                s.dayFaceMod = 1.16;
                s.nightFaceMod = .67;
            }

            if (atmDesc == Satellite.ATM_PRES_STANDARD)
            {
                s.hydCoverage = s.hydCoverage - .25;
                if (s.hydCoverage < 0) s.hydCoverage = 0.0;

                s.dayFaceMod = 1.12;
                s.nightFaceMod = .80;
            }

            if (atmDesc == Satellite.ATM_PRES_DENSE)
            {
                s.hydCoverage = s.hydCoverage - .1;
                if (s.hydCoverage < 0) s.hydCoverage = 0.0;
                s.dayFaceMod = 1.09;
                s.nightFaceMod = .88;
            }

            if (atmDesc == Satellite.ATM_PRES_VERYDENSE)
            {
                s.dayFaceMod = 1.05;
                s.nightFaceMod = .95;
            }

            if (atmDesc == Satellite.ATM_PRES_SUPERDENSE)
            {
                s.dayFaceMod = 1.0;
                s.nightFaceMod = 1.0;
            }
        }
        /// <summary>
        /// Determines RVM, and geologic values for a satelite
        /// </summary>
        /// <param name="s">The satelite</param>
        /// <param name="ourBag">Dice object</param>
        /// <param name="sysAge">System Age</param>
        /// <param name="isGasGiantMoon">Is this a moon of a gas giant?</param>
        public static void determineGeologicValues(Satellite s, Dice ourBag, double sysAge, bool isGasGiantMoon)
        {
            //volcanic set first.
            double addVal = (s.gravity / sysAge) * 40;

            if (s.majorMoons.Count == 1) addVal = addVal + 5;
            if (s.majorMoons.Count == 2) addVal = addVal + 10;

            if (s.SatelliteType == Satellite.SUBTYPE_SULFUR) addVal = addVal + 60;
            if (isGasGiantMoon) addVal = addVal + 5;

            int roll = ourBag.gurpsRoll();

            addVal = addVal + roll;

            if (addVal <= 16.5) s.volActivity = Satellite.GEOLOGIC_NONE;
            if (addVal > 16.5 && addVal <= 20.5) s.volActivity = Satellite.GEOLOGIC_LIGHT;
            if (addVal > 20.5 && addVal <= 26.5) s.volActivity = Satellite.GEOLOGIC_MODERATE;
            if (addVal > 26.5 && addVal <= 70.5) s.volActivity = Satellite.GEOLOGIC_HEAVY;
            if (addVal > 70.5) s.volActivity = Satellite.GEOLOGIC_EXTREME;

            roll = ourBag.gurpsRoll();
            if (s.volActivity == Satellite.GEOLOGIC_HEAVY && s.SatelliteType == Satellite.SUBTYPE_GARDEN && roll <= 8)
            {
                roll = ourBag.rng(6);
                if (roll <= 3) s.addAtmCategory(Satellite.ATM_MARG_POLLUTANTS);
                if (roll >= 4) s.addAtmCategory(Satellite.ATM_MARG_SULFUR);
            }

            roll = ourBag.gurpsRoll();
            if (s.volActivity == Satellite.GEOLOGIC_EXTREME && s.SatelliteType == Satellite.SUBTYPE_GARDEN && roll <= 14)
            {
                roll = ourBag.rng(6);
                if (roll <= 3) s.addAtmCategory(Satellite.ATM_MARG_POLLUTANTS);
                if (roll >= 4) s.addAtmCategory(Satellite.ATM_MARG_SULFUR);
            }

            //tectonic next
            roll = ourBag.gurpsRoll();

            //negative mods
            if (s.hydCoverage == 0) roll = roll - 4;
            if (s.hydCoverage > 0 && s.hydCoverage < .5) roll = roll - 2;
            if (s.volActivity == Satellite.GEOLOGIC_NONE) roll = roll - 8;
            if (s.volActivity == Satellite.GEOLOGIC_LIGHT) roll = roll - 4;

            //postive mods
            if (s.volActivity == Satellite.GEOLOGIC_HEAVY) roll = roll + 4;
            if (s.volActivity == Satellite.GEOLOGIC_EXTREME) roll = roll + 8;
            if (s.majorMoons.Count == 1) roll = roll + 2;
            if (s.majorMoons.Count > 1) roll = roll + 4;

            //nullers.
            if (s.SatelliteSize == Satellite.SIZE_TINY) roll = 0;
            if (s.SatelliteSize == Satellite.SIZE_SMALL) roll = 0;

            if (roll <= 6.5) s.tecActivity = Satellite.GEOLOGIC_NONE;
            if (roll > 6.5 && roll <= 10.5) s.tecActivity = Satellite.GEOLOGIC_LIGHT;
            if (roll > 10.5 && roll <= 14.5) s.tecActivity = Satellite.GEOLOGIC_MODERATE;
            if (roll > 14.5 && roll <= 18.5) s.tecActivity = Satellite.GEOLOGIC_HEAVY;
            if (roll > 18.5) s.tecActivity = Satellite.GEOLOGIC_EXTREME;

            //update RVM
            if (!OptionCont.highRVMVal) roll = ourBag.gurpsRoll();
            if (OptionCont.highRVMVal) roll = ourBag.rng(1, 6, 10);

            if (s.volActivity == Satellite.GEOLOGIC_NONE) roll = roll - 2;
            if (s.volActivity == Satellite.GEOLOGIC_LIGHT) roll = roll - 1;
            if (s.volActivity == Satellite.GEOLOGIC_HEAVY) roll = roll + 1;
            if (s.volActivity == Satellite.GEOLOGIC_EXTREME) roll = roll + 2;

            if (s.baseType == Satellite.BASETYPE_ASTEROIDBELT)
            {
                if (s.SatelliteSize == Satellite.SIZE_TINY) roll = roll - 1;
                if (s.SatelliteSize == Satellite.SIZE_MEDIUM) roll = roll + 2;
                if (s.SatelliteSize == Satellite.SIZE_LARGE) roll = roll + 4;
            }

            //set stable activity here:
            if (OptionCont.stableActivity && s.SatelliteSize >= Satellite.SIZE_SMALL &&
                (s.baseType == Satellite.BASETYPE_MOON || s.baseType == Satellite.BASETYPE_TERRESTIAL))
            {
                s.volActivity = Satellite.GEOLOGIC_MODERATE;
                s.tecActivity = Satellite.GEOLOGIC_MODERATE;
            }

            s.populateRVM(roll);
        }
Пример #39
0
 public static Satellite SaveSatellite(Satellite satellite)
 {
   using (ICardRepository cardRepository = new CardRepository())
   {
     cardRepository.AttachEntityIfChangeTrackingDisabled(cardRepository.ObjectContext.Satellites, satellite);
     cardRepository.ApplyChanges(cardRepository.ObjectContext.Satellites, satellite);
     cardRepository.UnitOfWork.SaveChanges();
     satellite.AcceptChanges();
     return satellite;
   }  
 }
Пример #40
0
        /// <summary>
        /// Adds a GPGSV sentence, and parses it. 
        /// </summary>
        /// <param name="nmeaSentence">NMEA string</param>
        /// <returns>Returns true if this is the last message in GSV nmea sentences</returns>
        public bool AddSentence(string nmeaSentence)
        {
            bool lastmsg = false;
            try
            {
                //Split into an array of strings.
                string[] split = nmeaSentence.Split(',');

                int satsInView = 0;
                int.TryParse(split[3], out satsInView);

                int msgCount =  0;
                int.TryParse(split[1], out msgCount); //Number of GPGSV messages

                int msgno =  0;
                int.TryParse(split[2], out msgno); //Current messagenumber

                if (msgCount < msgno || msgno < 1) //check for invalid data (could be zero if parse failed)
                    return false;

                if (msgno == 1)
                {
                    _satellites.Clear(); //First message. Let's clear the satellite list
                    _firstMessageParsed = true;
                }
                else if (!_firstMessageParsed) //If we haven't received the first GSV message, return
                    return false;

                lastmsg = (msgCount == msgno); //Is this the last GSV message in the GSV messages?
                int satsInMsg;
                if (!lastmsg)
                    satsInMsg = 4; //If this isn't the last message, the message will hold info for 4 satellites
                else
                    satsInMsg = satsInView - 4 * (msgno - 1); //calculate number of satellites in last message
                for (int i = 0; i < satsInMsg; i++)
                {
                    Satellite sat = new Satellite
                                        {
                                            PRN = split[i*4 + 4],
                                            Elevation = Convert.ToByte(split[i*4 + 5]),
                                            Azimuth = Convert.ToInt16(split[i*4 + 6]),
                                            SNR = Convert.ToByte(split[i*4 + 7])
                                        };
                    _satellites.Add(sat);
                }
            }
            catch { }
            return lastmsg;
        }
 /// <summary>
 /// Rolls the gas giant size and updates it.
 /// </summary>
 /// <param name="s">The gas gaint we are editing</param>
 /// <param name="roll">The dice roll</param>
 public static void updateGasGiantSize(Satellite s, int roll)
 {
     if (roll <= 10) s.updateSize(Satellite.SIZE_SMALL);
     if (roll >= 11 && roll <= 16) s.updateSize(Satellite.SIZE_MEDIUM);
     if (roll >= 17) s.updateSize(Satellite.SIZE_LARGE);
 }