コード例 #1
0
        /// <summary>
        /// Create base RDB block by name and get back DFBlock data.
        /// </summary>
        /// <param name="blockName">Name of block.</param>
        /// <param name="blockDataOut">DFBlock data out.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            string blockName,
            out DFBlock blockDataOut,
            int[] textureTable           = null,
            bool allowExitDoors          = true,
            DaggerfallRDBBlock cloneFrom = null)
        {
            blockDataOut = new DFBlock();

            // Validate
            if (string.IsNullOrEmpty(blockName))
            {
                return(null);
            }
            if (!blockName.ToUpper().EndsWith(".RDB"))
            {
                return(null);
            }
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return(null);
            }

            // Get block data
            blockDataOut = dfUnity.ContentReader.BlockFileReader.GetBlock(blockName);

            return(CreateBaseGameObject(ref blockDataOut, textureTable, allowExitDoors, cloneFrom));
        }
コード例 #2
0
        /// <summary>
        /// Create base RDB block by name and get back DFBlock data.
        /// </summary>
        /// <param name="blockName">Name of block.</param>
        /// <param name="blockDataOut">DFBlock data out.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <param name="serialize">Allow for serialization of supported sub-objects.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            string blockName,
            Dictionary <int, ActionLink> actionLinkDict,
            out DFBlock blockDataOut,
            int[] textureTable           = null,
            bool allowExitDoors          = true,
            DaggerfallRDBBlock cloneFrom = null,
            bool serialize = true)
        {
            blockDataOut = new DFBlock();

            // Validate
            if (string.IsNullOrEmpty(blockName))
            {
                return(null);
            }
            if (!blockName.EndsWith(".RDB", StringComparison.InvariantCultureIgnoreCase))
            {
                return(null);
            }
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return(null);
            }

            // Get block data
            blockDataOut = dfUnity.ContentReader.BlockFileReader.GetBlock(blockName);

            return(CreateBaseGameObject(ref blockDataOut, actionLinkDict, textureTable, allowExitDoors, cloneFrom, serialize));
        }
コード例 #3
0
        /// <summary>
        /// Layout a complete RDB block game object.
        /// </summary>
        /// <param name="blockName">Name of block to create.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block (for start blocks).</param>
        /// <param name="dungeonType">Dungeon type for random encounters.</param>
        /// <param name="seed">Seed for random encounters.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        public static GameObject CreateRDBBlockGameObject(
            string blockName,
            int[] textureTable  = null,
            bool allowExitDoors = true,
            DFRegion.DungeonTypes dungeonType = DFRegion.DungeonTypes.HumanStronghold,
            float monsterPower           = 0.5f,
            int monsterVariance          = 4,
            int seed                     = 0,
            DaggerfallRDBBlock cloneFrom = null)
        {
            // Get DaggerfallUnity
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return(null);
            }

            Dictionary <int, RDBLayout.ActionLink> actionLinkDict = new Dictionary <int, RDBLayout.ActionLink>();

            // Create base object
            DFBlock    blockData;
            GameObject go = RDBLayout.CreateBaseGameObject(blockName, actionLinkDict, out blockData, textureTable, allowExitDoors, cloneFrom);

            // Add action doors
            RDBLayout.AddActionDoors(go, actionLinkDict, ref blockData, textureTable);

            // Add lights
            RDBLayout.AddLights(go, ref blockData);

            // Add flats
            DFBlock.RdbObject[] editorObjects;
            GameObject[]        startMarkers;
            GameObject[]        enterMarkers;
            RDBLayout.AddFlats(go, actionLinkDict, ref blockData, out editorObjects, out startMarkers, out enterMarkers);

            // Set start and enter markers
            DaggerfallRDBBlock dfBlock = go.GetComponent <DaggerfallRDBBlock>();

            if (dfBlock != null)
            {
                dfBlock.SetMarkers(startMarkers, enterMarkers);
            }

            // Add treasure
            RDBLayout.AddTreasure(go, editorObjects, ref blockData);

            // Add enemies
            RDBLayout.AddFixedEnemies(go, editorObjects, ref blockData);
            RDBLayout.AddRandomEnemies(go, editorObjects, dungeonType, monsterPower, ref blockData, monsterVariance, seed);

            // Link action nodes
            RDBLayout.LinkActionNodes(actionLinkDict);

            return(go);
        }
