Example #1
0
        public static void DrawInventorySlots()
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.SetCursorPosition(2, Renderer.MapSecHeight + 3);
            string sp = "";

            for (int i = 0; i < Console.BufferWidth - 4; i++)
            {
                sp += " ";
            }
            Console.Write(sp);
            Console.SetCursorPosition(2, Renderer.MapSecHeight + 3);
            string w = "";

            for (int i = 0; i < HandSlots.Length; i++)
            {
                if (Inventory.ContainsKey(HandSlots[i]))
                {
                    if (i == ActiveItemSlot)
                    {
                        w += '\u00BB';
                    }
                    else
                    {
                        w += ' ';
                    }
                    w += Inventory[HandSlots[i]].Glyph;
                    w += " ";
                    w += Inventory[HandSlots[i]].Count;
                    w += " ";
                    w += Inventory[HandSlots[i]].Name;
                    w += " |";
                }
                else if (HandSlots[i] == -1)
                {
                    w += " <Empty> |";
                }
                else
                {
                    HandSlots[i] = -1;
                }
            }
            w = w.Remove(w.Length - 2);
            Console.WriteLine(w);
        }
Example #2
0
        public static int AddItem(Item itm)
        {
            int iid = GetInventoryID(itm.Glyph);

            if (iid == -1)
            {
                int index = 0;
                while (Inventory.ContainsKey(index))
                {
                    index++;
                }
                Inventory.Add(index, new Item(itm.Count, itm.Glyph));
                DrawInventorySlots();
                return(index);
            }
            else
            {
                Inventory[iid].Count += itm.Count;
                DrawInventorySlots();
                return(iid);
            }
        }