Esempio n. 1
0
 public void OnEnter(object sender, EventArgs e)
 {
     if (currentState == MenuState.StartMenu)
     {
         //Opens a selection menu with all of the available sessions in the folder, moves three main buttons up.
         currentState = MenuState.MovingToFile;
         List <string> sessionFiles = new List <string>(Directory.GetFiles(Content.BaseDirectory + "\\XML Files\\Sessions", "*.xml"));
         sessionButtonList = new List <Button>();
         for (int i = 0; i < sessionFiles.Count; i++)
         {
             Button loadSession = new Button(null, Content.Load <Texture2D>(".\\UI\\Blank Button.png"), null, new Coordinate(526 + (i / 4) * 800, 899 + (i % 4) * 66));
             sessionButtonList.Add(loadSession);
             sessionButtonList[i].AddModifier(new SmoothStepModifier2D(new Vector2(-1, 299 + (i % 4) * 66),
                                                                       loadSession, false, 60));
             string buttonText = Path.GetFileNameWithoutExtension(sessionFiles[i]);
             if (ScreenManager.Globals.Fonts["Default"].MeasureString(buttonText).X > 178)
             {
                 int ellipsisLength = (int)ScreenManager.Globals.Fonts["Default"].MeasureString("...").X;
                 while (ScreenManager.Globals.Fonts["Default"].MeasureString(buttonText).X + ellipsisLength > 178)
                 {
                     buttonText = buttonText.Remove(buttonText.Length - 1);
                 }
                 buttonText = buttonText.Insert(buttonText.Length, "...");
             }
             //TODO: Repair this
             loadSession.Text            = new StringFontPositionColor(buttonText, "Consolas", new Vector2(73, 21), Color.White);
             loadSession.Clicked        += OnLoadClick;
             buttonsToPaths[loadSession] = sessionFiles[i];
         }
         if (sessionButtonList.Count != 0)
         {
             for (int i = 0; i < mainButtonList.Count; i++)
             {
                 mainButtonList[i].AddModifier(new SmoothStepModifier2D(new Vector2(-1, -301 + i * 66), mainButtonList[i], false, 60));
             }
             fileToStart.AddModifier(new SmoothStepModifier2D(new Vector2(-1, 560), fileToStart, false, 60));
             prevFilePage.AddModifier(new SmoothStepModifier2D(new Vector2(-1, 560), prevFilePage, false, 60));
             nextFilePage.AddModifier(new SmoothStepModifier2D(new Vector2(-1, 560), nextFilePage, false, 60));
         }
         else
         {
             currentState = MenuState.StartMenu;
             errorMessage = "No .xml files found in " + Content.BaseDirectory + "\\XML Files\\Sessions.";
             errorTimer   = 120;
         }
     }
 }
Esempio n. 2
0
        public static TileData[] LoadBuildingData(string path, DynamicContentManager content)
        {
            BuildingDataLoader[] unprocessedTileData;
            XmlSerializer        xmlSerializer = new XmlSerializer(typeof(BuildingDataCont));
            StreamReader         streamReader  = new StreamReader(path);

            unprocessedTileData = ((BuildingDataCont)xmlSerializer.Deserialize(streamReader)).TileDefinitions;
            streamReader.Close();

            BuildingData[] result = new BuildingData[unprocessedTileData.Length];
            for (int i = 0; i < result.Length; i++)
            {
                Texture2D tileTexture = content.Load <Texture2D>(unprocessedTileData[i].Spritesheet);
                result[i] = new BuildingData {
                    ID = unprocessedTileData[i].ID, Name = unprocessedTileData[i].Name, Spritesheet = tileTexture, SampleArea = unprocessedTileData[i].SampleArea
                };
            }
            return(result);
        }
