コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            if (isSelected)
            {
                isSelected = false;
                m_InspectorPannel.ChangeInspectorImage(Selected.GetComponent<SpriteRenderer>().sprite);
                m_InformationPannel.display(Selected);
                m_RightClickCanvas.setActive(false);
            }
            else
            {
                Selected = null;
                m_InspectorPannel.ChangeInspectorImage(null);
                m_InformationPannel.display(null);
                m_RightClickCanvas.setActive(false);
            }
        }

        if (Input.GetMouseButtonUp(1))
        {
            if (Selected != null) {
               m_RightClickCanvas.setActive(true);
               m_RightClickCanvas.setPosition(Selected.getPosition());
            } else
            {
                m_RightClickCanvas.setActive(false);
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            if (isSelected)
            {
                isSelected = false;
                m_InspectorPannel.ChangeInspectorImage(Selected.GetComponent <SpriteRenderer>().sprite);
                m_InformationPannel.display(Selected);
                m_RightClickCanvas.setActive(false);
            }
            else
            {
                Selected = null;
                m_InspectorPannel.ChangeInspectorImage(null);
                m_InformationPannel.display(null);
                m_RightClickCanvas.setActive(false);
            }
        }

        if (Input.GetMouseButtonUp(1))
        {
            if (Selected != null)
            {
                m_RightClickCanvas.setActive(true);
                m_RightClickCanvas.setPosition(Selected.getPosition());
            }
            else
            {
                m_RightClickCanvas.setActive(false);
            }
        }
    }
コード例 #3
0
        private void Initialize()
        {
            var scaleLength = (double)nUD_Length.Value;

            var Earth = new AstronomicalObject
                        (
                name: "Земля",
                mass: 5.9726E24,
                radius: 6.371E6,
                position: new Position(4E8, 4E8),
                speedVector: new Vector(0, -12.6)
                        );
            var Moon = new AstronomicalObject
                       (
                name: "Місяць",
                mass: 7.3477E22,
                radius: 1.737E6,
                position: new Position(7.84467E8, 4E8),
                speedVector: new Vector(0, 1023)
                       );

            _mainObject = Earth;
            _canvas     = new Canvas(pb_Universe.Width, pb_Universe.Height);
            _canvas.AddObject(Earth);
            _canvas.AddObject(Moon);
            _canvas.InProcessObject = GetObjectFromFields();
            _canvas.Scale.Length    = scaleLength;
            _canvas.Scale.Time      = (int)(nUD_Time.Value / framesPerSecond);
            FillInForm();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Eugene851001/OOPLabs
 void AddNewAstroObject(AstronomicalObject obj)
 {
     astroEditors[obj.uid](obj);
     astroService.Add(obj, astroEditors, astroHashEditors);
     //UpdateObjectList(obj);
     astroService.UpdateObjectList(obj);
     UpdateListBox();
 }
コード例 #5
0
 private static string FormatFluxes(AstronomicalObject foundObject)
 {
     return(string.Join("\r\n", foundObject.Fluxes.Select(flux =>
     {
         var displayInformation = Flux.FluxRangesLookup.FirstOrDefault(x => x.Key == flux.FluxType);
         return $"{Enum.GetName(typeof(FluxType), flux.FluxType)}: {flux.Value} ({displayInformation.Value.From} - {displayInformation.Value.To})";
     })));
 }
コード例 #6
0
        private async Task Write(AstronomicalObject item, StreamWriter writer)
        {
            foreach (var satellite in item.Satellites)
            {
                await writer.WriteLineAsync($"   n_{item.Name} -> n_{satellite.Name}");

                await Write(satellite, writer);
            }
        }
コード例 #7
0
        public ObjectTypeSelectorViewModel(AstronomicalObject target = null)
        {
            TypeChoicesList = new List <string>();
            TypeChoicesView = new ListCollectionView(TypeChoicesList);

            Target = target;

            TypeChoicesView.CurrentChanged += TypeChoicesView_CurrentChanged;
        }
コード例 #8
0
 public void FillWithObject(AstronomicalObject target)
 {
     if (target != Target)
     {
         ObjectType.Target = target;
         Target            = target;
         RaisePropertyChanged("Target");
     }
 }
コード例 #9
0
 public DebugBody(AstronomicalObject reference)
 {
     this.reference  = reference;
     this.orbitColor = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
     this.position   = reference.transform.position;
     this.velocity   = reference.initialVelocity;
     this.mass       = reference.mass;
     this.name       = reference.name;
 }
コード例 #10
0
ファイル: Form1.cs プロジェクト: Eugene851001/OOPLabs
 private void btEdit_Click(object sender, EventArgs e)
 {
     if (lbStars.SelectedIndex != -1)
     {
         AstronomicalObject obj = (AstronomicalObject)lbStars.SelectedItem;
         astroEditors[obj.uid](obj);
         astroService.UpdateObjectList(obj);
         UpdateListBox();
     }
 }
コード例 #11
0
        public void CalculateEarthOrbitalPeriod()
        {
            AstronomicalObject earth = this.GetSunEarthMoonObject();

            double orbitalPeriodEarth = earth.CalculateOrbitalPeriod();

            Console.WriteLine(string.Format("{0:N} seconds", orbitalPeriodEarth));
            Console.WriteLine(string.Format("{0:N} days", Conversions.SecondsToDays(orbitalPeriodEarth)));

            Assert.AreEqual(365.0, Math.Round(Conversions.SecondsToDays(orbitalPeriodEarth)));
        }
コード例 #12
0
 public void display(AstronomicalObject o)
 {
     if (o != null)
     {
         NameText.text = o.ObjectName;
     }
     else
     {
         NameText.text = "";
     }
 }
コード例 #13
0
 public void display(AstronomicalObject o)
 {
     if (o != null)
     {
         NameText.text = o.ObjectName;
     }
     else
     {
         NameText.text = "";
     }
 }
コード例 #14
0
        public void SelectCurrent()
        {
            AstronomicalObject current = Environment.CurrentSituation.CurrentLocation as AstronomicalObject;

            if (!UserCanSelectCurrent || current == null)
            {
                return;
            }

            StationsView.MoveCurrentTo(current);
        }
コード例 #15
0
 private void CurrentSituation_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     switch (e.PropertyName)
     {
     case "CurrentLocation":
         AstronomicalObject newLoc = CurrentSituation.CurrentLocation;
         ShowLocationControls = newLoc != null;
         ObjectType.Target    = newLoc;
         break;
     }
 }
