Exemple #1
0
        private static void RenderPlayConsole(Game gameInstance, TCODConsole console, TCODColor fogOfWarColour, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true);


            for (int y = 0; y < gameInstance.Terrain.Height; y++)
            {
                for (int x = 0; x < gameInstance.Terrain.Width; x++)
                {
                    if (gameInstance.Player.VisibilityMap[x, y].WasSeen)
                    {
                        TCODColor lightColour = new TCODColor(gameInstance.LightMap[x, y].Colour.R,
                                                              gameInstance.LightMap[x, y].Colour.G,
                                                              gameInstance.LightMap[x, y].Colour.B);

                        if (lightColour.getValue() < fogOfWarColour.getValue())
                        {
                            lightColour = fogOfWarColour;
                        }

                        console.setForegroundColor(gameInstance.Player.VisibilityMap[x, y].IsVisible
                                                      ? lightColour
                                                      : fogOfWarColour);
                        console.putChar(x + 1, y + 1, gameInstance.Terrain[x, y].Symbol);
                    }
                }
            }

            console.setForegroundColor(
                new TCODColor(gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.R,
                              gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.G,
                              gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.B));
            console.putChar(gameInstance.Player.Location.Coordinate.X + 1, gameInstance.Player.Location.Coordinate.Y + 1,
                            '@');

            foreach (IActor actor in gameInstance.Actors.Where(x => x != gameInstance.Player))
            {
                if (gameInstance.Player.VisibilityMap[actor.Location.Coordinate].IsVisible)
                {
                    TCODColor lightColour = new TCODColor(gameInstance.LightMap[actor.Location.Coordinate].Colour.R,
                                                          gameInstance.LightMap[actor.Location.Coordinate].Colour.G,
                                                          gameInstance.LightMap[actor.Location.Coordinate].Colour.B);

                    if (lightColour.getValue() < fogOfWarColour.getValue())
                    {
                        lightColour = fogOfWarColour;
                    }

                    console.setForegroundColor(lightColour);
                    console.putChar(actor.Location.Coordinate.X + 1, actor.Location.Coordinate.Y + 1, actor.Race.Symbol);
                }
            }
        }
Exemple #2
0
        public void render()
        {
            if (i > 10000)
            {
                i = 0;
            }
            if (time > 10)
            {
                i++;
                time = 0;
            }
            time++;

            for (int x = renderX; x < renderWidth; x++)
            {
                for (int y = renderY; y < renderHeight; y++)
                {
                    if (x + offsetX >= 0 && x + offsetX < tiles.GetLength(0) && y + offsetY >= 0 && y + offsetY < tiles.GetLength(1))
                    {
                        if (isExplored(x + offsetX, y + offsetY) || showAllTiles)
                        {
                            bool      explored = tiles[x + offsetX, y + offsetY].explored;
                            TCODColor src;

                            if (isWall(x + offsetX, y + offsetY))
                            {
                                src = new TCODColor(darkWall.Red, darkWall.Green, darkWall.Blue);
                                if (explored)
                                {
                                    float v = (float)(((float)((float)darkWall.getValue())));
                                    float s = (float)(((float)((float)darkWall.getSaturation())));
                                    src.setSaturation(s);
                                    src.setValue(v);
                                }
                                TCODConsole.root.setCharBackground(x, y, src);
                            }
                            else
                            {
                                src = new TCODColor(darkGround.Red, darkGround.Green, darkGround.Blue);
                                if (explored)
                                {
                                    float v = (float)(((float)((float)darkGround.getValue())));
                                    float s = (float)(((float)((float)darkGround.getSaturation())));
                                    src.setSaturation(s);
                                    src.setValue(v);
                                }
                                TCODConsole.root.setCharBackground(x, y, src);
                            }
                        }
                    }
                }
            }

            updateFov    = false;
            updateDynFov = false;
        }