コード例 #4
0
        /// <summary>
        /// Create base RDB block by name.
        /// </summary>
        /// <param name="blockName">Name of block.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            string blockName,
            int[] textureTable           = null,
            bool allowExitDoors          = true,
            DaggerfallRDBBlock cloneFrom = null)
        {
            DFBlock blockData;

            return(CreateBaseGameObject(blockName, out blockData, textureTable, allowExitDoors, cloneFrom));
        }
コード例 #5
0
        /// <summary>
        /// Create base RDB block by name.
        /// </summary>
        /// <param name="blockName">Name of block.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <param name="serialize">Allow for serialization of supported sub-objects.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            string blockName,
            Dictionary <int, ActionLink> actionLinkDict,
            int[] textureTable           = null,
            bool allowExitDoors          = true,
            DaggerfallRDBBlock cloneFrom = null,
            bool serialize = true)
        {
            DFBlock blockData;

            return(CreateBaseGameObject(blockName, actionLinkDict, out blockData, textureTable, allowExitDoors, cloneFrom, serialize));
        }
コード例 #6
0
 public void SetupDungeonBlock
 (
     int index,
     bool isStartBlock,
     int[] textureTable,
     DFRegion.DungeonTypes dungeonType = DFRegion.DungeonTypes.HumanStronghold,
     int seed = 0,
     DaggerfallRDBBlock cloneFrom = null
 )
 {
     this.blockIndex   = index;
     this.isStartBlock = isStartBlock;
     this.textureTable = textureTable;
     this.dungeonType  = dungeonType;
     this.cloneFrom    = cloneFrom;
     CreateDungeonBlock();
 }
コード例 #7
0
        public void SetupDungeonBlock
        (
            BlockRecord record,
            bool isStartBlock,
            int[] textureTable,
            DFRegion.DungeonTypes dungeonType = DFRegion.DungeonTypes.HumanStronghold,
            int seed = 0,
            DaggerfallRDBBlock cloneFrom = null
        )
        {
            this.blockIndex = record.index;
            actLink         = new System.Collections.Generic.Dictionary <int, RDBLayout.ActionLink>();

            this.isStartBlock = isStartBlock;
            this.textureTable = textureTable;
            this.dungeonType  = dungeonType;
            this.cloneFrom    = cloneFrom;
            this.position     = record.position;
            CreateDungeonBlock();
        }
コード例 #8
0
ファイル: RDBLayout.cs プロジェクト: my0pic/daggerfall-unity
        /// <summary>
        /// Instantiate base RDB block by DFBlock data.
        /// </summary>
        /// <param name="blockData">Block data.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <param name="serialize">Allow for serialization of supported sub-objects.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            ref DFBlock blockData,
            Dictionary<int, ActionLink> actionLinkDict,
            int[] textureTable = null,
            bool allowExitDoors = true,
            DaggerfallRDBBlock cloneFrom = null,
            bool serialize = true)
        {
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;
            if (!dfUnity.IsReady)
                return null;

            // Use default texture table if one not specified
            if (textureTable == null)
                textureTable = StaticTextureTables.DefaultTextureTable;

            // Create gameobject
            GameObject go;
            string name = string.Format("DaggerfallBlock [{0}]", blockData.Name);
            if (cloneFrom != null)
            {
                go = GameObjectHelper.InstantiatePrefab(cloneFrom.gameObject, name, null, Vector3.zero);
            }
            else
            {
                go = new GameObject(name);
                go.AddComponent<DaggerfallRDBBlock>();
            }

            // Setup combiner
            ModelCombiner combiner = null;
            if (dfUnity.Option_CombineRDB)
                combiner = new ModelCombiner();

            // Add parent node
            GameObject modelsNode = new GameObject("Models");
            GameObject actionModelsNode = new GameObject("Action Models");
            modelsNode.transform.parent = go.transform;
            actionModelsNode.transform.parent = go.transform;

            // Add models
            List<StaticDoor> exitDoors;
            AddModels(
                dfUnity,
                ref blockData,
                actionLinkDict,
                textureTable,
                allowExitDoors,
                out exitDoors,
                serialize,
                combiner,
                modelsNode.transform,
                actionModelsNode.transform);

            // Apply combiner
            if (combiner != null)
            {
                if (combiner.VertexCount > 0)
                {
                    combiner.Apply();
                    GameObject cgo = GameObjectHelper.CreateCombinedMeshGameObject(
                        combiner,
                        "CombinedModels",
                        modelsNode.transform,
                        dfUnity.Option_SetStaticFlags);
                    cgo.GetComponent<DaggerfallMesh>().SetDungeonTextures(textureTable);
                }
            }

            // Add exit doors
            if (exitDoors.Count > 0)
            {
                DaggerfallStaticDoors c = go.AddComponent<DaggerfallStaticDoors>();
                c.Doors = exitDoors.ToArray();
            }

            return go;
        }
