/// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            PhysicalObject NewObj;

            //The font texture isn't needed, but this is an example of loading a PNG
            string     strFileName = INTERFACECONTENTDIR + "Font.png";
            FileStream FileLoad    = new FileStream(strFileName, FileMode.Open);
            Texture2D  FontTexture = Texture2D.FromStream(GraphicsDevice, FileLoad);

            FileLoad.Close();

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, INTERFACECONTENTDIR + "Font.png", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(ConsoleCommandHandler);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cTextureAtlas = new TextureAtlas(cGraphDevMgr.GraphicsDevice, INTERFACECONTENTDIR + "spaceShooter2_spritesheet.png", INTERFACECONTENTDIR + "spaceShooter2_spritesheet.xml");
            cObjManager   = new ObjectManager(cGraphDevMgr.GraphicsDevice, cTextureAtlas, INTERFACECONTENTDIR + "GameObjects.xml");
            cParticles    = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);

            //Plaeyer's object
            NewObj = cObjManager.SpawnGameObject("ship01", (int)eObjGroups_t.Player);

            NewObj.SetPosition(new Vector2(128, 128), new Vector2(0.25f, 0.25f), 0);
            NewObj.Updating += UserShipUpdating;

            cPlayer.nMaxSpeed = 12;

            return;
        }
Example #2
0
        public ObjectManager(GraphicsDevice GraphDev, TextureAtlas TileAtlas, string strXMLFile, string strXMLRoot = "/objects")
        {
            XmlDocument   ObjXML;
            XmlNodeList   ObjList, VertList;
            sObjectInfo_t NewDef;
            Vector2       vNewVert;

            //Prepare all class variables
            cObjDefsList = new Dictionary <string, sObjectInfo_t>();
            cObjGroups   = new Dictionary <int, List <PhysicalObject> >();
            cGraphDev    = GraphDev;
            cImageAtlas  = TileAtlas;

            //Load object definitions from XML file
            try {
                ObjXML = new XmlDocument();
                ObjXML.Load(strXMLFile);
            } catch (Exception ExErr) {
                throw new Exception(String.Format("Failed to load XML File {1}{0}Exception {2}{0}Message {3}", Environment.NewLine, strXMLFile, ExErr.GetType().ToString(), ExErr.Message));
            }

            ObjList = ObjXML.DocumentElement.SelectNodes(strXMLRoot + "/object");

            foreach (XmlNode ObjNode in ObjList)
            {
                NewDef            = new sObjectInfo_t();
                NewDef.avVertexes = new List <Vector2>();

                //Read all attribute values
                if (ObjNode.Attributes["name"] != null)
                {
                    NewDef.strObjName = ObjNode.Attributes["name"].InnerText;
                }
                else
                {
                    throw new Exception("Found object tag with no name attribute in file " + strXMLFile);
                }

                if (ObjNode.Attributes["subtexturename"] != null)
                {
                    NewDef.strTextureName = ObjNode.Attributes["subtexturename"].InnerText;
                }
                else
                {
                    throw new Exception(String.Format("Found object tag named '{0}' with no subtexturename attribute in file {1}", NewDef.strObjName, strXMLFile));
                }

                if (ObjNode.Attributes["texturerotation"] != null)
                {
                    if (float.TryParse(ObjNode.Attributes["texturerotation"].InnerText, out NewDef.nTextureRotate) == false)
                    {
                        throw new Exception(String.Format("Inside object tag named {0} attribute 'texturerotation' had invalid format: {1}{2}In file {3}", NewDef.strObjName, ObjNode.Attributes["texturerotation"].InnerText, Environment.NewLine, strXMLFile));
                    }

                    if (Math.Abs(NewDef.nTextureRotate) > 2 * Math.PI)                       //Angle is kinda big, user probably entered degrees
                    {
                        NewDef.nTextureRotate *= (float)(Math.PI / 180);
                    }
                }

                if (ObjNode.Attributes["width"] != null)
                {
                    if (Int32.TryParse(ObjNode.Attributes["width"].InnerText, out NewDef.nWidth) == false)
                    {
                        throw new Exception(String.Format("Inside object tag named {0} attribute 'width' had invalid format: {1}{2}In file {3}", NewDef.strObjName, ObjNode.Attributes["width"].InnerText, Environment.NewLine, strXMLFile));
                    }
                }

                if (ObjNode.Attributes["height"] != null)
                {
                    if (Int32.TryParse(ObjNode.Attributes["height"].InnerText, out NewDef.nHeight) == false)
                    {
                        throw new Exception(String.Format("Inside object tag named {0} attribute 'height' had invalid format: {1}{2}In file {3}", NewDef.strObjName, ObjNode.Attributes["height"].InnerText, Environment.NewLine, strXMLFile));
                    }
                }

                //Read all child node values
                VertList = ObjNode.SelectNodes("vertex");
                foreach (XmlNode VertNode in VertList)
                {
                    vNewVert = new Vector2(0, 0);

                    if (VertNode.Attributes["x"] != null)
                    {
                        if (float.TryParse(VertNode.Attributes["x"].InnerText, out vNewVert.X) == false)
                        {
                            throw new Exception(String.Format("Inside object tag named {0} vertex tag attribute 'x' had invalid format: {1}{2}In file {3}", NewDef.strObjName, VertNode.Attributes["x"].InnerText, Environment.NewLine, strXMLFile));
                        }
                    }

                    if (VertNode.Attributes["y"] != null)
                    {
                        if (float.TryParse(VertNode.Attributes["y"].InnerText, out vNewVert.Y) == false)
                        {
                            throw new Exception(String.Format("Inside object tag named {0} vertex tag attribute 'y' had invalid format: {1}{2}In file {3}", NewDef.strObjName, VertNode.Attributes["y"].InnerText, Environment.NewLine, strXMLFile));
                        }
                    }

                    NewDef.avVertexes.Add(vNewVert);
                }

                //Object definition loaded, add it to the list
                cObjDefsList.Add(NewDef.strObjName, NewDef);
            }

            return;
        }
Example #3
0
        /// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            TextureFont Font;

            Content.RootDirectory = INTERFACECONTENTDIR;

            Font = new TextureFont(Content.Load <Texture2D>("Font.png"));

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, "Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(ConsoleCommandEvent);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cTileSets = new TileSetManager(Content, INTERFACECONTENTDIR + @"\Tiles.XML", "/tilescene/tilesets");

            cSceneMgr = new TileSceneManager(cTileSets, INTERFACECONTENTDIR + @"\Tiles.XML", "/tilescene");

            cSpriteMgr = new SpriteManager(cTileSets, INTERFACECONTENTDIR + @"\Tiles.XML", "/tilescene");
        }
