private void InitializeDebug(Tribe tribe) { sitesPresent.Add(new Site("Home of DeGnats")); tribesPresent.Add(tribe); tribe.Initialize(); Debug.LogWarning("DEBUG MODE ENABLED"); areaSize = new Vector3(256, 10, 256); allThings = new List <Thing>(); thingContainer = new GameObject("ThingContainer"); creatureContainer = new GameObject("CreatureContainer"); if (disabledContainer == null) { disabledContainer = new GameObject("DisabledContainer"); } for (int i = 0; i < 0; i++) { Vector3 position = new Vector3(Random.Range(10f, 200), Random.Range(3f, 15f), Random.Range(10f, 200)); addThingToWorld("fruit", position, false); } for (int i = 0; i < 200; i++) { Vector3 position = new Vector3(Random.Range(10f, 200), Random.Range(3f, 15f), Random.Range(10f, 200)); addCreatureToWorldDEBUG(BASE_SPECIES.Gnat.ToString(), position, false, tribe); } CreatureUtilities.OptimizeUpdateTimes(allThings); FruitTree[] trees = GameObject.FindObjectsOfType <FruitTree>(); for (int count = 0; count < trees.Length; count++) { AddThingToAllThingsSync(trees[count]); trees[count].initialize("FruitTree"); } Debug.LogWarning("Updates balanced"); }
public void Initialize(Tribe tribe) { if (debug) // DEBUG { InitializeDebug(tribe); return; } areaSize = world.masterTerrain.GetSize(); for (int count = 0; count < walls.Length; count++) { walls[count] = GameObject.Instantiate(RAKUtilities.getWorldPrefab("Wall"), null); walls[count].transform.GetChild(0).localScale = new Vector3(areaSize.x, 256, 1); } walls[0].transform.position = new Vector3(areaSize.x / 2, 128, 1); walls[1].transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0)); walls[1].transform.position = new Vector3(0, 0, areaSize.z / 2); walls[2].transform.position = new Vector3(areaSize.x / 2, 0, areaSize.z); walls[3].transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0)); walls[3].transform.position = new Vector3(areaSize.x, 0, areaSize.z / 2); if (thingContainer == null) { thingContainer = new GameObject("ThingContainer"); } if (creatureContainer == null) { creatureContainer = new GameObject("CreatureContainer"); } if (disabledContainer == null) { disabledContainer = new GameObject("DisabledContainer"); } allThings = new List <Thing>(); // Scan the TerrainObjects placed in map for Things // foreach (RAKTerrain terrain in world.masterTerrain.getTerrain()) { foreach (RAKTerrainObject terrainObject in terrain.nonTerrainObjects) { Thing thing = terrainObject.gameObject.GetComponent <Thing>(); if (thing != null) { allThings.Add(thing); thing.initialize(thing.name); } } } int populationToCreate = tribe.GetPopulation(); int MAXPOP = 100; if (populationToCreate > MAXPOP) { populationToCreate = MAXPOP; } Debug.LogWarning("Generating a population of - " + populationToCreate); for (int count = 0; count < populationToCreate; count++) { addCreatureToWorld("Gnat"); } }
private void Awake() { ISDEBUGSCENE = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.ToLower().Contains("debug"); if (ISDEBUGSCENE && !_initialized) { InitializeDebugWorld(); return; } world = this; FollowCamera = this.followCamera; WORLD_DATAPATH = Application.persistentDataPath + "/Worlds/"; if (!Directory.Exists(WORLD_DATAPATH)) { Directory.CreateDirectory(WORLD_DATAPATH); } worldType = WorldType.CLASSM; worldName = "AlphaWorld"; tribes = new Dictionary <HexCell, Tribe>(); civilizations = new List <Civilization>(); civilizations.Add(new Civilization(BASE_SPECIES.Gnat, "DaGnats", true, 5, 15)); HexMetrics.Initialize(worldType); hexGrid = HexGrid.generate(this); mapCam.grid = hexGrid; //masterTerrain = GetComponent<RAKTerrainMaster>(); if (editing) { editor = Instantiate(RAKUtilities.getWorldPrefab("HexMapEditor")).GetComponent <HexMapEditor>(); } for (int count = 0; count < NUMBEROFSTARTINGCIVS; count++) { Tribe tribe = new Tribe(1200, BASE_SPECIES.Gnat); HexCell cell = tribe.FindHome(this, true); //civilizations[0].AddTribe(tribe); addTribe(tribe, cell); } hexGrid.RefreshAllChunks(); mainMenu = new MenuController(creatureBrowserPrefab, worldBrowserPrefab, debugMenuPrefab); if (AutoLoadArea) { HexCell autoLoadCell = hexGrid.GetCell(new Vector3(0, 0, 0)); LoadArea(autoLoadCell); mainMenu.Initialize(RootMenu.CreatureBrowser); } else { mainMenu.Initialize(RootMenu.WorldBrowser); } _initialized = true; }
public void LoadArea(HexCell cell) { masterTerrain.Initialize(this, cell); hexGrid.gameObject.SetActive(false); Tribe tribe = tribes[cell]; if (tribe != null) { CurrentArea = cell.MakeArea(this, tribe); tribe.Initialize(); } else { Debug.LogError("Civ is null during area load"); } MenuController.ChangeMenu(RootMenu.CreatureBrowser); }
private void InitializeDebugWorld() { civilizations = new List <Civilization>(); civilizations.Add(new Civilization(BASE_SPECIES.Gnat, "DaGnats", true, 5, 15)); Tribe debugTribe = new Tribe(5, BASE_SPECIES.Gnat); //civilizations[0].AddTribe(debugTribe); Debug.LogWarning("DEBUG MODE ENABLED"); world = this; worldType = WorldType.CLASSM; worldName = "DebugWorld"; tribes = new Dictionary <HexCell, Tribe>(); HexMetrics.Initialize(worldType); hexGrid = HexGrid.generate(this); currentCell = debugTribe.FindHome(this, true); masterTerrain.Initialize(this, currentCell); CurrentArea = currentCell.MakeArea(this, debugTribe); MenuController menuController = new MenuController(creatureBrowserPrefab, worldBrowserPrefab, debugMenuPrefab); FollowCamera = followCamera; menuController.Initialize(RootMenu.CreatureBrowser); _initialized = true; }
private void addCreatureToWorldDEBUG(string nameOfPrefab, Vector3 position, bool generatePosition, Tribe tribe) { GameObject thingObject = RAKUtilities.getCreaturePrefab(nameOfPrefab); GameObject newThing = Object.Instantiate(thingObject); newThing.transform.SetParent(creatureContainer.transform); newThing.GetComponent <Creature>().Initialize(nameOfPrefab, this, tribe); newThing.transform.localPosition = Vector3.zero; newThing.transform.rotation = Quaternion.identity; if (!generatePosition) { newThing.transform.position = position; } else { float x = Random.Range(0, areaSize.x); float z = Random.Range(0, areaSize.z); Vector2 targetSpawn = new Vector2(x, z); float y = world.masterTerrain.GetTerrainHeightAt(targetSpawn, GetClosestTerrainToPoint(targetSpawn)); newThing.transform.position = new Vector3(x, y, z); } AddThingToAllThingsSync(newThing.GetComponent <Thing>()); }
public void addTribe(Tribe tribe, HexCell cell) { tribes.Add(cell, tribe); }
public JobManager(Tribe tribe) { this.tribe = tribe; jobQueue = new List <TribeJob>(); tribeJobPostings = new List <TribeJobPosting>(); }