示例#1
0
        public static void renderGame()
        {
            if (!stuck)
            {
                Console.Clear();
                ConsoleEx.DrawRectangle(BorderStyle.Text, 0, 0, 26, 26, false);

                for (int y = -14; y < 13; y++)
                {
                    for (int x = -14; x < 13; x++)
                    {
                        while (renderX + x < 0)
                        {
                            x++;
                        }
                        while (renderY + y < 0)
                        {
                            y++;
                        }
                        if (Math.Sqrt(Math.Pow((renderX + x) - renderX, 2) + Math.Pow((renderY + y) - renderY, 2)) < 12.6)
                        {
                            Console.SetCursorPosition(Math.Min(26, Math.Max(1, x + 13)), Math.Min(26, Math.Max(1, y + 13)));
                            try
                            {
                                if (renderX + x == renderX && renderY + y == renderY)
                                {
                                    ConsoleEx.TextColor(ConsoleForeground.LightGray, ConsoleBackground.Black);
                                    if (player.status.hasAttr("Invisible"))
                                    {
                                        ConsoleEx.TextColor(ConsoleForeground.DarkGray, ConsoleBackground.Black);
                                    }
                                    Console.Write("P");
                                    ConsoleEx.TextColor(ConsoleForeground.LightGray, ConsoleBackground.Black);
                                }
                                else
                                {
                                    if (Mob.getMobsAtPos(renderX + x, renderY + y).Count == 0)
                                    {
                                        world.draw(renderX + x, renderY + y);
                                    }
                                    else
                                    {
                                        ConsoleEx.TextColor(Mob.getMobsAtPos(renderX + x, renderY + y)[0].colorFore, Mob.getMobsAtPos(renderX + x, renderY + y)[0].colorBack);
                                        Console.Write(Mob.getMobsAtPos(renderX + x, renderY + y)[0].symbol);
                                        msgLog.Add(Mob.getMobsAtPos(renderX + x, renderY + y)[0].name + " has been spotted near you!");
                                    }
                                }
                            }
                            catch
                            {
                                //ConsoleEx.TextColor(ConsoleForeground.Red, ConsoleBackground.Black);
                                //Console.Write('X');
                            }
                            ConsoleEx.TextColor(ConsoleForeground.LightGray, ConsoleBackground.Black);
                        }
                        else
                        {
                            Console.SetCursorPosition(Math.Min(26, Math.Max(1, x + 13)), Math.Min(26, Math.Max(1, y + 13)));
                            ConsoleEx.TextColor(ConsoleForeground.DarkGray, ConsoleBackground.Black);
                            Console.Write(':');
                        }
                    }
                }
                ConsoleEx.TextColor(ConsoleForeground.LightGray, ConsoleBackground.Black);
                ConsoleEx.DrawRectangle(BorderStyle.Text, 27, 0, 26, 40, false);
                ConsoleEx.DrawRectangle(BorderStyle.Text, 0, 27, 26, 13, false);
                Console.SetCursorPosition(2, 27);
                Console.WriteLine("Turn " + currTurn);
                Console.SetCursorPosition(2, 0);
                Console.Write(area + ":" + floor + " (" + renderX + " ~ " + renderY + ")");
                player.WriteRPGStats(28, 1);
                if (player.status.statusEffects.Count > 0)
                {
                    ConsoleEx.DrawRectangle(BorderStyle.Text, 54, 0, 35, player.status.statusEffects.Count + 1, false);
                    player.status.drawStatus(55, 1);
                }
                if (!showAbilities)
                {
                    for (int x = 0; x < player.inventory.Length; x++)
                    {
                        if (player.inventoryStacks[x] > 0)
                        {
                            string s = player.inventoryStacks[x] + " " + player.inventory[x].name;
                            if (Program.selectedSlot == x)
                            {
                                s = "> " + s;
                            }
                            if (player.inventoryEquip[x] || player.inventory[x].equipped)
                            {
                                s = s + " (Equipped)";
                            }
                            if (player.inventory[x].bound && player.inventory[x].discoveredBound)
                            {
                                s = s + " (Bound)";
                            }
                            if (player.status.statusEffects.Count > 0)
                            {
                                Util.writeLn(s, 91, 1 + x);
                            }
                            else
                            {
                                Util.writeLn(s, 54, 1 + x);
                            }
                        }
                        else
                        {
                            string s = "Empty Slot";
                            if (Program.selectedSlot == x)
                            {
                                s = "> " + s;
                            }
                            if (player.status.statusEffects.Count > 0)
                            {
                                Util.writeLn(s, 91, 1 + x);
                            }
                            else
                            {
                                Util.writeLn(s, 54, 1 + x);
                            }
                            player.inventory[x]       = null;
                            player.inventoryStacks[x] = 0;
                            player.inventoryEquip[x]  = false;
                        }
                    }
                }
                else
                {
                    int iter = 0;
                    foreach (Ability a in player.abilities)
                    {
                        string s = "";
                        if (iter == Program.selectedSlot)
                        {
                            s = "> ";
                        }
                        s += a.name;
                        if (a.etherCost > 0)
                        {
                            s += "(costs " + a.etherCost + " ether";
                            if (a.healthCost > 0)
                            {
                                s += " and " + a.healthCost + " health)";
                            }
                            else
                            {
                                s += ")";
                            }
                        }
                        if (a.healthCost > 0 && a.etherCost <= 0)
                        {
                            s += "(costs " + a.healthCost + " health)";
                        }
                        if (player.status.statusEffects.Count > 0)
                        {
                            Util.writeLn(s, 91, 1 + iter);
                        }
                        else
                        {
                            Util.writeLn(s, 54, 1 + iter);
                        }
                        iter++;
                    }
                }
                ConsoleEx.DrawRectangle(BorderStyle.Text, 0, 41, 88, 6, false);
                for (int x = 0; x < 5; x++)
                {
                    try
                    {
                        Util.writeLn(msgLog.ToArray()[msgLog.ToArray().Length - (1 + x)], 1, 42 + x);
                    }
                    catch
                    {
                        break;
                    }
                }
                player.status.update();
            }
        }