示例#1
0
 public ChunkHelper(LevelGeneratorPreset preset)
 {
     this.preset   = preset;
     chunkMetaData = new List <ChunkMetadata> ();
     BuildMetadata(Resources.LoadAll <GameObject> (GlobalPaths.RelativeChunkPath));
     this.progress = new ChunkHelperProgress(preset);
 }
示例#2
0
    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();
    }
示例#3
0
 void OnEnable()
 {
     if (preset == null)
     {
         preset = new LevelGeneratorPreset();
         preset.Reset();
     }
     if (debugInfo == null)
     {
         debugInfo = new DebugInfo();
     }
     xmlSerializer = new XmlSerializer(typeof(LevelGeneratorPreset));
 }
示例#4
0
    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);
    }
示例#5
0
    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);
    }
示例#6
0
    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;
    }
示例#7
0
    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;
                }
            }
        }
    }
示例#8
0
 public LevelGenerator(LevelGeneratorPreset preset)
 {
     myPreset = preset;
 }
示例#9
0
 public ChunkHelperProgress(LevelGeneratorPreset preset)
 {
     this.created = new List <ChunkMetadata> ();
     this.preset  = preset;
 }
示例#10
0
 public LevelGenerator()
 {
     preset = new LevelGeneratorPreset();
 }