Example #1
0
 public void Loot(Cell cell) {
     if (cell.HasItem) {
         IO.PlayPickUpItem();
         Inventory.Add(cell.Item);
         cell.HasItem = false;
         IO.PadLines(2);
     } else {
         IO.PadLines(2);
     }
 }
Example #2
0
        public Dungeon()
        {
            string[] chart = File.ReadAllLines("Dungeon.txt");

            int longestRow = 0;
            for (int i = 0; i < chart.Length; i++)
            {
                if (longestRow < chart[i].Length)
                {
                    longestRow = chart[i].Length;
                }
            }
            Cells = new Cell[longestRow, chart.Length];

            char icon;
            for (int x = 0; x < Cells.GetLength(0); x++)
            {
                for (int y = 0; y < Cells.GetLength(1); y++)
                {
                    try
                    {
                        icon = chart[y][x];
                    }
                    catch
                    {
                        icon = '\0';
                    }
                    Cells[x, y] = new Cell(icon);

                    if (Cells[x, y].Icon == Icon.PLAYER)
                    {
                        Cells[x, y].Icon = Icon.ROOM;
                        SpawnPoint = new int[] { x, y };
                    }
                }
            }

            using (FileStream stream = new FileStream("Items.xml", FileMode.Open, FileAccess.Read))
            {
                var serializer = new XmlSerializer(typeof(Items));
                var itemCollection = (Items)serializer.Deserialize(stream);
                PlaceItems(itemCollection.Item);
            }
        }