コード例 #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;
        }
コード例 #2
0
        public override void LoadContent()
        {
            base.LoadContent();

            cursor = new TexturedPlane(Vector3.Zero, Quaternion.Identity, new Vector2(7), Color.White, false,
                                       ScreenManager.Content.Load <Texture2D>(".//UI//Cursor.png"));

            currentSession = ScreenManager.Content.Load <SessionManager>(sessionPath);
            float innerRimSize = 90;

            innerRim = new TexturedPlane(new Vector3(0, 5, 0), Quaternion.Identity, new Vector2(innerRimSize), Color.White,
                                         false, ScreenManager.Content.Load <Texture2D>(".//Miscellaneous//Inner Rim.png"));
            float outerRimSize = currentSession.PlayerWorldCount * 25 + innerRimSize;

            outerRim = new TexturedPlane(new Vector3(0, 5, 0), Quaternion.Identity, new Vector2(outerRimSize), Color.White,
                                         false, ScreenManager.Content.Load <Texture2D>(".//Miscellaneous//Outer Rim.png"));

            ScreenManager.Globals.Camera = new SphericalCamera(new Vector3(0, 4, 0), new Vector2(0, 60), 125);
            (ScreenManager.Globals.Camera as SphericalCamera).MaxZoomLevel = 600;
            cameraRange = (outerRimSize / 2) + 45f;

            descriptionControl          = new Button(new AABox(new Rectangle(0, 0, 136, 23)), position: new Coordinate(0, 578));
            descriptionBox              = new Button(null, ScreenManager.Content.Load <Texture2D>(".//UI//Description Box.png"), null, new Coordinate(0, 574));
            descriptionText             = new TextBox("", new Rectangle(5, 605, 790, 186), "Default");
            descriptionControl.Clicked += OnOpenDescription;

            float  outerRimCircumference = (float)(outerRimSize * Math.PI);
            Random rand = new Random(4);

            if (outerRimCircumference < 1000)
            {
                genericMeteors = new GenericMeteor[(int)outerRimCircumference];
            }
            else
            {
                genericMeteors = new GenericMeteor[1000];
            }
            for (int i = 0; i < genericMeteors.Length; i++)
            {
                float angleOffset = (float)(rand.NextDouble() - 0.5);
                float distOffset  = (float)(rand.NextDouble() - 0.5) * 10f;
                float yOffset     = (float)(rand.NextDouble() - 0.5) * 3f;
                genericMeteors[i] = currentSession.GenericMeteors[rand.Next(currentSession.GenericMeteors.Length)].DeepCopy();
                genericMeteors[i].AddModifier(new OrbitModifier3D(new Vector3(0, 8 + yOffset, 0), Vector3.Up,
                                                                  (outerRimSize / 2) + 7.5f + distOffset, (float)((Math.PI * 2) * ((float)i / genericMeteors.Length)) + angleOffset,
                                                                  -0.002f, genericMeteors[i], false, -1));
            }
            //foreach (var keyValue in currentSession.Worlds)
            //    keyValue.Value.Initialize();
            if (currentSession.Worlds["Prospit"].UserPlaced == false)
            {
                currentSession.Worlds["Prospit"].WorldPlane.AddModifier(new OrbitModifier3D(new Vector3(0, 12, 0),
                                                                                            Vector3.Up, 15, 0, -0.002f, currentSession.Worlds["Prospit"].WorldPlane, false, -1));
            }
            if (currentSession.Worlds["Derse"].UserPlaced == false)
            {
                currentSession.Worlds["Derse"].WorldPlane.AddModifier(new OrbitModifier3D(new Vector3(0, 12, 0),
                                                                                          Vector3.Up, outerRimSize / 2 + 15, 1, 0.002f, currentSession.Worlds["Derse"].WorldPlane, false, -1));
            }
            //Prospit: new Vector3(0, 12, 0), Vector3.Up, 15, 0, -0.002f  Derse: new Vector3(0, 12, 0), Vector3.Up, outerRimSize / 2 + 15, 1, 0.002f
            int   h          = 0;
            float planetDist = (outerRimSize / 2 - innerRimSize / 2) / 2 + innerRimSize / 2;

            foreach (var keyValue in currentSession.Worlds)
            {
                if (keyValue.Value is PlayerWorld)
                {
                    PlayerWorld world = keyValue.Value as PlayerWorld;
                    world.Initialize(planetDist, (MathHelper.TwoPi / currentSession.PlayerWorldCount) * h, 0.003f);
                    h++;
                }
            }
            //timelineControl = new TimelineControl(currentSession, this);
            alphaTester = new AlphaTestEffect(ScreenManager.Globals.Graphics);
        }