コード例 #9
0
ファイル: RDBLayout.cs プロジェクト: my0pic/daggerfall-unity
        /// <summary>
        /// Create base RDB block by name and get back DFBlock data.
        /// </summary>
        /// <param name="blockName">Name of block.</param>
        /// <param name="blockDataOut">DFBlock data out.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <param name="serialize">Allow for serialization of supported sub-objects.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            string blockName,
            Dictionary<int, ActionLink> actionLinkDict,
            out DFBlock blockDataOut,
            int[] textureTable = null,
            bool allowExitDoors = true,
            DaggerfallRDBBlock cloneFrom = null,
            bool serialize = true)
        {
            blockDataOut = new DFBlock();

            // Validate
            if (string.IsNullOrEmpty(blockName))
                return null;
            if (!blockName.EndsWith(".RDB", StringComparison.InvariantCultureIgnoreCase))
                return null;
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;
            if (!dfUnity.IsReady)
                return null;

            // Get block data
            blockDataOut = dfUnity.ContentReader.BlockFileReader.GetBlock(blockName);

            return CreateBaseGameObject(ref blockDataOut, actionLinkDict, textureTable, allowExitDoors, cloneFrom, serialize);
        }
コード例 #10
0
ファイル: RDBLayout.cs プロジェクト: my0pic/daggerfall-unity
 /// <summary>
 /// Create base RDB block by name.
 /// </summary>
 /// <param name="blockName">Name of block.</param>
 /// <param name="textureTable">Optional texture table for dungeon.</param>
 /// <param name="allowExitDoors">Add exit doors to block.</param>
 /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
 /// <param name="serialize">Allow for serialization of supported sub-objects.</param>
 /// <returns>Block GameObject.</returns>
 public static GameObject CreateBaseGameObject(
     string blockName,
     Dictionary<int, ActionLink> actionLinkDict,
     int[] textureTable = null,
     bool allowExitDoors = true,
     DaggerfallRDBBlock cloneFrom = null,
     bool serialize = true)
 {
     DFBlock blockData;
     return CreateBaseGameObject(blockName, actionLinkDict, out blockData, textureTable, allowExitDoors, cloneFrom, serialize);
 }
