Beispiel #1
0
        /// <summary>
        /// Updates the consoles tiles to the default state of this window
        /// </summary>
        public virtual void InitializeConsole()
        {
            Vector2   screenCoords;
            TCODColor coordColor;
            Vector2   screenCenter = new Vector2(RogueGame.WindowWidth / 2, RogueGame.WindowHeight / 2);

            console.clear();

            for (int x = 0; x < console.getWidth(); x++)
            {
                for (int y = 0; y < console.getHeight(); y++)
                {
                    // Get the absolute screen coords
                    screenCoords = new Vector2(x + origin.x, y + origin.y);
                    coordColor   = Renderer.GetFadedColor(screenCoords, screenCenter, backgroundColor);

                    console.setCharBackground(x, y, coordColor);
                    DrawBorderAt(x, y, console.getWidth(), console.getHeight(), screenCoords, screenCenter);
                }
            }

            // draw the windows title
            if (title != null)
            {
                DrawText(2, 0, title, TCODColor.white);
            }
        }
Beispiel #2
0
        public void Render(TCODConsole con)
        {
            int maxchars = con.getWidth() - 4;
            int y = 2;

            con.setForegroundColor(TCODColor.darkerAzure);
            con.printFrame(0, 0, con.getWidth(), con.getHeight());
            con.setForegroundColor(TCODColor.white);

            foreach (String line in wrapLine(Text, maxchars))
            {
                con.print(2, y, line);
                y++;
            }
        }
Beispiel #3
0
        public override void Render(float deltaTime)
        {
            TCODConsole.root.setForegroundColor(Game.Settings.UiForeground);
            TCODConsole.root.setBackgroundColor(backgroundColor);
            TCODConsole.root.setBackgroundFlag(TCODBackgroundFlag.Set);
            TCODConsole.root.clear();

            // Render stars and clouds
            starfield.ForEach(s => s.Render(backgroundColor));
            clouds.ForEach(c => c.Render());

            // Render buildings.
            TCODConsole.blit(background, 0, 0, background.getWidth(), background.getHeight(),
                             TCODConsole.root, 0, 0);

            // Render credits.
            if (!creditsDoneRendering)
            {
                creditsDoneRendering =
                    TCODConsole.renderCredits(1, TCODConsole.root.getHeight() - 3, true);
            }

            // Reset colors and render menu
            TCODConsole.root.setForegroundColor(Game.Settings.UiForeground);
            TCODConsole.root.setBackgroundColor(Game.Settings.UiBackground);
            TCODConsole.root.printFrame(9, 13, 15, 13, true);
            TCODConsole.root.print(11, 15, "[N]ew Game");
            TCODConsole.root.print(11, 17, "[L]oad Game");
            TCODConsole.root.print(11, 19, "[O]ptions");
            TCODConsole.root.print(11, 21, "[C]redits");
            TCODConsole.root.print(11, 23, "[Q]uit");
        }
Beispiel #4
0
        public Engine(TCODConsole mainConsole)
        {
            instance  = this;
            isRunning = false;

            this.mainConsole = mainConsole;
            consoleWidth     = mainConsole.getWidth();
            consoleHeight    = mainConsole.getHeight();

            // Frame rate intialization
            TCODSystem.setFps(FRAME_RATE);
            internalTimer = new Stopwatch();
            MS_PER_UPDATE = 1000 / FRAME_RATE;

            renderer   = new Renderer();
            mainCamera = new Camera(20, 2, consoleWidth - 40, consoleHeight - 12);

            // Load blueprint data files
            data = new DataManager();
            data.LoadContent();

            // load data tables
            dataTables = new TableManager();
            dataTables.LoadData(TableManager.LoadDataFileList("DataTables.dir"));

#if ENTRY_GAME
            StartNewGame(null);
#else
            OpenMenu(new WindowMainMenu(0, 0, consoleWidth, consoleHeight, null, Window.EBorderStyle.NONE, null, null));
#endif
        }
Beispiel #5
0
        public void render()
        {
            map.render();

            TCODConsole.blit(lightMapConsole, 0, 0,
                             lightMapConsole.getWidth(), lightMapConsole.getHeight(), TCODConsole.root, 0, 0, 0.7F, 0.7F);
            lightMapConsole.clear();
            actorHandler.render();

            map.updateDynFov = false;
            map.updateFov    = false;
        }
