コード例 #1
0
        // Finds start and enter markers, should only be called for starting block
        private void FindMarkers(DaggerfallRDBBlock dfBlock)
        {
            if (!dfBlock)
            {
                throw new Exception("DaggerfallDungeon: dfBlock cannot be null.");
            }

            if (dfBlock.StartMarkers != null && dfBlock.StartMarkers.Length > 0)
            {
                // There should only be one start marker per start block
                // This message will let us know if more than one is found
                if (dfBlock.StartMarkers.Length > 1)
                {
                    DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple 'Start' markers found. Using first marker.", true);
                }

                startMarker = dfBlock.StartMarkers[0];
            }

            if (dfBlock.EnterMarkers != null && dfBlock.EnterMarkers.Length > 0)
            {
                // There should only be one enter marker per start block
                // This message will let us know if more than one is found
                if (dfBlock.EnterMarkers.Length > 1)
                {
                    DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple 'Enter' markers found. Using first marker.", true);
                }

                enterMarker = dfBlock.EnterMarkers[0];
            }
        }
コード例 #2
0
        // Orsinium defines two blocks at [-1,-1]
        private void LayoutOrsinium(ref DFLocation location)
        {
            // Create dungeon layout and handle misplaced block
            foreach (var block in location.Dungeon.Blocks)
            {
                if (block.X == -1 && block.Z == -1 && block.BlockName == "N0000065.RDB")
                {
                    continue;
                }

                GameObject go = GameObjectHelper.CreateRDBBlockGameObject(
                    block.BlockName,
                    DungeonTextureTable,
                    block.IsStartingBlock,
                    Summary.DungeonType,
                    RandomMonsterPower,
                    RandomMonsterVariance,
                    (int)DateTime.Now.Ticks /*Summary.ID*/,      // TODO: Add more options for seed
                    dfUnity.Option_DungeonBlockPrefab);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindMarkers(daggerfallBlock);
                }
            }
        }
コード例 #3
0
        // Orsinium defines two blocks at [-1,-1]
        private void LayoutOrsinium(ref DFLocation location, bool importEnemies = true)
        {
            // Calculate monster power - this is a clamped 0-1 value based on player's level from 1-20
            float monsterPower = Mathf.Clamp01(GameManager.Instance.PlayerEntity.Level / 20f);

            // Create dungeon layout and handle misplaced block
            foreach (var block in location.Dungeon.Blocks)
            {
                if (block.X == -1 && block.Z == -1 && block.BlockName == "N0000065.RDB")
                {
                    continue;
                }

                GameObject go = GameObjectHelper.CreateRDBBlockGameObject(
                    block.BlockName,
                    DungeonTextureTable,
                    block.IsStartingBlock,
                    Summary.DungeonType,
                    monsterPower,
                    RandomMonsterVariance,
                    (int)DateTime.Now.Ticks /*Summary.ID*/,      // TODO: Add more options for seed
                    dfUnity.Option_DungeonBlockPrefab,
                    importEnemies);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindMarkers(daggerfallBlock);
                }
            }
        }
コード例 #4
0
        private void LayoutDungeon(ref DFLocation location)
        {
            //// Start timing
            //Stopwatch stopwatch = Stopwatch.StartNew();
            //long startTime = stopwatch.ElapsedMilliseconds;

            // Create dungeon layout
            foreach (var block in location.Dungeon.Blocks)
            {
                GameObject go = GameObjectHelper.CreateRDBBlockGameObject(
                    block.BlockName,
                    DungeonTextureTable,
                    block.IsStartingBlock,
                    Summary.DungeonType,
                    RandomMonsterPower,
                    RandomMonsterVariance,
                    (int)DateTime.Now.Ticks /*Summary.ID*/,      // TODO: Add more options for seed
                    dfUnity.Option_DungeonBlockPrefab);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindStartMarker(daggerfallBlock);
                }
            }

            //// Show timer
            //long totalTime = stopwatch.ElapsedMilliseconds - startTime;
            //DaggerfallUnity.LogMessage(string.Format("Time to layout dungeon: {0}ms", totalTime), true);
        }
