public void CreateNewGameEvent(object sender, TGUI.SignalArgsVector2f args) { // TODO - Move to post galaxy options state GalaxyGenerator.GenerateStars(GlobalConstants.GalaxySize.SMALL, GlobalConstants.GalaxyType.DISK); Engine.Instance.GameStates.Push(new GalaxyViewState()); IsStateActive = false; }
//Function to load faction data public static FactionData[] LoadFactions(FactionData[] factionData) { //Clears current faction data ClearFactions(factionData.Length); for (int i = 0; i < factionData.Length; i++) { //Faction variable assignment factions[i] = factionData[i]; factions[i].homeSystem = GalaxyGenerator.GetGalaxyNodeFromID(factionData[i].homeSystemID, GalaxyGenerator.GetAllGalaxySystems()); factions[i].exploredSystems = new List <GalaxyNode>(); factions[i].ownedSystems = new List <GalaxyNode>(); factions[i].ownedSystemIDs = new List <int>(); factions[i].exploredSystemIDs = new List <int>(); factions[i].resourceData = ResetFactionResourceData(factions[i].factionID); //Get all explored systems for (int j = 0; j < factionData[i].exploredSystemIDs.Count; j++) { GalaxyNode newNode = GalaxyGenerator.GetGalaxyNodeFromID(factionData[i].exploredSystemIDs[j], GalaxyGenerator.GetAllGalaxySystems()); AddExploredSystem(factions[i].factionID, newNode); } //Get all owned systems for (int j = 0; j < factionData[i].ownedSystemIDs.Count; j++) { GalaxyNode newNode = GalaxyGenerator.GetGalaxyNodeFromID(factionData[i].ownedSystemIDs[j], GalaxyGenerator.GetAllGalaxySystems()); AddControlledSystem(factions[i].factionID, newNode); } } SaveData.current.factions = factions; return(factions); }
public void GetSystems() { //arrange GameCore core = new GameCore(10); GalaxyGenerator sut = new GalaxyGenerator(core, 10); //act var stellarSystem = sut.GetRoot(); //assert Console.WriteLine("test"); }
public void NotEnoughSpaceForPlanetsCausesException(int size, int planets, int minDistance) { var generator = new GalaxyGenerator(); var settings = new GalaxyGeneratorSettings() { GalaxySize = size, PlanetCount = planets, MinimumDistanceBetweenPlanets = minDistance, }; Assert.Throws <OutOfSpaceException>(() => generator.Generate(settings)); }
public void EachPlanetHasADistinctPosition() { var generator = new GalaxyGenerator(); var settings = new GalaxyGeneratorSettings() { GalaxySize = 800, PlanetCount = 100, }; var galaxy = generator.Generate(settings); Assert.Equal(galaxy.Planets.Count, galaxy.Planets.Select(planet => planet.Position).Distinct().Count()); }
public void GalaxyHasCorrectSize(int size) { var generator = new GalaxyGenerator(); var settings = new GalaxyGeneratorSettings() { GalaxySize = size, PlanetCount = 0, }; var galaxy = generator.Generate(settings); Assert.Equal(size, galaxy.Bounds.Size); }
public void GalaxyHasCorrectNumberOfPlanets(int planets) { var generator = new GalaxyGenerator(); var settings = new GalaxyGeneratorSettings() { GalaxySize = 1000, PlanetCount = planets, }; var galaxy = generator.Generate(settings); Assert.Equal(planets, galaxy.Planets.Count); }
// Use this for initialization void Start() { Tilemap = GetComponent <Tilemap>(); GalaxyGenerator = GetComponent <GalaxyGenerator>(); Spritemanager = GetComponent <Spritemanager>(); PrefabManager = GetComponent <PrefabManager>(); TimeController = GetComponent <TimeController>(); EntityManager = GetComponent <EntityManager>(); EmpireManager = GetComponent <EmpireManager>(); MenuManager = GetComponent <MenuManager>(); Flag.EmptyPrefab = new GameObject(); MenuManager.LoadMainMenu(); }
public void MinDistanceBetweenPlanetsIsValid(int size, int planets, int minDistance) { var generator = new GalaxyGenerator(); var settings = new GalaxyGeneratorSettings() { GalaxySize = size, PlanetCount = planets, MinimumDistanceBetweenPlanets = minDistance }; var galaxy = generator.Generate(settings); Assert.All(galaxy.Planets, planet => Assert.True(MinDistanceKept(planet))); bool PassesSocialDistancingRule(Planet p1, Planet p2) => p1 != p2?p1.Position.DistanceTo(p2.Position) >= minDistance : true; bool MinDistanceKept(Planet planet) => galaxy.Planets.All(otherPlanet => PassesSocialDistancingRule(planet, otherPlanet)); }
public void PlanetsHaveValidPositions(int size, int planets, int padding) { var generator = new GalaxyGenerator(); var settings = new GalaxyGeneratorSettings() { GalaxySize = size, PlanetCount = planets, Padding = padding, }; var galaxy = generator.Generate(settings); var bounds = new GalaxyBounds(size); var min = bounds.Min + padding; var max = bounds.Max - padding; Assert.All(galaxy.Planets, planet => Assert.True(PointInRange(planet.Position))); bool CoordInRange(int coord) => coord >= min && coord <= max; bool PointInRange(Position position) => CoordInRange(position.X) && CoordInRange(position.Y);; }
static void Main(string[] args) { _rootConsole = new RLRootConsole("terminal8x8.png", _rootConsoleWidth, _rootConsoleHeight, _fontSize, _fontSize, 1.5f, "Test Console"); _starMapConsole = new RLConsole(_starMapConsoleWidth, _starMapConsoleHeight); _logConsole = new RLConsole(_logConsoleWidth, _logConsoleHeight); _galaxyMapConsole = new RLConsole(_galaxyMapConsoleWidth, _galaxyMapConsoleHeight); _loreLogConsole = new RLConsole(_loreLogConsoleWidth, _loreLogConsoleHeight); loreBox = new LoreBox(null, 40, 30, "Genesis"); Galaxy = GalaxyGenerator.Generate(); currentSystem = 0; currentWindowView = CurrentView.Log; _rootConsole.Update += RootConsoleUpdate; _rootConsole.Render += RootConsoleRender; isRenderRequired = true; _rootConsole.Run(); }
private static void DisplayGalaxyLog() { _galaxyMapConsole.SetBackColor(0, 0, _galaxyMapConsole.Width, _galaxyMapConsole.Height, RLColor.Black); DisplayBorder(_galaxyMapConsole); Galaxy g = GalaxyGenerator.Generate(); _galaxyMapConsole.Print(2, 2, "Galaxy Logs", RLColor.White); _galaxyMapConsole.Print(5, 5, g.Name, RLColor.White); for (int i = 0; i < 8; i++) { SpaceSystem temp = (SpaceSystem)g.Systems[i]; string NoP = $"Number of Planets - {temp.Bodies.Length}"; _galaxyMapConsole.Print(5, 7 + 2 * i, temp.Name, temp.Star.Color); _galaxyMapConsole.Print(12, 7 + 2 * i, NoP, temp.Star.Color); } RLConsole.Blit(_galaxyMapConsole, 0, 0, _galaxyMapConsole.Width, _galaxyMapConsole.Height, _rootConsole, 0, 0); }
public async Task <IQueryable <Star> > GetSectorsAsync(long sxMin, long syMin, long sxMax, long syMax, [Service] UniverseContext dbContext, [Service] GalaxyGenerator generator) { var existingSectors = ( from s in dbContext.Stars where s.SectorX >= sxMin && s.SectorX <= sxMax && s.SectorY >= syMin && s.SectorY <= syMax group s by new { s.SectorX, s.SectorY } into g select new { g.Key.SectorX, g.Key.SectorY }).ToHashSet(); for (long sx = sxMin; sx <= sxMax; ++sx) { for (long sy = syMin; sy <= syMax; ++sy) { if (!existingSectors.Contains(new { SectorX = sx, SectorY = sy })) { await generator.GenerateSector(sx, sy, dbContext); } } } return(dbContext.Stars .Where(s => s.SectorX >= sxMin && s.SectorX <= sxMax && s.SectorY >= syMin && s.SectorY <= syMax)); }