Beispiel #6
0
        public void DrawMenu(TCODConsole targetConsole, WindowGameMenu menu)
        {
            if (!menu.isVisible)
            {
                return;
            }

            // ask for sub menus, this is completely optional on the part of the menu
            List <Window> subMenus = menu.GetSubMenus();
            TCODConsole   console  = menu.GetUpdatedConsole();

            TCODConsole.blit(console, 0, 0, console.getWidth(), console.getHeight(),           // source
                             targetConsole, menu.origin.X, menu.origin.Y, 1);

            // handle dragdrops
            var dragdrop = menu.dragdrop;

            if (dragdrop.active)
            {
                DrawRect(targetConsole, dragdrop.x, dragdrop.y, dragdrop.text.Length + 1, Window.elementDark);
                DrawText(targetConsole, dragdrop.x + 1, dragdrop.y, dragdrop.text, Constants.COL_FRIENDLY);
                DrawText(targetConsole, dragdrop.x, dragdrop.y, "" + (char)(25), TCODColor.white);
            }

            // sub menus (if any)
            foreach (Window sub in subMenus)
            {
                if (!sub.isVisible)
                {
                    continue;
                }

                console = sub.GetUpdatedConsole();
                TCODConsole.blit(console, 0, 0, console.getWidth(), console.getHeight(),           // source
                                 targetConsole, sub.origin.X, sub.origin.Y, 1);
            }
        }
Beispiel #7
0
        public void draw(bool transparency, bool direct)
        {
            if (direct)
            {
                for (int j = 0; j < height; j++)
                {
                    for (int i = 0; i < width; i++)
                    {
                        Tile temp = glyphs[i, j];

                        if (transparency)
                        {
                            TCODConsole.root.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(TCODConsole.root.getCharForeground(i - x, j - y)), temp.backGround.GetTCODColor(TCODConsole.root.getCharBackground(i - x, j - y)));
                        }
                        else
                        {
                            TCODConsole.root.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(), temp.backGround.GetTCODColor());
                        }
                    }
                }
            }
            else
            {
                for (int j = 0; j < height; j++)
                {
                    for (int i = 0; i < width; i++)
                    {
                        Tile temp = glyphs[i, j];

                        if (transparency)
                        {
                            terminal.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(TCODConsole.root.getCharForeground(i - x, j - y)), temp.backGround.GetTCODColor(TCODConsole.root.getCharBackground(i - x, j - y)));
                        }
                        else
                        {
                            terminal.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(), temp.backGround.GetTCODColor());
                        }
                    }
                }

                TCODConsole.blit(terminal, 0, 0, terminal.getWidth(), terminal.getHeight(), TCODConsole.root, x, y);
            }
        }
Beispiel #8
0
        public void Render(TCODConsole con, bool linewrap = true)
        {
            int maxlines = con.getHeight()-2;   //Corrected for border
            int maxchars = con.getWidth()-2;
            List<String> lines = new List<string>();
            List<MessageColor> colors = new List<MessageColor>();
            string temp;

            if (log.Count == 0)
                return;

            int i = log.Count-maxlines-1;
            if (log.Count <= maxlines)
                i = 0;
            while (i < log.Count)
            {
                if (log[i].MessageText.Length > maxchars && linewrap)
                {
                    //Oh god the horror that is this function
                    //
                    //Further down, lines are printed from latest to newest (added to "lines")
                    //so in order to display multiline messages correctly, the last of the multiple
                    //lines must be added to lines first and the first last. This is done via
                    //a temporary array which is filled from highest to lowest and then added to lines.
                    int templines =(int)Math.Ceiling((double)log[i].MessageText.Length / (double)maxchars);
                    string[] temparr = new string[templines];
                    int k = templines-1;

                    temp = log[i].MessageText;
                    while (temp.Length > maxchars)
                    {
                        temparr[k] = temp.Substring(0, maxchars);
                        colors.Add(log[i].GetMessageColor());
                        temp = temp.Remove(0, maxchars);
                        k--;
                    }
                    temparr[k] = temp;

                    foreach (String s in temparr)
                    {
                        lines.Add(s);
                    }

                    colors.Add(log[i].GetMessageColor());
                }
                else
                {
                    lines.Add(log[i].MessageText);
                    colors.Add(log[i].GetMessageColor());
                }
                i++;
            }

            int endcount = lines.Count - maxlines;
            if (lines.Count < maxlines)
                endcount = 0;
            int y = 0;
            for (int j = lines.Count-1; j >= endcount; j--)
            {
                con.setForegroundColor(colors[j].ForeColor);
                con.setBackgroundFlag(TCODBackgroundFlag.None);
                if (colors[j].BackColor != null)
                {
                    con.setBackgroundColor(colors[j].BackColor);
                    con.setBackgroundFlag(TCODBackgroundFlag.Screen);
                }

                con.print(1, 1 + y, lines[j]);
                y++;
            }
        }
Beispiel #9
0
 public int WriteString(TCODConsole console, int x, int y, string msg, TCODColor col)
 {
     console.setForegroundColor(col);
     return console.printRect(x, y, console.getWidth()-2, 0, msg);
 }
