public MainGalaxyViewModel(IGalaxyPopulator initGalaxyCreator, IGalaxyViewModelFactory initGalaxyViewModelFactory, ISolarSystemViewModelFactory initSolarSystemViewModelFactory, IPlanetViewModelFactory initPlanetViewModelFactory, ITextOutputViewModel initTextOutputViewModel, ITickEngine initTickEngine) { _galaxyCreator = initGalaxyCreator; _tickEngine = initTickEngine; _galaxyViewModelFactory = initGalaxyViewModelFactory; _solarSystemViewModelFactory = initSolarSystemViewModelFactory; _planetViewModelFactory = initPlanetViewModelFactory; TextOutput = initTextOutputViewModel; StarChart.InitialiseStarChart(); ResourceTypes.InitialiseResourceTypes(); BluePrints.InitialiseBluePrints(); loadOrCreateGalaxy(); initialiseEngine(); saveGalaxy(); }
public override bool OnDragDrop(Mobile m, Item dropped) { if (dropped is StarChart) { StarChart chart = (StarChart)dropped; if (chart.Constellation >= 0 && chart.Constellation < AstronomySystem.MaxConstellations) { if (String.IsNullOrEmpty(chart.ConstellationName)) { m.SendLocalizedMessage(1158751); // You must name your constellation before submitting it. } else { ConstellationInfo info = AstronomySystem.GetConstellation(chart.Constellation); if (info != null) { Gump gump = new Gump(100, 100); gump.AddBackground(0, 0, 720, 270, 0x2454); gump.AddImage(0, 0, 0x69D); gump.AddHtmlLocalized(290, 14, 418, 18, 1114513, "#1158517", 0xC63, false, false); // Willebrord the Astronomer if (info.HasBeenDiscovered) { m.SendLocalizedMessage(1158764); // That constellation name has already been chosen, please choose another and resubmit your star chart. gump.AddHtmlLocalized(290, 51, 418, 209, 1158530, 0xC63, false, true); // Sorry to say that constellation has already been discovered! Fix your eyes to the heavens and keep up the searc } else { gump.AddHtmlLocalized(290, 51, 418, 209, 1158519, 0xC63, false, true); // Wow! Would you look at that! Always amazes me how even an amateur can make such profound discoveries! // I've recorded your discovery in the ledger. Here's some items I think you have more than earned! Well done! info.DiscoveredBy = chart.ChartedBy; info.Name = chart.ConstellationName; info.DiscoveredOn = chart.ChartedOn; AstronomySystem.AddDiscovery(info); m.AddToBackpack(new RecipeScroll(465)); m.AddToBackpack(new AstronomerTitleDeed()); } m.SendGump(gump); } } } } else { SayTo(m, 1158529, 1163); // What's this? I haven't time for this! Star Charts only please! } return(false); }
private void createPVmFromSelectedScP() { Int64 pId = StarChart.GetIdForObject(selectedScPlanet_Var); Planet p = SelectedSolarSystemVm.Planets.Select(x => x.Model).Where(x => x.StarChartId == pId).FirstOrDefault(); if (p != null) { IPlanetViewModel pVm = _planetViewModelFactory.CreatePlanetViewModel(); pVm.Model = p; SelectedPlanetVm = pVm; } }
private void createSsVmFromSelectedScSS() { Int64 scId = StarChart.GetIdForObject(selectedScSolarSystem_Var); SolarSystem ss = Galaxy.Model.SolarSystems.Where(x => x.StarChartId == scId).FirstOrDefault(); if (ss != null) { ISolarSystemViewModel ssVm = _solarSystemViewModelFactory.CreateSolarSystemViewModel(); ssVm.Model = ss; SelectedSolarSystemVm = ssVm; } }
private void updateFromModel() { ScPlanet p = StarChart.GetPlanet(model_Var.StarChartId); name_Var = p.Name; //Population = model_Var.Population; societyVm_Var.Model = model_Var.Society; foreach (Producer prod in model_Var.Producers) { IProducerViewModel prodVm = _producerVmFactory.CreateProducerViewModel(); prodVm.Model = prod; producers_Var.Add(prodVm); } }
public PlanetController(Planet p, IActorRef actorTextOutput) { _model = p; _actorTextOutput = actorTextOutput; _scPlanet = StarChart.GetPlanet(_model.StarChartId); _orbitHours = _scPlanet.OrbitDays * (double)Globals.DAYS_TO_TICKS_FACTOR; _producerCs = new HashSet <ProducerController>(); // create child controllers for each producer in planet foreach (Producer prod in p.Producers) { ProducerController pc = new ProducerController(prod, this, actorTextOutput); _producerCs.Add(pc); } // TODO create a controller for market. }
private string shipStatus() { StringBuilder initStr = new StringBuilder(); initStr.Append(_model.Name); initStr.Append(" ["); if (_model.ShipState == ShipStateEnum.Docked) { ScPlanet p = StarChart.GetPlanet(_model.DockedPlanet.StarChartId); initStr.Append(p.Name); } else { initStr.Append(_model.PositionX); initStr.Append(","); initStr.Append(_model.PositionY); } initStr.Append("]"); return(initStr.ToString()); }
public Galaxy GetFullGalaxy() { Galaxy gal = this.GetGalaxy(); gal.MaxId = 100; ShipType shipT = new ShipType(); shipT.Name = "Basic Ship"; shipT.MaxCruisingSpeedKmH = 300000; gal.ShipTypes.Add(shipT); foreach (ScSolarSystem chartSS in StarChart.SolarSystems.Values) { SolarSystem ss = getSolarSystemFromStarChartSS(chartSS); ss.StarChartId = StarChart.GetIdForObject(chartSS); Agent ag = this.GetAgent("Agent " + chartSS.Name); ss.Agents.Add(ag); ag.SolarSystem = ss; int j = 0; foreach (ScPlanet chartP in chartSS.Planets) { Planet p = this.GetPlanet(chartP); p.StarChartId = StarChart.GetIdForObject(chartP); if (j % 2 == 0) { //addMetalProducerToPlanet(ag, p); addNewStoreToPlanet(p, ag, new List <ResourceQuantity>() { new ResourceQuantity(ResourceTypeEnum.Spice, 10) }); } else { //addSpiceProducerToPlanet(ag, p); addNewStoreToPlanet(p, ag, new List <ResourceQuantity>() { new ResourceQuantity(ResourceTypeEnum.Platinum, 5) }); } j++; ss.Planets.Add(p); } Ship s = this.GetShip("Ship" + chartSS.Name, shipT); s.Owner = ag; s.ShipState = ShipStateEnum.Docked; s.Agents.Add(ag); ag.Location = s; s.Pilot = ag; ag.AgentState = AgentStateEnum.PilotingShip; s.DockedPlanet = ss.Planets.First(); ss.Planets.First().DockedShips.Add(s); ag.ShipsOwned.Add(s); addNewCargoStoreToShip(s, ag); s.SolarSystem = ss; ss.Ships.Add(s); for (int i = 0; i < 1000; i++) { ag = this.GetAgent("Agent " + i); ss.Agents.Add(ag); ag.SolarSystem = ss; s = this.GetShip("Ship" + i, shipT); s.Owner = ag; s.ShipState = ShipStateEnum.Docked; s.Agents.Add(ag); ag.Location = s; s.Pilot = ag; ag.AgentState = AgentStateEnum.PilotingShip; s.DockedPlanet = ss.Planets.First(); ss.Planets.First().DockedShips.Add(s); ag.ShipsOwned.Add(s); addNewCargoStoreToShip(s, ag); s.SolarSystem = ss; ss.Ships.Add(s); foreach (Planet p in ss.Planets) { if (j % 2 == 0) { //addMetalProducerToPlanet(ag, p); addNewStoreToPlanet(p, ag, new List <ResourceQuantity>() { new ResourceQuantity(ResourceTypeEnum.Spice, 10) }); } else { //addSpiceProducerToPlanet(ag, p); addNewStoreToPlanet(p, ag, new List <ResourceQuantity>() { new ResourceQuantity(ResourceTypeEnum.Platinum, 5) }); } j++; } } gal.SolarSystems.Add(ss); } return(gal); }