Esempio n. 3
0
        public Window(WindowManager manager, DynamicContentManager content, Rectangle dimensions, Color[] borderColors, IContainer layout, string title = "Window", bool closable = true, bool growForPadding = false)
        {
            //Reserve space for title bar (? x 17) + edges (4 x 2)
            this.manager = manager;
            if (!(layout is Element))
            {
                throw new ArgumentException();
            }
            mainContainer     = (Element)layout;
            this.borderColors = borderColors;
            if (uiComponents == null)
            {
                uiComponents = content.Load <Texture2D>(".//UI//UI Elements.png");
            }
            Title           = title;
            TopPad          = 2;
            BotPad          = 2;
            TitlePad        = 15;
            LeftPad         = 2;
            RightPad        = 2;
            this.dimensions = dimensions;
            if (growForPadding)
            {
                dimensions.Width  += LeftPad + RightPad;
                dimensions.Height += TitlePad + TopPad + BotPad;
            }
            if (closable)
            {
                closeButton = new Button(new AABox(new Rectangle(0, 0, 13, 13)), uiComponents,
                                         new Rectangle[] { new Rectangle(13, 0, 13, 13), new Rectangle(13, 0, 13, 13), new Rectangle(13, 0, 13, 13), new Rectangle(13, 0, 13, 13) },
                                         new Coordinate(0, 0));
                closeButton.Released += CloseWindow;
            }

            layout.BuildNames();
            buildBindables();
            Resize(new Coordinate(dimensions.Width, dimensions.Height));
        }
Esempio n. 4
0
        private void reload(string filePath, DynamicContentManager Content)
        {
            SessionLocation newState = Content.Load <SessionLocation>(filePath);

            newState.plane.ClearModifiers();
            TexturedPlane oldPlane = plane;

            plane               = newState.plane;
            plane.Color         = oldPlane.Color;
            plane.WorldPosition = oldPlane.WorldPosition;
            IsVisible           = newState.isVisible;
            PrimaryColor        = newState.PrimaryColor;
            Name               = newState.Name;
            Description        = newState.Description;
            CursorDetectRadius = newState.CursorDetectRadius;
            for (int i = 0; i < oldPlane.Modifiers.Length; i++)
            {
                if (oldPlane.Modifiers[i] != null)
                {
                    plane.AddModifier(oldPlane.Modifiers[i].DeepCopy(plane));
                }
            }
        }
Esempio n. 5
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;
        }
Esempio n. 6
0
        public static Tile[, ,] LoadTileMap(string path, MapToTileData conversions, int levels, DynamicContentManager content)
        {
            if (levels < 1)
            {
                throw new ArgumentException("The map must have at least one level.");
            }
            Texture2D mapImage = content.Load <Texture2D>(path);

            Color[] mapData = new Color[mapImage.Width * mapImage.Height];
            mapImage.GetData <Color>(mapData);
            Tile[,,] map = new Tile[mapImage.Width, mapImage.Height, levels];
            for (int z = 0; z < levels; z++)
            {
                for (int y = 0; y < mapImage.Height; y++)
                {
                    for (int x = 0; x < mapImage.Width; x++)
                    {
                        if (z == 0)
                        {
                            if (mapData[y * mapImage.Width + x] == new Color(128, 128, 128))
                            {
                                map[x, y, z] = new Tile(conversions.ADozed, true);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(128, 128, 0))
                            {
                                map[x, y, z] = new Tile(conversions.ASmooth, true);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(0, 128, 0))
                            {
                                map[x, y, z] = new Tile(conversions.ARough, true);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(128, 0, 0))
                            {
                                map[x, y, z] = new Tile(conversions.AHostile, true);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(0, 0, 0))
                            {
                                map[x, y, z] = new Tile(conversions.AImpassible, true);
                            }
                        }
                        else
                        {
                            if (mapData[y * mapImage.Width + x] == new Color(128, 128, 128))
                            {
                                map[x, y, z] = new Tile(conversions.UDozed, true);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(128, 128, 0))
                            {
                                map[x, y, z] = new Tile(conversions.USmooth, false);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(0, 128, 0))
                            {
                                map[x, y, z] = new Tile(conversions.URough, false);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(128, 0, 0))
                            {
                                map[x, y, z] = new Tile(conversions.UHostile, false);
                            }
                            else if (mapData[y * mapImage.Width + x] == new Color(0, 0, 0))
                            {
                                map[x, y, z] = new Tile(conversions.UImpassible, false);
                            }
                        }
                    }
                }
            }
            return(map);
        }