コード例 #16
0
        private int GetChecksum(AstronomicalObject start, int depth)
        {
            int total = 0;

            foreach (var satellite in start.Satellites)
            {
                total += depth;
                total += GetChecksum(satellite, depth + 1);
            }

            return(total);
        }
コード例 #17
0
        public void Build_a_chart_1_satellite_at_depth_1()
        {
            var chart = new AstronomicalChart(new AstronomicalObject("com"));
            var a     = new AstronomicalObject("a");

            chart.Root.AddSatellite(a);

            var calculator = new ChecksumCalculator();
            var checksum   = calculator.GetChecksum(chart);

            Assert.AreEqual(1, checksum);
        }
コード例 #18
0
    private void SelectAstroObject()
    {
        changeCursor(highlightCursor, new Vector2(40, 40));

        //If clicked on planet/asteroid/moon e.t.c
        if (Input.GetMouseButton(0))
        {
            //uiManager.showPlanet(selectedAstronomicalObject, false);
            selectedAstronomicalObject = selection.GetComponent <AstronomicalObject>();
            //uiManager.showPlanet(selectedAstronomicalObject);
            ui.displayPlanetUI(selectedAstronomicalObject);
        }
    }
コード例 #19
0
 private void SelectPlane(RaycastHit hit)
 {
     if (Input.GetMouseButtonDown(1))
     {
         lastClickedCoordinate = hit.point;
     }
     //Makes it so when you click UI elements there will be no selection
     if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
     {
         selectedAstronomicalObject = null;
         //uiManager.showPlanet(selectedAstronomicalObject);
         ui.hidePlanetUI();
     }
 }
