示例#1
0
        public List <Item> Search()
        {
            if (SearchedThisTurn)
            {
                return(null);
            }
            //Check to see if the player is in a room or if there are zombies present
            if (MainGameScreen.tileData.Where(x => x.row == PlayerTile.row && x.column == PlayerTile.column).First().room == false || Zombie.zombieList.Where(x => x.ZombieTile[0] == PlayerTile.row).Where(x => x.ZombieTile[1] == PlayerTile.column).Count() > 0)
            {
                return(null);
            }
            int draws = 1;

            //Check for torch
            if (MainHandSlot != null)
            {
                if (MainHandSlot.Name == "Torch")
                {
                    draws++;
                }
            }
            if (OffHandSlot != null)
            {
                if (OffHandSlot.Name == "Torch")
                {
                    draws++;
                }
            }

            //Randomly draw Items
            List <Item> Searchlist = new List <Item>();

            for (int i = 1; i <= draws; i++)
            {
                var undrawn = Item.ItemList.Where(x => x.drawn == false);
                if (undrawn.Count() == 0)
                {
                    foreach (Item I in Item.ItemList)
                    {
                        I.drawn = false;
                    }
                    undrawn = Item.ItemList.Where(x => x.drawn == false);
                }
                Item draw = undrawn.ElementAt(MainGameScreen.RNG.Next(0, undrawn.Count()));
                draw.drawn = true;
                Searchlist.Add(draw);
            }
            SearchedThisTurn = true;
            movesLeft--;
            Backpack.AddRange(Searchlist);
            return(Searchlist);
        }