Beispiel #10
0
        public void Unequip()
        {
            List<Item> equipped = GetAllEquippedItems();
            if(equipped.Count == 0)
            {
                DarkRL.WriteMessage("There's nothing to unequip.");
                return;
            }
            TCODConsole overlay = new TCODConsole(40, equipped.Count);
            char sym = 'a';
            int y = 0;
            //now display them all
            foreach (Item i in equipped)
            {

                overlay.print(0, y, sym.ToString() + ")" + i.ToString());
                ++y;
                ++sym;
            }
            DarkRL.WriteMessage("What do you want to unequip?");
            DarkRL.AddOverlayConsole(overlay, 0, 0, overlay.getWidth(), overlay.getHeight(), TCODConsole.root, Window.StatusPanelWidth,
                Window.MessagePanelHeight);
            Key input = InputSystem.WaitForAndReturnInput();
            char index = (char)(input.Character - 'a');
            if (index >= equipped.Count || index < 0)
            {
                DarkRL.WriteMessage("Couldn't find anything..");
                return;
            }
            //so unequip
            Item item = Unequip(Backpack[index].Slot);
            return;
        }
Beispiel #11
0
        public void PickupItem()
        {
            List<int> items = GetEntitiesSharingTileWithThis();
            if(items.Count == 0)
            {
                DarkRL.WriteMessage("There's nothing to pick up..");
                return;
            }
            else if (items.Count == 1)
                base.PickupItem((Item)level.GetEntity(items[0]));
            else //there's multiple items here
            {
                TCODConsole pickup = new TCODConsole(30, items.Count+1);
                pickup.setBackgroundColor(TCODColor.black);
                pickup.setForegroundColor(TCODColor.white);
                char sym = 'a';
                int y = 0;
                //now display them all
                foreach (Item i in items.Select(t => level.GetEntity(t)))
                {

                    pickup.print(0, y, sym.ToString() + ")" + i.ToString());
                    ++y;
                    ++sym;
                }
                DarkRL.WriteMessage("What do you want to pick up?");
                DarkRL.AddOverlayConsole(pickup, 0, 0, pickup.getWidth(), pickup.getHeight(), TCODConsole.root, Window.StatusPanelWidth,
                    Window.MessagePanelHeight);
                Key input = InputSystem.WaitForAndReturnInput();
                char index = (char)(input.Character - 'a');
                if (index >= items.Count|| index < 0)
                {
                    DarkRL.WriteMessage("Couldn't find anything..");
                    return;
                }
                //so pick it up
                base.PickupItem((Item)level.GetEntity(items[index]));
                DarkRL.WriteMessage("You pick up the " + level.GetEntity(items[index]).Name);
                return;
            }
            DarkRL.WriteMessage("You pick up the " + level.GetEntity(items[0]).Name);
        }
