public List<WorldSector> getBorderSectors(NeighborDirections border_side) { List<WorldSector> border = new List<WorldSector> (); switch (border_side) { case NeighborDirections.N: for(int i = 0; i < GameSettings.LoadedConfig.ChunkLength_Sectors; ++i) { border.Add(getSector(i, GameSettings.LoadedConfig.ChunkLength_Sectors-1)); } return border; case NeighborDirections.NE: border.Add(getSector(GameSettings.LoadedConfig.ChunkLength_Sectors-1, GameSettings.LoadedConfig.ChunkLength_Sectors-1)); return border; case NeighborDirections.E: for(int i = 0; i < GameSettings.LoadedConfig.ChunkLength_Sectors; ++i) { border.Add(getSector(GameSettings.LoadedConfig.ChunkLength_Sectors-1, i)); } return border; case NeighborDirections.SE: border.Add(getSector(GameSettings.LoadedConfig.ChunkLength_Sectors-1, 0)); return border; case NeighborDirections.S: for(int i = 0; i < GameSettings.LoadedConfig.ChunkLength_Sectors; ++i) { border.Add(getSector(i, 0)); } return border; case NeighborDirections.SW: border.Add(getSector(0, 0)); return border; case NeighborDirections.W: for(int i = 0; i < GameSettings.LoadedConfig.ChunkLength_Sectors; ++i) { border.Add(getSector(0, i)); } return border; case NeighborDirections.NW: border.Add(getSector(0, GameSettings.LoadedConfig.ChunkLength_Sectors-1)); return border; } return null; }
public List<WorldCell> getBorderCells(NeighborDirections border_side) { List<WorldCell> border = new List<WorldCell> (); switch (border_side) { case NeighborDirections.N: for(int i = 0; i < GameSettings.LoadedConfig.SectorLength_Cells; ++i) { border.Add(getCell(i, GameSettings.LoadedConfig.SectorLength_Cells-1)); } return border; case NeighborDirections.NE: border.Add(getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, GameSettings.LoadedConfig.SectorLength_Cells-1)); return border; case NeighborDirections.E: for(int i = 0; i < GameSettings.LoadedConfig.SectorLength_Cells; ++i) { border.Add(getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, i)); } return border; case NeighborDirections.SE: border.Add(getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, 0)); return border; case NeighborDirections.S: for(int i = 0; i < GameSettings.LoadedConfig.SectorLength_Cells; ++i) { border.Add(getCell(i, 0)); } return border; case NeighborDirections.SW: border.Add(getCell(0, 0)); return border; case NeighborDirections.W: for(int i = 0; i < GameSettings.LoadedConfig.SectorLength_Cells; ++i) { border.Add(getCell(0, i)); } return border; case NeighborDirections.NW: border.Add(getCell(0, GameSettings.LoadedConfig.SectorLength_Cells-1)); return border; } return null; }
public IEnumerable <DiamondPoint> GetPrincipleNeighborDirections() { return(NeighborDirections.TakeHalf()); }
public WorldChunk getNeighborChunk(NeighborDirections direction) { switch (direction) { case NeighborDirections.N: if(z < GameSettings.LoadedConfig.WorldLength_Chunks-1) { return World.GetChunk (x, z+1, false); } break; case NeighborDirections.NE: if(x < GameSettings.LoadedConfig.WorldLength_Chunks-1 && z < GameSettings.LoadedConfig.WorldLength_Chunks-1) { return World.GetChunk (x+1, z+1, false); } break; case NeighborDirections.E: if(x < GameSettings.LoadedConfig.WorldLength_Chunks-1) { return World.GetChunk (x+1, z, false); } break; case NeighborDirections.SE: if(x < GameSettings.LoadedConfig.WorldLength_Chunks-1 && z > 0) { return World.GetChunk (x+1, z-1, false); } break; case NeighborDirections.S: if(z > 0) { return World.GetChunk (x, z-1, false); } break; case NeighborDirections.SW: if(x > 0 && z > 0) { return World.GetChunk (x-1, z-1, false); } break; case NeighborDirections.W: if(x > 0) { return World.GetChunk (x-1, z, false); } break; case NeighborDirections.NW: if(x > 0 && z < GameSettings.LoadedConfig.WorldLength_Chunks-1) { return World.GetChunk (x-1, z+1, false); } break; } return null; }
public WorldSector getNeighborSector(NeighborDirections direction) { int local_x, local_z; getLocalIndex (out local_x, out local_z); switch (direction) { case NeighborDirections.N: if(local_z < GameSettings.LoadedConfig.ChunkLength_Sectors-1) { return parent.getSector (x, z+1); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.N); if(ch != null) return ch.getSector(local_x, 0); } break; case NeighborDirections.NE: if(local_x < GameSettings.LoadedConfig.ChunkLength_Sectors-1 && local_z < GameSettings.LoadedConfig.ChunkLength_Sectors-1) { return parent.getSector (x+1, z+1); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.NE); if(ch != null) return ch.getSector(0, 0); } break; case NeighborDirections.E: if(local_x < GameSettings.LoadedConfig.ChunkLength_Sectors-1) { return parent.getSector (x+1, z); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.E); if(ch != null) return ch.getSector(0, local_z); } break; case NeighborDirections.SE: if(local_x < GameSettings.LoadedConfig.ChunkLength_Sectors-1 && local_z > 0) { return parent.getSector (x+1, z-1); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.SE); if(ch != null) return ch.getSector(0, GameSettings.LoadedConfig.ChunkLength_Sectors-1); } break; case NeighborDirections.S: if(local_z > 0) { return parent.getSector (x, z-1); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.S); if(ch != null) return ch.getSector(local_x, GameSettings.LoadedConfig.ChunkLength_Sectors-1); } break; case NeighborDirections.SW: if(local_x > 0 && local_z > 0) { return parent.getSector (x-1, z-1); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.SW); if(ch != null) return ch.getSector(GameSettings.LoadedConfig.ChunkLength_Sectors-1, GameSettings.LoadedConfig.ChunkLength_Sectors-1); } break; case NeighborDirections.W: if(local_x > 0) { return parent.getSector (x-1, z); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.W); if(ch != null) return ch.getSector(GameSettings.LoadedConfig.ChunkLength_Sectors-1, local_z); } break; case NeighborDirections.NW: if(local_x > 0 && local_z < GameSettings.LoadedConfig.ChunkLength_Sectors-1) { return parent.getSector (x-1, z+1); } else { WorldChunk ch = parent.getNeighborChunk (NeighborDirections.NW); if(ch != null) return ch.getSector(GameSettings.LoadedConfig.ChunkLength_Sectors-1, 0); } break; } return null; }
public WorldCell getNeighborCell(NeighborDirections direction) { int local_x, local_z; getLocalIndex (out local_x, out local_z); switch (direction) { case NeighborDirections.N: if(local_z < GameSettings.LoadedConfig.SectorLength_Cells-1) { return parent.getCell (x, z+1); } else { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.N); if (sc != null) return sc.levels.getLevel(y).getCell(local_x, 0); } break; case NeighborDirections.NE: if(local_x < GameSettings.LoadedConfig.SectorLength_Cells-1 && local_z < GameSettings.LoadedConfig.SectorLength_Cells-1) { return parent.getCell (x+1, z+1); } else { if(local_x == GameSettings.LoadedConfig.SectorLength_Cells-1 && local_z == GameSettings.LoadedConfig.SectorLength_Cells-1) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.NE); if (sc != null) return sc.levels.getLevel(y).getCell(0, 0); } else if (local_x == GameSettings.LoadedConfig.SectorLength_Cells-1) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.E); if (sc != null) return sc.levels.getLevel(y).getCell(0, z+1); } else if (local_z == GameSettings.LoadedConfig.SectorLength_Cells-1) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.N); if (sc != null) return sc.levels.getLevel(y).getCell(x+1, 0); } } break; case NeighborDirections.E: if(local_x < GameSettings.LoadedConfig.SectorLength_Cells-1) { return parent.getCell (x+1, z); } else { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.E); if (sc != null) return sc.levels.getLevel(y).getCell(0, local_z); } break; case NeighborDirections.SE: if(local_x < GameSettings.LoadedConfig.SectorLength_Cells-1 && local_z > 0) { return parent.getCell (x+1, z-1); } else { if(local_x == GameSettings.LoadedConfig.SectorLength_Cells-1 && local_z == 0) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.SE); if (sc != null) return sc.levels.getLevel(y).getCell(0, GameSettings.LoadedConfig.SectorLength_Cells-1); } else if (local_x == GameSettings.LoadedConfig.SectorLength_Cells-1) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.E); if (sc != null) return sc.levels.getLevel(y).getCell(0, z-1); } else if (local_z == 0) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.S); if (sc != null) return sc.levels.getLevel(y).getCell(x+1, GameSettings.LoadedConfig.SectorLength_Cells-1); } } break; case NeighborDirections.S: if(local_z > 0) { return parent.getCell (x, z-1); } else { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.S); if (sc != null) return sc.levels.getLevel(y).getCell(local_x, GameSettings.LoadedConfig.SectorLength_Cells-1); } break; case NeighborDirections.SW: if(local_x > 0 && local_z > 0) { return parent.getCell (x-1, z-1); } else { if(local_x == 0 && local_z == 0) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.SW); if (sc != null) return sc.levels.getLevel(y).getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, GameSettings.LoadedConfig.SectorLength_Cells-1); } else if (local_x == 0) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.W); if (sc != null) return sc.levels.getLevel(y).getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, z-1); } else if (local_z == 0) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.S); if (sc != null) return sc.levels.getLevel(y).getCell(x-1, GameSettings.LoadedConfig.SectorLength_Cells-1); } } break; case NeighborDirections.W: if(local_x > 0) { return parent.getCell (x-1, z); } else { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.W); if (sc != null) return sc.levels.getLevel(y).getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, local_z); } break; case NeighborDirections.NW: if(local_x > 0 && local_z < GameSettings.LoadedConfig.SectorLength_Cells-1) { return parent.getCell (x-1, z+1); } else { if(local_x == 0 && local_z == GameSettings.LoadedConfig.SectorLength_Cells-1) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.NW); if (sc != null) return sc.levels.getLevel(y).getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, 0); } else if (local_x == 0) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.W); if (sc != null) return sc.levels.getLevel(y).getCell(GameSettings.LoadedConfig.SectorLength_Cells-1, z+1); } else if (local_z == GameSettings.LoadedConfig.SectorLength_Cells-1) { WorldSector sc = parent.getParent().getNeighborSector (NeighborDirections.N); if (sc != null) return sc.levels.getLevel(y).getCell(x-1, 0); } } break; } return null; }