コード例 #20
0
        public void CalculateEarthPeriapsisVelocity()
        {
            AstronomicalObject earth = this.GetSunEarthMoonObject();

            double velocityAtPeriapsis = earth.CalculateVelocityAtAltitude(earth.Orbit.Periapsis);

            Console.WriteLine(string.Format("{0:N} m/s", velocityAtPeriapsis));

            //TODO: Finish writing this test
            Assert.AreNotEqual(0.0, velocityAtPeriapsis);

            //Should equal approximately 30,300 m/s for Earth at perihelion
            Assert.AreEqual(303, Math.Round((velocityAtPeriapsis / 100)));
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: Eugene851001/OOPLabs
 public void UpdateObjectList(AstronomicalObject obj)
 {
     if (obj is IComplexObj)
     {
         var item = obj as IComplexObj;
         for (int i = 0; i < item.Count; i++)
         {
             astroService.UpdateObjectList((AstronomicalObject)item[i]);
         }
         if (obj.uid > astroService.astroObjects[astroService.astroObjects.Count - 1].uid)
         {
             astroService.astroObjects.Add(obj);
         }
     }
 }
コード例 #22
0
        public void CalculateSemiMajorAxisForDesiredOrbitalPeriod()
        {
            // I want to launch a geosynchronous satellite.
            // What semi-major axis do I need to accomplish an orbital period around Earth of exactly 24 hours?

            AstronomicalObject earth = this.GetSunEarthMoonObject();

            AstronomicalObject satellite = new AstronomicalObject(earth);

            satellite.Name = "Geosync Satellite";
            satellite.Mass = 3000.0;

            double desiredSemiMajorAxis = satellite.CalculateSemiMajorAxisForDesiredOrbitalPeriod(Conversions.HoursToSeconds(24));

            // Semi-major axis of a geosynchronous orbit is 42,164 km according to https://en.wikipedia.org/wiki/Geosynchronous_orbit
            Assert.AreEqual(42164000.0, Math.Round(desiredSemiMajorAxis));
        }
コード例 #23
0
    void newTick()
    {
        //Updates the UI every tick
        AstronomicalObject selectedAstronomicalObject = cameraControlls.selectedAstronomicalObject;

        /*if (selectedAstronomicalObject != null)
         *  uimanager.showPlanet(selectedAstronomicalObject, true);*/
        ui.displayDate();
        ui.date = ui.date.AddDays(1);
        if (month != ui.date.Month)
        {
            newMonth();
        }

        month = ui.date.Month;
        tick++;
    }
コード例 #24
0
        public void Compute()
        {
            ResultsList.Clear();

            AstronomicalObject origin = StationSelector.SelectedStation;

            AstronomicalObject[] stations = Environment.Stations.Where(s => s.Star.KnownObjectProximities.ContainsKey(origin.Star) && s.Star.KnownObjectProximities[origin.Star] < MaxDistanceFromOrigin).ToArray();
            ThreadPool.QueueUserWorkItem(ComputeWorker, new ComputeArgs()
            {
                stations       = stations,
                cargo          = Cargo,
                budget         = Budget,
                maxJumps       = MaxJumpsPerTravel,
                origin         = origin,
                maxDistPerJump = MaxDistancePerjump,
            });
        }
コード例 #25
0
    public void displayPlanetUI(AstronomicalObject planet)
    {
        //Clears previous UI
        hidePlanetUI();

        selectedPlanet       = planet;
        planetScreen.visible = true;
        planetName.text      = planet.Name;

        foreach (Region region in planet.regions)
        {
            Button regionButton = new Button();
            regionButton.text      = region.name;
            regionButton.focusable = true;
            planetButtons.hierarchy.Add(regionButton);
            regionButton.RegisterCallback <ClickEvent>(ev => displayRegionUI(region));
        }
    }
コード例 #26
0
        /// <summary>
        /// Parse the result text and create the astronomical objects
        /// </summary>
        public IReadOnlyList <AstronomicalObject> ToAstronomicalObjects()
        {
            var astronomicalObjects = new List <AstronomicalObject>();

            foreach (var entity in ResultDataSet)
            {
                var properties = ParseProperties(entity.Select(x => x.Key).ToArray(), entity.Select(x => x.Value).ToArray());
                var shortType  = properties.ContainsKey("TYPESHORT") ? Convert.ToString(properties["TYPESHORT"]) : string.Empty;

                var astronomicalObject = new AstronomicalObject(properties);
                if (!astronomicalObjects.Any(x => x.Name == astronomicalObject.Name))
                {
                    astronomicalObjects.Add(astronomicalObject);
                }
            }

            return(astronomicalObjects);
        }
コード例 #27
0
        private IAstronomicalObject GetObjectFromFields()
        {
            var speedX    = (double)nUD_speedX.Value;
            var speedY    = (double)nUD_speedY.Value;
            var positionX = (double)nUD_positionX.Value;
            var positionY = (double)nUD_positionY.Value;
            var mass      = (double)nUD_Mass.Value * 1000;
            var radius    = (double)nUD_Radius.Value;
            var Asteroid  = new AstronomicalObject
                            (
                name: "Астероїд",
                mass: mass,
                radius: radius,
                position: new Position(positionX, positionY),
                speedVector: new Vector(speedX, speedY)
                            );

            return(Asteroid);
        }
コード例 #28
0
        public void Build_a_chart_4_satellites_at_depth_1_and_2()
        {
            var chart = new AstronomicalChart(new AstronomicalObject("com"));
            var a     = new AstronomicalObject("a");

            chart.Root.AddSatellite(a);
            var a2 = new AstronomicalObject("a");

            a.AddSatellite(a2);
            var b = new AstronomicalObject("b");

            chart.Root.AddSatellite(b);
            var b2 = new AstronomicalObject("b2");

            a.AddSatellite(b2);

            var calculator = new ChecksumCalculator();
            var checksum   = calculator.GetChecksum(chart);

            Assert.AreEqual(6, checksum);
        }
コード例 #29
0
        /// <summary>
        /// Generates an sun-earth-moon system for use in the orbital calculation tests
        /// </summary>
        /// <returns></returns>
        private AstronomicalObject GetSunEarthMoonObject()
        {
            AstronomicalObject sun = new AstronomicalObject();

            // Orbital parameters and mass taken from https://en.wikipedia.org/wiki/Sun
            sun.Name = "Sun";
            sun.Mass = 1.98855E30;

            // GM for Sol taken from https://en.wikipedia.org/wiki/Standard_gravitational_parameter
            sun.StandardGravitationalParameter = 1.32712440018E20;

            AstronomicalObject earth = new AstronomicalObject(sun);

            // Orbital parameters and mass taken from https://en.wikipedia.org/wiki/Earth
            earth.Name               = "Earth";
            earth.Mass               = 5.97237E24; //5.97237×1024 kg
            earth.Orbit.Apoapsis     = 152100000000;
            earth.Orbit.Periapsis    = 147095000000;
            earth.Orbit.Eccentricity = 0.0167086;
            earth.Orbit.Inclination  = 7.155;

            // GM for Earth taken from https://en.wikipedia.org/wiki/Standard_gravitational_parameter
            earth.StandardGravitationalParameter = 3.986004418E14;

            AstronomicalObject moon = new AstronomicalObject(earth);

            // Orbital parameters and mass taken from https://en.wikipedia.org/wiki/Moon
            moon.Name               = "Moon";
            moon.Orbit.Periapsis    = 362600000;
            moon.Orbit.Apoapsis     = 405400000;
            moon.Orbit.Eccentricity = 0.0549;
            moon.Orbit.Inclination  = 5.145;

            // GM for Moon taken from https://en.wikipedia.org/wiki/Standard_gravitational_parameter
            moon.StandardGravitationalParameter = 4.9048695E12;

            return(earth);
        }
コード例 #30
0
    private void FixedUpdate()
    {
        Vector3 strongestPull = Vector3.zero;

        foreach (var obj in objects)
        {
            float   sqrDst       = (obj.Position - rb.position).sqrMagnitude;
            Vector3 forceDir     = (obj.Position - rb.position).normalized;
            Vector3 acceleration = forceDir * Universe.GravitationalConstant * obj.mass / sqrDst;
            rb.AddForce(acceleration, ForceMode.Acceleration);

            if (acceleration.magnitude > strongestPull.sqrMagnitude)
            {
                strongestPull = acceleration;
                referenceBody = obj;
            }
        }

        Vector3 gravityUp = -strongestPull.normalized;

        rb.rotation = Quaternion.FromToRotation(transform.up, gravityUp) * rb.rotation;
        rb.MovePosition(rb.position + smoothVelocity * Time.deltaTime);
    }
コード例 #31
0
 public AstronomicalChart(AstronomicalObject root)
 {
     Root = root;
 }
コード例 #32
0
 public void OnSelect(AstronomicalObject select)
 {
     isSelected = true;
     Selected   = select;
 }
コード例 #33
0
 public void OnSelect(AstronomicalObject select)
 {
     isSelected = true;
     Selected = select;
 }