// Update is called once per frame void Update() { //This is really a big, delayed for loop, iterating through all of the //nodes of the streaming map lastUpdate += Time.deltaTime; if (lastUpdate >= updateRate) { lastUpdate = 0.0f; x += runnerStep; if (x >= width) { x = 0; y += runnerStep; if (y >= height) { y = 0; z += runnerStep; if (z >= depth) { z = 0; } } } streamingMap.DrawMap(x, y, z, drawRadius, bypassQueue); } }
void AddPlayerToMap() { player_x = start_player_x; player_y = start_player_y; streamingMap.DrawMap(player_x, player_y, 1, drawRadius, true); //We want to draw the map before we add the player player = GameObject.Instantiate(playerPrefab) as PlatformerPlayer; Vector3 coords = BlockUtilities.GetMathematicalPosition(streamingMap.blockMap, player_x, player_y, 0); player.transform.parent = streamingMap.blockMap.transform; player.transform.localPosition = coords; player.InitializeEntity(streamingMap.blockMap); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (GUILayout.Button("Add Color Profile")) { StreamingMap map = target as StreamingMap; StreamingMapColorProfile mp = map.gameObject.GetComponentInChildren <StreamingMapColorProfile>(); if (mp != null) { Debug.LogWarning("No dice, there's already a color profile attached to the map. Look down a little in the inspector!"); } else { //We add this to a new gameobject to allow the user to create a prefab from this color profile // //In this way, they can transfer color profiles between maps GameObject colorRoot = new GameObject("Color Profile"); colorRoot.transform.parent = map.transform; colorRoot.transform.localPosition = Vector3.zero; mp = colorRoot.AddComponent <StreamingMapColorProfile>(); mp.map = map; Selection.activeGameObject = colorRoot.gameObject; } } if (EditorApplication.isPlaying) { //Warning! This will take a long time for larger maps // //Use this function at your own discretion. It's for debugging purposes ONLY if (GUILayout.Button("Debug: Draw Map")) { StreamingMap map = target as StreamingMap; int radius = map.width; if (radius < map.height) { radius = map.height; } int x = (int)((float)map.width * 0.5f); int y = (int)((float)map.height * 0.5f); map.DrawMap(x, y, 1, radius, true); } } }