Example #4
0
        /// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            String     strFileName;
            FileStream FileLoad;
            Vector2    Vert;

            strFileName    = INTERFACECONTENTDIR + "\\Circle.png";
            FileLoad       = new FileStream(strFileName, FileMode.Open);
            cCircleTexture = Texture2D.FromStream(cGraphDevMgr.GraphicsDevice, FileLoad);
            FileLoad.Close();

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, INTERFACECONTENTDIR + "\\Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(ConsoleCommandHandler);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cPolyList = new List <ConvexPolygon>();
            cPolyList.Add(new ConvexPolygon(cGraphDevMgr.GraphicsDevice));
            cPolyList[0].LineColor = Color.Blue;
            cPolyList[0].LineWidth = 2;

            cPolyList[0].FillColor = Color.DarkOliveGreen;
            cPolyList[0].FillShape = true;

            Vert.X = 100;
            Vert.Y = 100;
            cPolyList[0].AddVertex(Vert);

            Vert.X = 200;
            Vert.Y = 100;
            cPolyList[0].AddVertex(Vert);

            Vert.X = 200;
            Vert.Y = 200;
            cPolyList[0].AddVertex(Vert);

            cPolyList.Add(new ConvexPolygon(cGraphDevMgr.GraphicsDevice));
            cPolyList[1].LineColor = Color.Green;
            cPolyList[1].FillColor = Color.Wheat;
            cPolyList[1].LineWidth = 2;

            strFileName = INTERFACECONTENTDIR + "\\Ship.png";
            FileLoad    = new FileStream(strFileName, FileMode.Open);
            Texture2D tmpTexture = Texture2D.FromStream(cGraphDevMgr.GraphicsDevice, FileLoad);

            FileLoad.Close();

            cPolyList[1].FillTexture = tmpTexture;
            cPolyList[1].FillShape   = true;
            cPolyList[1].MoveShape(new Vector2(250, 250));

            Vert.X = 50;
            Vert.Y = 50;
            cPolyList[1].AddVertex(Vert, new Vector2(0, 1));

            Vert.X = -50;
            Vert.Y = 50;
            cPolyList[1].AddVertex(Vert, new Vector2(0, 0));

            Vert.X = -50;
            Vert.Y = -50;
            cPolyList[1].AddVertex(Vert, new Vector2(1, 0));

            Vert.X = 50;
            Vert.Y = -50;
            cPolyList[1].AddVertex(Vert, new Vector2(1, 1));

            cPolyList.Add(new ConvexPolygon(cGraphDevMgr.GraphicsDevice));
            cPolyList[2].LineColor = Color.Gray;
            cPolyList[2].FillColor = Color.BlueViolet;
            cPolyList[2].LineWidth = 2;


            //tmpTexture = new Texture2D(cGraphDevMgr.GraphicsDevice, 2, 2);
            //tmpTexture.SetData(new Color[] { Color.RosyBrown, Color.Aqua, Color.DarkOrchid, Color.PaleGreen });
            cPolyList[2].FillTexture = tmpTexture;

            Vert.X = 450;
            Vert.Y = 150;
            cPolyList[2].AddVertex(Vert, new Vector2(0.5f, 0));

            Vert.X = 500;
            Vert.Y = 200;
            cPolyList[2].AddVertex(Vert, new Vector2(1f, 0));

            Vert.X = 500;
            Vert.Y = 300;
            cPolyList[2].AddVertex(Vert, new Vector2(1f, 1));

            Vert.X = 400;
            Vert.Y = 300;
            cPolyList[2].AddVertex(Vert, new Vector2(0f, 1));

            Vert.X = 400;
            Vert.Y = 200;
            cPolyList[2].AddVertex(Vert, new Vector2(0f, 0));

            return;
        }
Example #5
0
        public TextureAtlas(GraphicsDevice GraphDev, string strImageFile, string strXMLFile, string strXMLRoot = "/TextureAtlas")
        {
            XmlDocument TilesXML;
            XmlNodeList TilesList;
            Rectangle   NewRect;

            cTileSet = new Dictionary <string, Rectangle>();

            FileStream FileLoad = new FileStream(strImageFile, FileMode.Open);

            cTexture = Texture2D.FromStream(GraphDev, FileLoad);
            FileLoad.Close();

            try {
                TilesXML = new XmlDocument();
                TilesXML.Load(strXMLFile);
            } catch (Exception ExErr) {
                throw new Exception(String.Format("Failed to load XML File {1}{0}Exception {2}{0}Message {3}", Environment.NewLine, strXMLFile, ExErr.GetType().ToString(), ExErr.Message));
            }

            TilesList = TilesXML.DocumentElement.SelectNodes(strXMLRoot + "/SubTexture");
            foreach (XmlNode TileNode in TilesList)
            {
                NewRect = new Rectangle()                   //Default values to supply for omitted attributes
                {
                    X      = 0,
                    Y      = 0,
                    Width  = 0,
                    Height = 0,
                };

                if (TileNode.Attributes["x"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["x"].InnerText, out NewRect.X) == false)
                    {
                        throw new Exception("Attribute 'x' in SubTexture tag had invalid format: " + TileNode.Attributes["x"].InnerText + Environment.NewLine + TileNode.ToString());
                    }
                }

                if (TileNode.Attributes["y"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["y"].InnerText, out NewRect.Y) == false)
                    {
                        throw new Exception("Attribute 'Y' in SubTexture tag had invalid format: " + TileNode.Attributes["y"].InnerText + Environment.NewLine + TileNode.ToString());
                    }
                }

                if (TileNode.Attributes["width"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["width"].InnerText, out NewRect.Width) == false)
                    {
                        throw new Exception("Attribute 'width' in SubTexture tag had invalid format: " + TileNode.Attributes["width"].InnerText + Environment.NewLine + TileNode.ToString());
                    }
                }

                if (TileNode.Attributes["height"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["height"].InnerText, out NewRect.Height) == false)
                    {
                        throw new Exception("Attribute 'height' in SubTexture tag had invalid format: " + TileNode.Attributes["height"].InnerText + Environment.NewLine + TileNode.ToString());
                    }
                }

                if ((TileNode.Attributes["name"] == null) || (String.IsNullOrEmpty(TileNode.Attributes["name"].InnerText) == true))
                {
                    throw new Exception("Attribute 'name' in SubTexture tag is blank or missing" + Environment.NewLine + TileNode.ToString());
                }

                cTileSet.Add(TileNode.Attributes["name"].InnerText, NewRect);
            }

            return;
        }
