示例#1
0
        protected override PopulateRoomResults PopulateRoom(Scene scene, Zone zone, int x, int y, PopulateSchemeFlags flags)
        {
            PopulateRoomResults results = new PopulateRoomResults
            {
                GenerateFloor = true
            };

            float   left       = x * tileSize - size * tileSize / 2;
            float   right      = left + tileSize;
            float   bottom     = y * tileSize - size * tileSize / 2;
            float   top        = bottom + tileSize;
            Vector3 roomCenter = new Vector3((left + right) / 2, 0f, (top + bottom) / 2);

            if (!flags.IsSpecial)
            {
                int monsterCount = rand.Next(flags.ClearCenter ? 1 : 2, monstersPerRoom + 1);
                game.PlayerStats.totalMonsters += monsterCount;
                Vector2 shift       = monsterCount == 1 ? Vector2.Zero : new Vector2(30f, 0f);
                float   angleOffset = (float)(rand.NextDouble() * Math.PI * 2f);
                for (int i = 0; i < monsterCount; i++)
                {
                    Vector2 position = new Vector2(roomCenter.X, roomCenter.Z);
                    position += Vector2.Transform(shift, Mathg.RotationMatrix2D(angleOffset + i * (float)Math.PI * 2f / monsterCount));
                    Vector3 position3 = new Vector3(position.X, -1f, position.Y);

                    Monster monster = Mathg.DiscreteChoiceFn(rand, new Func <Monster>[]
                    {
                        () => new BasicMonster(position3, monsterHP, monsterDamage),
                        () => new IceMonster(position3, monsterHP, monsterDamage * 0.3f),
                        () => new ShotgunDude(position3, monsterHP, monsterDamage),
                        () => new IceShotgunDude(position3, monsterHP, monsterDamage * 0.3f),
                        () => new SpinnyBoi(position3, monsterHP * 2, monsterDamage),
                        () => new Spooper(position3, monsterHP * 1.5f, monsterDamage)
                    }, monsterChances);

                    scene.AddGameObject(monster);
                }

                if (monsterCount != 1)
                {
                    flags.ClearPerimeter = false;
                }
                else
                {
                    flags.ClearCenter = false;
                }
            }

            if (rand.Next(4) == 0 || (flags.ClearPerimeter && rand.Next(2) == 0)) // special room
            {
                PopulateSpecialRoom(scene, zone, roomCenter, flags, ref results);
            }
            else
            {
                PopulateRoomCenter(scene, zone, roomCenter, flags);
                PopulateRoomWalls(scene, zone, roomCenter, flags);
            }

            return(results);
        }
示例#2
0
        protected override PopulateRoomResults PopulateRoom(Scene scene, Zone zone, int x, int y, PopulateSchemeFlags flags)
        {
            PopulateRoomResults results = new PopulateRoomResults
            {
                GenerateFloor = true
            };

            float   left       = x * tileSize - size * tileSize / 2;
            float   right      = left + tileSize;
            float   bottom     = y * tileSize - size * tileSize / 2;
            float   top        = bottom + tileSize;
            Vector3 roomCenter = new Vector3((left + right) / 2, 0f, (top + bottom) / 2);

            bool[] roomCorridors = Enumerable.Range(0, 4).Select(t => corridorLayout[x, y, t]).ToArray();

            if ((x != exitRoom.X || y != exitRoom.Y) && (x != size / 2 || y != size / 2))
            {
                int monsterCount = rand.Next(2, monstersPerRoom + 1);
                game.PlayerStats.totalMonsters += monsterCount;
                List <Vector3> spawnPoints = new List <Vector3>();
                Vector2        shift       = monsterCount == 1 ? Vector2.Zero : new Vector2(30f, 0f);
                float          angleOffset = (float)(rand.NextDouble() * Math.PI * 2f);
                for (int i = 0; i < monsterCount; i++)
                {
                    Vector2 position = new Vector2(roomCenter.X, roomCenter.Z);
                    position += Vector2.Transform(shift, Mathg.RotationMatrix2D(angleOffset + i * (float)Math.PI * 2f / monsterCount));
                    Vector3 position3 = new Vector3(position.X, -1f, position.Y);

                    Monster monster = Mathg.DiscreteChoiceFn(rand, new Func <Monster>[]
                    {
                        () => new BasicMonster(position3, monsterHP, monsterDamage),
                        () => new BasicMonster(position3, monsterHP, monsterDamage),
                        () => new ShotgunDude(position3, monsterHP, monsterDamage),
                        () => new SpinnyBoi(position3, monsterHP * 2, monsterDamage),
                        () => new Spooper(position3, monsterHP * 1.5f, monsterDamage)
                    }, monsterChances);

                    scene.AddGameObject(monster);
                }
            }



            if (rand.Next(7) == 0)
            {
                SceneStructures.PitWithBridges(FloorTexture, WallTexture, FloorTexture, roomCorridors).Invoke(scene, zone, roomCenter);
                SceneGenUtils.AddFloor(zone, -50f * Vector2.One, 50f * Vector2.One, -10f, Assets.lavaTexture, true, roomCenter, 75f);
                results.GenerateFloor = false;
            }
            else if (rand.Next(3) == 0)
            {
                if (x != size / 2 || y != size / 2)
                {
                    SpawnPools(scene, x, y, roomCenter, flags);
                }

                List <Generator> generators = new List <Generator>
                {
                    SceneStructures.Pillars4Inner(WallTexture),
                    SceneStructures.Pillars4Outer(WallTexture)
                };

                if (flags.ClearCenter)
                {
                    generators.Add(SceneStructures.PillarBig(WallTexture));
                    generators.Add(SceneStructures.PillarSmall(WallTexture));
                }

                Mathg.DiscreteChoice(rand, generators).Invoke(scene, zone, roomCenter);
            }

            return(results);
        }