Beispiel #12
0
        public override void render(bool insight)
        {
            if (!insight && owner != null)
            {
                Map m  = map;
                int ox = owner.x - m.offsetX;
                int oy = owner.y - m.offsetY;
                if (ox >= -fovRadius && ox < m.renderWidth + fovRadius && oy >= -fovRadius && oy < m.renderHeight + fovRadius)
                {
                    if (owner.x >= 0 && owner.x < m.tiles.GetLength(0) && owner.y >= 0 && owner.y < m.tiles.GetLength(1))
                    {
                        lightmap.clear();
                        int OFX = m.renderX - ox + mapx <= 0 ? 0 : m.renderX - ox + mapx;
                        int OFY = m.renderY - oy + mapy <= 0 ? 0 : m.renderY - oy + mapy;
                        int OFW = ox + width - m.renderWidth <= 0 ? 0 : ox + width - m.renderWidth;
                        int OFH = oy + height - m.renderHeight <= 0 ? 0 : oy + height - m.renderHeight;
                        for (int x = -mapx + OFX; x < width - OFW; x++)
                        {
                            for (int y = -mapy + OFY; y < height - OFH; y++)
                            {
                                int    mx       = owner.x + x;
                                int    my       = owner.y + y;
                                double distance = Math.Sqrt(Math.Pow(owner.x - (mx), 2) + Math.Pow(owner.y - (my), 2));
                                if (distance <= fovRadius)
                                {
                                    if ((m.isExplored(mx, my) || m.showAllTiles))
                                    {
                                        try
                                        {
                                            byte rs = (byte)((strenght * color.Red) / 255);
                                            byte gs = (byte)((strenght * color.Green) / 255);
                                            byte bs = (byte)((strenght * color.Blue) / 255);

                                            byte r = (byte)(rs - (((float)rs / ((float)fovRadius)) * ((byte)distance)));
                                            byte g = (byte)(gs - (((float)gs / ((float)fovRadius)) * ((byte)distance)));
                                            byte b = (byte)(bs - (((float)bs / ((float)fovRadius)) * ((byte)distance)));

                                            TCODColor lcolor = level.lightMapConsole.getCharBackground(mx - m.offsetX, my - m.offsetY);
                                            if ((int)r + (int)lcolor.Red < 255)
                                            {
                                                r += lcolor.Red;
                                            }
                                            else
                                            {
                                                r = 255;
                                            }
                                            //r += (byte)(lcolor.Red - ((int)r + (int)lcolor.Red - 255));
                                            if ((int)g + (int)lcolor.Green < 255)
                                            {
                                                g += lcolor.Green;
                                            }
                                            else
                                            {
                                                g = 255;
                                            }
                                            //g += (byte)(lcolor.Green - ((int)g + (int)lcolor.Green - 255));
                                            if ((int)b + (int)lcolor.Blue < 255)
                                            {
                                                b += lcolor.Blue;
                                            }
                                            else
                                            {
                                                b = 255;
                                            }
                                            //b += (byte)(lcolor.Blue - ((int)b + (int)lcolor.Blue - 255));
                                            byte tile = calculatedMaps[x + mapx, y + mapy, 0];

                                            /*
                                             * if (tile == 2)
                                             * {
                                             *  if (r > (byte)(rs / 3))
                                             *      r -= (byte)(rs / 3);
                                             *  if (g > (byte)(gs / 3))
                                             *      g -= (byte)(gs / 3);
                                             *  if (b > (byte)(bs / 3))
                                             *      b -= (byte)(bs / 3);
                                             * }
                                             */
                                            TCODColor col = new TCODColor(r, g, b);
                                            if (tile != 0)
                                            {
                                                lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, col, TCODBackgroundFlag.Set);
                                            }
                                            else if (false)
                                            {
                                                tile = calculatedMaps[x + mapx, y + mapy, 1];
                                                if (tile != 0)
                                                {
                                                    if (r > (byte)(rs / 3))
                                                    {
                                                        r -= (byte)(rs / 3);
                                                    }
                                                    if (g > (byte)(gs / 3))
                                                    {
                                                        g -= (byte)(gs / 3);
                                                    }
                                                    if (b > (byte)(bs / 3))
                                                    {
                                                        b -= (byte)(bs / 3);
                                                    }
                                                    if (tile == 2)
                                                    {
                                                        if (r > (byte)(rs / 5))
                                                        {
                                                            r -= (byte)(rs / 5);
                                                        }
                                                        if (g > (byte)(gs / 5))
                                                        {
                                                            g -= (byte)(gs / 5);
                                                        }
                                                        if (b > (byte)(bs / 5))
                                                        {
                                                            b -= (byte)(bs / 5);
                                                        }
                                                    }
                                                    col = new TCODColor(r, g, b);
                                                    lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, col, TCODBackgroundFlag.Set);
                                                }
                                            }
                                        }

                                        catch (Exception e)
                                        {
                                            Console.WriteLine(e.Message);
                                            throw new Exception(e.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    //if (lightmap.getCharBackground(mx - m.offsetX, my - m.offsetY)!= TCODColor.black)
                                    //lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, TCODColor.black, TCODBackgroundFlag.Set);
                                }
                            }
                        }
                        TCODConsole.blit(lightmap, 0, 0,
                                         lightmap.getWidth(), lightmap.getHeight(), level.lightMapConsole, 0, 0, (float)strenght / (255 * 2), (float)strenght / (255 * 2));
                    }
                }
            }
        }
Beispiel #13
0
        public new void Render(TCODConsole con)
        {
            int maxchars = con.getWidth() - 4;
            int y = 2;
            int cap_lines = 0;

            con.setBackgroundColor(TCODColor.black);
            con.setBackgroundFlag(TCODBackgroundFlag.Set);
            con.clear();
            con.setBackgroundFlag(TCODBackgroundFlag.Default);

            con.setForegroundColor(TCODColor.darkerAzure);
            con.printFrame(0, 0, con.getWidth(), con.getHeight());
            con.setForegroundColor(TCODColor.white);

            List<string> lines = new List<string>();

            lines.AddRange(wrapLine(Text, maxchars));
            cap_lines = lines.Count;

            foreach (KeyValuePair<char, string> kv in responses)
            {
                lines.Add(kv.Key + ") " + kv.Value);
            }

            for (int i = 0; i < lines.Count; i++)
            {
                con.setBackgroundFlag(TCODBackgroundFlag.Set);
                if (i - cap_lines == selectedIndex)
                    con.setBackgroundColor(TCODColor.sepia);
                else
                    con.setBackgroundColor(TCODColor.black);

                con.print(2, y+i, lines[i]);
                con.setBackgroundFlag(TCODBackgroundFlag.Default);
            }
        }