public void DisplayGalaxyData(GalaxyData d) { allSectors.Clear(); sectorObjectPool.ReleaseAll(); float xpos = 0; float ypos = 0; for (int x = 0; x < d.sectors.Length; x++) { ypos = 0; for (int y = 0; y < d.sectors[0].Length; y++) { GameObject g = sectorObjectPool.GetGameObject(); g.transform.position = new Vector3(xpos, ypos, 0); SectorObject so = g.GetComponent <SectorObject>(); allSectors.Add(so); so.baseColor = gradient.Evaluate((float)d.sectors[x][y].SystemCount / d.maxCount); if (d.sectors[x][y].SystemCount == 0) { so.SetTransparent(true); } else { so.SetTransparent(false); so.DisplayBaseColor(); } so.DisplaySector(d.sectors[x][y]); ypos += spacing; } xpos += spacing; } }
public List <GameObject> stellarList = new List <GameObject>(); // add the star prefabs here // Use this for initialization void Start() { gData = GameObject.Find("GameManager").GetComponent <GalaxyData>(); Debug.Log("Drawing stars..."); DrawStars(); // draw the star map DrawNebulas(); }
static void func(UIGalaxySelect __instance, GalaxyData galaxy) { InputField seedInput = Traverse.Create(__instance).Field("seedInput").GetValue <InputField>(); seedInput.characterLimit = 12; seedInput.text = galaxy.seed.ToString("00 0000 0000"); }
public static void GenerateAllPlanets(GalaxyData galaxy, StarData star, GameDesc gameDesc, List <PlanetForGenerator> planetsToGenerate) { Patch.Debug("Recap of what have to be generated : \n", LogLevel.Debug, Patch.DebugStarGen); var finalIndex = 0; foreach (var planet in planetsToGenerate) { var debugLine = "A "; planet.planetIndex = finalIndex; foreach (var planetForGenerator in planet.moons) { planetForGenerator.orbitAround = finalIndex + 1; } if (planet.isGasGiant) { debugLine += " Gas Giant :" + planet.planetIndex + "with values : \n"; } else { debugLine += " Telluric Planet :" + planet.planetIndex + "with values : \n"; } //planet.ToString(); //planet.GenerateThePlanet(ref galaxy,ref star,ref gameDesc); // Debug.Log(); PlanetGen.CreatePlanet(galaxy, star, gameDesc, planet.planetIndex, planet.orbitAround, planet.orbitIndex, planet.number, planet.isGasGiant, planet.infoSeed, planet.genSeed); star.planets[finalIndex].name = star.name + " - " + RomanNumbers.roman[planet.number]; planet.name = star.planets[finalIndex].name; if (planet.moons.Count >= 2) { star.planets[finalIndex].HasMultipleSatellites(); } Patch.Debug(star.planets[finalIndex].name, LogLevel.Debug, Patch.DebugStarNamingGen); finalIndex++; //debugLine += planet.ToString() + "\n\n"; if (planet.moons.Count != 0) { debugLine += "with " + planet.moons.Count + " Moons : \n\n"; foreach (var moon in planet.moons) { moon.planetIndex = finalIndex; debugLine += " Moon : " + moon.planetIndex + "\n"; PlanetGen.CreatePlanet(galaxy, star, gameDesc, moon.planetIndex, moon.orbitAround, moon.orbitIndex, moon.number, moon.isGasGiant, moon.infoSeed, moon.genSeed); star.planets[moon.planetIndex].name = planet.name + " - " + RomanNumbers.roman[moon.number]; Patch.Debug(star.planets[moon.planetIndex].name, LogLevel.Debug, Patch.DebugStarNamingGen); finalIndex++; } } Patch.Debug(debugLine, LogLevel.Debug, Patch.DebugStarGen); } }
public static void RepairBirthIds(ref GalaxyData galaxy) { // Repair bad birth star if (galaxy.birthStarId == 0) { galaxy.birthStarId = 1; Debug.LogWarning($"alternatestart -- WARNING: Reassigned birth star id to {galaxy.birthStarId}"); } // Repair bad birth planet if (galaxy.birthPlanetId == 0) { StarData birthStar = galaxy.StarById(galaxy.birthStarId); for (int i = 0; i < birthStar.planets.Length; i++) { // Pick the first or only ocean planet if (birthStar.planets[i].type == EPlanetType.Ocean) { galaxy.birthPlanetId = birthStar.planets[i].id; Debug.LogWarning($"alternatestart -- WARNING: Reassigned birth planet id to {galaxy.birthPlanetId}"); } } if (galaxy.birthPlanetId == 0) { // Panic and choose any valid planet int?newBirthPlanet = birthStar.planets.FirstOrDefault(x => x.type != EPlanetType.Gas).id; if (newBirthPlanet == null) { throw new Exception("Alternatestart: No birth planet or candidates for birth planet found."); } galaxy.birthPlanetId = (int)newBirthPlanet; Debug.LogError($"alternatestart -- DANGER: Reassigned birth planet id to non-ocean planet {galaxy.birthPlanetId}"); } } }
public static bool CreateBirthStar(GalaxyData galaxy, int seed) { int gSize = galaxy.starCount > 64 ? galaxy.starCount * 4 * 100 : 25600; galaxy.astroPoses = new AstroPose[gSize]; return(true); }
public SetupState(StateManager managerRef) { manager = managerRef; gData = GameObject.Find("GameManager").GetComponent <GalaxyData>(); gameData = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); Debug.Log("In SetupState"); }
public SetupState(StateManager managerRef) { manager = managerRef; gData = GameObject.Find("GameManager").GetComponent<GalaxyData>(); gameData = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); Debug.Log("In SetupState"); }
//GalaxySeed = 14171500; //StarSeed = 1826783713 static void Main() { DateTime StartTime = DateTime.Now; GameDesc gameDesc = new GameDesc { starCount = 64 }; ThemeProtoSet themes = ThemeWorks.GetThemes(); int length = themes.dataArray.Length; gameDesc.themeIds = new int[length]; ParallelOptions options = new ParallelOptions(); options.MaxDegreeOfParallelism = 50; for (int index = 0; index < length; ++index) { gameDesc.themeIds[index] = themes.dataArray[index].ID; } int StartSeed = 73295657; int EndSeed = 73295657; Parallel.For( StartSeed, EndSeed + 1, options, (i, loopState) => { System.Console.WriteLine("StartLoop " + i.ToString("D8")); gameDesc.galaxySeed = i; MUniverseGen MUniverseGen = new MUniverseGen(); GalaxyData galaxyData = MUniverseGen.CreateGalaxy(gameDesc); System.Console.WriteLine("Seed: " + galaxyData.seed.ToString("D8") + " BirthStar: " + galaxyData.stars[0].displayName); } ); //for (int i = StartSeed; i < EndSeed+1; i++) //{ // gameDesc.galaxySeed = i; // GalaxyData galaxyData = MUniverseGen.CreateGalaxy(gameDesc); // System.Console.WriteLine("Seed: " + galaxyData.seed.ToString("D8") + " BirthStar: "+galaxyData.stars[0].displayName); // //System.Console.WriteLine("START: " + galaxyData.stars[0].displayName); // //System.Console.WriteLine("BH: " + galaxyData.stars[63].displayName); // //System.Console.WriteLine("BH: " + galaxyData.stars[63].position.magnitude); //} DateTime EndTime = DateTime.Now; System.Console.WriteLine("Finished"); Console.WriteLine("Time Used: " + EndTime.Subtract(StartTime).TotalSeconds + "Seconds"); Console.WriteLine("Seed Calculated: " + (EndSeed - StartSeed + 1)); System.Console.ReadLine(); }
// Use this for initialization void Start() { gData = GameObject.Find("GameManager").GetComponent <GalaxyData>(); gameData = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); planetsGenerated = GameObject.Find("Planets Generated").GetComponent <Text>(); housesGenerated = GameObject.Find("Houses Generated").GetComponent <Text>(); charactersGenerated = GameObject.Find("Characters Generated").GetComponent <Text>(); }
// Use this for initialization void Start() { gData = GameObject.Find("GameManager").GetComponent<GalaxyData>(); gameData = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); planetsGenerated = GameObject.Find("Planets Generated").GetComponent<Text>(); housesGenerated = GameObject.Find("Houses Generated").GetComponent<Text>(); charactersGenerated = GameObject.Find("Characters Generated").GetComponent<Text>(); }
public void Load() { Debug.Log("Loading data"); galaxyData = SaveGame.Load <GalaxyData>(identifier, new GalaxyData()); Debug.Log("Loaded stars: " + galaxyData.starData.Count); galaxy.GetComponent <Galaxy.Galaxy>().BuildGalaxyFromData(galaxyData.starData); }
public static PlanetData GetPlanet(string ID) { GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); PlanetData pData = new PlanetData(); pData = galaxyDataRef.GalaxyPlanetDataList.Find(p => p.ID == ID); return(pData); }
public static StarData GetSystem(string ID) { GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); StarData sData = new StarData(); sData = galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == ID); return(sData); }
public static Province GetProvince(string ID) { GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); Province prov = new Province(); prov = galaxyDataRef.ProvinceList.Find(p => p.ID == ID); return(prov); }
public static Region GetRegion(string ID) { GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); Region rData = new Region(); rData = galaxyDataRef.GalaxyRegionDataList.Find(p => p.ID == ID); return(rData); }
public void GenerateEntities() { data = GameDataManager.instance.masterGalaxyData; GameDataManager.instance.ClearAllEntities(); GameDataManager.instance.ClearAllSpecies(); string[] speciesNames = MarkovGenerator.GenerateMarkovWord(StringLoader.GetAllStrings("SpeciesButterfly"), numberOfSpecies); for (int i = 0; i < numberOfSpecies; i++) { GameDataManager.instance.AddNewSpecies(SpeciesGenerator.GetSpecies(speciesNames[i])); } for (int i = 0; i < data.sectors.Length; i++) { for (int j = 0; j < data.sectors[0].Length; j++) { if (data.sectors[i][j].Owner == null && data.sectors[i][j].SystemCount > 0) { unoccupiedSectors.Add(data.sectors[i][j]); } } } List <List <SectorData> > partitions = GenerateSectorPartitions(unoccupiedSectors); string[] entityNames = MarkovGenerator.GenerateMarkovWord(StringLoader.GetAllStrings("StarNames"), partitions.Count); for (int i = 0; i < partitions.Count; i++) { float averageSystem = 0; float maxSystem = 0; float minSystem = 10000; float sumOfSquares = 0; foreach (SectorData d in partitions[i]) { averageSystem += d.SystemCount; sumOfSquares += d.SystemCount * d.SystemCount; if (d.SystemCount > maxSystem) { maxSystem = d.SystemCount; } if (d.SystemCount < minSystem) { minSystem = d.SystemCount; } } float totalSystem = averageSystem; averageSystem = averageSystem / partitions[i].Count; float sumOfSquaresAverage = sumOfSquares / partitions[i].Count; float standardDeviation = Mathf.Sqrt(sumOfSquaresAverage - (averageSystem * averageSystem)); Debug.Log("Total System:" + totalSystem + " averageSystem:" + averageSystem + " minSystem:" + minSystem + " maxSystem:" + maxSystem + " stdDeviation:" + standardDeviation); GalaxyEntity g = GetEntity(partitions[i]); g.name = entityNames[i]; Debug.Log(g.leader.FullName + " " + g.Government.governmentName + " " + g.Government.governmentCatagory); GameDataManager.instance.AddNewEntity(g); } entityList.Display(GameDataManager.instance.Entitites); speciesList.Display(GameDataManager.instance.Species); WorldMap.instance.ShowTerritory(); }
void Start() { // initialize state machine and managers activeState = new BeginState(this); galaxyDataRef = GetComponent <GalaxyData>(); // gets the galaxy data script containing the data structure gameDataRef = GetComponent <GlobalGameData>(); // gets global game data (screens, etc) that are used universally Debug.Log("This object is of type: " + activeState); }
public static void CreateGalaxy_Postfix(GameDesc gameDesc, GalaxyData __result) { if (Multiplayer.IsActive && UIVirtualStarmap_Transpiler.customBirthStar != -1) { Debug.Log("Overwriting with " + __result.PlanetById(UIVirtualStarmap_Transpiler.customBirthPlanet) + " and " + __result.StarById(UIVirtualStarmap_Transpiler.customBirthStar)); __result.birthPlanetId = UIVirtualStarmap_Transpiler.customBirthPlanet; __result.birthStarId = UIVirtualStarmap_Transpiler.customBirthStar; } }
public static List <StarData> GetProvinceSystems(string ID) { GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); StarData sData = new StarData(); List <StarData> sDataList = new List <StarData>(); sDataList = galaxyDataRef.GalaxyStarDataList.FindAll(p => p.AssignedProvinceID == ID); return(sDataList); }
void Start() { // initialize state machine and managers activeState = new BeginState(this); galaxyDataRef = GetComponent<GalaxyData>(); // gets the galaxy data script containing the data structure gameDataRef = GetComponent<GlobalGameData>(); // gets global game data (screens, etc) that are used universally Debug.Log("This object is of type: " + activeState); }
public static void CreateBirthStar(ref GalaxyData galaxy, int seed, ref StarData __result) { //var x = LDB.veges; //foreach (VegeProto vege in x.dataArray) { // Debug.LogWarning($"{vege.ID} {vege.Name.ToString().Translate()} {vege.Type}"); //} //foreach (ThemeProto theme in LDB.themes.dataArray) { // Debug.LogWarning($"{theme.ID} name:{theme.DisplayName.ToString().Translate()} type:{theme.PlanetType} ocean:{theme?.oceanMat?.name?.ToString()?.Translate()}"); //} }
private void Start() { buldgeCountInput.onSubmit.AddListener(GetValuesFromFields); armCountInput.onSubmit.AddListener(GetValuesFromFields); numberOfArmsInput.onSubmit.AddListener(GetValuesFromFields); armWindingInput.onSubmit.AddListener(GetValuesFromFields); armWidthInput.onSubmit.AddListener(GetValuesFromFields); GetValuesFromFields(); data = GameDataManager.instance.masterGalaxyData; }
public static void Patch(ref UIGalaxySelect __instance, GalaxyData galaxy) { if (__instance.starCountSlider.minValue != desiredMinStars) { __instance.starCountSlider.minValue = desiredMinStars; } if (__instance.starCountSlider.maxValue != desiredMaxStars) { __instance.starCountSlider.maxValue = desiredMaxStars; } }
public static bool CreateStarPlanets(GalaxyData galaxy, StarData star, GameDesc gameDesc) { if (Patch.EnableCustomStarAlgorithm.Value) { // InnerCount for the System ReworkStarGen.CreateStarPlanetsRework(galaxy, star, gameDesc, new PlanetGeneratorSettings()); return(false); } return(true); }
private void InitializeGalaxyData() { var galaxyData = new GalaxyData(); galaxyData.Name = "Sefardim"; var ssg = new StarSystemGenerator(galaxyData); var starSystem = ssg.GenerateStarSystem(GameState.PlayerData.SpaceShipData.GridPosition); galaxyData.StarSystems.Add(starSystem.Position, starSystem); GameState.GalaxyData = galaxyData; }
public void Initialize() { if (instance == null) { instance = this; } else { Debug.LogError("You've put another GameDataManager somewhere"); } masterGalaxyData = new GalaxyData(); }
private static void findStar(GalaxyData g, string s) { resDate.Clear(); foreach (var d in g.stars) { if (d.name.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) > -1) { resDate.Add(d.name, d); } } rect.height = 220 + resDate.Count * 20; }
void Start() { // data structure references gData = GameObject.Find("GameManager").GetComponent <GalaxyData>(); gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); //DataManager.PopulateObjectNameLists(); // populate the name lists once! galaxySizeWidth = gameDataRef.GalaxySizeWidth; // these will be selected in new game screen galaxySizeHeight = gameDataRef.GalaxySizeHeight; GenerateNebulas(); GenerateStars(); GeneratePlanets(); }
public static void DeletePlanet(this GalaxyData galaxy, int planetId, bool updateChildren) { var target = galaxy.PlanetById(planetId); if (target != null) { target.star.DeletePlanet(target, updateChildren); return; } Debug.LogWarningFormat("No planet with ID {0} found in galaxy", planetId); }
public static StarData GetCivHomeSystem(Civilization civ) { GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>(); GalaxyData galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>(); PlanetData pData = new PlanetData(); StarData sData = new StarData(); pData = galaxyDataRef.GalaxyPlanetDataList.Find(p => p.ID == civ.CapitalPlanetID); sData = galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == pData.SystemID); return(sData); }
public Galaxy(GalaxyData data) { solarSystems = new List <SolarSystem>(); foreach (var ssData in data.solarSystems) { var ss = new SolarSystem(ssData, this); AddSolarSystem(ss); } foreach (SolarSystem ss in solarSystems) { ss.LoadLinks(); } }
private static bool Free(GalaxyData __instance) { foreach (StarData star in __instance.stars) { foreach (PlanetData planet in star.planets) { if (planet.loading) { Debug.Log("由StarMapTools阻止的GalaxyData.Free()"); return(false); } } } return(true); }
public static Civilization CreateNewCivilization() { List<String> civNameList = DataManager.civNameList; // populate the color list if needed if (civColorList.Count == 0) PopulateCivColorList(); Civilization newCiv = new Civilization(); int dieRoll = 0; galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); // access galaxy data gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // access galaxy data // Step 1: Generate type of civ dieRoll = UnityEngine.Random.Range(1, 7); newCiv.Type = (Civilization.eCivType)dieRoll; // cast to enum // Step 2: Generate ID of civ newCiv.ID = "CIV" + gameDataRef.CivList.Count.ToString("N0"); // Step 2: Generate name of civ string primaryName = ""; string surName = ""; if (civNameList.Count > 0) { var nameIndex = UnityEngine.Random.Range(0, civNameList.Count); primaryName = civNameList[nameIndex]; civNameList.RemoveAt(nameIndex); civNameList.TrimExcess(); } else primaryName = "GenericName"; var surNameIndex = UnityEngine.Random.Range(0, DataManager.civSurNameList.Count); surName = DataManager.civSurNameList[surNameIndex]; newCiv.Name = primaryName + " " + surName; // Step 3: Generate other base stats (treasury, size, etc) // size/range newCiv.Range = 40; // to start with int size = UnityEngine.Random.Range(0, 100); // adjust size/other ratings for civ type switch(newCiv.Type) { case Civilization.eCivType.Confederation : { size += 55; break; } case Civilization.eCivType.MinorEmpire: { size += 40; break; } case Civilization.eCivType.Satrapy: { size += 20; break; } case Civilization.eCivType.BrokenCivilization: { size -= 30; break; } case Civilization.eCivType.Pirates: { size -= 15; break; } } // add a empire type mod here if (size < 40) newCiv.Size = Civilization.eCivSize.SinglePlanet; else if (size < 70) newCiv.Size = Civilization.eCivSize.Local; else if (size < 90) { newCiv.Size = Civilization.eCivSize.Minor; newCiv.Range = UnityEngine.Random.Range(MultiSystemEmpireRange - 200, MultiSystemEmpireRange + 200); } else { newCiv.Size = Civilization.eCivSize.Major; newCiv.Range = UnityEngine.Random.Range(MultiRegionEmpireRange - 400, MultiRegionEmpireRange + 400); } // skill ratings newCiv.FarmingBaseRating = UnityEngine.Random.Range(70, 100) - (int)newCiv.Type * 10; newCiv.MiningBaseRating = UnityEngine.Random.Range(50, 90) - (int)newCiv.Type * 10; newCiv.ScienceBaseRating = UnityEngine.Random.Range(0, 50) + (int)newCiv.Type * 10; newCiv.HighTechBaseRating = UnityEngine.Random.Range(0, 40) + (int)newCiv.Type * 10; newCiv.ManufacturingBaseRating = UnityEngine.Random.Range(5, 50) + (int)newCiv.Type * 10; // tolerance newCiv.PlanetMinTolerance = UnityEngine.Random.Range(40, 60); // sets the base minimum habitable world a civilization is willing to tolerate // province size if (newCiv.Size == Civilization.eCivSize.Major) { newCiv.CivMaxProvinceSize = UnityEngine.Random.Range(1, 6); // sets a province size between 1 and 5 systems newCiv.AdminRating = UnityEngine.Random.Range(5, 21); // generates the civ's base admin rating (how efficient they are in adminstering provinces } else { newCiv.CivMaxProvinceSize = 0; // no provinces can be created; the civ is essentially one province newCiv.AdminRating = 1; } // admin rating // Step 4: Determine planet of origin retryPlanet: // beginning of retry loop PlanetData civPlanet = new PlanetData(); dieRoll = UnityEngine.Random.Range(0, galaxyDataRef.GalaxyPlanetDataList.Count); // find the planets in the quadrant civPlanet = galaxyDataRef.GalaxyPlanetDataList[dieRoll]; if (galaxyDataRef.GalaxyPlanetDataList[dieRoll].AdjustedBio < newCiv.PlanetMinTolerance) // if the bio is too low, throw it out goto retryPlanet; if (gameDataRef.CivList.Count > 0) { foreach (Civilization civ in gameDataRef.CivList) { List<StarData> populatedHomeSystems = new List<StarData>(); populatedHomeSystems = HelperFunctions.DataRetrivalFunctions.GetCivSystemList(civ); if (civPlanet.ID == civ.CapitalPlanetID) // check for capital world goto retryPlanet; if (civ.PlanetIDList.Exists(p => p == civPlanet.ID)) // then all other worlds goto retryPlanet; if (newCiv.ID != civ.ID) if (populatedHomeSystems.Exists(p => p.ID == civPlanet.SystemID)) // check for systems that other civs have claimed goto retryPlanet; } // assign a name for the civ's planet if (DataManager.planetNameList.Count > 0) { var nameIndex = UnityEngine.Random.Range(0, DataManager.planetNameList.Count); civPlanet.Name = DataManager.planetNameList[nameIndex]; DataManager.planetNameList.RemoveAt(nameIndex); DataManager.planetNameList.TrimExcess(); } else civPlanet.Name = "GenericName"; // set as capital and send to assign pops, developments, etc. newCiv.CapitalPlanetID = civPlanet.ID; ClaimCivPlanet(civPlanet, newCiv); civPlanet.Rank = PlanetData.ePlanetRank.ImperialCapital; newCiv.PlanetIDList.Add(civPlanet.ID); // add the planet } // Step 5: Determine additional planets if (newCiv.Size != Civilization.eCivSize.SinglePlanet) ClaimPlanetsForCiv(newCiv); // Step 5: Generate color of civ retryColor: // beginning of retry loop Color civColor = new Color(); civColor = new Color(UnityEngine.Random.Range(.01f, .99f), UnityEngine.Random.Range(.01f, .99f), UnityEngine.Random.Range(.01f, .99f)); // select a random color if (gameDataRef.CivList.Count > 0) { foreach (Civilization civ in gameDataRef.CivList) { if (civColor == civ.Color) goto retryColor; } newCiv.Color = civColor; } return newCiv; }
public static void GenerateNebula() { NebulaData nData = new NebulaData(); galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // Step 1: Generate name if (DataManager.planetNameList.Count > 0) { var nameIndex = UnityEngine.Random.Range(0, DataManager.planetNameList.Count); nData.Name = DataManager.planetNameList[nameIndex] + " Nebula"; DataManager.planetNameList.RemoveAt(nameIndex); DataManager.planetNameList.TrimExcess(); } else nData.Name = "GenericName"; // Step 2: Set location nData.WorldLocation = new Vector3(UnityEngine.Random.Range(-gameDataRef.GalaxySizeWidth,gameDataRef.GalaxySizeWidth), UnityEngine.Random.Range(-gameDataRef.GalaxySizeHeight, gameDataRef.GalaxySizeHeight), UnityEngine.Random.Range(-25,-75)); // set slightly back of X axis for parallax effect // Step 3: Assign sprite # nData.NebulaSpriteNumber = UnityEngine.Random.Range(0, SpritesPerNebulaType - 1); // Step 4: Generate size nData.NebulaSize = UnityEngine.Random.Range(.5f, 1.5f); // Step 5: Assign rotation switch (nData.NebulaSpriteNumber) { case 0: { nData.TextRotation = -55f; break; } case 1: { nData.TextRotation = -55f; break; } case 2: { nData.TextRotation = 45f; break; } case 3: { nData.TextRotation = -55f; break; } case 4: { nData.TextRotation = -60f; break; } default: { nData.TextRotation = 0f; break; } } // Step 6: Assign the data galaxyDataRef.AddStellarPhenonomaDataToList(nData); }
void Awake() { gDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); // set the reference planetUICanvas = GameObject.Find("Planet UI Canvas").GetComponent<Canvas>(); uiCamera = GameObject.Find("UI Camera").GetComponent<Camera>(); }
void Start() { galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); mainCamera = GameObject.Find("Main Camera").GetComponent<Camera>(); gStyle = new GUIStyle(); maxZoomLevel = 3500f; backingSphere.SetActive(false); starmapSprite.transform.localScale = new Vector3((gameDataRef.GalaxySizeWidth / 6.5f), (gameDataRef.GalaxySizeWidth / 6.5f), 1); // scale the galaxy based on the size of the galaxy // set canvas as inactive depending on mode (will move to helper UI state script eventually) systemUICanvas.SetActive(false); selectedUnitInfoCanvas.SetActive(false); }
// Use this for initialization void Start() { galDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); gDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // run 4 times before first turn to maximize for (int x = 0; x < 4; x++) { foreach (Civilization civ in gDataRef.CivList) { UpdatePlanets(civ); CheckForMigration(civ); // check for intraplanet migration MigratePopsBetweenPlanets(civ); // and if there are any pops who want to leave, check for where } } UpdateTrades(); UpdateEmperor(); gDataRef.UpdateGameDate(); gDataRef.RequestGraphicRefresh = true; }
void Awake() { gDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); // set the reference galCameraRef = GameObject.Find("Main Camera").GetComponent<GalaxyCameraScript>(); toolTipOriginalLocation = TooltipItem.transform.localPosition; }
void Awake() { gDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); // set the reference galCameraRef = GameObject.Find("Main Camera").GetComponent<GalaxyCameraScript>(); }
void Start() { // data structure references gData = GameObject.Find("GameManager").GetComponent<GalaxyData>(); gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); //DataManager.PopulateObjectNameLists(); // populate the name lists once! galaxySizeWidth = gameDataRef.GalaxySizeWidth; // these will be selected in new game screen galaxySizeHeight = gameDataRef.GalaxySizeHeight; GenerateNebulas(); GenerateStars(); GeneratePlanets(); }
// this 'flags' planets to seed with pops in the next step public static void ClaimPlanetsForCiv(Civilization newCiv) { gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); float civMaxDistance = newCiv.Range; PlanetData homePlanet = galaxyDataRef.GalaxyPlanetDataList.Find(p => p.ID == newCiv.CapitalPlanetID); StarData homeStar = galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == homePlanet.SystemID); List<StarData> eligibleSystems = new List<StarData>(); foreach (StarData star in galaxyDataRef.GalaxyStarDataList) { float distance = HelperFunctions.Formulas.MeasureDistanceBetweenSystems(star, homeStar); if ( distance <= civMaxDistance) // must be within range and also include the home system eligibleSystems.Add(star); // add systems that are close to the home star } // // now check planets in those systems to see if they can be owned foreach (StarData potStar in eligibleSystems) { foreach(PlanetData pData in potStar.PlanetList) { if (pData.AdjustedBio >= newCiv.PlanetMinTolerance) { bool planetEligible = true; foreach (Civilization civ in gameDataRef.CivList) // check each civ to make sure they don't own the planet { if (civ.PlanetIDList.Exists (p => p == pData.ID)) planetEligible = false; if (pData.ID == homePlanet.ID) planetEligible = false; if (pData.AdjustedMaxHabitableTiles == 0) // if after traits there are no tiles to put people on, it's not a good planet! planetEligible = false; } if (planetEligible) // if they don't, then claim! ClaimCivPlanet(pData,newCiv); } } } }
void Start() { gData = GameObject.Find("GameManager").GetComponent<GalaxyData>(); gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // now generate civilizations GenerateHumanCiv(); GenerateAICivs(); GenerateCommonHouses(); // generate houses GenerateHouseStats(); // generate the other house status GenerateCharacters(); // generate characters for the global pool GenerateCivLeaders(); AssignHouses(); // assign houses GenerateRelationships(); // determine everyone's relationship to everyone else GenerateProvinces(); // generate provinces for each civilization DetermineSystemCapitals(); GenerateStellarObjectLeaders(); // test; put back after generate primes if needed GenerateInfrastructure(); SetPlanetTaxes(); GeneratePrimes(); GeneratePlanetIntelLevels(gameDataRef.CivList.Find(p => p.HumanCiv == true)); gameDataRef.CivsGenerated = true; // sends flag to move to the galaxy screen }
// Use this for initialization void Start() { gData = GameObject.Find("GameManager").GetComponent<GalaxyData>(); Debug.Log("Drawing stars..."); DrawStars(); // draw the star map DrawNebulas(); }
public static void GeneratePlanetRegions(PlanetData cPlan) { galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); List<int> tileNumberList = new List<int>(); // for the uninhabitable tiles List<Region> tempTileList = new List<Region>(); cPlan.RegionList.Clear(); // remove any old tiles for (int x = 0; x < cPlan.MaxTiles; x++) { Region newTile = new Region(); // create temp tile newTile.IsHabitable = true; // determine region type int[] tRegions = DataManager.planetAttributeDataList.Find(p => p.planetType == cPlan.Type).planetTraitsTable.validRegions; int typeChoice = tRegions[UnityEngine.Random.Range(0, tRegions.GetLength(0))]; newTile.RegionType = regionTypeDataList[typeChoice]; // finish the tile based on region type newTile.ID = cPlan.ID + "TILE" + x.ToString("N0"); newTile.BioRating = (int)(UnityEngine.Random.Range((int)(cPlan.AdjustedBio / 1.5f),(int)(cPlan.AdjustedBio * 1.5f)) * newTile.RegionType.BioMod); newTile.EnergyRating = (int)(UnityEngine.Random.Range((int)(cPlan.Energy / 1.5f), (int)(cPlan.Energy * 1.5f)) * newTile.RegionType.MineralMod); newTile.HeavyRating = (int)(UnityEngine.Random.Range((int)(cPlan.HeavyMaterials / 1.5f), (int)(cPlan.HeavyMaterials * 1.5f)) * newTile.RegionType.MineralMod); newTile.AlphaRating = (int)(UnityEngine.Random.Range((int)(cPlan.BasicMaterials / 1.5f), (int)(cPlan.BasicMaterials * 1.5f)) * newTile.RegionType.MineralMod); newTile.RareRating = (int)(UnityEngine.Random.Range((int)(cPlan.RareMaterials / 1.5f), (int)(cPlan.RareMaterials * 1.5f)) * newTile.RegionType.MineralMod); newTile.MaxDevelopmentLevel = (int)(newTile.BioRating / 4); // 25% of bio rating for tile newTile.CurLevel = 0; // new tile newTile.PlanetLocationID = cPlan.ID; // assign the planet's ID to the region to allocate during loading // now add to the temp list tempTileList.Add(newTile); } foreach (Region reg in tempTileList) { if (reg.BioRating == 0) { reg.IsHabitable = false; reg.MaxDevelopmentLevel = 0; } } // finally add the tiles to the respective lists for (int x = 0; x < tempTileList.Count; x++) { cPlan.RegionList.Add(tempTileList[x]); galaxyDataRef.AddTileToList(tempTileList[x]); } }