示例#1
0
        private void Roam(GameState gameState)
        {
            var direction = _rand.UniformBetween(0, 4) switch
            {
                0 => CardinalDirection.Top,
                1 => CardinalDirection.Right,
                2 => CardinalDirection.Bottom,
                3 => CardinalDirection.Left
            };

            Atom.MoveAtom(Atom.Position.GetRelativePosition(direction), gameState);
        }
示例#2
0
        private IEnumerable <Atom> GenerateRoom(int left, int top, int width, int height, int level)
        {
            var right  = left + width - 1;
            var bottom = top + height - 1;

            yield return(GenerateWall(CardinalDirection.TopLeft, left, top, level));

            yield return(GenerateWall(CardinalDirection.TopRight, right, top, level));

            yield return(GenerateWall(CardinalDirection.BottomLeft, left, bottom, level));

            yield return(GenerateWall(CardinalDirection.BottomRight, right, bottom, level));

            for (int x = left + 1; x < right; x++)
            {
                yield return(GenerateWall(CardinalDirection.Top, x, top, level));

                yield return(GenerateWall(CardinalDirection.Bottom, x, bottom, level));
            }
            for (int y = top + 1; y < bottom; y++)
            {
                yield return(GenerateWall(CardinalDirection.Left, left, y, level));

                yield return(GenerateWall(CardinalDirection.Right, right, y, level));
            }

            for (int x = left + 1; x < right; x++)
            {
                for (int y = top + 1; y < bottom; y++)
                {
                    var r = _rand.UniformBetween(131, 210);
                    var g = _rand.UniformBetween(80, 165);
                    var b = _rand.UniformBetween(46, 109);
                    yield return(new Atom("Floor", new ColouredChar('.', Color.FromArgb(255, r, g, b)), new GamePosition(x, y, level, Layer.Floor)));
                }
            }
        }