Esempio n. 7
0
        public override void LoadContent()
        {
            Content = new DynamicContentManager(ScreenManager.StaticGame, ScreenManager.StaticGame.Content, ScreenManager.StaticGame.Content.RootDirectory);
            //Content.LogFailures = true;

            copyrightText = new StringPositionColor("Homestuck © Andrew Hussie", new Vector2(0, 575), Color.White);
            ScreenManager.Globals.Fonts.AddFont("Consolas", ".//Fonts//Consolas.spritefont");
            ScreenManager.Globals.Fonts.AddFont("Carima", ".//Fonts//Carima.spritefont");
            Texture2D sessionTexture = Content.Load <Texture2D>(".//UI//Session.png");

            titleText = new Sprite(new Vector2(393, 111), Vector2.One, 0, Color.White, Content.Load <Texture2D>(".//UI//Title Text.png"));
            Button enterButton = new Button(null, Content.Load <Texture2D>(".//UI//Enter Button.png"), null, new Coordinate(526, 299));
            Button guideButton = new Button(null, Content.Load <Texture2D>(".//UI//Guide Button.png"), null, new Coordinate(526, 365));
            Button exitButton  = new Button(null, Content.Load <Texture2D>(".//UI//Exit Button.png"), null, new Coordinate(526, 431));

            Content.Load <Texture2D>(".//UI//Blank Button.png");

            fileToStart  = new Button(null, Content.Load <Texture2D>(".//UI//Up Button.png"), null, new Coordinate(650, 1160));
            prevFilePage = new Button(null, Content.Load <Texture2D>(".//UI//Left Button.png"), null, new Coordinate(580, 1160));
            nextFilePage = new Button(null, Content.Load <Texture2D>(".//UI//Right Button.png"), null, new Coordinate(720, 1160));

            guideToStart  = new Button(null, Content.Load <Texture2D>(".//UI//Down Button.png"), null, new Coordinate(650, -40));
            prevGuidePage = new Button(null, Content.Load <Texture2D>(".//UI//Left Button.png"), null, new Coordinate(580, -40));
            nextGuidePage = new Button(null, Content.Load <Texture2D>(".//UI//Right Button.png"), null, new Coordinate(720, -40));

            enterButton.Clicked += OnEnter;
            mainButtonList.Add(enterButton);
            guideButton.Clicked += OnGuide;
            mainButtonList.Add(guideButton);
            exitButton.Clicked += OnExit;
            mainButtonList.Add(exitButton);

            backgroundSession = new Sprite(new Vector2(227 - sessionTexture.Width / 2, 300 - sessionTexture.Height / 2),
                                           Vector2.One, 0, Color.White, sessionTexture);

            backgroundSession.AddModifier(new RotateModifier2D(0.006f, false, -1));

            guideScreen    = new Page[1];
            guideScreen[0] = new Page(new Vector2(0, -600),
                                      new StringPositionColor[] {
                new StringPositionColor("LMB", new Vector2(10, 0), Color.White), new StringPositionColor("-Select World", new Vector2(70, 0), Color.White),
                new StringPositionColor("RMB", new Vector2(10, 20), Color.White), new StringPositionColor("-Deselect World", new Vector2(70, 20), Color.White),
                new StringPositionColor("MMB", new Vector2(10, 40), Color.White), new StringPositionColor("-Rotate Camera", new Vector2(70, 40), Color.White),
                new StringPositionColor("F", new Vector2(10, 60), Color.White), new StringPositionColor("-Skip forward on timeline", new Vector2(70, 60), Color.White),
                new StringPositionColor("B", new Vector2(10, 80), Color.White), new StringPositionColor("-Skip backward on timeline", new Vector2(70, 80), Color.White),
                new StringPositionColor("Esc", new Vector2(10, 100), Color.White), new StringPositionColor("-Quit to main menu", new Vector2(70, 100), Color.White),
                new StringPositionColor("Up", new Vector2(10, 120), Color.White), new StringPositionColor("-Move forward", new Vector2(70, 120), Color.White),
                new StringPositionColor("Down", new Vector2(10, 140), Color.White), new StringPositionColor("-Move backward", new Vector2(70, 140), Color.White),
                new StringPositionColor("Left", new Vector2(10, 160), Color.White), new StringPositionColor("-Move left", new Vector2(70, 160), Color.White),
                new StringPositionColor("Right", new Vector2(10, 180), Color.White), new StringPositionColor("-Move right", new Vector2(70, 180), Color.White)
            },
                                      new Sprite[] { new Sprite(Vector2.Zero, Vector2.One, 0, Color.White, Content.Load <Texture2D>(".//UI//Guide Screen.png")) }
                                      );

            ScreenManager.StaticGame.Window.Title = "Session Viewer";

            fileToStart.Clicked  += OnLeaveEnter;
            prevFilePage.Clicked += OnPrevFile;
            nextFilePage.Clicked += OnNextFile;

            guideToStart.Clicked  += OnLeaveGuide;
            prevGuidePage.Clicked += OnPrevGuide;
            nextGuidePage.Clicked += OnNextGuide;

            base.LoadContent();
        }
