Ejemplo n.º 1
0
        public Chunk(int size)
        {
            Size = size;

            Terrain          = new ArrayMapOf <GameObject>(size, size);
            Entities         = new MultiSpatialMap <GameObject>();
            BackgroundColors = new ArrayMapOf <RLColor?>(size, size);
        }
Ejemplo n.º 2
0
        // Generate basic terrain, no connectivity stuff
        public sealed override void Generate()
        {
            var terrainGen = new ArrayMapOf <bool>(Width, Height);

            RectangleMapGenerator.Generate(terrainGen);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (terrainGen[x, y])
                    {
                        Add(new Floor(Coord.Get(x, y)));
                    }
                    else
                    {
                        Add(new Wall(Coord.Get(x, y)));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // Use generate here for now, loading can be implemented by another function later in place of generate.
        public sealed override void Generate()
        {
            var terrainGen = new ArrayMapOf <bool>(Width, Height);

            RectangleMapGenerator.Generate(terrainGen);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (terrainGen[x, y])
                    {
                        if (SingletonRandom.DefaultRNG.Next(1, 100) > 95)
                        {
                            Add(new Tree(Coord.Get(x, y)));
                        }
                        else
                        {
                            Add(new Floor(Coord.Get(x, y)));
                        }
                    }
                    else
                    {
                        Add(new Wall(Coord.Get(x, y)));
                    }
                }
            }

            SetBackgroundColor(new RLColor(0, .05f, 0)); // Dark green, need to pull this out.

            // Generate enemies
            for (int i = 0; i < 5; i++)
            {
                Coord enemyPos = RandomOpenPosition(this, SingletonRandom.DefaultRNG);
                Add(new PassiveEnemy(enemyPos));
            }
        }
Ejemplo n.º 4
0
        // Generate basic terrain, no connectivity stuff
        public sealed override void Generate()
        {
            var terrainGen = new ArrayMapOf <bool>(Width, Height);

            RectangleMapGenerator.Generate(terrainGen);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (terrainGen[x, y])
                    {
                        Add(new Floor(Coord.Get(x, y)));
                    }
                    else
                    {
                        Add(new Wall(Coord.Get(x, y)));
                    }
                }
            }

            // Ooh, we can learn stuff!
            Add(new AltarOfGating(Coord.Get(Width / 2, Height / 2)));
        }