示例#1
0
    public FractionData GetRandomByDifficulty(Constants.Difficulty difficulty, bool forceProper = false, bool forceAlwaysOne = false, bool forceNumeratorOne = false)
    {
        Debug.Log("forceProper: " + forceProper + ", forceAlwaysOne: " + forceAlwaysOne + ", forceNumeratorOne: " + forceNumeratorOne);
        //if (difficulty == Constants.Difficulty.EASY)
        //    throw new ArgumentException("Easy difficulty can't have improper fractions!");

        List <FractionData> fractionData = Data[(int)difficulty];

        if (forceAlwaysOne)
        {
            fractionData = fractionData.Where(fd => fd.Value.numerator == fd.Value.denominator).ToList();
        }
        else if (forceNumeratorOne)
        {
            fractionData = fractionData.Where(fd => fd.Value.numerator == 1).ToList();
        }
        else if (forceProper)
        {
            fractionData = fractionData.Where(fd => fd.Value.numerator < fd.Value.denominator).ToList();
        }

        /* Choose a random bit of data from the list */
        FractionData choice = fractionData[UnityEngine.Random.Range(0, fractionData.Count)];

        return(choice);
    }
示例#2
0
 private static void ChangeQuests(Constants.Difficulty difficulty, bool complete, byte[] rawSaveFile)
 {
     ChangeQuests(difficulty, Constants.Act.TheSightlessEye, complete, rawSaveFile);
     ChangeQuests(difficulty, Constants.Act.SecretOfTheVizjerei, complete, rawSaveFile);
     ChangeQuests(difficulty, Constants.Act.TheInfernalGate, complete, rawSaveFile);
     ChangeQuests(difficulty, Constants.Act.TheHarrowing, complete, rawSaveFile);
     ChangeQuests(difficulty, Constants.Act.LordOfDestruction, complete, rawSaveFile);
 }
示例#3
0
 private static void ChangeQuests(Constants.Difficulty difficulty, Constants.Act act, bool complete, byte[] rawSaveFile)
 {
     ChangeQuest(difficulty, act, Constants.Quest.FirstQuest, complete, rawSaveFile);
     ChangeQuest(difficulty, act, Constants.Quest.SecondQuest, complete, rawSaveFile);
     ChangeQuest(difficulty, act, Constants.Quest.ThirdQuest, complete, rawSaveFile);
     if (act != Constants.Act.TheHarrowing)
     {
         ChangeQuest(difficulty, act, Constants.Quest.FourthQuest, complete, rawSaveFile);
         ChangeQuest(difficulty, act, Constants.Quest.FifthQuest, complete, rawSaveFile);
         ChangeQuest(difficulty, act, Constants.Quest.SixthQuest, complete, rawSaveFile);
     }
 }
示例#4
0
        private static int GetQuestOffset(Constants.Difficulty difficulty, Constants.Act act, Constants.Quest quest)
        {
            int offset = -1;

            if (act != Constants.Act.TheHarrowing || quest < Constants.Quest.FourthQuest)
            {
                offset = 12;                    // 10 bytes for the quest header, 2 bytes for the act introduction

                offset += (int)difficulty * 96; // choose to the right difficulty
                offset += (int)act * 16;        // choose to the right act
                offset += (int)quest * 2;       // choose the right quest

                if (act == Constants.Act.LordOfDestruction)
                {
                    offset += 4;                // there are additional bytes in act 4
                }
            }

            return(offset);
        }
示例#5
0
        private static void ChangeQuest(Constants.Difficulty difficulty, Constants.Act act, Constants.Quest quest, bool complete, byte[] rawSaveFile)
        {
            int offset = Constants.QUESTS_SECTION_OFFSET + GetQuestOffset(difficulty, act, quest);

            if (offset == -1)
            {
                return;
            }

            if (complete)
            {
                rawSaveFile[offset]     = 0x01; // Quest complete
                rawSaveFile[offset + 1] = 0x10; // Quest log animation viewed

                if (act == Constants.Act.LordOfDestruction && quest == Constants.Quest.ThirdQuest)
                {
                    // Scroll of resist
                    rawSaveFile[offset] += 0xC0;
                }
            }
            else
            {
                rawSaveFile[offset]     = 0;
                rawSaveFile[offset + 1] = 0;
            }

            // Allow travel to the next act.
            // For Act4, the diablo quest is quest2
            if (complete && (quest == Constants.Quest.SixthQuest || (act == Constants.Act.TheHarrowing && quest == Constants.Quest.SecondQuest)))
            {
                if (act != Constants.Act.TheHarrowing)
                {
                    rawSaveFile[offset + 2] = 1;
                }
                else
                {
                    rawSaveFile[offset + 4] = 1;
                }
            }
        }