コード例 #5
0
        private void LayoutDungeon(ref DFLocation location, bool importEnemies = true)
        {
#if SHOW_LAYOUT_TIMES
            // Start timing
            System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
            long startTime = stopwatch.ElapsedMilliseconds;
#endif

            // Get player level - use level 1 if game not running (e.g. importing in editor mode)
            float playerLevel = 1;
            if (Application.isPlaying)
            {
                playerLevel = GameManager.Instance.PlayerEntity.Level;
            }

            // Calculate monster power - this is a clamped 0-1 value based on player's level from 1-20
            float monsterPower = Mathf.Clamp01(playerLevel / 20f);

            // Create dungeon layout
            for (int i = 0; i < summary.LocationData.Dungeon.Blocks.Length; i++)
            {
                DFLocation.DungeonBlock block = summary.LocationData.Dungeon.Blocks[i];
                GameObject go = GameObjectHelper.CreateRDBBlockGameObject(
                    block.BlockName,
                    DungeonTextureTable,
                    block.IsStartingBlock,
                    Summary.DungeonType,
                    monsterPower,
                    RandomMonsterVariance,
                    (int)DateTime.Now.Ticks /*Summary.ID*/,      // TODO: Add more options for seed
                    dfUnity.Option_DungeonBlockPrefab,
                    importEnemies);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindMarkers(daggerfallBlock, ref block, true); // Assign start marker and enter marker
                }
                else
                {
                    FindMarkers(daggerfallBlock, ref block, false); // Only find water level and palaceblock info from start marker
                }
                summary.LocationData.Dungeon.Blocks[i].WaterLevel  = block.WaterLevel;
                summary.LocationData.Dungeon.Blocks[i].CastleBlock = block.CastleBlock;

                // Add water blocks
                RDBLayout.AddWater(go, go.transform.position, block.WaterLevel);
            }

            RemoveOverlappingDoors();

#if SHOW_LAYOUT_TIMES
            // Show timer
            long totalTime = stopwatch.ElapsedMilliseconds - startTime;
            DaggerfallUnity.LogMessage(string.Format("Time to layout dungeon: {0}ms", totalTime), true);
#endif
        }
コード例 #6
0
        // Finds start and enter markers, should be called with true for starting block, otherwise false to just get water level and castle block data
        private void FindMarkers(DaggerfallRDBBlock dfBlock, ref DFLocation.DungeonBlock block, bool assign)
        {
            if (!dfBlock)
            {
                throw new Exception("DaggerfallDungeon: dfBlock cannot be null.");
            }

            if (dfBlock.StartMarkers != null && dfBlock.StartMarkers.Length > 0)
            {
                // There should only be one start marker per start block
                // This message will let us know if more than one is found
                if (dfBlock.StartMarkers.Length > 1)
                {
                    DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple 'Start' markers found. Using first marker.", true);
                }

                if (assign)
                {
                    startMarker = dfBlock.StartMarkers[0];
                }

                DaggerfallBillboard dfBillboard = dfBlock.StartMarkers[0].GetComponent <DaggerfallBillboard>();
                block.WaterLevel  = dfBillboard.Summary.WaterLevel;
                block.CastleBlock = dfBillboard.Summary.CastleBlock;
            }
            else // No water
            {
                block.WaterLevel = 10000;
            }

            if (dfBlock.EnterMarkers != null && dfBlock.EnterMarkers.Length > 0)
            {
                // There should only be one enter marker per start block
                // This message will let us know if more than one is found
                if (dfBlock.EnterMarkers.Length > 1)
                {
                    DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple 'Enter' markers found. Using first marker.", true);
                }

                if (assign)
                {
                    enterMarker = dfBlock.EnterMarkers[0];
                }
            }
        }
コード例 #7
0
        // Orsinium defines two blocks at [-1,-1]
        private void LayoutOrsinium(ref DFLocation location, bool importEnemies = true)
        {
            // Calculate monster power - this is a clamped 0-1 value based on player's level from 1-20
            float monsterPower = Mathf.Clamp01(GameManager.Instance.PlayerEntity.Level / 20f);

            // Create dungeon layout and handle misplaced block
            for (int i = 0; i < summary.LocationData.Dungeon.Blocks.Length; i++)
            {
                DFLocation.DungeonBlock block = summary.LocationData.Dungeon.Blocks[i];
                if (block.X == -1 && block.Z == -1 && block.BlockName == "N0000065.RDB")
                {
                    continue;
                }

                GameObject go = GameObjectHelper.CreateRDBBlockGameObject(
                    block.BlockName,
                    DungeonTextureTable,
                    block.IsStartingBlock,
                    Summary.DungeonType,
                    monsterPower,
                    RandomMonsterVariance,
                    (int)DateTime.Now.Ticks /*Summary.ID*/,      // TODO: Add more options for seed
                    dfUnity.Option_DungeonBlockPrefab,
                    importEnemies);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindMarkers(daggerfallBlock, ref block, true); // Assign start marker and enter marker
                }
                else
                {
                    FindMarkers(daggerfallBlock, ref block, false); // Only find water level and castle block info from start marker
                }
                summary.LocationData.Dungeon.Blocks[i].WaterLevel  = block.WaterLevel;
                summary.LocationData.Dungeon.Blocks[i].CastleBlock = block.CastleBlock;

                // Add water blocks
                RDBLayout.AddWater(go, go.transform.position, block.WaterLevel);
            }

            RemoveOverlappingDoors();
        }
コード例 #8
0
        // Finds start marker, should only be called for starting block
        private void FindStartMarker(DaggerfallRDBBlock dfBlock)
        {
            if (!dfBlock)
            {
                throw new Exception("DaggerfallDungeon: dfBlock cannot be null.");
            }
            if (dfBlock.StartMarkers.Length == 0)
            {
                DaggerfallUnity.LogMessage("DaggerfallDungeon: No start markers found in block.", true);
                return;
            }

            // There should only be one start marker per start block
            // This message will let us know if more than one is found
            if (dfBlock.StartMarkers.Length > 1)
            {
                DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple start markers found. Using first marker.", true);
            }

            startMarker = dfBlock.StartMarkers[0];
        }