Esempio n. 8
0
        private void reload(string filePath, DynamicContentManager Content)
        {
            PlayerWorld   newState = Content.Load <PlayerWorld>(filePath);
            TexturedPlane oldPlane = plane;

            plane               = newState.plane;
            plane.Color         = oldPlane.Color;
            plane.WorldPosition = oldPlane.WorldPosition;
            //planeOrbit = (OrbitModifier3D)planeOrbit.DeepCopy(plane);
            //plane.AddModifier(planeOrbit);
            IsVisible      = newState.isVisible;
            PrimaryColor   = newState.PrimaryColor;
            SecondaryColor = newState.SecondaryColor;
            Name           = newState.Name;
            Description    = newState.Description;
            PlayerName     = newState.PlayerName;
            if (newState.CursorDetectRadius > 0)
            {
                CursorDetectRadius = newState.CursorDetectRadius;
            }

            if (gateLevel != newState.gateLevel && PlayerEntered)
            {
                setGates(gateLevel);
            }
            gateLevel = newState.gateLevel;

            for (int i = 0; i < oldPlane.Modifiers.Length; i++)
            {
                if (oldPlane.Modifiers[i] != null)
                {
                    IModifier3D newMod = oldPlane.Modifiers[i].DeepCopy(plane);
                    if (oldPlane.Modifiers[i] == planeOrbit)
                    {
                        planeOrbit = (OrbitModifier3D)newMod;
                    }
                    plane.AddModifier(newMod);
                }
            }

            if (PlayerEntered != newState.PlayerEntered)
            {
                PlayerEntered = newState.PlayerEntered;
                for (int i = 0; i < lowerSpirograph.Modifiers.Length; i++)
                {
                    if (lowerSpirograph.Modifiers[i] != null && lowerSpirograph.Modifiers[i] is ColorModifier3D)
                    {
                        lowerSpirograph.Modifiers[i].Remove();
                        i--;
                    }
                }
                for (int i = 0; i < plane.Modifiers.Length; i++)
                {
                    if (plane.Modifiers[i] != null && plane.Modifiers[i] is ColorModifier3D)
                    {
                        plane.Modifiers[i].Remove();
                        i--;
                    }
                }
                if (PlayerEntered)
                {
                    lowerSpirograph.AddModifier(new ColorModifier3D(PrimaryColor, true, lowerSpirograph, 90));
                    plane.AddModifier(new ColorModifier3D(Color.White, true, plane, 90));
                    setGates(gateLevel);
                }
                else
                {
                    lowerSpirograph.AddModifier(new ColorModifier3D(Color.Lerp(PrimaryColor, Color.Black, 0.8f), true, lowerSpirograph, 90));
                    plane.AddModifier(new ColorModifier3D(new Color(50, 50, 50), true, plane, 90));
                    setGates(0);
                }
            }
            //else if (!PlayerEntered)
            //    setGates(0);
        }