コード例 #1
0
ファイル: BaseGrid.cs プロジェクト: otogyongyosi/Emberpoint
        public static BaseGrid Create(int width, int height)
        {
            // Build a custom cell grid
            var cells = new EmberCell[width * height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    var cell = new EmberCell
                    {
                        Background = Color.Black,
                        Foreground = Color.Gray,
                        Glyph      = ' ',
                        Position   = new Point(x, y)
                    };
                    cell.CellProperties = new EmberCell.EmberCellProperties
                    {
                        Name             = null,
                        Walkable         = true,
                        BlocksFov        = false,
                        NormalForeground = cell.Foreground,
                        NormalBackground = cell.Background,
                        ForegroundFov    = cell.Foreground == Color.Transparent ? Color.Transparent : Color.Lerp(cell.Foreground, Color.Black, .5f),
                        BackgroundFov    = cell.Background == Color.Transparent ? Color.Transparent : Color.Lerp(cell.Foreground, Color.Black, .5f)
                    };
                    cells[y * width + x] = cell;
                }
            }
            return(new BaseGrid(width, height, cells));
        }
コード例 #2
0
        public static EmberGrid BuildCustomGrid(int width, int height)
        {
            // Build a custom cell grid
            var cells = new EmberCell[width * height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    cells[y * width + x] = new EmberCell
                    {
                        Background = Color.Black,
                        Foreground = Color.Gray,
                        Glyph      = '.',

                        CellProperties = new EmberCell.EmberCellProperties
                        {
                            Name     = "floor",
                            Walkable = true
                        },
                        Position = new Point(x, y),
                    };
                }
            }
            return(new EmberGrid(width, height, cells));
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: nupick/Emberpoint
        private static void SetMapArea(int gridSizeX, int gridSizeY)
        {
            var cells = new EmberCell[gridSizeX * gridSizeY];

            for (int x = 0; x < gridSizeX; x++)
            {
                for (int y = 0; y < gridSizeY; y++)
                {
                    cells[y * gridSizeX + x] = new EmberCell(new Point(x, y), '.', Color.Green);
                }
            }
            Grid = new EmberGrid(gridSizeX, gridSizeY, cells);
            Grid.RenderObject(Map);
        }
コード例 #4
0
        private void GetRadiusNeighbors(EmberCell cell, int radius, List <EmberCell> cells)
        {
            if (radius == 0)
            {
                return;
            }
            var neighbors = _grid.GetNeighbors(cell);

            foreach (var neighbor in neighbors)
            {
                if (!cells.Contains(neighbor))
                {
                    cells.Add(neighbor);
                }

                GetRadiusNeighbors(neighbor, radius - 1, cells);
            }
        }
コード例 #5
0
 private void HandleDoorInteraction(EmberCell cell)
 {
     if (cell.CellProperties.Walkable)
     {
         interactionWindow.PrintMessage(Constants.CloseDoor);
         cell.CellProperties.Walkable = false;
         cell.Glyph = '+';
     }
     else
     {
         interactionWindow.PrintMessage(Constants.OpenDoor);
         cell.CellProperties.Walkable = true;
         cell.Glyph = '=';
     }
     GridManager.Grid.SetCell(cell);
     player.MapWindow.Update();
     _fovObjectsWindow.Update(player);
 }
コード例 #6
0
        private void HandleDoorInteraction(EmberCell cell)
        {
            if (cell.CellProperties.Walkable)
            {
                interactionWindow.PrintMessage(Constants.CloseDoor);
                cell.CellProperties.Walkable = false;
                cell.Glyph = '+';
                cell.CellProperties.BlocksFov = true;
            }
            else
            {
                interactionWindow.PrintMessage(Constants.OpenDoor);
                cell.CellProperties.Walkable = true;
                cell.Glyph = '=';
                cell.CellProperties.BlocksFov = false;
            }
            GridManager.Grid.SetCell(cell);

            // Incase some effects need to be updated/shown after an interaction
            UpdateMapAfterInteraction();
        }
コード例 #7
0
 private void HandleDefaultInteraction(EmberCell cell)
 {
     interactionWindow.PrintMessage("Interacting with " + cell.CellProperties.Name);
 }