Example #6
0
        public void LoadSceneXML(string XMLFile, string RootPath)
        {
            XmlDocument   SceneXML;
            XmlNodeList   SceneList, TileList;
            SceneInfo     NewScene;
            SceneTileInfo NewTile;

            cSceneList.Clear();

            try {
                SceneXML = new XmlDocument();
                SceneXML.Load(XMLFile);
            } catch (Exception ExErr) {
                throw new Exception(String.Format("Failed to load XML File {1}{0}Exception {2}{0}Message {3}", Environment.NewLine, XMLFile, ExErr.GetType().ToString(), ExErr.Message));
            }

            SceneList = SceneXML.DocumentElement.SelectNodes(RootPath + "/scene");
            foreach (XmlNode SceneNode in SceneList)
            {
                //Load all details regarding this scene
                if (SceneNode.Attributes["name"] != null)
                {
                    NewScene = new SceneInfo(SceneNode.Attributes["name"].InnerText);
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a scene tag with no name attribute.", Environment.NewLine, XMLFile));
                }

                if (SceneNode.Attributes["tilewidth"] != null)
                {
                    if (Int32.TryParse(SceneNode.Attributes["tilewidth"].InnerText, out NewScene.TileWidth) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with an invalid tilewidth attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                    }
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with no tilewidth attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                }

                if (SceneNode.Attributes["tileheight"] != null)
                {
                    if (Int32.TryParse(SceneNode.Attributes["tileheight"].InnerText, out NewScene.TileHeight) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with an invalid tileheight attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                    }
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with no tileheight attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                }

                //Load individual tiles to draw in this scene
                TileList = SceneNode.SelectNodes("tile");
                foreach (XmlNode TileNode in TileList)
                {
                    NewTile = new SceneTileInfo();

                    //Load all tile details from the XML file
                    if (TileNode.Attributes["setname"] != null)
                    {
                        NewTile.TileSetName = TileNode.Attributes["setname"].InnerText;
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tile tag with no name attribute in scene {2}.", Environment.NewLine, XMLFile, NewScene.Name));
                    }

                    if (TileNode.Attributes["tilecol"] != null)
                    {
                        if (Int32.TryParse(TileNode.Attributes["tilecol"].InnerText, out NewTile.TileCoords.X) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid tilecol attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                        }
                    }
                    else
                    {
                        NewTile.TileCoords.X = -1;
                    }

                    if (TileNode.Attributes["tilerow"] != null)
                    {
                        if (Int32.TryParse(TileNode.Attributes["tilerow"].InnerText, out NewTile.TileCoords.Y) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid tilerow attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                        }
                    }
                    else
                    {
                        NewTile.TileCoords.Y = -1;
                    }

                    if (TileNode.Attributes["scenecol"] != null)
                    {
                        if (Int32.TryParse(TileNode.Attributes["scenecol"].InnerText, out NewTile.SceneCoords.X) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid scenecol attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                        }
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with no scenecol attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                    }

                    if (TileNode.Attributes["scenerow"] != null)
                    {
                        if (Int32.TryParse(TileNode.Attributes["scenerow"].InnerText, out NewTile.SceneCoords.Y) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid scenerow attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                        }
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with no scenerow attribute.", Environment.NewLine, XMLFile, NewScene.Name));
                    }

                    if (TileNode.Attributes["tilename"] != null)
                    {
                        NewTile.TileNameInSet = TileNode.Attributes["tilename"].InnerText;
                    }
                    else
                    {
                        NewTile.TileNameInSet = "";
                    }

                    NewScene.TileList.Add(NewTile);
                }

                cSceneList.Add(NewScene.Name, NewScene);
            }
        }
