예제 #1
0
        /// <summary>
        /// This routine reads the record on a saved file that contains the Global Definition values
        /// </summary>
        /// <param name="entries"></param>
        public void ReadGlobalVariables(string[] entries)
        {
            GlobalDefinitions.numberOfCarpetBombingsUsed = Convert.ToInt32(entries[1]);
            GlobalDefinitions.numberInvasionsExecuted    = Convert.ToInt32(entries[2]);
            GlobalDefinitions.firstInvasionAreaIndex     = Convert.ToInt32(entries[3]);
            if (GlobalDefinitions.firstInvasionAreaIndex != -1)
            {
                GlobalDefinitions.invasionAreas[GlobalDefinitions.firstInvasionAreaIndex].invaded = true;
            }
            GlobalDefinitions.secondInvasionAreaIndex = Convert.ToInt32(entries[4]);
            if (GlobalDefinitions.secondInvasionAreaIndex != -1)
            {
                GlobalDefinitions.invasionAreas[GlobalDefinitions.secondInvasionAreaIndex].invaded = true;
            }
            GlobalDefinitions.germanReplacementsRemaining = Convert.ToInt32(entries[5]);
            GlobalDefinitions.alliedReplacementsRemaining = Convert.ToInt32(entries[6]);
            GlobalDefinitions.alliedCapturedBrest         = Convert.ToBoolean(entries[7]);
            GlobalDefinitions.alliedCapturedBoulogne      = Convert.ToBoolean(entries[8]);
            GlobalDefinitions.alliedCapturedRotterdam     = Convert.ToBoolean(entries[9]);
            if (GlobalDefinitions.firstInvasionAreaIndex != -1)
            {
                GlobalDefinitions.invasionAreas[GlobalDefinitions.firstInvasionAreaIndex].turn = Convert.ToInt32(entries[10]);
            }
            if (GlobalDefinitions.secondInvasionAreaIndex != -1)
            {
                GlobalDefinitions.invasionAreas[GlobalDefinitions.secondInvasionAreaIndex].turn = Convert.ToInt32(entries[11]);
            }
            GlobalDefinitions.numberOfTurnsWithoutSuccessfulAttack = Convert.ToInt32(entries[12]);

            GlobalDefinitions.hexesAttackedLastTurn.Clear();
            int loopLimit  = Convert.ToInt32(entries[13]);
            int entryIndex = 13;

            for (int index = 0; index < loopLimit; index++)
            {
                entryIndex++;
                GlobalDefinitions.hexesAttackedLastTurn.Add(GameObject.Find(entries[entryIndex]));
            }

            entryIndex++;
            GlobalDefinitions.combatResultsFromLastTurn.Clear();
            loopLimit = Convert.ToInt32(entries[entryIndex]);
            for (int index = 0; index < loopLimit; index++)
            {
                entryIndex++;

                switch (entries[entryIndex])
                {
                case "Delim":
                    GlobalDefinitions.combatResultsFromLastTurn.Add(GlobalDefinitions.CombatResults.Delim);
                    break;

                case "Dback2":
                    GlobalDefinitions.combatResultsFromLastTurn.Add(GlobalDefinitions.CombatResults.Dback2);
                    break;

                case "Aelim":
                    GlobalDefinitions.combatResultsFromLastTurn.Add(GlobalDefinitions.CombatResults.Aelim);
                    break;

                case "Aback2":
                    GlobalDefinitions.combatResultsFromLastTurn.Add(GlobalDefinitions.CombatResults.Aback2);
                    break;

                case "Exchange":
                    GlobalDefinitions.combatResultsFromLastTurn.Add(GlobalDefinitions.CombatResults.Exchange);
                    break;
                }
            }
            entryIndex++;
            GlobalDefinitions.turnsAlliedMetVictoryCondition = Convert.ToInt32(entries[entryIndex]);
            entryIndex++;
            GlobalDefinitions.alliedFactorsEliminated = Convert.ToInt32(entries[entryIndex]);
            entryIndex++;
            GlobalDefinitions.germanFactorsEliminated = Convert.ToInt32(entries[entryIndex]);

            entryIndex++;
            GlobalDefinitions.easiestDifficultySettingUsed = Convert.ToInt32(entries[entryIndex]);

            GlobalDefinitions.GuiUpdateLossRatioText();
            GlobalDefinitions.GuiDisplayAlliedVictoryStatus();
        }