コード例 #11
0
        /// <summary>
        /// Layout a complete RDB block game object.
        /// </summary>
        /// <param name="blockName">Name of block to create.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block (for start blocks).</param>
        /// <param name="dungeonType">Dungeon type for random encounters.</param>
        /// <param name="seed">Seed for random encounters.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        public static GameObject CreateRDBBlockGameObject(
            string blockName,
            int[] textureTable = null,
            bool allowExitDoors = true,
            DFRegion.DungeonTypes dungeonType = DFRegion.DungeonTypes.HumanStronghold,
            float monsterPower = 0.5f,
            int monsterVariance = 4,
            int seed = 0,
            DaggerfallRDBBlock cloneFrom = null)
        {
            // Get DaggerfallUnity
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;
            if (!dfUnity.IsReady)
                return null;

            Dictionary<int, RDBLayout.ActionLink> actionLinkDict = new Dictionary<int, RDBLayout.ActionLink>();

            // Create base object
            DFBlock blockData;
            GameObject go = RDBLayout.CreateBaseGameObject(blockName, actionLinkDict, out blockData, textureTable, allowExitDoors, cloneFrom);
            // Add action doors
            RDBLayout.AddActionDoors(go, actionLinkDict, ref blockData, textureTable);

            // Add lights
            RDBLayout.AddLights(go, ref blockData);

            // Add flats
            DFBlock.RdbObject[] editorObjects;
            GameObject[] startMarkers;
            GameObject[] enterMarkers;
            RDBLayout.AddFlats(go, actionLinkDict, ref blockData, out editorObjects, out startMarkers, out enterMarkers);

            // Set start and enter markers
            DaggerfallRDBBlock dfBlock = go.GetComponent<DaggerfallRDBBlock>();
            if (dfBlock != null)
                dfBlock.SetMarkers(startMarkers, enterMarkers);

            // Add treasure
            RDBLayout.AddTreasure(go, editorObjects, ref blockData);

            // Add enemies
            RDBLayout.AddFixedEnemies(go, editorObjects, ref blockData);
            RDBLayout.AddRandomEnemies(go, editorObjects, dungeonType, monsterPower, ref blockData, monsterVariance, seed);

            // Link action nodes
            RDBLayout.LinkActionNodes(actionLinkDict);
            return go;
        }
コード例 #12
0
        /// <summary>
        /// Instantiate base RDB block by DFBlock data.
        /// </summary>
        /// <param name="blockData">Block data.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            ref DFBlock blockData,
            int[] textureTable           = null,
            bool allowExitDoors          = true,
            DaggerfallRDBBlock cloneFrom = null)
        {
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return(null);
            }

            // Use default texture table if one not specified
            if (textureTable == null)
            {
                textureTable = StaticTextureTables.DefaultTextureTable;
            }

            // Create gameobject
            GameObject go;
            string     name = string.Format("DaggerfallBlock [{0}]", blockData.Name);

            if (cloneFrom != null)
            {
                go = GameObjectHelper.InstantiatePrefab(cloneFrom.gameObject, name, null, Vector3.zero);
            }
            else
            {
                go = new GameObject(name);
                go.AddComponent <DaggerfallRDBBlock>();
            }

            // Setup combiner
            ModelCombiner combiner = null;

            if (dfUnity.Option_CombineRDB)
            {
                combiner = new ModelCombiner();
            }

            // Add parent node
            GameObject modelsNode       = new GameObject("Models");
            GameObject actionModelsNode = new GameObject("Action Models");

            modelsNode.transform.parent       = go.transform;
            actionModelsNode.transform.parent = go.transform;

            // Add models
            List <StaticDoor> exitDoors;

            AddModels(
                dfUnity,
                ref blockData,
                textureTable,
                allowExitDoors,
                out exitDoors,
                combiner,
                modelsNode.transform,
                actionModelsNode.transform);

            // Apply combiner
            if (combiner != null)
            {
                if (combiner.VertexCount > 0)
                {
                    combiner.Apply();
                    GameObject cgo = GameObjectHelper.CreateCombinedMeshGameObject(
                        combiner,
                        "CombinedModels",
                        modelsNode.transform,
                        dfUnity.Option_SetStaticFlags);
                    cgo.GetComponent <DaggerfallMesh>().SetDungeonTextures(textureTable);
                }
            }

            // Add exit doors
            if (exitDoors.Count > 0)
            {
                DaggerfallStaticDoors c = go.AddComponent <DaggerfallStaticDoors>();
                c.Doors = exitDoors.ToArray();
            }

            return(go);
        }