Example #7
0
        /// <summary>
        /// Load sprite data from an XML file
        /// </summary>
        /// <param name="XMLFile">Path and name of the XML file to load</param>
        /// <param name="RootPath">Path within the XML scheme to look for the sprite tags</param>
        public void LoadSpriteXML(string XMLFile, string RootPath)
        {
            XmlDocument     SpriteXML;
            XmlNodeList     SpriteList, AnimList, FrameList;
            SpriteInfo      NewSprite;
            SpriteAnimation NewAnim;
            Point           Pos = new Point();

            cSpriteList.Clear();

            try {
                SpriteXML = new XmlDocument();
                SpriteXML.Load(XMLFile);
            } catch (Exception ExErr) {
                throw new Exception(String.Format("Failed to load XML File {1}{0}Exception {2}{0}Message {3}", Environment.NewLine, XMLFile, ExErr.GetType().ToString(), ExErr.Message));
            }

            SpriteList = SpriteXML.DocumentElement.SelectNodes(RootPath + "/sprite");
            foreach (XmlNode SpriteNode in SpriteList)
            {
                //Load all details regarding this scene
                if (SpriteNode.Attributes["name"] != null)
                {
                    NewSprite = new SpriteInfo(SpriteNode.Attributes["name"].InnerText);
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a sprite tag with no name attribute.", Environment.NewLine, XMLFile));
                }

                if (SpriteNode.Attributes["tileset"] != null)
                {
                    NewSprite.TileSet = SpriteNode.Attributes["tileset"].InnerText;
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a sprite tag with no tileset attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                }

                if (SpriteNode.Attributes["height"] != null)
                {
                    if (Int32.TryParse(SpriteNode.Attributes["height"].InnerText, out NewSprite.ScreenRect.Height) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a sprite tag named {2} with an invalid height attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                    }
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a sprite tag named {2} with no height attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                }

                if (SpriteNode.Attributes["width"] != null)
                {
                    if (Int32.TryParse(SpriteNode.Attributes["width"].InnerText, out NewSprite.ScreenRect.Width) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a sprite tag named {2} with an invalid width attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                    }
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a sprite tag named {2} with no width attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                }

                FrameList = SpriteNode.SelectNodes("default");
                if (FrameList.Count != 1)
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a sprite tag with no incorrect number of default tags.", Environment.NewLine, XMLFile, NewSprite.Name));
                }

                if (FrameList[0].Attributes["down"] != null)
                {
                    if (RegEx.QuickTest(FrameList[0].Attributes["down"].InnerText, "^([0-9+]),([0-9])+$") == true)
                    {
                        Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["down"].InnerText, "^([0-9+]),([0-9])+$", 1));
                        Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["down"].InnerText, "^([0-9+]),([0-9])+$", 2));

                        NewSprite.DefaultTilePos[SpriteFacing.Down] = Pos;
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid down attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                    }
                }

                if (FrameList[0].Attributes["up"] != null)
                {
                    if (RegEx.QuickTest(FrameList[0].Attributes["up"].InnerText, "^([0-9+]),([0-9])+$") == true)
                    {
                        Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["up"].InnerText, "^([0-9+]),([0-9])+$", 1));
                        Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["up"].InnerText, "^([0-9+]),([0-9])+$", 2));

                        NewSprite.DefaultTilePos[SpriteFacing.Up] = Pos;
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid up attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                    }
                }

                if (FrameList[0].Attributes["left"] != null)
                {
                    if (RegEx.QuickTest(FrameList[0].Attributes["left"].InnerText, "^([0-9+]),([0-9])+$") == true)
                    {
                        Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["left"].InnerText, "^([0-9+]),([0-9])+$", 1));
                        Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["left"].InnerText, "^([0-9+]),([0-9])+$", 2));

                        NewSprite.DefaultTilePos[SpriteFacing.Left] = Pos;
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid left attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                    }
                }

                if (FrameList[0].Attributes["right"] != null)
                {
                    if (RegEx.QuickTest(FrameList[0].Attributes["right"].InnerText, "^([0-9+]),([0-9])+$") == true)
                    {
                        Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["right"].InnerText, "^([0-9+]),([0-9])+$", 1));
                        Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameList[0].Attributes["right"].InnerText, "^([0-9+]),([0-9])+$", 2));

                        NewSprite.DefaultTilePos[SpriteFacing.Right] = Pos;
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid right attribute.", Environment.NewLine, XMLFile, NewSprite.Name));
                    }
                }

                AnimList = SpriteNode.SelectNodes("animation");
                foreach (XmlNode AnimNode in AnimList)
                {
                    if (AnimNode.Attributes["name"] != null)
                    {
                        NewAnim = new SpriteAnimation(AnimNode.Attributes["name"].InnerText);
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered an animation tag with no name attribute.", Environment.NewLine, XMLFile));
                    }

                    if (AnimNode.Attributes["duration"] != null)
                    {
                        if (Int32.TryParse(AnimNode.Attributes["duration"].InnerText, out NewAnim.TimeMS) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a animation tag named {2} with an invalid duration attribute.", Environment.NewLine, XMLFile, NewAnim.Name));
                        }
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a animation tag named {2} with no duration attribute.", Environment.NewLine, XMLFile, NewAnim.Name));
                    }

                    FrameList = AnimNode.SelectNodes("frame");
                    foreach (XmlNode FrameNode in FrameList)
                    {
                        if (FrameNode.Attributes["down"] != null)
                        {
                            if (RegEx.QuickTest(FrameNode.Attributes["down"].InnerText, "^([0-9+]),([0-9])+$") == true)
                            {
                                Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["down"].InnerText, "^([0-9+]),([0-9])+$", 1));
                                Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["down"].InnerText, "^([0-9+]),([0-9])+$", 2));

                                NewAnim.TilePos[SpriteFacing.Down].Add(Pos);
                            }
                            else
                            {
                                throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid down attribute.", Environment.NewLine, XMLFile, NewAnim.Name));
                            }
                        }

                        if (FrameNode.Attributes["up"] != null)
                        {
                            if (RegEx.QuickTest(FrameNode.Attributes["up"].InnerText, "^([0-9+]),([0-9])+$") == true)
                            {
                                Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["up"].InnerText, "^([0-9+]),([0-9])+$", 1));
                                Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["up"].InnerText, "^([0-9+]),([0-9])+$", 2));

                                NewAnim.TilePos[SpriteFacing.Up].Add(Pos);
                            }
                            else
                            {
                                throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid up attribute.", Environment.NewLine, XMLFile, NewAnim.Name));
                            }
                        }

                        if (FrameNode.Attributes["left"] != null)
                        {
                            if (RegEx.QuickTest(FrameNode.Attributes["left"].InnerText, "^([0-9+]),([0-9])+$") == true)
                            {
                                Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["left"].InnerText, "^([0-9+]),([0-9])+$", 1));
                                Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["left"].InnerText, "^([0-9+]),([0-9])+$", 2));

                                NewAnim.TilePos[SpriteFacing.Left].Add(Pos);
                            }
                            else
                            {
                                throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid left attribute.", Environment.NewLine, XMLFile, NewAnim.Name));
                            }
                        }

                        if (FrameNode.Attributes["right"] != null)
                        {
                            if (RegEx.QuickTest(FrameNode.Attributes["right"].InnerText, "^([0-9+]),([0-9])+$") == true)
                            {
                                Pos.X = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["right"].InnerText, "^([0-9+]),([0-9])+$", 1));
                                Pos.Y = Int32.Parse(RegEx.GetRegExGroup(FrameNode.Attributes["right"].InnerText, "^([0-9+]),([0-9])+$", 2));

                                NewAnim.TilePos[SpriteFacing.Right].Add(Pos);
                            }
                            else
                            {
                                throw new Exception(String.Format("Failed to load XML File {1}{0}In sprite named {2} Encountered a default tag with invalid right attribute.", Environment.NewLine, XMLFile, NewAnim.Name));
                            }
                        }
                    }

                    NewSprite.AnimationList.Add(NewAnim.Name, NewAnim);
                }

                cSpriteList.Add(NewSprite.Name, NewSprite);
            }
        }
Example #8
0
        /// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            TextureFont Font;

            Content.RootDirectory = INTERFACECONTENTDIR;

            Font = new TextureFont(Content.Load <Texture2D>("Font.png"));

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, "Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(CommandEvent);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cDevConsole.AddText(String.Format("Viewport Height={0} Width={1}", cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width));

            //Build card deck frames
            cAOFrame               = new DeckFrame(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width / 2);
            cAOFrame.Visible       = true;
            cAOFrame.CloseEffect   = DisplayEffect.SlideUp;
            cAOFrame.OpenEffect    = DisplayEffect.SlideDown;
            cAOFrame.Font          = Font;
            cAOFrame.MaxCardsShown = 1;

            cOLFrame             = new DeckFrame(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width / 2);
            cOLFrame.Left        = cGraphDevMgr.GraphicsDevice.Viewport.Width / 2;
            cOLFrame.Visible     = true;
            cOLFrame.CloseEffect = DisplayEffect.SlideUp;
            cOLFrame.OpenEffect  = DisplayEffect.SlideDown;
            cOLFrame.Font        = Font;
            cOLFrame.CardClick  += OLCardClickedHandler;

            //build config frame
            cOpenConfig                 = new Button(cGraphDevMgr.GraphicsDevice, null, 0, 0, 100, 100);
            cOpenConfig.Font            = Font;
            cOpenConfig.FontColor       = new Color(0.1f, 0.1f, 0.1f, 1.0f);
            cOpenConfig.BackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.7f);
            cOpenConfig.Text            = "Config";
            cOpenConfig.Visible         = true;
            cOpenConfig.Click          += ConfigClickHandler;

            cOLConfigFrame             = new OverlordDecksFrame(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width);
            cOLConfigFrame.Visible     = false;
            cOLConfigFrame.OpenEffect  = DisplayEffect.SlideUp;
            cOLConfigFrame.CloseEffect = DisplayEffect.SlideDown;
            cOLConfigFrame.Font        = Font;

            //Load config files
            cDevConsole.AddText(LoadGameDecks(Content, INTERFACECONTENTDIR + Path.DirectorySeparatorChar + "AOCardsList.xml"));

            cAOFrame.ShuffleCompleteDeck(true, false);
            cAOFrame.SelectRandomCardBack();
            cOLFrame.ShuffleCompleteDeck(true, false);
            cOLFrame.SelectRandomCardBack();

            cOLConfigFrame.SetIconImageSet(cIconImages);
        }
