Exemplo n.º 1
0
        public static void CalculateLevelBits(string[] route)
        {
            //declaring local variables

            //this is an array that tells how many starbits each star will collect.
            int[] starbitsCollected = new int[61];

            for (int i = 0; i < 61; i++)
            {
                //marks the level as complete and increments the star counter
                StarInfo.levelList[i].isStarComplete = true;
                currentStarCount++;

                //keeps track of the level's star number
                StarInfo.levelList[i].starNumber = currentStarCount;

                //this special counter checks if buoy base is completed.

                if (StarInfo.levelList[i] == StarInfo.buoybase1 || StarInfo.levelList[i] == StarInfo.buoybases)
                {
                    buoyBaseCounter += 1;
                    if (buoyBaseCounter == 2)
                    {
                        StarInfo.buoybase1.isGalaxyComplete = true;
                        StarInfo.buoybases.isGalaxyComplete = true;
                    }
                }

                if (!StarInfo.levelList[i].HasNotifs() && !SpecialNotifs(StarInfo.levelList[i], StarInfo.levelList[i - 1]))
                {
                    if (StarInfo.levelList[i].minBits < 18 - minBitLeeway)
                    {
                        StarInfo.levelList[i].collectedBits = StarInfo.levelList[i].minBits;
                    }
                    else
                    {
                        StarInfo.levelList[i].collectedBits = 18 - minBitLeeway;
                    }
                }


                else
                {
                    StarInfo.levelList[i].collectedBits = 0;
                }

                if (StarInfo.levelList[i].collectedBits <= 0)
                {
                    StarInfo.levelList[i].collectedBits = 0;
                }

                //this allows the program to check if a certain dome has been unlocked yet.
                if (StarInfo.levelList[i] == StarInfo.bowserjr1)
                {
                    Galaxy.isFoutainUnlocked = true;
                }

                if (StarInfo.levelList[i] == StarInfo.bowser1)
                {
                    Galaxy.isKitchenUnlocked = true;
                }

                if (StarInfo.levelList[i] == StarInfo.bowserjr2)
                {
                    Galaxy.isBedroomUnlocked = true;
                }

                if (StarInfo.levelList[i] == StarInfo.bowser2)
                {
                    Galaxy.isEngineRoomUnlocked = true;
                }

                if (StarInfo.levelList[i] == StarInfo.honeyclimb)
                {
                    StarInfo.honeyclimb.collectedBits = StarInfo.honeyclimb.maxBits;
                    notifOverlapLevels[i]             = "Honeyclimb";
                    notifOverlap += 1;
                }

                if (StarInfo.levelList[i] == StarInfo.bowser3)
                {
                    StarInfo.bowser3.collectedBits = 69;
                }
                //this section will check if the player has enough starbits total. This tells the program whether to require minimum or maximum bits from a level.
                while (StarInfo.levelList[i] == StarInfo.slingpod && currentTotalStarbits < 400 + totalBitLeeway)
                {
                    //This galaxy is only in this loop so it doesn't have to call this method every single time I want to use
                    //what it returns.
                    Galaxy tempGalaxy = CurrentMaxStarbitLevel(i);

                    currentTotalStarbits           -= tempGalaxy.collectedBits;
                    tempGalaxy.collectedBits        = tempGalaxy.maxBits;
                    currentTotalStarbits           += tempGalaxy.collectedBits;
                    tempGalaxy.hasStarbitsCollected = true;
                }

                while (StarInfo.levelList[i] == StarInfo.sweetsweet && currentTotalStarbits < 400 + totalBitLeeway)
                {
                    Galaxy tempGalaxy = CurrentMaxStarbitLevel(i);

                    currentTotalStarbits           -= tempGalaxy.collectedBits;
                    tempGalaxy.collectedBits        = tempGalaxy.maxBits;
                    currentTotalStarbits           += tempGalaxy.collectedBits;
                    tempGalaxy.hasStarbitsCollected = true;
                }

                while (StarInfo.levelList[i] == StarInfo.dripdrop && currentTotalStarbits < 600 + totalBitLeeway)
                {
                    Galaxy tempGalaxy = CurrentMaxStarbitLevel(i);

                    currentTotalStarbits           -= tempGalaxy.collectedBits;
                    tempGalaxy.collectedBits        = tempGalaxy.maxBits;
                    currentTotalStarbits           += tempGalaxy.collectedBits;
                    tempGalaxy.hasStarbitsCollected = true;
                }

                //decrements starbit counter if luma is fed.
                if (StarInfo.levelList[i] == StarInfo.sweetsweet)
                {
                    currentTotalStarbits          -= 400;
                    StarInfo.sweetsweet.hasBeenFed = true;
                }

                if (StarInfo.levelList[i] == StarInfo.dripdrop)
                {
                    currentTotalStarbits        -= 600;
                    StarInfo.dripdrop.hasBeenFed = true;
                }

                if (StarInfo.levelList[i] == StarInfo.slingpod)
                {
                    currentTotalStarbits        -= 400;
                    StarInfo.slingpod.hasBeenFed = true;
                }

                //This checks if all hungry lumas have been fed. This should work regardless of which hungry lumas you have in whatever order.
                if (StarInfo.sweetsweet.hasBeenFed && StarInfo.dripdrop.hasBeenFed && StarInfo.slingpod.hasBeenFed &&
                    StarInfo.levelList[i] != StarInfo.bowser3)
                {
                    StarInfo.levelList[i].collectedBits = 0;
                }

                //stores how many bits are collected. Adds to the total current starbits.
                currentTotalStarbits += StarInfo.levelList[i].collectedBits;

                //Calls methods that will determine the type of notification each star has
                StarInfo.levelList[i].WhatNotifs();
                if (i > 0)
                {
                    if (SpecialNotifs(StarInfo.levelList[i], StarInfo.levelList[i - 1]))
                    {
                        WhatSpecialNotifs(StarInfo.levelList[i], StarInfo.levelList[i - 1]);
                    }
                }
            }

            for (int i = 0; i < 61; i++)
            {
                starbitsCollected[i] = StarInfo.levelList[i].collectedBits;
            }


            //Writes final route to text file.
            System.IO.StreamWriter splitText = new StreamWriter(path);
            for (int i = 0; i < 61; i++)
            {
                if (printReason)
                {
                    if (StarInfo.levelList[i].reason[0] != null ||
                        StarInfo.levelList[i].reason[1] != null ||
                        StarInfo.levelList[i].reason[2] != null ||
                        StarInfo.levelList[i].reason[3] != null ||
                        StarInfo.levelList[i].reason[4] != null)
                    {
                        if (starbitsCollected[i] != 0)
                        {
                            splitText.Write("{0} ({1}) (", route[i], starbitsCollected[i]);

                            for (int j = 0; j < 5; j++)
                            {
                                splitText.Write("{0}", StarInfo.levelList[i].reason[j]);
                            }

                            splitText.WriteLine(")");
                        }
                        else
                        {
                            splitText.Write("{0} (", route[i]);

                            for (int j = 0; j < 5; j++)
                            {
                                splitText.Write("{0}", StarInfo.levelList[i].reason[j]);
                            }

                            splitText.WriteLine(")");
                        }
                    }
                    else
                    {
                        if (starbitsCollected[i] != 0)
                        {
                            splitText.WriteLine("{0} ({1})", route[i], starbitsCollected[i]);
                        }
                        else
                        {
                            splitText.WriteLine("{0}", route[i]);
                        }
                    }
                }
                else
                {
                    if (starbitsCollected[i] != 0)
                    {
                        splitText.WriteLine("{0} ({1})", route[i], starbitsCollected[i]);
                    }
                    else
                    {
                        splitText.WriteLine(route[i]);
                    }
                }
            }

            splitText.Write("\nNumber of times starbit textboxes overlap with other notifications: {0}\n" +
                            "Levels where it happens: ", notifOverlap);

            for (int i = 0; i < 61; i++)
            {
                if (notifOverlapLevels[i] != null)
                {
                    splitText.Write("{0}(#{1}, ", notifOverlapLevels[i], StarInfo.levelList[i].starNumber);

                    for (int j = 0; j < 5; j++)
                    {
                        splitText.Write("{0}", StarInfo.levelList[i].reason[j]);
                    }

                    splitText.Write("), ");
                }
            }

            splitText.Write("\n\nC = Galaxy Complete\n" +
                            "Co = Coins\n" +
                            "G = Galaxy Unlocked\n" +
                            "R = New Story Chapter\n" +
                            "H = Hungry Luma");
            splitText.Close();
        }