// Use this for initialization public void SetFaces(ESCell u, ESCell d, ESCell n, ESCell s, ESCell e, ESCell w) { _faces[(int)FACE.UP] = u; _faces[(int)FACE.DOWN] = d; _faces[(int)FACE.NORTH] = n; _faces[(int)FACE.SOUTH] = s; _faces[(int)FACE.EAST] = e; _faces[(int)FACE.WEST] = w; _isInitialized = true; }
public void SetFace(FACE dir, ESCell face) { _faces[(int)dir] = face; foreach (ESCell f in _faces) { if (f == null) { return; } } _isInitialized = true; }
public void SetRoom(Vector3[][] simCells, string type) { for (int x = 0; x < simCells.Length; x++) { for (int z = 0; z < simCells[0].Length; z++) { //Extract volume cell and set volume type Vector3 pos = simCells[x][z]; ESCell cell = GetVolume(pos); cell.SetVolume(ESCell.TYPE.VOLUME); //West - East walls if (x == 0) { cell.SetFace(ESCell.FACE.WEST, ESCell.TYPE.FACE); ESCell westVolume = GetVolume(pos + new Vector3(-1, 0, 0)); if (!IsEmpty(westVolume)) { cell.GetFace(ESCell.FACE.WEST).SetFace(ESCell.FACE.WEST, westVolume); } else { cell.GetFace(ESCell.FACE.WEST).SetFace(ESCell.FACE.WEST, _worldCell.GetFace(ESCell.FACE.WEST)); } } if (x == simCells.Length - 1) { cell.SetFace(ESCell.FACE.EAST, ESCell.TYPE.FACE); } //North - South walls if (z == 0) { cell.SetFace(ESCell.FACE.SOUTH, ESCell.TYPE.FACE); } if (z == simCells[0].Length - 1) { cell.SetFace(ESCell.FACE.NORTH, ESCell.TYPE.FACE); } //Up - Down walls cell.SetFace(ESCell.FACE.UP, ESCell.TYPE.FACE); cell.SetFace(ESCell.FACE.DOWN, ESCell.TYPE.FACE); //TODO check for room outside room or set to world faces } } }
public void SetFace(FACE dir, TYPE type) { ESCell face = _faces[(int)dir]; face.SetCellType(type); }
public bool IsEmpty(ESCell cell) { return(cell.GetCellType() == ESCell.TYPE.EMPTY); }
// Use this for initialization void Start() { // PREFAB_CELL = GameObject.Find("ent_cell"); // // PREFAB_FLOOR = GameObject.Find("ent_block"); // PREFAB_FIRE = GameObject.Find("ent_campfire"); // _simVolumes = new SimulationVolume[xMax, yMax, zMax]; _cells = new ESCell[xMax, yMax, zMax]; // _worldFaces = new Dictionary<string, SimulationFace> (); // _worldFaces.Add("up", new SimulationFace()); // _worldFaces.Add("down", new SimulationFace()); // _worldFaces.Add("north", new SimulationFace()); // _worldFaces.Add("south", new SimulationFace()); // _worldFaces.Add("east", new SimulationFace()); // _worldFaces.Add("west", new SimulationFace()); // SimulationVolume world = new SimulationVolume(); // SimulationFace up = new SimulationFace(); // SimulationFace down = new SimulationFace(); // SimulationFace north = new SimulationFace(); // SimulationFace south = new SimulationFace(); // SimulationFace west = new SimulationFace(); // SimulationFace east = new SimulationFace(); //Instantiate all cells with respective type for (int x = 0; x < xMax; x++) { for (int y = 0; y < yMax; y++) { for (int z = 0; z < zMax; z++) { if (y % 2 == 0) { if (x % 2 == 1 && z % 2 == 1) { _cells[x, y, z] = new ESCell(ESCell.TYPE.FACE); } else { _cells[x, y, z] = new ESCell(ESCell.TYPE.VOID); } } else { if (x % 2 == 0) { if (z % 2 == 0) { _cells[x, y, z] = new ESCell(ESCell.TYPE.VOID); } else { _cells[x, y, z] = new ESCell(ESCell.TYPE.FACE); } } else { if (z % 2 == 0) { _cells[x, y, z] = new ESCell(ESCell.TYPE.FACE); } else { _cells[x, y, z] = new ESCell(ESCell.TYPE.EMPTY); } } } } } } //Set all connections for relevant cells types for (int x = 0; x < xMax; x++) { for (int y = 0; y < yMax; y++) { for (int z = 0; z < zMax; z++) { // SimulationCell cell = _cells[x, y, z]; // cell.SetFace((int)SimulationCell.FACE.UP, _cells[x, y + 1, z]); // cell.SetFace((int)SimulationCell.FACE.DOWN, _cells[x, y - 1, z]); // cell.SetFace((int)SimulationCell.FACE.NORTH, _cells[x + 1, y, z]); // cell.SetFace((int)SimulationCell.FACE.SOUTH, _cells[x - 1, y, z]); // cell.SetFace((int)SimulationCell.FACE.EAST, _cells[x, y, z + 1]); // cell.SetFace((int)SimulationCell.FACE.WEST, _cells[x, y, z - 1]); } } } //Instantiate all volumes and their faces to each other // for(int x = 0; x < xMax; x++){ // for(int y = 0; y < yMax; y++){ // for(int z = 0; z < zMax; z++){ // if(x > offset && y > offset && z > offset && // x < xMax-1 && y < yMax-1 && z < zMax-1){ // _simVolumes[x, y, z] = new SimulationVolume(); // } else{ // _simVolumes[x, y, z] = new SimulationVolume(Block.Void); // } // } // } // } //Create and connect faces between all volumes // for (int x = 0; x < xMax; x++) { // for (int y = 0; y < yMax; y++) { // for (int z = 0; z < zMax; z++) { //// SimulationVolume curVol = _simVolumes[x, y, z]; //// //North //// if(x == 0){ //// curVol.SetFace("north", world); //// } else{ //// curVol.SetFace("north", _simVolumes[x - 1, y, z]); //// } //// //South //// if(x == xMax){ //// curVol.SetFace("south", world); //// } else{ //// curVol.SetFace("south", _simVolumes[x + 1, y, z]); //// } //// //Bottom //// if(y == 0){ //// curVol.SetFace("bottom", world); //// } else{ //// curVol.SetFace("south", _simVolumes[x, y - 1, z]); //// } //// //Top //// if(y == yMax){ //// curVol.SetFace("top", world); //// } else{ //// curVol.SetFace("south", _simVolumes[x, y + 1, z]); //// } //// //West //// if(z == 0){ //// curVol.SetFace("west", world); //// } else{ //// curVol.SetFace("south", _simVolumes[x, y, z - 1]); //// } //// //East //// if(z == zMax){ //// curVol.SetFace("east", world); //// } else{ //// curVol.SetFace("south", _simVolumes[x, y, z + 1]); //// } // //// if(_simVolumes[x, y, z].GetBlockType() != Block.Void){ //// _simVolumes[x, y, z].Init( //// _simVolumes[x - 1, y, z + 1], //NW //// _simVolumes[x, y, z + 1], //N //// _simVolumes[x + 1, y, z + 1], //NE //// _simVolumes[x + 1, y, z], //E //// _simVolumes[x + 1, y, z - 1], //SE //// _simVolumes[x, y, z - 1], //S //// _simVolumes[x - 1, y, z - 1], //SW //// _simVolumes[x - 1, y, z] //W //// ); //// } // } // } // } //add all top faces //add n face // // //Instantiate all cells, void if at border and empty otherwise // for(int x = 0; x < xMax; x++){ // for(int y = 0; y < yMax; y++){ // for(int z = 0; z < zMax; z++){ // if(x > offset && y > offset && z > offset && // x < xMax-1 && y < yMax-1 && z < zMax-1){ // _simVolumes[x, y, z] = new SimulationVolume(Block.Empty); // } else{ // _simVolumes[x, y, z] = new SimulationVolume(Block.Void); // } // } // } // } // // //Set Neighbours // for (int x = 0; x < xMax; x++) { // for (int y = 0; y < yMax; y++) { // for (int z = 0; z < zMax; z++) { // if(_simVolumes[x, y, z].GetBlockType() != Block.Void){ // _simVolumes[x, y, z].Init( // _simVolumes[x - 1, y, z + 1], //NW // _simVolumes[x, y, z + 1], //N // _simVolumes[x + 1, y, z + 1], //NE // _simVolumes[x + 1, y, z], //E // _simVolumes[x + 1, y, z - 1], //SE // _simVolumes[x, y, z - 1], //S // _simVolumes[x - 1, y, z - 1], //SW // _simVolumes[x - 1, y, z] //W // ); // } // } // } // } }