Example #9
0
        /// <summary>
        /// Loads all cards and decks from a common XML file
        /// </summary>
        /// <param name="Content">COntent manager object that will load the image files</param>
        /// <param name="DeckXMLFile">Path and file name of the XML file containing the card information</param>
        /// <returns>Text messages reporting any information related to loaded the deck information and images</returns>
        private string LoadGameDecks(ContentManager Content, string DeckXMLFile)
        {
            XmlDocument  DeckXML;
            XmlNodeList  CardNodeList;
            Texture2D    CardImage;
            string       Message = "";
            int          Ctr, CardCnt;
            OverlordCard NewOLCard;

            Message = "Loading card list from " + DeckXMLFile + "\n";
            cOLFrame.CardBackList.Clear();
            cOLFrame.CardFaceList.Clear();

            try {
                DeckXML = new XmlDocument();
                DeckXML.Load(DeckXMLFile);
            } catch (Exception ExErr) {
                Message += String.Format("Failed to load XML file: {0} - {1}\n", ExErr.GetType().ToString(), ExErr.Message);
                return(Message);
            }

            CardNodeList = DeckXML.DocumentElement.SelectNodes("//cardlist");
            Ctr          = 0;
            foreach (XmlNode CardNode in CardNodeList)
            {
                Ctr += 1;
                foreach (XmlNode Tag in CardNode.ChildNodes)
                {
                    if (Tag.Attributes == null)
                    {
                        Message += String.Format("Tag {0} '{1}' contains no attributes, skipping.\n", Ctr, Tag.Name);
                        continue;
                    }

                    switch (Tag.Name)
                    {
                    case "autooverlord":
                        if (Tag.Attributes["image"] != null)
                        {
                            CardImage = Content.Load <Texture2D>(Tag.Attributes["image"].InnerText);
                            cAOFrame.CardFaceList.Add(CardImage);
                        }
                        else
                        {
                            Message += String.Format("Tag {0} '{1}' contains no image attribute, skipping.\n", Ctr, Tag.Name);
                        }

                        break;

                    case "autooverlordback":
                        if (Tag.Attributes["image"] != null)
                        {
                            CardImage = Content.Load <Texture2D>(Tag.Attributes["image"].InnerText);
                            cAOFrame.CardBackList.Add(CardImage);
                        }
                        else
                        {
                            Message += String.Format("Tag {0} '{1}' contains no image attribute, skipping.\n", Ctr, Tag.Name);
                        }

                        break;

                    case "reference":
                        /*
                         * if (Tag.Attributes["image"] != null) {
                         *      CardImage = Content.Load<Texture2D>(Tag.Attributes["image"].InnerText);
                         * } else {
                         *      Message += String.Format("Tag {0} '{1}' contains no image attribute, skipping.\n", Ctr, Tag.Name);
                         *      continue;
                         * }
                         *
                         * if (Tag.Attributes["description"] != null) {
                         *      cAORefCards.Add(Tag.Attributes["description"].InnerText, CardImage);
                         * } else {
                         *      Message += String.Format("Tag {0} '{1}' contains no description attribute, skipping.\n", Ctr, Tag.Name);
                         *      continue;
                         * }
                         */
                        break;

                    case "overlordback":
                        if (Tag.Attributes["image"] != null)
                        {
                            CardImage = Content.Load <Texture2D>(Tag.Attributes["image"].InnerText);

                            try {
                                CardCnt = Int32.Parse(Tag.Attributes["count"].InnerText);
                            } catch (Exception) {
                                CardCnt = 1;
                            }

                            cOLFrame.CardBackList.Add(CardImage);
                        }
                        else
                        {
                            Message += String.Format("Tag {0} '{1}' contains no image attribute, skipping.\n", Ctr, Tag.Name);
                        }

                        break;

                    case "overlord":
                        if (Tag.Attributes["image"] != null)
                        {
                            NewOLCard         = new OverlordCard();
                            NewOLCard.Image   = Content.Load <Texture2D>(Tag.Attributes["image"].InnerText);
                            NewOLCard.Count   = Int32.Parse(Tag.Attributes["count"].InnerText);
                            NewOLCard.Include = 0;
                            NewOLCard.Class   = Tag.Attributes["class"].InnerText;
                            NewOLCard.Set     = Tag.Attributes["set"].InnerText;

                            cOLConfigFrame.AddOverlordCard(NewOLCard);
                        }
                        else
                        {
                            Message += String.Format("Tag {0} '{1}' contains no image attribute, skipping.\n", Ctr, Tag.Name);
                        }

                        break;

                    case "icon":
                        if (Tag.Attributes["image"] != null)
                        {
                            CardImage = Content.Load <Texture2D>(Tag.Attributes["image"].InnerText);

                            cIconImages.Add(Tag.Attributes["type"].InnerText, CardImage);
                        }
                        else
                        {
                            Message += String.Format("Tag {0} '{1}' contains no image attribute, skipping.\n", Ctr, Tag.Name);
                        }

                        break;

                    default:
                        if (Tag.Name.CompareTo("#comment") == 0)
                        {
                            Message += "Found text '" + Tag.InnerText + "' outisde any tag.\n";
                        }
                        else
                        {
                            Message += "Unrecognized tag '" + Tag.Name + "'.\n";
                        }
                        break;
                    }
                }
            }

            Message += String.Format("Card decks loading complete.\n");

            return(Message);
        }
        /// <summary>
        /// Constructor that attempts to load all data during initialization.  This will discard any
        /// ppreviously loaded data and replace it with this new information.
        /// </summary>
        /// <param name="ContentMgr">The content manager to use when loading image data</param>
        /// <param name="XMLFile">The path to the XML file containing the tileset information</param>
        /// <param name="RootPath">The root path in the XML file to find the tile information tags</param>
        public void LoadTileSetXML(ContentManager ContentMgr, string XMLFile, string RootPath)
        {
            XmlDocument TilesXML;
            XmlNodeList TilesList, NamedTilesList;
            TileSetInfo NewSet;
            string      Name;
            UInt32      MarchID;
            Point       Coords;

            cTileSetList.Clear();

            try {
                TilesXML = new XmlDocument();
                TilesXML.Load(XMLFile);
            } catch (Exception ExErr) {
                throw new Exception(String.Format("Failed to load XML File {1}{0}Exception {2}{0}Message {3}", Environment.NewLine, XMLFile, ExErr.GetType().ToString(), ExErr.Message));
            }

            TilesList = TilesXML.DocumentElement.SelectNodes(RootPath + "/tiles");
            foreach (XmlNode TileNode in TilesList)
            {
                NewSet = new TileSetInfo();
                NewSet.MarchingSquaresList = new Dictionary <MarchingSquaresTiles, Point>();
                NewSet.NamedTileList       = new Dictionary <string, Point>();

                //Load all tile set details from the XML file
                if (TileNode.Attributes["name"] != null)
                {
                    NewSet.Name = TileNode.Attributes["name"].InnerText;
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag with no name attribute.", Environment.NewLine, XMLFile));
                }

                if (TileNode.Attributes["file"] != null)
                {
                    NewSet.ImageFile = TileNode.Attributes["file"].InnerText;
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with no file attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                }

                if (TileNode.Attributes["columns"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["columns"].InnerText, out NewSet.ColumnCnt) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with an invalid columns attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                    }
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with no columns attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                }

                if (TileNode.Attributes["rows"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["columns"].InnerText, out NewSet.RowCnt) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with an invalid rows attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                    }
                }
                else
                {
                    throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with no rows attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                }

                if (TileNode.Attributes["columnwidth"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["columnwidth"].InnerText, out NewSet.TileWidth) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with an invalid columnwidth attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                    }
                }
                else
                {
                    NewSet.TileWidth = -1;
                }

                if (TileNode.Attributes["rowheight"] != null)
                {
                    if (Int32.TryParse(TileNode.Attributes["rowheight"].InnerText, out NewSet.TileHeight) == false)
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with an invalid rowheight attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                    }
                }
                else
                {
                    NewSet.TileHeight = -1;
                }

                NamedTilesList = TileNode.SelectNodes("namedtile");
                foreach (XmlNode NamedTileNode in NamedTilesList)
                {
                    if (NamedTileNode.Attributes["column"] != null)
                    {
                        if (Int32.TryParse(NamedTileNode.Attributes["column"].InnerText, out Coords.X) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with a namedtile tag with an invalid column attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                        }
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with a namedtile tag with an missing column attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                    }

                    if (NamedTileNode.Attributes["row"] != null)
                    {
                        if (Int32.TryParse(NamedTileNode.Attributes["row"].InnerText, out Coords.Y) == false)
                        {
                            throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with a namedtile tag with an invalid row attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                        }
                    }
                    else
                    {
                        throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tiles tag named {2} with a namedtile tag with an missing row attribute.", Environment.NewLine, XMLFile, NewSet.Name));
                    }

                    if (NamedTileNode.Attributes["name"] != null)
                    {
                        Name = NamedTileNode.Attributes["name"].InnerText;

                        NewSet.NamedTileList.Add(Name, Coords);
                    }

                    if (NamedTileNode.Attributes["marchid"] != null)
                    {
                        Name    = NamedTileNode.Attributes["marchid"].InnerText;
                        MarchID = MDLN.Tools.TypeTools.BinaryStringToUInt32(Name);

                        NewSet.MarchingSquaresList.Add((MarchingSquaresTiles)MarchID, Coords);
                    }
                }

                //Load the image data for use
                NewSet.TileTexture = ContentMgr.Load <Texture2D>(NewSet.ImageFile);

                //Add this tile set to the list
                cTileSetList.Add(NewSet.Name, NewSet);
            }
        }
