Пример #1
0
        //Player Action Buttons

        private void SearchBtn_Click(object sender, EventArgs e)
        {
            GameItemCollection itemCollection = new GameItemCollection();



            player.Search(player);
        }
Пример #2
0
        //Search actions
        public void Search(Player player)
        {
            Random             random             = new Random();
            Locations          location           = new Locations();
            GameItemCollection gameItemCollection = new GameItemCollection();

            List <Locations> randomLocations = new List <Locations>()
            {
                new Cave()
                {
                    Name = "Cave"
                },
                new Dungeon()
                {
                    Name = "Dungeon"
                },
                new MonsterNest()
                {
                    Name = "Monster Nest"
                },
                new Tower()
                {
                    Name = "Tower"
                },
                new Town()
                {
                    Name = "Town"
                },
                new Camp()
                {
                    Name = "Camp"
                },
                new Locations()
                {
                    Name = "Wilderness"
                }
            };

            var randomWeapon = new Random();

            randomWeapon.Next(0, 2);
            var lowLevelWeaponList = gameItemCollection.lowLevelWeapons.ToList();

            var randomNumber = random.Next(1, 100);

            if (randomNumber > 0 && randomNumber < 5)
            {
                var currentLocation = randomLocations.ElementAt(0);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }

            else if (randomNumber > 5 && randomNumber < 10)
            {
                var currentLocation = randomLocations.ElementAt(1);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }

            else if (randomNumber > 10 && randomNumber < 15)
            {
                var currentLocation = randomLocations.ElementAt(2);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }

            else if (randomNumber > 15 && randomNumber < 20)
            {
                var currentLocation = randomLocations.ElementAt(3);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }

            else if (randomNumber > 20 && randomNumber < 25)
            {
                Random randomMerchantGenerator = new Random();
                var    merchGen = randomMerchantGenerator.Next(1, 10);

                if (merchGen > 0 && merchGen < 3)
                {
                    location.HasBlacksmith      = true;
                    location.HasGeneralMerchant = true;
                    location.HasHerbalist       = true;
                }

                var currentLocation = randomLocations.ElementAt(4);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }

            else if (randomNumber > 25 && randomNumber < 30)
            {
                Random randomMerchantGenerator = new Random();
                var    merchGen = randomMerchantGenerator.Next(1, 10);

                if (merchGen > 0 && merchGen < 3)
                {
                    location.HasTravelingMerchant = true;
                }

                var currentLocation = randomLocations.ElementAt(5);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }

            else
            {
                var currentLocation = randomLocations.ElementAt(6);
                location.PopulateLocation(currentLocation);
                player.PlayerLocation = currentLocation;
            }
        }