public ChunkHelper(LevelGeneratorPreset preset) { this.preset = preset; chunkMetaData = new List <ChunkMetadata> (); BuildMetadata(Resources.LoadAll <GameObject> (GlobalPaths.RelativeChunkPath)); this.progress = new ChunkHelperProgress(preset); }
private AStarGrid grid; //The grid used by the AStar algorithm, used to retrieve the segment positions public HallwayHelper(AStarGrid grid, LevelGeneratorPreset preset, GameObject hallwayObject) { this.preset = preset; this.chunkInstantiator = ChunkInstantiator.Instance; //this.preset = preset; this.grid = grid; this.hallwayObject = hallwayObject; this.hallwayTemplates = new List <HallwayTemplateMeta> (); BuildMetadata(); }
void OnEnable() { if (preset == null) { preset = new LevelGeneratorPreset(); preset.Reset(); } if (debugInfo == null) { debugInfo = new DebugInfo(); } xmlSerializer = new XmlSerializer(typeof(LevelGeneratorPreset)); }
public LevelGeneratorPreset LoadPreset(string presetName) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(LevelGeneratorPreset)); string absolutePath = Application.dataPath + GlobalPaths.PresetPath; string pathWithFilename = absolutePath + presetName + ".xml"; if (File.Exists(pathWithFilename)) { FileStream fileStream = new FileStream(pathWithFilename, FileMode.Open); LevelGeneratorPreset loadedPreset = xmlSerializer.Deserialize(fileStream) as LevelGeneratorPreset; loadedPreset.LoadMaterials(); fileStream.Close(); if (loadedPreset != null) { preset = loadedPreset; } } return(preset); }
public LevelGeneratorPreset LoadPreset(string presetName) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(LevelGeneratorPreset)); string path = GlobalPaths.PresetPathIngame; string pathWithFilename = path + presetName;// + ".xml"; TextAsset textAsset = Resources.Load(pathWithFilename) as TextAsset; TextReader textReader = new StringReader(textAsset.text); //FileStream fileStream = new FileStream (pathWithFilename, FileMode.Open); LevelGeneratorPreset loadedPreset = xmlSerializer.Deserialize(textReader) as LevelGeneratorPreset; loadedPreset.LoadMaterials(); //fileStream.Close (); if (loadedPreset != null) { preset = loadedPreset; } return(preset); }
public ProceduralLevel(LevelGraph graph, LevelGeneratorPreset preset, bool setIsStatic) { //IMPORTANT, multiply with the door size. Doors require the chunk to be aligned on the grid on GENERATION time //Ensure, that chunks are on the grid, since the doors align to the grid regardless of the chunk position, which //Will result in shifted doorpositions on repositioning the chunks tmpChunkPos = DoorDefinition.GlobalSize * -5000f; tmpChunkStep = DoorDefinition.GlobalSize * -50f; isGenerating = true; this.preset = preset; this.hallwayTiling = preset.HallwayTiling; this.distance = preset.RoomDistance; this.rootnode = graph.Rootnode; this.spacing = preset.Spacing; this.isSeparate = preset.IsSeparateRooms; this.hallwayMaterials = preset.HallwayMaterials; this.helper = new ChunkHelper(preset); this.debugData = new DebugData(); this.chunkInstantiator = ChunkInstantiator.Instance; this.hallwayMeta = new List <HallwayMeta> (); this.positionMeta = new List <RoomTransformation>(); this.levelMetadata = new LevelMetadata(); this.setIsStatic = setIsStatic; GenerateLevel(graph); if (!isConstraintError) { ApplyTransformation(); CreateHallways(); } else { HandleRollback(); } helper.CleanUp(); ChunkInstantiator.RemoveManualProperties(); isGenerating = false; }
private void LoadPreset() { string absolutePath = Application.dataPath + GlobalPaths.PresetPath; Directory.CreateDirectory(absolutePath); string path = EditorUtility.OpenFilePanel("Load Preset", absolutePath, "xml"); if (path.Length != 0) { if (File.Exists(path)) { isExternPreset = true; presetName = Path.GetFileName(path); FileStream fileStream = new FileStream(path, FileMode.Open); LevelGeneratorPreset loadedPreset = xmlSerializer.Deserialize(fileStream) as LevelGeneratorPreset; loadedPreset.LoadMaterials(); fileStream.Close(); if (loadedPreset != null) { preset = loadedPreset; } } } }
public LevelGenerator(LevelGeneratorPreset preset) { myPreset = preset; }
public ChunkHelperProgress(LevelGeneratorPreset preset) { this.created = new List <ChunkMetadata> (); this.preset = preset; }
public LevelGenerator() { preset = new LevelGeneratorPreset(); }