コード例 #13
0
        /// <summary>
        /// Creates a new RDB GameObject and performs block layout.
        /// Can pass information about dungeon for texture swaps and random enemies.
        /// </summary>
        /// <param name="dfUnity">DaggerfallUnity singleton. Required for content readers and settings.</param>
        /// <param name="blockName">Name of RDB block to build.</param>
        /// <param name="isStartingBlock">True if this is the starting block. Controls exit doors.</param>
        /// <param name="textureTable">Dungeon texture table.</param>
        /// <param name="dungeonType">Type of dungeon for random encounter tables.</param>
        /// <param name="seed">Seed for random encounters.</param>
        /// <returns>GameObject.</returns>
        public static GameObject CreateGameObject(
            string blockName,
            bool isStartingBlock,
            int[] textureTable = null,
            DFRegion.DungeonTypes dungeonType = DFRegion.DungeonTypes.HumanStronghold,
            int seed = 0)
        {
            // Validate
            if (string.IsNullOrEmpty(blockName))
            {
                return(null);
            }
            if (!blockName.ToUpper().EndsWith(".RDB"))
            {
                return(null);
            }
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return(null);
            }

            // Create gameobject
            GameObject         go      = new GameObject(string.Format("DaggerfallBlock [Name={0}]", blockName));
            DaggerfallRDBBlock dfBlock = go.AddComponent <DaggerfallRDBBlock>();

            // Start new layout
            RDBLayout layout = new RDBLayout(blockName);

            layout.isStartingBlock  = isStartingBlock;
            layout.textureTable     = textureTable;
            layout.dungeonType      = dungeonType;
            layout.staticModelsNode = new GameObject("Static Models");
            layout.actionModelsNode = new GameObject("Action Models");
            layout.doorsNode        = new GameObject("Doors");
            layout.flatsNode        = new GameObject("Flats");
            layout.lightsNode       = new GameObject("Lights");
            layout.enemiesNode      = new GameObject("Enemies");

            // Parent child game objects
            layout.staticModelsNode.transform.parent = go.transform;
            layout.actionModelsNode.transform.parent = go.transform;
            layout.doorsNode.transform.parent        = go.transform;
            layout.flatsNode.transform.parent        = go.transform;
            layout.lightsNode.transform.parent       = go.transform;
            layout.enemiesNode.transform.parent      = go.transform;

            // List to receive any exit doors found
            List <StaticDoor> allDoors = new List <StaticDoor>();

            // Seed random generator
            UnityEngine.Random.seed = seed;

            // Iterate object groups
            layout.groupIndex = 0;
            DFBlock blockData = dfUnity.ContentReader.BlockFileReader.GetBlock(blockName);

            foreach (DFBlock.RdbObjectRoot group in blockData.RdbBlock.ObjectRootList)
            {
                // Skip empty object groups
                if (null == group.RdbObjects)
                {
                    layout.groupIndex++;
                    continue;
                }

                // Iterate objects in this group
                List <StaticDoor> modelDoors;
                foreach (DFBlock.RdbObject obj in group.RdbObjects)
                {
                    // Handle by object type
                    switch (obj.Type)
                    {
                    case DFBlock.RdbResourceTypes.Model:
                        layout.AddRDBModel(obj, out modelDoors, layout.staticModelsNode.transform);
                        if (modelDoors.Count > 0)
                        {
                            allDoors.AddRange(modelDoors);
                        }
                        break;

                    case DFBlock.RdbResourceTypes.Flat:
                        layout.AddRDBFlat(obj, layout.flatsNode.transform);
                        break;

                    case DFBlock.RdbResourceTypes.Light:
                        layout.AddRDBLight(obj, layout.lightsNode.transform);
                        break;

                    default:
                        break;
                    }
                }

                // Increment group index
                layout.groupIndex++;
            }

            // Link action nodes
            layout.LinkActionNodes();

            // Combine meshes
            if (dfUnity.Option_CombineRDB)
            {
                layout.combiner.Apply();
                GameObject cgo = GameObjectHelper.CreateCombinedMeshGameObject(layout.combiner, "CombinedMeshes", layout.staticModelsNode.transform, dfUnity.Option_SetStaticFlags);
                cgo.GetComponent <DaggerfallMesh>().SetDungeonTextures(textureTable);
            }

            // Fix enemy standing positions for this block
            // Some enemies are floating in air or sunk into ground
            // Can only adjust this after geometry instantiated
            layout.FixEnemyStanding(go);

            // Store start markers in block
            dfBlock.SetStartMarkers(layout.startMarkers.ToArray());

            // Add doors
            if (allDoors.Count > 0)
            {
                layout.AddDoors(allDoors.ToArray(), go);
            }

            return(go);
        }