コード例 #9
0
        // Orsinium defines two blocks at [-1,-1]
        private void LayoutOrsinium(ref DFLocation location)
        {
            // Create dungeon layout and handle misplaced block
            foreach (var block in location.Dungeon.Blocks)
            {
                if (block.X == -1 && block.Z == -1 && block.BlockName == "N0000065.RDB")
                {
                    continue;
                }

                GameObject go = RDBLayout.CreateGameObject(block.BlockName, block.IsStartingBlock, DungeonTextureTable, Summary.DungeonType, Summary.ID);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindStartMarker(daggerfallBlock);
                }
            }
        }
コード例 #10
0
        private void LayoutDungeon(ref DFLocation location)
        {
#if SHOW_LAYOUT_TIMES
            // Start timing
            System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
            long startTime = stopwatch.ElapsedMilliseconds;
#endif

            // Calculate monster power - this is a clamped 0-1 value based on player's level from 1-20
            float monsterPower = Mathf.Clamp01(GameManager.Instance.PlayerEntity.Level / 20f);

            // Create dungeon layout
            foreach (var block in location.Dungeon.Blocks)
            {
                GameObject go = GameObjectHelper.CreateRDBBlockGameObject(
                    block.BlockName,
                    DungeonTextureTable,
                    block.IsStartingBlock,
                    Summary.DungeonType,
                    monsterPower,
                    RandomMonsterVariance,
                    (int)DateTime.Now.Ticks /*Summary.ID*/,      // TODO: Add more options for seed
                    dfUnity.Option_DungeonBlockPrefab);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindMarkers(daggerfallBlock);
                }
            }

#if SHOW_LAYOUT_TIMES
            // Show timer
            long totalTime = stopwatch.ElapsedMilliseconds - startTime;
            DaggerfallUnity.LogMessage(string.Format("Time to layout dungeon: {0}ms", totalTime), true);
#endif
        }
コード例 #11
0
        private void LayoutDungeon(ref DFLocation location)
        {
            //// Start timing
            //Stopwatch stopwatch = Stopwatch.StartNew();
            //long startTime = stopwatch.ElapsedMilliseconds;

            // Create dungeon layout
            foreach (var block in location.Dungeon.Blocks)
            {
                GameObject go = RDBLayout.CreateGameObject(block.BlockName, block.IsStartingBlock, DungeonTextureTable, Summary.DungeonType, Summary.ID);
                go.transform.parent   = this.transform;
                go.transform.position = new Vector3(block.X * RDBLayout.RDBSide, 0, block.Z * RDBLayout.RDBSide);

                DaggerfallRDBBlock daggerfallBlock = go.GetComponent <DaggerfallRDBBlock>();
                if (block.IsStartingBlock)
                {
                    FindStartMarker(daggerfallBlock);
                }
            }

            //// Show timer
            //long totalTime = stopwatch.ElapsedMilliseconds - startTime;
            //DaggerfallUnity.LogMessage(string.Format("Time to layout dungeon: {0}ms", totalTime), true);
        }
コード例 #12
0
        // Finds start and enter markers, should only be called for starting block
        private void FindMarkers(DaggerfallRDBBlock dfBlock)
        {
            if (!dfBlock)
                throw new Exception("DaggerfallDungeon: dfBlock cannot be null.");

            if (dfBlock.StartMarkers != null && dfBlock.StartMarkers.Length > 0)
            {
                // There should only be one start marker per start block
                // This message will let us know if more than one is found
                if (dfBlock.StartMarkers.Length > 1)
                    DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple 'Start' markers found. Using first marker.", true);

                startMarker = dfBlock.StartMarkers[0];
            }

            if (dfBlock.EnterMarkers != null && dfBlock.EnterMarkers.Length > 0)
            {

                // There should only be one enter marker per start block
                // This message will let us know if more than one is found
                if (dfBlock.EnterMarkers.Length > 1)
                    DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple 'Enter' markers found. Using first marker.", true);

                enterMarker = dfBlock.EnterMarkers[0];
            }
        }
コード例 #13
0
        // Finds start marker, should only be called for starting block
        private void FindStartMarker(DaggerfallRDBBlock dfBlock)
        {
            if (!dfBlock)
                throw new Exception("DaggerfallDungeon: dfBlock cannot be null.");
            if (dfBlock.StartMarkers.Length == 0)
            {
                DaggerfallUnity.LogMessage("DaggerfallDungeon: No start markers found in block.", true);
                return;
            }

            // There should only be one start marker per start block
            // This message will let us know if more than one is found
            if (dfBlock.StartMarkers.Length > 1)
            {
                DaggerfallUnity.LogMessage("DaggerfallDungeon: Multiple start markers found. Using first marker.", true);
            }

            startMarker = dfBlock.StartMarkers[0];
        }