Example #11
0
        /// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            String      strFileName;
            Texture2D   NewTexture;
            TextureFont Font = new TextureFont();
            FileStream  FileLoad;

            strFileName      = INTERFACECONTENTDIR + "\\Font.png";
            FileLoad         = new FileStream(strFileName, FileMode.Open);
            NewTexture       = Texture2D.FromStream(cGraphDevMgr.GraphicsDevice, FileLoad);
            Font.FontTexture = NewTexture;
            FileLoad.Close();

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, INTERFACECONTENTDIR + "\\Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(ConsoleCommandHandler);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cSettingsCont                 = new MDLN.MGTools.Container(GraphicsDevice, GraphicsDevice.Viewport.Height, 300);
            cSettingsCont.Width           = 300;
            cSettingsCont.Height          = GraphicsDevice.Viewport.Height;
            cSettingsCont.Visible         = true;
            cSettingsCont.BackgroundColor = new Color(Color.White, 0.5f);
            cSettingsCont.Top             = 0;
            cSettingsCont.Left            = 0;

            cShowingLbl                 = new Button(GraphicsDevice, null, 10, 10, 20, 280);
            cShowingLbl.Text            = "";
            cShowingLbl.Visible         = true;
            cShowingLbl.Font            = Font;
            cShowingLbl.BackgroundColor = Color.Transparent;
            cShowingLbl.FontColor       = LBLTEXTCOLOR;

            cAddParitclesBtn                 = new Button(GraphicsDevice, null, 40, 10, 20, 280);
            cAddParitclesBtn.Text            = "Add Particles";
            cAddParitclesBtn.Visible         = true;
            cAddParitclesBtn.Font            = Font;
            cAddParitclesBtn.BackgroundColor = Color.LightGray;
            cAddParitclesBtn.FontColor       = Color.Black;
            cAddParitclesBtn.Click          += AddParticlesClickHandler;

            cNumParticlesLbl                 = new Button(GraphicsDevice, null, 70, 10, 20, 105);
            cNumParticlesLbl.Text            = "Add Amount";
            cNumParticlesLbl.Visible         = true;
            cNumParticlesLbl.Font            = Font;
            cNumParticlesLbl.BackgroundColor = Color.Transparent;
            cNumParticlesLbl.FontColor       = LBLTEXTCOLOR;

            cNumParticlesTxt                 = new TextBox(GraphicsDevice, null, 70, 125, 20, 165);
            cNumParticlesTxt.Text            = "1";
            cNumParticlesTxt.Visible         = true;
            cNumParticlesTxt.Font            = Font;
            cNumParticlesTxt.BackgroundColor = Color.Black;
            cNumParticlesTxt.FontColor       = Color.White;
            cNumParticlesTxt.Alignment       = Justify.MiddleCenter;

            cHeightLbl                 = new Button(GraphicsDevice, null, 100, 10, 20, 90);
            cHeightLbl.Text            = "Height";
            cHeightLbl.Visible         = true;
            cHeightLbl.Font            = Font;
            cHeightLbl.BackgroundColor = Color.Transparent;
            cHeightLbl.FontColor       = LBLTEXTCOLOR;

            cHeightMinTxt                 = new TextBox(GraphicsDevice, null, 100, 100, 20, 90);
            cHeightMinTxt.Text            = "64";
            cHeightMinTxt.Visible         = true;
            cHeightMinTxt.Font            = Font;
            cHeightMinTxt.BackgroundColor = Color.Black;
            cHeightMinTxt.FontColor       = Color.White;
            cHeightMinTxt.Alignment       = Justify.MiddleCenter;

            cHeightMaxTxt                 = new TextBox(GraphicsDevice, null, 100, 200, 20, 90);
            cHeightMaxTxt.Text            = "64";
            cHeightMaxTxt.Visible         = true;
            cHeightMaxTxt.Font            = Font;
            cHeightMaxTxt.BackgroundColor = Color.Black;
            cHeightMaxTxt.FontColor       = Color.White;
            cHeightMaxTxt.Alignment       = Justify.MiddleCenter;

            cWidthLbl                 = new Button(GraphicsDevice, null, 130, 10, 20, 90);
            cWidthLbl.Text            = "Width";
            cWidthLbl.Visible         = true;
            cWidthLbl.Font            = Font;
            cWidthLbl.BackgroundColor = Color.Transparent;
            cWidthLbl.FontColor       = LBLTEXTCOLOR;

            cWidthMinTxt                 = new TextBox(GraphicsDevice, null, 130, 100, 20, 90);
            cWidthMinTxt.Text            = "64";
            cWidthMinTxt.Visible         = true;
            cWidthMinTxt.Font            = Font;
            cWidthMinTxt.BackgroundColor = Color.Black;
            cWidthMinTxt.FontColor       = Color.White;
            cWidthMinTxt.Alignment       = Justify.MiddleCenter;

            cWidthMaxTxt                 = new TextBox(GraphicsDevice, null, 130, 200, 20, 90);
            cWidthMaxTxt.Text            = "64";
            cWidthMaxTxt.Visible         = true;
            cWidthMaxTxt.Font            = Font;
            cWidthMaxTxt.BackgroundColor = Color.Black;
            cWidthMaxTxt.FontColor       = Color.White;
            cWidthMaxTxt.Alignment       = Justify.MiddleCenter;

            cRedLbl                 = new Button(GraphicsDevice, null, 160, 10, 20, 90);
            cRedLbl.Text            = "Red";
            cRedLbl.Visible         = true;
            cRedLbl.Font            = Font;
            cRedLbl.BackgroundColor = Color.Transparent;
            cRedLbl.FontColor       = LBLTEXTCOLOR;

            cRedMinTxt                 = new TextBox(GraphicsDevice, null, 160, 100, 20, 90);
            cRedMinTxt.Text            = "0";
            cRedMinTxt.Visible         = true;
            cRedMinTxt.Font            = Font;
            cRedMinTxt.BackgroundColor = Color.Black;
            cRedMinTxt.FontColor       = Color.White;
            cRedMinTxt.Alignment       = Justify.MiddleCenter;

            cRedMaxTxt                 = new TextBox(GraphicsDevice, null, 160, 200, 20, 90);
            cRedMaxTxt.Text            = "255";
            cRedMaxTxt.Visible         = true;
            cRedMaxTxt.Font            = Font;
            cRedMaxTxt.BackgroundColor = Color.Black;
            cRedMaxTxt.FontColor       = Color.White;
            cRedMaxTxt.Alignment       = Justify.MiddleCenter;

            cGreenLbl                 = new Button(GraphicsDevice, null, 190, 10, 20, 90);
            cGreenLbl.Text            = "Green";
            cGreenLbl.Visible         = true;
            cGreenLbl.Font            = Font;
            cGreenLbl.BackgroundColor = Color.Transparent;
            cGreenLbl.FontColor       = LBLTEXTCOLOR;

            cGreenMinTxt                 = new TextBox(GraphicsDevice, null, 190, 100, 20, 90);
            cGreenMinTxt.Text            = "0";
            cGreenMinTxt.Visible         = true;
            cGreenMinTxt.Font            = Font;
            cGreenMinTxt.BackgroundColor = Color.Black;
            cGreenMinTxt.FontColor       = Color.White;
            cGreenMinTxt.Alignment       = Justify.MiddleCenter;

            cGreenMaxTxt                 = new TextBox(GraphicsDevice, null, 190, 200, 20, 90);
            cGreenMaxTxt.Text            = "255";
            cGreenMaxTxt.Visible         = true;
            cGreenMaxTxt.Font            = Font;
            cGreenMaxTxt.BackgroundColor = Color.Black;
            cGreenMaxTxt.FontColor       = Color.White;
            cGreenMaxTxt.Alignment       = Justify.MiddleCenter;

            cBlueLbl                 = new Button(GraphicsDevice, null, 220, 10, 20, 90);
            cBlueLbl.Text            = "Blue";
            cBlueLbl.Visible         = true;
            cBlueLbl.Font            = Font;
            cBlueLbl.BackgroundColor = Color.Transparent;
            cBlueLbl.FontColor       = LBLTEXTCOLOR;

            cBlueMinTxt                 = new TextBox(GraphicsDevice, null, 220, 100, 20, 90);
            cBlueMinTxt.Text            = "0";
            cBlueMinTxt.Visible         = true;
            cBlueMinTxt.Font            = Font;
            cBlueMinTxt.BackgroundColor = Color.Black;
            cBlueMinTxt.FontColor       = Color.White;
            cBlueMinTxt.Alignment       = Justify.MiddleCenter;

            cBlueMaxTxt                 = new TextBox(GraphicsDevice, null, 220, 200, 20, 90);
            cBlueMaxTxt.Text            = "255";
            cBlueMaxTxt.Visible         = true;
            cBlueMaxTxt.Font            = Font;
            cBlueMaxTxt.BackgroundColor = Color.Black;
            cBlueMaxTxt.FontColor       = Color.White;
            cBlueMaxTxt.Alignment       = Justify.MiddleCenter;

            cLifeLbl                 = new Button(GraphicsDevice, null, 250, 10, 20, 90);
            cLifeLbl.Text            = "Dur mSec";
            cLifeLbl.Visible         = true;
            cLifeLbl.Font            = Font;
            cLifeLbl.BackgroundColor = Color.Transparent;
            cLifeLbl.FontColor       = LBLTEXTCOLOR;

            cLifeMinTxt                 = new TextBox(GraphicsDevice, null, 250, 100, 20, 90);
            cLifeMinTxt.Text            = "1000";
            cLifeMinTxt.Visible         = true;
            cLifeMinTxt.Font            = Font;
            cLifeMinTxt.BackgroundColor = Color.Black;
            cLifeMinTxt.FontColor       = Color.White;
            cLifeMinTxt.Alignment       = Justify.MiddleCenter;

            cLifeMaxTxt                 = new TextBox(GraphicsDevice, null, 250, 200, 20, 90);
            cLifeMaxTxt.Text            = "5000";
            cLifeMaxTxt.Visible         = true;
            cLifeMaxTxt.Font            = Font;
            cLifeMaxTxt.BackgroundColor = Color.Black;
            cLifeMaxTxt.FontColor       = Color.White;
            cLifeMaxTxt.Alignment       = Justify.MiddleCenter;

            cDelayLbl                 = new Button(GraphicsDevice, null, 280, 10, 20, 90);
            cDelayLbl.Text            = "Delay mS";
            cDelayLbl.Visible         = true;
            cDelayLbl.Font            = Font;
            cDelayLbl.BackgroundColor = Color.Transparent;
            cDelayLbl.FontColor       = LBLTEXTCOLOR;

            cDelayMinTxt                 = new TextBox(GraphicsDevice, null, 280, 100, 20, 90);
            cDelayMinTxt.Text            = "0";
            cDelayMinTxt.Visible         = true;
            cDelayMinTxt.Font            = Font;
            cDelayMinTxt.BackgroundColor = Color.Black;
            cDelayMinTxt.FontColor       = Color.White;
            cDelayMinTxt.Alignment       = Justify.MiddleCenter;

            cDelayMaxTxt                 = new TextBox(GraphicsDevice, null, 280, 200, 20, 90);
            cDelayMaxTxt.Text            = "50";
            cDelayMaxTxt.Visible         = true;
            cDelayMaxTxt.Font            = Font;
            cDelayMaxTxt.BackgroundColor = Color.Black;
            cDelayMaxTxt.FontColor       = Color.White;
            cDelayMaxTxt.Alignment       = Justify.MiddleCenter;

            cXDistLbl                 = new Button(GraphicsDevice, null, 310, 10, 20, 90);
            cXDistLbl.Text            = "X Dist";
            cXDistLbl.Visible         = true;
            cXDistLbl.Font            = Font;
            cXDistLbl.BackgroundColor = Color.Transparent;
            cXDistLbl.FontColor       = LBLTEXTCOLOR;

            cXDistMinTxt                 = new TextBox(GraphicsDevice, null, 310, 100, 20, 90);
            cXDistMinTxt.Text            = "-300";
            cXDistMinTxt.Visible         = true;
            cXDistMinTxt.Font            = Font;
            cXDistMinTxt.BackgroundColor = Color.Black;
            cXDistMinTxt.FontColor       = Color.White;
            cXDistMinTxt.Alignment       = Justify.MiddleCenter;

            cXDistMaxTxt                 = new TextBox(GraphicsDevice, null, 310, 200, 20, 90);
            cXDistMaxTxt.Text            = "300";
            cXDistMaxTxt.Visible         = true;
            cXDistMaxTxt.Font            = Font;
            cXDistMaxTxt.BackgroundColor = Color.Black;
            cXDistMaxTxt.FontColor       = Color.White;
            cXDistMaxTxt.Alignment       = Justify.MiddleCenter;

            cYDistLbl                 = new Button(GraphicsDevice, null, 340, 10, 20, 90);
            cYDistLbl.Text            = "Y Dist";
            cYDistLbl.Visible         = true;
            cYDistLbl.Font            = Font;
            cYDistLbl.BackgroundColor = Color.Transparent;
            cYDistLbl.FontColor       = LBLTEXTCOLOR;

            cYDistMinTxt                 = new TextBox(GraphicsDevice, null, 340, 100, 20, 90);
            cYDistMinTxt.Text            = "-300";
            cYDistMinTxt.Visible         = true;
            cYDistMinTxt.Font            = Font;
            cYDistMinTxt.BackgroundColor = Color.Black;
            cYDistMinTxt.FontColor       = Color.White;
            cYDistMinTxt.Alignment       = Justify.MiddleCenter;

            cYDistMaxTxt                 = new TextBox(GraphicsDevice, null, 340, 200, 20, 90);
            cYDistMaxTxt.Text            = "300";
            cYDistMaxTxt.Visible         = true;
            cYDistMaxTxt.Font            = Font;
            cYDistMaxTxt.BackgroundColor = Color.Black;
            cYDistMaxTxt.FontColor       = Color.White;
            cYDistMaxTxt.Alignment       = Justify.MiddleCenter;

            cRotateLbl                 = new Button(GraphicsDevice, null, 370, 10, 20, 90);
            cRotateLbl.Text            = "Rotations";
            cRotateLbl.Visible         = true;
            cRotateLbl.Font            = Font;
            cRotateLbl.BackgroundColor = Color.Transparent;
            cRotateLbl.FontColor       = LBLTEXTCOLOR;

            cRotateMinTxt                 = new TextBox(GraphicsDevice, null, 370, 100, 20, 90);
            cRotateMinTxt.Text            = "-5";
            cRotateMinTxt.Visible         = true;
            cRotateMinTxt.Font            = Font;
            cRotateMinTxt.BackgroundColor = Color.Black;
            cRotateMinTxt.FontColor       = Color.White;
            cRotateMinTxt.Alignment       = Justify.MiddleCenter;

            cRotateMaxTxt                 = new TextBox(GraphicsDevice, null, 370, 200, 20, 90);
            cRotateMaxTxt.Text            = "5";
            cRotateMaxTxt.Visible         = true;
            cRotateMaxTxt.Font            = Font;
            cRotateMaxTxt.BackgroundColor = Color.Black;
            cRotateMaxTxt.FontColor       = Color.White;
            cRotateMaxTxt.Alignment       = Justify.MiddleCenter;

            cRotateAfterBtn                 = new Button(GraphicsDevice, null, 400, 10, 20, 280);
            cRotateAfterBtn.Text            = "Spiral Path";
            cRotateAfterBtn.Visible         = true;
            cRotateAfterBtn.Font            = Font;
            cRotateAfterBtn.BackgroundColor = Color.Red;
            cRotateAfterBtn.FontColor       = Color.Black;
            cRotateAfterBtn.Click          += RotateAfterClickHandler;

            cAlphaFadeBtn                 = new Button(GraphicsDevice, null, 430, 10, 20, 280);
            cAlphaFadeBtn.Text            = "Alpha Fade";
            cAlphaFadeBtn.Visible         = true;
            cAlphaFadeBtn.Font            = Font;
            cAlphaFadeBtn.BackgroundColor = Color.Red;
            cAlphaFadeBtn.FontColor       = Color.Black;
            cAlphaFadeBtn.Click          += AlphaFadeClickHandler;

            foreach (TextureFiles CurrTexture in Enum.GetValues(typeof(TextureFiles)))
            {
                strFileName = INTERFACECONTENTDIR + "\\" + EnumTools.GetEnumDescriptionAttribute(CurrTexture);

                NewTexture = Texture2D.FromStream(cGraphDevMgr.GraphicsDevice, new FileStream(strFileName, FileMode.Open));
                cTextureDict.Add(CurrTexture, NewTexture);
            }

            cSparkles = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);

            return;
        }