Exemplo n.º 1
0
        public void Draw()
        {
            Triangle.Draw(_engine.Surface.Canvas);
            Planets.ForEach(p => p.Draw(_engine.Surface.Canvas));

            _engine.Surface.Canvas.DrawLine(0, Planets.Last().Transform.Y - 150, _engine.Surface.Width, Planets.Last().Transform.Y - 150, PaintFinishedLine);
        }
Exemplo n.º 2
0
        public static void ReadfromPlanetlist()
        {
            string filePath = @"C:\Users\opilane\samples";
            string fileName = @"Planets.txt";


            List <Planets> PlanetsItem = new List <Planets>();

            List <string> LinesFromFile = File.ReadAllLines(Path.Combine(filePath, fileName)).ToList();

            foreach (string line in LinesFromFile)
            {
                string[] tempArray  = line.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                Planets  newPlanets = new Planets(tempArray[0], Int32.Parse(tempArray[1]));
                PlanetsItem.Add(newPlanets);
            }
            Console.WriteLine("Your Planets:");

            int total = 0;

            foreach (Planets planets in PlanetsItem)
            {
                Console.WriteLine($"Planets:{planets.Name}; Mass:{planets.Mass}");
                total += planets.Mass;
            }

            Console.WriteLine(total);
        }
Exemplo n.º 3
0
        private void CheckEndGame()
        {
            if (Triangle.Transform.X <= -Triangle.Radius * 2 || Triangle.Transform.X >= _engine.Surface.Width + Triangle.Radius * 2)
            {
                OnGameEnd(new GameResult
                {
                    IsWon = false,
                    Balls = Balls
                });
            }

            if (Planets.Last().Transform.Y - 150 >= Triangle.Transform.Y)
            {
                for (var i = 0; i < _engine.Surface.Width; i += 10)
                {
                    var ps = (ParticlesControllerFire)_engine.Particles.GetSystem(typeof(ParticlesControllerFire));
                    ps.AddBlood(i, Planets.Last().Transform.Y - 150, new Vec2(), 1);
                }

                OnGameEnd(new GameResult
                {
                    IsWon = true,
                    Balls = Balls
                });
            }

            if ((-_engine.Surface.Canvas.Camera.Y - Triangle.Transform.Y) + _engine.Surface.Height <= 0)
            {
                OnGameEnd(new GameResult
                {
                    IsWon = false,
                    Balls = Balls
                });
            }
        }
Exemplo n.º 4
0
 void OnTriggerExit(Collider col)
 {
     if (col.gameObject.layer == 9)
     {
         currentPlanet = null;
     }
 }
        public void Planet_Moons_ReturnsNonEmpty(int planetId)
        {
            var planet = Planets.Get(planetId).Value;
            var moons  = planet.Moons().ToList();

            moons.Should().NotHaveCount(0);
        }
Exemplo n.º 6
0
 void movePlayerToPlanet(Planets planet)
 {
     currentPlanet.SetActive(true);
     player.transform.position = planets[planet].transform.position;
     currentPlanet = planets[planet];
     currentPlanet.SetActive(false);
 }
 public Location(double latitude, double longitude, Planets planet)
     : this()
 {
     this.Latitude = latitude;
     this.Longitude = longitude;
     this.Planet = planet;
 }
Exemplo n.º 8
0
        public static void ReadFromPlanetsFiles()
        {
            string FilePath = @"C:\Users\opilane\Samples";
            string FileName = @"planets.txt";

            List <Planets> planets = new List <Planets>();

            List <string> PlanetsFromFile = File.ReadAllLines(Path.Combine(FilePath, FileName)).ToList();



            foreach (string line in PlanetsFromFile)
            {
                string[] temparray = line.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
                Planets  newPlanet = new Planets(temparray[0], Int32.Parse(temparray[1]));
                planets.Add(newPlanet);
                Console.WriteLine(line);
            }


            foreach (Planets planet in planets)
            {
                Console.WriteLine($"Planets: {planet.Name}; Mass: {planet.Mass}");
            }
        }
