Ejemplo n.º 1
0
        public MarketplaceControl(IngameModel viewModel)
        {
            ViewModel = viewModel;

            Content = Factory.StackPanel(new List <IControl>
            {
                Factory.Headline1(() => $"{Ship.CurrentStation.Name} - MARKETPLACE"),
                Factory.Box(
                    content: Factory.StackPanel(new List <IControl>
                {
                    Factory.Text(() => $"Credits: ${Ship.Credits.ToStringInvariant()}   Free Space: {Ship.CargoBay.FreeSpace}"),
                    Factory.Text(() => string.Empty),
                    Factory.HorizintalSplit(
                        Factory.Table(() => Ship.CurrentStation.OfferedItems, new Dictionary <string, Func <MarketplaceItem, string> >
                    {
                        { "Offered Item", item => item.ItemStack.Name },
                        { "Price", item => item.Price.ToStringInvariant() },
                        { "Amount", item => item.ItemStack.Amount.ToStringInvariant() }
                    }, "No items offered"),
                        50,
                        Factory.Table(() => Ship.CurrentStation.RequestedItems, new Dictionary <string, Func <MarketplaceItem, string> >
                    {
                        { "Requested Item", item => item.ItemStack.Name },
                        { "Price", item => item.Price.ToStringInvariant() },
                        { "Amount", item => item.ItemStack.Amount.ToStringInvariant() }
                    }, "No items requested"))
                })
                    )
            });
        }
Ejemplo n.º 2
0
        public IngameControl(IngameModel viewModel)
        {
            ViewModel = viewModel;

            ShipOverview   = new ShipOverviewControl(viewModel.Ship);
            CargoBay       = new CargoBayControl(viewModel.Ship);
            NavigationRoom = new NavigationRoomControl(ViewModel.NavigationRoom);
            Marketplace    = new MarketplaceControl(ViewModel);
            Engine         = new EngineControl(viewModel.Ship);

            Box.Padding = 1;
            Content     = ShipOverview;
        }
Ejemplo n.º 3
0
        public CommandService(IngameModel viewModel)
        {
            var commands = new List <object>
            {
                new Goto(viewModel),
                new MoveTo(viewModel),
                new Buy(viewModel),
                new Sell(viewModel)
            };

            CommandInvoker = new CommandInvoker(
                commands.Select(c => new CommandInvoker.Item(CommandReflector.Reflect(c.GetType().GetTypeInfo()), c)).ToList());
        }
Ejemplo n.º 4
0
        private Program()
        {
            var asteroidRadius   = 10.Kilometer();
            var moonRadius       = 800.Kilometer();
            var rockPlanetRadius = 6500.Kilometer();
            var gasGiantRadius   = 90000.Kilometer();
            var starRadius       = 100 * gasGiantRadius;
            var blackHoleRadius  = 100 * starRadius;

            var factory = new CelestialFactory();

            var universe = factory.Create(
                systemName: "Universe",
                name: "Universe Center",
                orbit: 0,
                radius: 1,
                density: 1,
                children: new []
            {
                factory.Create(
                    systemName: "Milkiway",
                    name: "Black Hole",
                    orbit: Math.Pow(10, 9).AstronomicUnits(),
                    radius: blackHoleRadius,
                    density: 1000.TonsPerCubicMeter(),
                    children: new []
                {
                    factory.Create(
                        name: "Sun",
                        orbit: Math.Pow(10, 6).AstronomicUnits(),
                        radius: 696342.Kilometer(),
                        density: 1.408.GramPerCubicCentimeter(),
                        children: new []
                    {
                        factory.Create(
                            name: "Mercury",
                            orbit: 0.387098.AstronomicUnits(),
                            radius: 2439.7.Kilometer(),
                            density: 5.427.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Venus",
                            orbit: 0.723332.AstronomicUnits(),
                            radius: 6051.8.Kilometer(),
                            density: 5.243.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Earth",
                            orbit: 1.AstronomicUnits(),
                            radius: 6371.Kilometer(),
                            density: 5.514.GramPerCubicCentimeter(),
                            children: new []
                        {
                            factory.Create(
                                name: "Moon",
                                orbit: 384399.Kilometer(),
                                radius: 1737.1.Kilometer(),
                                density: 3.344.GramPerCubicCentimeter())
                        }),
                        factory.Create(
                            name: "Mars",
                            orbit: 1.523679.AstronomicUnits(),
                            radius: 3389.5.Kilometer(),
                            density: 3.9335.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Jupiter",
                            orbit: 5.2044.AstronomicUnits(),
                            radius: 69911.Kilometer(),
                            density: 1.326.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Saturn",
                            orbit: 9.5826.AstronomicUnits(),
                            radius: 58232.Kilometer(),
                            density: 0.687.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Uranus",
                            orbit: 19.2184.AstronomicUnits(),
                            radius: 25362.Kilometer(),
                            density: 1.27.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Neptune",
                            orbit: 30.11.AstronomicUnits(),
                            radius: 24622.Kilometer(),
                            density: 1.638.GramPerCubicCentimeter()),
                        factory.Create(
                            name: "Pluto",
                            orbit: 39.48.AstronomicUnits(),
                            radius: 1188.3.Kilometer(),
                            density: 1.854.GramPerCubicCentimeter())
                    })
                })
            });

            var ship = new Ship
            {
                Crew        = 3,
                PowerOutput = 100,
                PowerUsage  = 80,
                Credits     = 1000
            };

            World = new World {
                Ship = ship
            };

            var earth = universe.GetDescendent("Earth System");

            World.Stations.Add(CreateStation(earth));

            World.Ship.CurrentStation = World.Stations[0];

            foreach (var system in earth.GetSiblings())
            {
                World.Stations.Add(CreateStation(system));
            }

            ViewModel = new IngameModel(World);
            ViewModel.Update();

            CommandService = new CommandService(ViewModel);

            MainControl = new IngameControl(ViewModel);
        }
Ejemplo n.º 5
0
 public MoveTo(IngameModel viewModel)
 {
     ViewModel = viewModel;
 }
Ejemplo n.º 6
0
 public Goto(IngameModel ingameModel)
 {
     IngameModel = ingameModel;
 }
Ejemplo n.º 7
0
 public Buy(IngameModel viewModel)
 {
     ViewModel = viewModel;
 }
Ejemplo n.º 8
0
 public Sell(IngameModel viewModel)
 {
     ViewModel = viewModel;
 }