コード例 #14
0
        /// <summary>
        /// Create base RDB block by name and get back DFBlock data.
        /// </summary>
        /// <param name="blockName">Name of block.</param>
        /// <param name="blockDataOut">DFBlock data out.</param>
        /// <param name="textureTable">Optional texture table for dungeon.</param>
        /// <param name="allowExitDoors">Add exit doors to block.</param>
        /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
        /// <returns>Block GameObject.</returns>
        public static GameObject CreateBaseGameObject(
            string blockName,
            out DFBlock blockDataOut,
            int[] textureTable = null,
            bool allowExitDoors = true,
            DaggerfallRDBBlock cloneFrom = null)
        {
            blockDataOut = new DFBlock();

            // Validate
            if (string.IsNullOrEmpty(blockName))
                return null;
            if (!blockName.ToUpper().EndsWith(".RDB"))
                return null;
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;
            if (!dfUnity.IsReady)
                return null;

            // Get block data
            blockDataOut = dfUnity.ContentReader.BlockFileReader.GetBlock(blockName);

            return CreateBaseGameObject(ref blockDataOut, textureTable, allowExitDoors, cloneFrom);
        }
コード例 #15
0
 /// <summary>
 /// Create base RDB block by name.
 /// </summary>
 /// <param name="blockName">Name of block.</param>
 /// <param name="textureTable">Optional texture table for dungeon.</param>
 /// <param name="allowExitDoors">Add exit doors to block.</param>
 /// <param name="cloneFrom">Clone and build on a prefab object template.</param>
 /// <returns>Block GameObject.</returns>
 public static GameObject CreateBaseGameObject(
     string blockName,
     int[] textureTable = null,
     bool allowExitDoors = true,
     DaggerfallRDBBlock cloneFrom = null)
 {
     DFBlock blockData;
     return CreateBaseGameObject(blockName, out blockData, textureTable, allowExitDoors, cloneFrom);
 }
コード例 #16
0
        public void CreateDungeonBlock()
        {
            DungeonGenerator myGen = GetComponent <DungeonRecord>().MyGenerator;

            Debug.LogWarning("Creating dungeon block: " + blockIndex + " isStarting block: " + isStartBlock);
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                Debug.LogError("CreateDungeonBlock found dfUnity not ready; stopping");
                return;
            }

            // Create base object
            DFBlock blockData = dfUnity.ContentReader.BlockFileReader.GetBlock(blockIndex);

            if (blockData.Type != DFBlock.BlockTypes.Rdb)
            {
                Debug.LogError(string.Format("Invalid block index : {0} | block name: {1} | block type: {2}, returning", blockIndex, blockData.Name, blockData.Type));
                return;
            }

            GameObject go = RDBLayout.CreateBaseGameObject(blockData.Name, actLink, textureTable, true, cloneFrom);

            // Add exit doors
            if (isStartBlock)
            {
                StaticDoor[] doorsOut;
                RDBLayout.AddActionDoors(go, actLink, ref blockData, textureTable);
            }

            // Add action doors
            RDBLayout.AddActionDoors(go, actLink, ref blockData, textureTable);

            // Add lights
            RDBLayout.AddLights(go, ref blockData);

            // Add flats
            DFBlock.RdbObject[] editorObjectsOut = new DFBlock.RdbObject[0];
            GameObject[]        startMarkersOut  = null;
            GameObject[]        enterMarkersOut  = null;

            if (myGen.GenerateTreasure)
            {
                RDBLayout.AddFlats(go, actLink, ref blockData, out editorObjectsOut, out startMarkersOut, out enterMarkersOut, dungeonType);
            }

            // Set start markers
            DaggerfallRDBBlock dfBlock = (cloneFrom != null) ? cloneFrom : go.GetComponent <DaggerfallRDBBlock>();

            if (dfBlock != null)
            {
                dfBlock.SetMarkers(startMarkersOut, enterMarkersOut);
            }

            // Add enemies
            if (myGen.GenerateEnemies)
            {
                RDBLayout.AddRandomEnemies(go, editorObjectsOut, dungeonType, 0.5f, ref blockData, startMarkersOut);
            }

            go.transform.SetParent(this.transform);
            go.transform.localPosition = new Vector3(position.x, 0, position.y);
        }