Exemplo n.º 9
0
        public double GetAltitudeForLatLongForPlanet(int planetID, double viewLat, double viewLong)
        {
            Imageset layer = WWTControl.Singleton.GetImagesetByName(Planets.GetNameFrom3dId(planetID));

            if (layer == null)
            {
                return(0);
            }

            int maxX = GetTilesXForLevel(layer, layer.BaseLevel);
            int maxY = GetTilesYForLevel(layer, layer.BaseLevel);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null);
                    if (tile != null)
                    {
                        if (tile.IsPointInTile(viewLat, viewLong))
                        {
                            return(tile.GetSurfacePointAltitude(viewLat, viewLong, true));
                        }
                    }
                }
            }
            return(0);
        }
Exemplo n.º 10
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Planets.Clear();
                var planets = await DataStore.GetItemsAsync(true);

                foreach (var planet in planets)
                {
                    Planets.Add(planet);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 11
0
 public void Apply(Models.EphemerisResult ephemerisResult)
 {
     DateUTC               = ephemerisResult.DateUTC;
     JulianDay             = ephemerisResult.JulianDay;
     EphemerisTime         = ephemerisResult.EphemerisTime;
     SideralTime           = ephemerisResult.SideralTime;
     MeanEclipticObliquity = ephemerisResult.MeanEclipticObliquity;
     TrueEclipticObliquity = ephemerisResult.TrueEclipticObliquity;
     NutationLongitude     = ephemerisResult.NutationLongitude;
     NutationObliquity     = ephemerisResult.NutationObliquity;
     Planets.Clear();
     foreach (var p in ephemerisResult.Planets)
     {
         Planets.Add(p);
     }
     Houses.Clear();
     foreach (var h in ephemerisResult.Houses)
     {
         Houses.Add(h);
     }
     ASMCs.Clear();
     foreach (var h in ephemerisResult.ASMCs)
     {
         ASMCs.Add(h);
     }
 }
Exemplo n.º 12
0
        public void CreateSolarSystem()
        {
            Planet sun     = new Planet(60, Color.Yellow, new Point2D(Size.Width / 2, Size.Height / 2));
            Planet mercury = new Planet(sun, 80, 8, 0.5f, Color.Red, 10, 1);
            Planet venus   = new Planet(sun, 110, 9, 0.1f, Color.DarkOrange, 15, 1);
            Planet earth   = new Planet(sun, 150, 12, 0.2f, Color.Green, 18, 1);
            Planet moon    = new Planet(earth, 17, 3, 0.2f, Color.Gray, 55, 1);
            Planet mars    = new Planet(sun, 225, 10, 0.7f, Color.Red, 17, 1);
            Planet upiter  = new Planet(sun, 275, 25, 0.9f, Color.RosyBrown, 13, 1);
            Planet cerera  = new Planet(upiter, 45, 6, 0.2f, Color.Gray, 45, 1);
            Planet saturn  = new Planet(sun, 350, 45, 0.3f, Color.SandyBrown, 10, 1);
            Planet titan   = new Planet(saturn, 56, 7, 0.2f, Color.BlueViolet, 35, 1);
            Planet uran    = new Planet(sun, 435, 20, 0.9f, Color.Cyan, 12, 1);
            Planet neptune = new Planet(sun, 500, 18, 0.4f, Color.Blue, 7, 1);

            Planets.Add(sun);
            Planets.Add(mercury);
            Planets.Add(venus);
            Planets.Add(earth);
            Planets.Add(moon);
            Planets.Add(mars);
            Planets.Add(upiter);
            Planets.Add(cerera);
            Planets.Add(saturn);
            Planets.Add(titan);
            Planets.Add(uran);
            Planets.Add(neptune);
        }
        public StatusResult GetStatus(StatusRequest request)
        {
            var status = new StatusResult()
            {
                Success              = true,
                Status               = this.Status,
                IsGameOver           = this.GameOver,
                Waiting              = this.Waiting,
                CurrentTurn          = Turn,
                NextTurnStart        = endServerTurn,
                EndOfCurrentTurn     = endPlayerTurn,
                PlayerTurnLength     = (int)PLAYER_TURN_LENGTH,
                ServerTurnLength     = (int)SERVER_TURN_LENGTH,
                Planets              = Planets.Select(p => Mapper.Map <Shared.Planet>(p)).ToList(),
                Fleets               = Fleets.Select(f => Mapper.Map <Shared.Fleet>(f)).ToList(),
                PlayerA              = 1,
                PlayerAScore         = _getPlayerScore(1),
                PlayerAScoreOverTime = PlayerAScoreOverTime,
                PlayerB              = 2,
                PlayerBScore         = _getPlayerScore(2),
                PlayerBScoreOverTime = PlayerBScoreOverTime
            };

            return(status);
        }
Exemplo n.º 14
0
        public override string ToString()
        {
            List <string> results = Planets.Select(x => x.ToString()).ToList();

            results.AddRange(Fleets.Select(x => x.ToString()));
            return(string.Join("\n", GetPlayerOneState()));
        }
        public void Delete(int id)
        {
            Planets entity = database.Planets.First(registro => registro.Id == id);

            database.Planets.Remove(entity);
            database.SaveChanges();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Метод загрузки в память создаваемых объектов
        /// </summary>
        public static void Load()
        {
            int    s, p;
            Random rnd = new Random();

            _stars      = new Star[100];
            _background = new Background(new Point(0, 0), new Point(0, 0), new Size(0, 0));
            _asteroids  = new Asteroid[16];
            _planets    = new Planets[1];
            _bullet     = new Bullet(new Point(0, rnd.Next(0, GetHeight())), new Point(15, 0), new Size(30, 1));
            _ship       = new Ship(new Point(100, 400), new Point(50, 50), new Size(50, 50));
            _aids       = new Aids(new Point(0, rnd.Next(0, GetHeight())), new Point(20, 0), new Size(50, 50));

            for (int i = 0; i < _asteroids.Length; i++)
            {
                s             = rnd.Next(30, 90);
                p             = rnd.Next(50, 980);
                _asteroids[i] = new Asteroid(new Point(1920, p), new Point(15, 0), new Size(s, s), rnd.Next(4));
            }

            for (int i = 0; i < _stars.Length; i++)
            {
                s         = rnd.Next(1, 2);
                p         = rnd.Next(0, 1080);
                _stars[i] = new Star(new Point(1920, rnd.Next(0, Game.height)), new Point(s - i, s), new Size(s, s));
            }

            for (int i = 0; i < _planets.Length; i++)
            {
                s           = rnd.Next(80, 150);
                p           = rnd.Next(100, 800);
                _planets[i] = new Planets(new Point(1920, p), new Point(5, 0), new Size(s, s), rnd.Next(1));
            }
        }
Exemplo n.º 17
0
        private void ApplyArrivals()
        {
            Dictionary <int, List <Fleet> > arrivalLocations = new Dictionary <int, List <Fleet> >();
            List <Fleet> toRemove = new List <Fleet>();

            foreach (Fleet f in Fleets)
            {
                if (f.RemainingTurns == 0)
                {
                    if (!arrivalLocations.ContainsKey(f.Destination))
                    {
                        arrivalLocations.Add(f.Destination, new List <Fleet>());
                    }

                    arrivalLocations[f.Destination].Add(f);
                    toRemove.Add(f);
                }
            }

            toRemove.ForEach(x => Fleets.Remove(x));

            foreach (var arrival in arrivalLocations)
            {
                Planet planet = Planets.First(x => x.Identifier == arrival.Key);
                if (planet == null)
                {
                    throw new Exception("Wha?  There's a fleet en route to a non-existant planet?");
                }

                ApplySpecificArrival(planet, arrival.Value);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Executes the load planets command.
        /// </summary>
        async Task ExecuteLoadPlanetsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Planets.Clear();
                var planets = await this._service.GetAllPlanets().ConfigureAwait(false);

                Device.BeginInvokeOnMainThread(() =>
                {
                    foreach (var planet in planets)
                    {
                        Planets.Add(planet);
                    }
                });
            }
            catch (Exception ex)
            {
                // Proper handling of exception
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Generate a brand new solarsystem
        /// </summary>
        public void Init()
        {
            _updating = true;
            // Set up time event
            Clock.DayChange += DayChangeUpdater;
            Clock.Tick      += VisualUpdater;

            // Destroy any children that might exist previously.
            DestroyChildren();

            // Create Host Star
            var host = HostStar;

            // Create Planetary Bodies
            foreach (var lane in host.GetPlanetLanes())
            {
                Children.Add(Planet.GeneratePlanet(this, host, lane));
            }

            // Create Moons
            foreach (var planet in Planets.Where(p => p.CanHaveMoons()))
            {
                var lanes = planet.GetPlanetLanes();
                foreach (var lane in lanes)
                {
                    planet.Children.Add(Planet.GeneratePlanet(this, planet, lane));
                }
            }

            // Create Asteroids

            _updating = false;
        }
Exemplo n.º 20
0
        // Private methods
        private async Task LoadPlanets()
        {
            var result = await _planetsService.GetPlanetsAsync(_nextPage);

            List <IPlanet> planetsToAdd = new List <IPlanet>();

            for (int i = 0; i < result.Results.Count(); i++)
            {
                if (i % 2 == 0)
                {
                    planetsToAdd.Add(result.Results.ElementAt(i).ToPlanet());
                }
                else
                {
                    planetsToAdd.Add(result.Results.ElementAt(i).ToPlanet2());
                }
            }

            if (string.IsNullOrEmpty(_nextPage))
            {
                Planets.Clear();
            }
            Planets.AddRange(planetsToAdd);

            _nextPage = result.Next;
        }
Exemplo n.º 21
0
        private static void ImportPlanets()
        {
            var context = new MassDefectContext();
            var json    = File.ReadAllText(PlanetsPath);
            var planets = JsonConvert.DeserializeObject <IEnumerable <PlanetsDTO> >(json);

            foreach (var planet in planets)
            {
                if (planet.Name == null || planet.SolarSystem == null || planet.Sun == null)
                {
                    RaiseError();
                    continue;
                }

                var planetEntity = new Planets
                {
                    Name        = planet.Name,
                    SolarSystem = GetSolarSystemByName(planet.SolarSystem, context),
                    Sun         = GetSunByName(planet.Sun, context)
                };

                if (planetEntity.Name == null || planetEntity.Sun == null || planetEntity.SolarSystem == null)
                {
                    RaiseError();
                    continue;
                }

                context.Planets.Add(planetEntity);

                Console.WriteLine($"Successfully imported Planet {planetEntity.Name}.");
            }
            context.SaveChanges();
        }
Exemplo n.º 22
0
        public Universe Copy(int newID)
        {
            Universe copy = new Universe(Parent, newID);

            copy.Camera.Position2D = this.Camera.Position2D;
            copy.Camera.Zoom       = this.Camera.Zoom;

            foreach (Planet planet in Planets.ToArray())
            {
                Planet planetCopy = planet.Copy(copy);

                copy.Planets.Add(planetCopy);

                if (IsPlanetSelected(planet))
                {
                    copy.SelectedPlanets.Add(planetCopy);
                }

                if (planet == Camera.FocusPlanet)
                {
                    copy.FocusPlanet(planetCopy);
                }
            }

            return(copy);
        }
Exemplo n.º 23
0
 public PlanetRecord?GetPlanet(StarDate time, int planetId)
 {
     return(Planets
            .Where(p => p.Time == time)
            .Where(p => p.PlanetId == planetId)
            .SingleOrDefault());
 }
Exemplo n.º 24
0
        // ** Begin
        public static void DrawMPC3D(RenderContext renderContext, float opacity, Vector3d centerPoint)
        {
            double zoom      = renderContext.ViewCamera.Zoom;
            double distAlpha = ((Math.Log(Math.Max(1, zoom)) / Math.Log(4)) - 15.5) * 90;

            int alpha = Math.Min(255, Math.Max(0, (int)distAlpha));



            if (alpha > 254)
            {
                return;
            }


            if (mpcVertexBuffer == null)
            {
                if (starTexture == null)
                {
                    starTexture = Planets.LoadPlanetTexture(URLHelpers.singleton.engineAssetUrl("StarProfileAlpha.png"));
                }
                for (int i = 0; i < 7; i++)
                {
                    mpcBlendStates[i] = BlendState.Create(false, 1000);
                }

                if (!initBegun)
                {
                    StartInit();
                    initBegun = true;
                }
                return;
            }

            Matrix3d offset   = Matrix3d.Translation(Vector3d.Negate(centerPoint));
            Matrix3d world    = Matrix3d.MultiplyMatrix(renderContext.World, offset);
            Matrix3d matrixWV = Matrix3d.MultiplyMatrix(world, renderContext.View);

            Vector3d cam = Vector3d.TransformCoordinate(renderContext.CameraPosition, Matrix3d.InvertMatrix(renderContext.World));

            //todo star profile texture

            if (mpcVertexBuffer != null)
            {
                for (int i = 0; i < 7; i++)
                {
                    // mpcBlendStates[i].TargetState = ((Properties.Settings.Default.MinorPlanetsFilter & (int)Math.Pow(2, i)) != 0);
                    mpcBlendStates[i].TargetState = true;

                    if (mpcBlendStates[i].State)
                    {
                        KeplerPointSpriteShader.Use(renderContext, matrixWV, mpcVertexBuffer[i].VertexBuffer, starTexture.Texture2d, Colors.White,
                                                    opacity * mpcBlendStates[i].Opacity, false,
                                                    (float)(SpaceTimeController.JNow - KeplerVertex.baseDate), 0, renderContext.CameraPosition, 200f, .1f);

                        renderContext.gl.drawArrays(GL.POINTS, 0, mpcVertexBuffer[i].Count);
                    }
                }
            }
        }
Exemplo n.º 25
0
        private void ApplyDepartures(List <Order> orders)
        {
            foreach (Order o in orders)
            {
                Planet sourcePlanet = Planets.First(x => x.Identifier == o.Source);
                if (sourcePlanet == null)
                {
                    throw new Exception("No source planet.  Order validation went wrong.");
                }

                Planet destinationPlanet = Planets.First(x => x.Identifier == o.Destination);
                if (destinationPlanet == null)
                {
                    throw new Exception("No destination planet.  Order validation went wrong.");
                }

                if (sourcePlanet.Ships < o.Ships)
                {
                    SetErrorMessage(o.Player, $"Tried to send too many ships from planet {o.Source}");
                }

                int totalTurns =
                    (int)Math.Ceiling(
                        Math.Sqrt(Math.Pow(destinationPlanet.X - sourcePlanet.X, 2) +
                                  Math.Pow(destinationPlanet.Y - sourcePlanet.Y, 2)));
                Fleets.Add(new Fleet(o.Player, o.Ships, o.Source, o.Destination, totalTurns, totalTurns));
                sourcePlanet.Ships -= o.Ships;
            }
        }
Exemplo n.º 26
0
    // Update is called once per frame
    void Update()
    {
        if (isInSequence && Input.GetMouseButtonDown(0))
        {
            if (currentSequenceCount >= curDs.dialogues.Count)
            {
                currentSequenceCount = 0;
                isInSequence         = false;
                textHolder.SetActive(false);
                disableDialogueBar();
                if (curDs.questID != 0)
                {
                    qm.displayQuest(curDs.questID, curPlanet);
                }

                curDs     = null;
                curPlanet = null;
            }
            else
            {
                print(curDs.dialogues.Count);

                displayDialog(curDs.dialogues [currentSequenceCount].message);
                currentSequenceCount += 1;
            }
        }
    }
Exemplo n.º 27
0
        public List <string> GetPlayerOneState()
        {
            List <string> results = Planets.Select(x => x.ToString()).ToList();

            results.AddRange(Fleets.Select(x => x.ToString()));
            return(results);
        }
Exemplo n.º 28
0
        public void ProcessEnergy(int turn)
        {
            var energy  = EnergyProducedLastTurn;
            var structs = Planets.SelectMany(x => x.PlanetStructures).ToList();
            var demand  = structs.Sum(x => (double?)(x.StructureType.UpkeepEnergy ?? 0)) ?? 0;

            if (energy >= demand)
            {
                foreach (var s in structs)
                {
                    s.PoweredTick(turn);
                }
            }
            else
            {
                // todo implement complex energy behavior with multilayered distribution
                foreach (var s in structs.OrderByDescending(x => (int)x.EnergyPriority).ThenBy(x => x.StructureType.UpkeepEnergy ?? 0))
                {
                    if (energy >= s.StructureType.UpkeepEnergy)
                    {
                        s.PoweredTick(turn);
                        energy -= s.StructureType.UpkeepEnergy ?? 0;
                    }
                    else
                    {
                        s.UnpoweredTick(turn);
                    }
                }
            }

            EnergyDemandLastTurn   = demand;
            EnergyProducedLastTurn =
                Planets.SelectMany(x => x.PlanetStructures).Where(x => x.IsActive && x.StructureType.EffectEnergyPerTurn > 0).Sum(
                    x => x.StructureType.EffectEnergyPerTurn) ?? 0;
        }
Exemplo n.º 29
0
        public void ProcessProduction()
        {
            foreach (var grp in Planets.SelectMany(x => x.PlanetStructures).Where(x => x.IsActive && x.Account != null).GroupBy(x => x.Account))
            {
                var structs = grp.ToList();
                var drops   = structs.Where(x => x.StructureType.EffectDropshipProduction > 0).Sum(x => x.StructureType.EffectDropshipProduction) ?? 0;
                grp.Key.ProduceDropships(drops);

                var bombers = structs.Where(x => x.StructureType.EffectBomberProduction > 0).Sum(x => x.StructureType.EffectBomberProduction) ?? 0;
                grp.Key.ProduceBombers(bombers);

                var warps = structs.Where(x => x.StructureType.EffectWarpProduction > 0).Sum(x => x.StructureType.EffectWarpProduction) ?? 0;
                grp.Key.ProduceWarps(warps);
            }


            // produce victory points
            foreach (var fac in Planets.Where(x => x.Faction != null).GroupBy(x => x.Faction))
            {
                fac.Key.VictoryPoints +=
                    fac.SelectMany(x => x.PlanetStructures)
                    .Where(x => x.IsActive && x.StructureType.EffectVictoryPointProduction != null)
                    .Sum(x => x.StructureType.EffectVictoryPointProduction) ?? 0;
            }



            // planets generate metal
            foreach (var p in Planets.Where(x => x.Faction != null && x.Account != null))
            {
                p.Account.ProduceMetal(GlobalConst.PlanetMetalPerTurn);
            }
        }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        thisPlanet = Planets.currentPlanet;

        //Sell Inventory slots are equal to the slots in the Inventory
        sellInventory = inventoryManager.inventorySlots;

        //This simply allows you to exit back to the planet menu
        if (Input.GetKeyUp(KeyCode.E))
        {
            gameObject.SetActive(false);
            planetMenu.SetActive(true);
        }

        for (int k = 0; k < inventoryManager.inventorySlots.Length; k++)
        {
            //Displays icon inside the "sell" section of the buy/ sell menu
            ExtensionMethods.DisplayIconsInInventoryByIndex(k, sellSlotGrid, sellInventory, inventoryManager.Inventory);
        }

        for (int k = 0; k < sellSlotGrid.transform.childCount; k++)
        {
            if (sellInventory[k] != null)
            {
                //Updates price of item based on the CalculatePrice method
                ExtensionMethods.FindBySprite(sellInventory[k], itemDatabase).eachPlanet.Find(x => x.ID == thisPlanet.ID).price
                    = CalculatePrice(ExtensionMethods.FindBySprite(sellInventory[k], itemDatabase).ID);
            }
        }
    }
Exemplo n.º 31
0
 public void UpdatePlanetLocation(double jNow)
 {
     if (Target != SolarSystemObjects.Undefined && Target != SolarSystemObjects.Custom)
     {
         camParams.ViewTarget = Planets.GetPlanetTargetPoint(Target, Lat, Lng, jNow);
     }
 }
Exemplo n.º 32
0
        public static void ReadFromPlanetsFiles()
        {
            string filePath = @"C:\Users\opilane\Samples";
            string fileName = @"planets.txt";

            List <Planets> planets = new List <Planets>();

            List <string> planetList = File.ReadAllLines(Path.Combine(filePath, fileName)).ToList();

            foreach (string line in planetList)
            {
                string[] tempArray = line.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
                Planets  newPlanet = new Planets(tempArray[0], Int32.Parse(tempArray[1]));
                planets.Add(newPlanet);
            }

            int total = 0;

            foreach (Planets planet in planets)
            {
                Console.WriteLine($"Planet: {planet.Name}; Mass: {planet.Mass}");
                total += planet.Mass;
            }

            Console.WriteLine($"Total mass: {total}");
        }
Exemplo n.º 33
0
 public Satellite(float radio, Planets tipo, Position posicion, string texture)
 {
     this.radio = radio;
     this.tipo = tipo;
     planetaPos = posicion;
     lunaPos = planetaPos;
     lunaPos.x += 3;
     //velocidadOrbita = (float)r.NextDouble() * 0.3f;
     this.texture = texture;
 }
Exemplo n.º 34
0
        public NewGame(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            this.game = game;
            this.playing = false;
            this.ship = new Ship.Ship(300, 100);
            this.planets = new Planets();

            this.world = new World(this.game.GraphicsDevice.Viewport.AspectRatio);
            this.network = new Network();
            this.time = 0.0f;
        }
Exemplo n.º 35
0
 public Planet(float radio, Planets tipo, Position posision, string texture,bool hasMoon)
 {
     this.radio = radio;
     this.tipo = tipo;
     p = posision;
     anguloOrbita = r.Next(360);
     velocidadOrbita = (float)r.NextDouble() * 0.3f;
     this.texture = texture;
     if (hasMoon)
     {
         moon = new Satellite(0.5f, Planets.Earth, p, "luna.jpg");
     }
 }
Exemplo n.º 36
0
        public NewGame(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            this.game = game;
            this.playing = false;
            this.ship = new Ship.Ship();
            this.planets = new Planets();

            this.world = new World(this.game.GraphicsDevice.Viewport.AspectRatio);
            this.network = new Network();
            this.time = 0.0f;

            this.currentItem = MenuList.game;
            this.exitMenu = new ExitMenu.ExitMenu();
        }
Exemplo n.º 37
0
 private void TestEnumerationValues(Planets value, string expectedName, int expectedOrdinal)
 {
     Assert.That(value.Name, Is.EqualTo(expectedName));
     Assert.That(value.Ordinal, Is.EqualTo(expectedOrdinal));
 }
        private static Func<double, double> AllBusinessCooldownUnlock(Planets applicablePlanet, int applicableLevel)
        {
            return (i) =>
                {
                    if (Businesses.Where(b => b.Planet == applicablePlanet).All(b => b.TotalLevel >= applicableLevel))
                        i = i / 2;

                    return i;
                };
        }
        private static Func<double, double> AllBusinessProfitMultiplierUnlock(Planets applicablePlanet, int applicableLevel, double profitMultiplier)
        {
            return (i) =>
            {
                if (Businesses.Where(b => b.Planet == applicablePlanet).All(b => b.TotalLevel >= applicableLevel))
                    i = i * profitMultiplier;

                return i;
            };
        }