Exemple #1
0
        public Wilderness(Town start, Town finish) //parameters are not in a form of a collection for better usability and readability
        {
            endpoints[0] = start;
            endpoints[1] = finish;

            level = CalculateLevel(endpoints[0], endpoints[1]);
            title = $"{Output.LoadingLabel} {Output.TownToFilename(finish)}...";

            encountersAt   = CalculateLoadingEvents(CalculateEncounterAmount());
            loadingStuckAt = CalculateLoadingEvents(GenericOperations.GetRandom().Next(0, Settings.MaxStuckTimes));

            description = $"{Output.DidYouKnowSentence} {Output.ProTips[GenericOperations.GetRandom().Next(0, Output.ProTips.Count)]}";

            screen = ScreenType.wilderness;
        }
Exemple #2
0
 private int[] CalculateLoadingEvents(int amount)
 {
     int [] result = new int[amount];
     for (int i = 0; i < amount; i++)
     {
         while (true) //ensure there are no duplicate values
         {
             int encIndex = GenericOperations.GetRandom().Next(0, Settings.DefaultWildernessGoal);
             if (!result.Contains(encIndex))
             {
                 result[i] = encIndex;
                 break;
             }
         }
     }
     Array.Sort(result);
     return(result);
 }
Exemple #3
0
        public void Explore(Player player)
        {
            Output.InitializeLoadingScreen(exploredCurrent, "");
            int loadingDelay = GenericOperations.GetRandom().Next(Settings.MinLoadingDelay, Settings.MaxLoadingDelay);

            int nextStuck = 0;

            int nextEncounter = (encounterIndex < encountersAt.Length) ? encountersAt[encounterIndex] : 0;

            if (loadingStuckAt.Length > 0)
            {
                nextStuck = loadingStuckAt[0];
            }

            while (exploredCurrent <= Settings.DefaultWildernessGoal)
            {
                Output.AnimateLoadingBar(exploredCurrent);
                Thread.Sleep(loadingDelay);
                exploredCurrent++;
                if (nextEncounter == exploredCurrent)
                {
                    EncounterIndex++;
                    GenerateEncounter(player);
                    return;
                }

                if (exploredCurrent == nextStuck)
                {
                    Thread.Sleep(Settings.LoadingStuckDelay);
                    loadingDelay   = GenericOperations.GetRandom().Next(Settings.MinLoadingDelay, Settings.MaxLoadingDelay);
                    loadingStuckAt = loadingStuckAt.Skip(1).ToArray();
                    if (loadingStuckAt.Length > 0)
                    {
                        nextStuck = loadingStuckAt[0];
                    }
                }
            }
            player.ChangeLocation(endpoints[1]);
        }
Exemple #4
0
 public static void WriteBinary()
 {
     Console.Write(GenericOperations.GetRandom().Next(0, 2));
     Thread.Sleep(10);
 }