示例#1
0
        public SessionManager(string filePath, DynamicContentManager Content)
        {
            SessionBuilder builder = SessionBuilder.BuilderRead(filePath);

            if (builder.OtherLocations == null)
            {
                builder.OtherLocations = new string[0];
            }
            Worlds           = new Dictionary <string, Location>(3 + builder.Lands.Length + builder.OtherLocations.Length);
            GenericMeteors   = new GenericMeteor[builder.GenericMeteors.Length];
            Description      = builder.Description;
            PlayerWorldCount = builder.Lands.Length;

            if (builder.Scratched)
            {
                Timeline = new TimelineEvent[builder.Timeline.Length + PlayerWorldCount + builder.OtherLocations.Length + 4];
            }
            else
            {
                Timeline = new TimelineEvent[builder.Timeline.Length + PlayerWorldCount + builder.OtherLocations.Length + 3];
            }

            Skaia tempSkaia = Content.Load <Skaia>(builder.Skaia);

            Worlds.Add("Skaia", tempSkaia);
            SessionLocation tempProspit = Content.Load <SessionLocation>(builder.Prospit);

            Worlds.Add("Prospit", tempProspit);
            SessionLocation tempDerse = Content.Load <SessionLocation>(builder.Derse);

            Worlds.Add("Derse", tempDerse);
            PlayerWorld[] tempLands = new PlayerWorld[PlayerWorldCount];
            for (int i = 0; i < builder.Lands.Length; i++)
            {
                tempLands[i]    = Content.Load <PlayerWorld>(builder.Lands[i]);
                Timeline[i + 2] = new TimelineEvent(tempLands[i].Name, EventTypes.Reload, "None", builder.Lands[i]);
                Worlds.Add(tempLands[i].Name, tempLands[i]);
            }
            SessionLocation[] tempMeteors = new SessionLocation[builder.OtherLocations.Length];
            for (int i = 0; i < tempMeteors.Length; i++)
            {
                tempMeteors[i] = Content.Load <SessionLocation>(builder.OtherLocations[i]);
                Timeline[i + 2 + tempLands.Length] = new TimelineEvent(tempMeteors[i].Name, EventTypes.Reload, "None", builder.OtherLocations[i]);
                Worlds.Add(tempMeteors[i].Name, tempMeteors[i]);
            }
            for (int i = 0; i < GenericMeteors.Length; i++)
            {
                GenericMeteors[i] = new GenericMeteor(Path.Combine(Content.BaseDirectory, builder.GenericMeteors[i]), Content);
            }

            Timeline[0] = new TimelineEvent("Prospit", EventTypes.Reload, "None", builder.Prospit);
            Timeline[1] = new TimelineEvent("Derse", EventTypes.Reload, "None", builder.Derse);

            Timeline[tempLands.Length + tempMeteors.Length + 2] = new TimelineEvent("Skaia", EventTypes.Reload, true, "None", builder.Skaia);
            if (builder.Scratched)
            {
                for (int i = tempLands.Length + tempMeteors.Length + 3; i < Timeline.Length - 1; i++)
                {
                    Timeline[i] = builder.Timeline[i - (tempLands.Length + tempMeteors.Length + 3)];
                }
                Timeline[Timeline.Length - 1] = new TimelineEvent("Session", EventTypes.ScratchComplete, true, "", "");
            }
            else
            {
                for (int i = tempLands.Length + tempMeteors.Length + 3; i < Timeline.Length; i++)
                {
                    Timeline[i] = builder.Timeline[i - (tempLands.Length + tempMeteors.Length + 3)];
                }
            }

            List <int> visibleEvents = new List <int>();

            for (int i = 0; i < Timeline.Length; i++)
            {
                if (Timeline[i].IsVisible)
                {
                    visibleEvents.Add(i);
                }
            }
            VisibleEvents   = visibleEvents.ToArray();
            Scratched       = builder.Scratched;
            VoidSession     = builder.VoidSession;
            NullSession     = builder.NullSession;
            ReckoningActive = false;
        }