public void StartGame() { OnStartGame.Invoke(); Time.timeScale = 1; GameInProgress = true; BertController.Instance.Reset(); EnvironmentSpawner.Reset(); }
override public IEnumerator Start() { yield return(null); Initialize(); EnvironmentSpawner environment = FindObjectOfType <EnvironmentSpawner>(); if (environment != null && environment.CurrentEnvironment != null) { OnSpawn(environment.CurrentEnvironment); } }
public void GenerateMap() { var startTime = DateTime.Now; var points = GetPoints(); var time = DateTime.Now; var voronoi = new Delaunay.Voronoi(points, null, new Rect(0, 0, meshSize, meshSize)); Debug.Log(string.Format("Voronoi Generated: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); time = DateTime.Now; heightMapSettings.noiseSettings.seed = seed; var heightMap = HeightMapGenerator.GenerateHeightMap(meshSize, meshSize, heightMapSettings, Vector2.zero); Debug.Log(string.Format("Heightmap Generated: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); time = DateTime.Now; var mapGraph = new MapGraph(voronoi, heightMap, snapDistance); Debug.Log(string.Format("Finished Generating Map Graph: {0:n0}ms with {1} nodes", DateTime.Now.Subtract(time).TotalMilliseconds, mapGraph.nodesByCenterPosition.Count)); time = DateTime.Now; MapGenerator.GenerateMap(mapGraph); Debug.Log(string.Format("Map Generated: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); time = DateTime.Now; OnMeshDataReceived(MapMeshGenerator.GenerateMesh(mapGraph, meshSize)); Debug.Log(string.Format("Mesh Generated: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); time = DateTime.Now; var texture = MapTextureGenerator.GenerateTexture(mapGraph, meshSize, textureSize, colours, drawNodeBoundries, drawDelaunayTriangles); Debug.Log(string.Format("Texture Generated: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); UpdateTexture(texture); time = DateTime.Now; EnvironmentSpawner.Spawn(mapGraph, GameObject.Find("Environment").transform, environmentSettings, seed); Debug.Log(string.Format("Environment Spawned: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); time = DateTime.Now; AnimalSpawner.Spawn(mapGraph, GameObject.Find("Animals").transform, animalSettings, seed); Debug.Log(string.Format("Animals Spawned: {0:n0}ms", DateTime.Now.Subtract(time).TotalMilliseconds)); Debug.Log(string.Format("Finished Generating World: {0:n0}ms with {1} nodes", DateTime.Now.Subtract(startTime).TotalMilliseconds, mapGraph.nodesByCenterPosition.Count)); }
void Awake() { // Assign References playerRbody2D = player.GetComponent <Rigidbody2D>(); envSpawner = GetComponent <EnvironmentSpawner>(); }
internal void SetObjectToDestroy(EnvironmentSpawner environmentInitializer) { LastEnvironment = environmentInitializer; }
void Init() { map_manager = GetComponent <MapManager>(); enemySpawner = GetComponent <EnemySpawner>(); environmentSpawner = GetComponent <EnvironmentSpawner>(); tileSelector = GameObject.FindGameObjectWithTag("Selector").GetComponent <TileSelector>(); map_manager.Init(this); tileSelector.Init(map_manager); environmentSpawner.Init(map_manager); turn_manager = GetComponent <TurnManager>(); turn_manager.Init(this); map_manager.spawnChests(randomChest); List <Client> players = Network.getPeers(); List <Pos> spawn_locations = map_manager.findSpawnpoints(players.Count); Pos level_end = spawn_locations[0]; map_manager.instantiate_environment(endportal, level_end, false); Debug.Log("Spawned " + players.Count + " players"); // spawn players for (int i = 0; i < players.Count; i++) { if (players[i].playerObject == null) { Debug.Log(spawn_locations[i + 1] + "," + players.Count); Player instance = map_manager.instantiate(playerPrefab, spawn_locations[i + 1], null, players[i].nickname).GetComponent <Player>(); instance.SetCharacterClass(players[i].classname); players[i].playerObject = instance; if (players[i].ID == NetworkManager.clientID) { localPlayer = instance; } } else { Debug.Log("Respawning player"); map_manager.re_instantiate(players[i].playerObject.gameObject, spawn_locations[i + 1]); } } // spawn enemies if (level % 3 != 0) { enemySpawner.Init(map_manager); } else { map_manager.SPAWN_ILMI_DEVOURER_OF_WORLDS(ilmiPrefab, level / 3); UI_TextAlert.DisplayText("A cold chill goes across your spine...", 1000); } tileSelector.setPlayer(localPlayer); Camera.main.GetComponent <CameraControl>().SetTarget(localPlayer.gameObject); UI_BattleMenu.SetActButtons(localPlayer.getActionNames()); turn_manager.StartLoop(); Network.submitCommand(new ReadyCommand(NetworkManager.clientID)); }
private void Awake() { instance = this; }
public void Spawn(EnvironmentSpawner spawner, Vector3 position) { this.spawner = spawner; this.transform.position = position; }
/// <summary> /// Spawns next environment, and prepares last for destruction /// </summary> /// <param name="source"></param> public void Spawn(EnvironmentSpawner source) { Destroyer.SetObjectToDestroy(source); }