Esempio n. 1
0
        public void Draw(TCODConsole cons)
        {
            cons.setForegroundColor(TCODColor.white);
            for (int i = 0; i < MAP_WIDTH; i++)
            {
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    cons.putChar(i, j, this[i, j] ? '#' : '.');
                }
            }

            _stair.Draw(cons);
            cons.putChar(StartPosX, StartPosY, '<');

            foreach (Item item in _items)
            {
                item.Draw(cons);
            }

            foreach (Monster mons in _monsters)
            {
                mons.Draw(cons);
            }

            Player.Draw(cons);

            for (int i = 0; i < MAP_WIDTH; i++)
            {
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    /*int intens;
                     * Light light = LightAt(i, j);
                     *
                     * if (light == null)
                     *  intens = 0;
                     * else
                     * {
                     *  intens = light.IntensityAt(i, j);
                     *  color = color.Multiply(light.Color);
                     * }
                     * float value = (float)intens / 20 + (Game.ShowWall ? 0.05f : 0f);
                     * color.setValue(System.Math.Min(value, 1f));//*/

                    TCODColor color  = cons.getCharForeground(i, j);
                    TCODColor newCol = ColorAt(i, j);

                    if (newCol.NotEqual(TCODColor.black))
                    {
                        _known[i, j] = true;
                    }
                    color = color.Multiply(newCol);

                    cons.setCharForeground(i, j, color);
                }
            }
        }
Esempio n. 2
0
        public bool pickATile(out int x, out int y, float maxRange)
        {
            int pickX = Program.engine.player.x - map.offsetX, pickY = Program.engine.player.y - map.offsetY;

            for (int cx = map.renderX; cx < map.renderWidth; cx++)
            {
                for (int cy = map.renderY; cy < map.renderHeight; cy++)
                {
                    if (Program.engine.player.fov.isInFov(cx + map.offsetX, cy + map.offsetY) &&
                        (maxRange == 0 || Program.engine.player.getDistance(cx + map.offsetX, cy + map.offsetY) <= maxRange))
                    {
                        TCODColor col = TCODConsole.root.getCharBackground(cx, cy);
                        col = col.Multiply(1.2f);
                        TCODConsole.root.setCharBackground(cx, cy, col);
                    }
                }
            }
            int       oldX = pickX, oldY = pickY;
            TCODColor oldC = TCODConsole.root.getCharBackground(pickX, pickY);

            while (!TCODConsole.isWindowClosed())
            {
                render();


                mousedata          = TCODMouse.getStatus();
                Program.engine.key = TCODConsole.checkForKeypress((int)TCODKeyStatus.KeyPressed);
                if (Engine.useMouse)
                {
                    if (Program.engine.player.fov.isInFov(mousedata.CellX + map.offsetX, mousedata.CellY + map.offsetY))
                    {
                        if ((maxRange == 0 || Program.engine.player.getDistance(mousedata.CellX + map.offsetX, mousedata.CellY + map.offsetY) <= maxRange))
                        {
                            pickX = mousedata.CellX;
                            pickY = mousedata.CellY;
                            if (mousedata.LeftButtonPressed)
                            {
                                x = mousedata.CellX + map.offsetX;
                                y = mousedata.CellY + map.offsetY;
                                return(true);
                            }
                        }
                    }
                    if (mousedata.RightButtonPressed)
                    {
                        x = 0;
                        y = 0;
                        return(false);
                    }
                }
                if (pickX != oldX || pickY != oldY)
                {
                    TCODConsole.root.setCharBackground(oldX, oldY, oldC);
                    oldC = TCODConsole.root.getCharBackground(pickX, pickY);
                    TCODConsole.root.setCharBackground(pickX, pickY, TCODColor.white);
                    oldX = pickX;
                    oldY = pickY;
                }
                if (Program.engine.player.fov.isInFov(pickX + map.offsetX, pickY + map.offsetY))
                {
                    if ((maxRange == 0 || Program.engine.player.getDistance(pickX + map.offsetX, pickY + map.offsetY) <= maxRange))
                    {
                        switch (Program.engine.key.KeyCode)
                        {
                        case TCODKeyCode.Enter:
                        {
                            x = pickX + map.offsetX;
                            y = pickY + map.offsetY;

                            return(true);
                        }

                        case TCODKeyCode.Up:
                        {
                            if (Program.engine.player.fov.isInFov(pickX + map.offsetX, pickY - 1 + map.offsetY))
                            {
                                if (Program.engine.player.getDistance(pickX + map.offsetX, pickY - 1 + map.offsetY) <= maxRange)
                                {
                                    pickY--;
                                }
                            }
                            break;
                        }

                        case TCODKeyCode.Down:
                            if (Program.engine.player.fov.isInFov(pickX + map.offsetX, pickY + 1 + map.offsetY))
                            {
                                if (Program.engine.player.getDistance(pickX + map.offsetX, pickY + 1 + map.offsetY) <= maxRange)
                                {
                                    pickY++;
                                }
                            }
                            break;

                        case TCODKeyCode.Left:
                            if (Program.engine.player.fov.isInFov(pickX - 1 + map.offsetX, pickY + map.offsetY))
                            {
                                if (Program.engine.player.getDistance(pickX - 1 + map.offsetX, pickY + map.offsetY) <= maxRange)
                                {
                                    pickX--;
                                }
                            }
                            break;

                        case TCODKeyCode.Right:
                            if (Program.engine.player.fov.isInFov(pickX + 1 + map.offsetX, pickY + map.offsetY))
                            {
                                if (Program.engine.player.getDistance(pickX + 1 + map.offsetX, pickY + map.offsetY) <= maxRange)
                                {
                                    pickX++;
                                }
                            }
                            break;
                        }
                    }
                }

                TCODConsole.flush();
                Program.engine.lastKey = Program.engine.key;
            }
            x = 0;
            y = 0;
            return(false);
        }
Esempio n. 3
0
 public void Draw(float lightMod, TCODColor foregroundColor, char character, int x, int y)
 {
     console.putCharEx(x, y, character, foregroundColor.Multiply(lightMod), TCODColor.black);
 }