public void ClearLevel() { Grid.ClearTiles(); Grid.worldsize.x = wordsiz_temp.x; Grid.worldsize.y = wordsiz_temp.y; Grid.Initialize(z_depth); }
void Start() { Grid = GetComponent <s_grid>(); Grid.Initialize(); Player = GameObject.Find("player").GetComponent <o_player>(); GameObject lev = GameObject.Find("Game"); s_levelstructure l = lev.GetComponent <s_levelstructure>(); GameObject ingalev = GameObject.Find("InGame"); ing = ingalev.GetComponent <s_levelstructure>(); List <data_level> lstruct = new List <data_level>(); lstruct = l.levels; if (GameObject.Find("Position") != null) { txt = GameObject.Find("Position").GetComponent <UnityEngine.UI.Text>(); } //Copy all the data from the Editor's to the inGame's foreach (data_level da in lstruct) { ing.levels.Add(da); } levels = ing.levels; //De-references the original levels object so it dosen't get changed. l = null; LoadLevel(); }
private void OnGUI() { x = (int)GUI.HorizontalSlider(new Rect(10, 40, 180, 15), x, 0, Grid.gridworldsize.x); GUI.Label(new Rect(10, 50, 180, 90), "X " + x); y = (int)GUI.HorizontalSlider(new Rect(10, 60 * 2, 180, 15), y, 0, Grid.gridworldsize.y); GUI.Label(new Rect(10, 70 * 2 - 10, 180, 90), "Y " + y); if (GUILayout.Button("NewGrid")) { Grid.groundworldsize.y = y; Grid.groundworldsize.x = x; Grid.Initialize(); } }
void LoadLevel() { Player.worldpos = new Vector3Int( last_player_pos.x * Grid.GetNodeLength, last_player_pos.y * Grid.GetNodeLength, last_player_pos.z * Grid.GetNodeLength); data_level dat = levels[currentLevNum]; Grid.ClearTiles(); Grid.worldsize = new Vector3Int(dat.size_x, dat.size_y, 45); Grid.Initialize(); for (int x = 0; x < Grid.worldsize.x - 1; x++) { for (int y = 0; y < Grid.worldsize.y - 1; y++) { for (int z = 0; z < Grid.worldsize.z - 1; z++) { data_level.data_block blok = dat.blocks.Find(bl => bl.x == x && bl.y == y && bl.z == z); data_level.data_door dr = dat.doors.Find(bl => bl.x == x && bl.y == y && bl.z == z); data_level.data_item it = dat.items.Find(bl => bl.x == x && bl.y == y && bl.z == z); if (blok != null) { o_block block = Grid.SpawnObject(blok.name, new Vector3Int(x, y, z)); } if (dr != null) { o_block block = Grid.SpawnObject(dr.name, new Vector3Int(x, y, z)); o_door door = block.GetComponent <o_door>(); door.location = dr.lev; door.teleport_position = new Vector3Int(dr.tele_x, dr.tele_y, dr.tele_z); door.locked = dr.locked; door.required_waterstones = dr.require; door.DOOR_STATE = (o_door.DOOR_MODE)dr.doortype; } if (it != null) { o_block block = Grid.SpawnObject(it.name, new Vector3Int(x, y, z)); o_item item = block.GetComponent <o_item>(); item.item = it.item; } } } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); s_grid st = (s_grid)target; if (GUILayout.Button("Create Prefabs")) { st.Initialize(); } if (st.ObjectPool != null) { EditorGUILayout.LabelField("Object pooler present."); } else { EditorGUILayout.LabelField("Object pooler not present."); } }
private void Start() { if (GameObject.Find("Position") != null) { txt = GameObject.Find("Position").GetComponent <UnityEngine.UI.Text>(); } cursor = GameObject.Find("Cursor"); left_bar = GameObject.Find("<").GetComponent <Button>(); right_bar = GameObject.Find(">").GetComponent <Button>(); button = GameObject.Find("Brush").GetComponent <Button>(); load_level = GameObject.Find("Load Level").GetComponent <Button>(); inpfeild = GameObject.Find("Level Name").GetComponent <InputField>(); text = button.gameObject.transform.GetChild(0).GetComponent <Text>(); Grid = GetComponent <s_grid>(); Grid.Initialize(); currentblock = Grid.BlockTypes[0]; if (Resources.Load("Game") != null) { LevelStructureLoad(); } }