├── .gitattributes ├── .gitignore ├── FadeEffect.cs ├── Game1.cs ├── GameScreen.cs ├── Image.cs ├── ImageEffect.cs ├── InputManager.cs ├── Program.cs ├── Readme.md ├── ScreenManager.cs ├── SplashScreen.cs └── XmlManager.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /FadeEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace YoutubeRPG 9 | { 10 | public class FadeEffect : ImageEffect 11 | { 12 | public float FadeSpeed; 13 | public bool Increase; 14 | 15 | public FadeEffect() 16 | { 17 | FadeSpeed = 1; 18 | Increase = false; 19 | } 20 | 21 | public override void LoadContent(ref Image Image) 22 | { 23 | base.LoadContent(ref Image); 24 | } 25 | 26 | public override void UnloadContent() 27 | { 28 | base.UnloadContent(); 29 | } 30 | 31 | public override void Update(GameTime gameTime) 32 | { 33 | base.Update(gameTime); 34 | if (image.IsActive) 35 | { 36 | if (!Increase) 37 | image.Alpha -= FadeSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; 38 | else 39 | image.Alpha += FadeSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; 40 | 41 | if (image.Alpha < 0.0f) 42 | { 43 | Increase = true; 44 | image.Alpha = 0.0f; 45 | } 46 | else if (image.Alpha > 1.0f) 47 | { 48 | Increase = false; 49 | image.Alpha = 1.0f; 50 | } 51 | } 52 | else 53 | image.Alpha = 1.0f; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Game1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.Xna.Framework; 5 | using Microsoft.Xna.Framework.Audio; 6 | using Microsoft.Xna.Framework.Content; 7 | using Microsoft.Xna.Framework.GamerServices; 8 | using Microsoft.Xna.Framework.Graphics; 9 | using Microsoft.Xna.Framework.Input; 10 | using Microsoft.Xna.Framework.Media; 11 | 12 | namespace YoutubeRPG 13 | { 14 | /// 15 | /// This is the main type for your game 16 | /// 17 | public class Game1 : Microsoft.Xna.Framework.Game 18 | { 19 | GraphicsDeviceManager graphics; 20 | SpriteBatch spriteBatch; 21 | 22 | public Game1() 23 | { 24 | graphics = new GraphicsDeviceManager(this); 25 | Content.RootDirectory = "Content"; 26 | } 27 | 28 | /// 29 | /// Allows the game to perform any initialization it needs to before starting to run. 30 | /// This is where it can query for any required services and load any non-graphic 31 | /// related content. Calling base.Initialize will enumerate through any components 32 | /// and initialize them as well. 33 | /// 34 | protected override void Initialize() 35 | { 36 | graphics.PreferredBackBufferWidth = (int)YoutubeRPG.ScreenManager.Instance.Dimensions.X; 37 | graphics.ApplyChanges(); 38 | base.Initialize(); 39 | } 40 | 41 | /// 42 | /// LoadContent will be called once per game and is the place to load 43 | /// all of your content. 44 | /// 45 | protected override void LoadContent() 46 | { 47 | // Create a new SpriteBatch, which can be used to draw textures. 48 | spriteBatch = new SpriteBatch(GraphicsDevice); 49 | ScreenManager.Instance.GraphicsDevice = GraphicsDevice; 50 | ScreenManager.Instance.SpriteBatch = spriteBatch; 51 | ScreenManager.Instance.LoadContent(Content); 52 | } 53 | 54 | /// 55 | /// UnloadContent will be called once per game and is the place to unload 56 | /// all content. 57 | /// 58 | protected override void UnloadContent() 59 | { 60 | ScreenManager.Instance.UnloadContent(); 61 | } 62 | 63 | /// 64 | /// Allows the game to run logic such as updating the world, 65 | /// checking for collisions, gathering input, and playing audio. 66 | /// 67 | /// Provides a snapshot of timing values. 68 | protected override void Update(GameTime gameTime) 69 | { 70 | // Allows the game to exit 71 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || 72 | Keyboard.GetState().IsKeyDown(Keys.Escape)) 73 | this.Exit(); 74 | 75 | ScreenManager.Instance.Update(gameTime); 76 | 77 | base.Update(gameTime); 78 | } 79 | 80 | /// 81 | /// This is called when the game should draw itself. 82 | /// 83 | /// Provides a snapshot of timing values. 84 | protected override void Draw(GameTime gameTime) 85 | { 86 | GraphicsDevice.Clear(Color.Black); 87 | 88 | spriteBatch.Begin(); 89 | ScreenManager.Instance.Draw(spriteBatch); 90 | spriteBatch.End(); 91 | 92 | base.Draw(gameTime); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /GameScreen.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Serialization; 6 | 7 | using Microsoft.Xna.Framework; 8 | using Microsoft.Xna.Framework.Content; 9 | using Microsoft.Xna.Framework.Graphics; 10 | 11 | namespace YoutubeRPG 12 | { 13 | public class GameScreen 14 | { 15 | protected ContentManager content; 16 | [XmlIgnore] 17 | public Type Type; 18 | 19 | public string XmlPath; 20 | 21 | public GameScreen() 22 | { 23 | Type = this.GetType(); 24 | XmlPath = "Load/" + Type.ToString().Replace("YoutubeRPG.", "") + ".xml"; 25 | } 26 | 27 | public virtual void LoadContent() 28 | { 29 | content = new ContentManager( 30 | ScreenManager.Instance.Content.ServiceProvider, "Content"); 31 | } 32 | 33 | public virtual void UnloadContent() 34 | { 35 | content.Unload(); 36 | } 37 | 38 | public virtual void Update(GameTime gameTime) 39 | { 40 | InputManager.Instance.Update(); 41 | } 42 | 43 | public virtual void Draw(SpriteBatch spriteBatch) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Image.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Serialization; 6 | 7 | using Microsoft.Xna.Framework; 8 | using Microsoft.Xna.Framework.Content; 9 | using Microsoft.Xna.Framework.Graphics; 10 | 11 | namespace YoutubeRPG 12 | { 13 | public class Image 14 | { 15 | public float Alpha; 16 | public string Text, FontName, Path; 17 | public Vector2 Position, Scale; 18 | public Rectangle SourceRect; 19 | public bool IsActive; 20 | 21 | public Texture2D Texture; 22 | Vector2 origin; 23 | ContentManager content; 24 | RenderTarget2D renderTarget; 25 | SpriteFont font; 26 | Dictionary effectList; 27 | public string Effects; 28 | 29 | public FadeEffect FadeEffect; 30 | 31 | void SetEffect(ref T effect) 32 | { 33 | if (effect == null) 34 | effect = (T)Activator.CreateInstance(typeof(T)); 35 | else 36 | { 37 | (effect as ImageEffect).IsActive = true; 38 | var obj = this; 39 | (effect as ImageEffect).LoadContent(ref obj); 40 | } 41 | 42 | effectList.Add(effect.GetType().ToString().Replace("YoutubeRPG.", ""), (effect as ImageEffect)); 43 | } 44 | 45 | public void ActivateEffect(string effect) 46 | { 47 | if (effectList.ContainsKey(effect)) 48 | { 49 | effectList[effect].IsActive = true; 50 | var obj = this; 51 | effectList[effect].LoadContent(ref obj); 52 | } 53 | } 54 | 55 | public void DeactivateEffect(string effect) 56 | { 57 | if (effectList.ContainsKey(effect)) 58 | { 59 | effectList[effect].IsActive = false; 60 | effectList[effect].UnloadContent(); 61 | } 62 | } 63 | 64 | public Image() 65 | { 66 | Path = Text = Effects = String.Empty; 67 | FontName = "Fonts/Orbitron"; 68 | Position = Vector2.Zero; 69 | Scale = Vector2.One; 70 | Alpha = 1.0f; 71 | SourceRect = Rectangle.Empty; 72 | effectList = new Dictionary(); 73 | } 74 | 75 | public void LoadContent() 76 | { 77 | content = new ContentManager( 78 | ScreenManager.Instance.Content.ServiceProvider, "Content"); 79 | 80 | if (Path != String.Empty) 81 | Texture = content.Load(Path); 82 | 83 | font = content.Load(FontName); 84 | 85 | Vector2 dimensions = Vector2.Zero; 86 | 87 | if(Texture != null) 88 | dimensions.X += Texture.Width; 89 | dimensions.X += font.MeasureString(Text).X; 90 | 91 | if(Texture != null) 92 | dimensions.Y = Math.Max(Texture.Height, font.MeasureString(Text).Y); 93 | else 94 | dimensions.Y = font.MeasureString(Text).Y; 95 | 96 | if (SourceRect == Rectangle.Empty) 97 | SourceRect = new Rectangle(0, 0, (int)dimensions.X, (int)dimensions.Y); 98 | 99 | renderTarget = new RenderTarget2D(ScreenManager.Instance.GraphicsDevice, 100 | (int)dimensions.X, (int)dimensions.Y); 101 | ScreenManager.Instance.GraphicsDevice.SetRenderTarget(renderTarget); 102 | ScreenManager.Instance.GraphicsDevice.Clear(Color.Transparent); 103 | ScreenManager.Instance.SpriteBatch.Begin(); 104 | if(Texture != null) 105 | ScreenManager.Instance.SpriteBatch.Draw(Texture, Vector2.Zero, Color.White); 106 | ScreenManager.Instance.SpriteBatch.DrawString(font, Text, Vector2.Zero, Color.White); 107 | ScreenManager.Instance.SpriteBatch.End(); 108 | 109 | Texture = renderTarget; 110 | 111 | ScreenManager.Instance.GraphicsDevice.SetRenderTarget(null); 112 | 113 | 114 | SetEffect(ref FadeEffect); 115 | 116 | if (Effects != String.Empty) 117 | { 118 | string[] split = Effects.Split(':'); 119 | foreach (string item in split) 120 | ActivateEffect(item); 121 | } 122 | } 123 | 124 | public void UnloadContent() 125 | { 126 | content.Unload(); 127 | foreach (var effect in effectList) 128 | DeactivateEffect(effect.Key); 129 | } 130 | 131 | public void Update(GameTime gameTime) 132 | { 133 | foreach (var effect in effectList) 134 | { 135 | if(effect.Value.IsActive) 136 | effect.Value.Update(gameTime); 137 | } 138 | } 139 | 140 | public void Draw(SpriteBatch spriteBatch) 141 | { 142 | origin = new Vector2(SourceRect.Width / 2, 143 | SourceRect.Height / 2); 144 | spriteBatch.Draw(Texture, Position + origin, SourceRect, Color.White * Alpha, 145 | 0.0f, origin, Scale, SpriteEffects.None, 0.0f); 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /ImageEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace YoutubeRPG 9 | { 10 | public class ImageEffect 11 | { 12 | protected Image image; 13 | public bool IsActive; 14 | 15 | public ImageEffect() 16 | { 17 | IsActive = false; 18 | } 19 | 20 | public virtual void LoadContent(ref Image Image) 21 | { 22 | this.image = Image; 23 | } 24 | 25 | public virtual void UnloadContent() 26 | { 27 | } 28 | 29 | public virtual void Update(GameTime gameTime) 30 | { 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /InputManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using Microsoft.Xna.Framework.Input; 7 | 8 | namespace YoutubeRPG 9 | { 10 | public class InputManager 11 | { 12 | KeyboardState currentKeyState, prevKeyState; 13 | 14 | private static InputManager instance; 15 | 16 | public static InputManager Instance 17 | { 18 | get 19 | { 20 | if (instance == null) 21 | instance = new InputManager(); 22 | 23 | return instance; 24 | } 25 | } 26 | 27 | public void Update() 28 | { 29 | prevKeyState = currentKeyState; 30 | if (!ScreenManager.Instance.IsTransitioning) 31 | currentKeyState = Keyboard.GetState(); 32 | } 33 | 34 | public bool KeyPressed(params Keys[] keys) 35 | { 36 | foreach (Keys key in keys) 37 | { 38 | if (currentKeyState.IsKeyDown(key) && prevKeyState.IsKeyUp(key)) 39 | return true; 40 | } 41 | return false; 42 | } 43 | 44 | public bool KeyReleased(params Keys[] keys) 45 | { 46 | foreach (Keys key in keys) 47 | { 48 | if (currentKeyState.IsKeyUp(key) && prevKeyState.IsKeyDown(key)) 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | public bool KeyDown(params Keys[] keys) 55 | { 56 | foreach (Keys key in keys) 57 | { 58 | if (currentKeyState.IsKeyDown(key)) 59 | return true; 60 | } 61 | return false; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace YoutubeRPG 4 | { 5 | #if WINDOWS || XBOX 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | static void Main(string[] args) 12 | { 13 | using (Game1 game = new Game1()) 14 | { 15 | game.Run(); 16 | } 17 | } 18 | } 19 | #endif 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ScreenManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Serialization; 6 | using System.IO; 7 | 8 | using Microsoft.Xna.Framework; 9 | using Microsoft.Xna.Framework.Content; 10 | using Microsoft.Xna.Framework.Graphics; 11 | 12 | namespace YoutubeRPG 13 | { 14 | public class ScreenManager 15 | { 16 | private static ScreenManager instance; 17 | [XmlIgnore] 18 | public Vector2 Dimensions { private set; get; } 19 | [XmlIgnore] 20 | public ContentManager Content { private set; get; } 21 | XmlManager xmlGameScreenManager; 22 | 23 | GameScreen currentScreen, newScreen; 24 | [XmlIgnore] 25 | public GraphicsDevice GraphicsDevice; 26 | [XmlIgnore] 27 | public SpriteBatch SpriteBatch; 28 | 29 | public Image Image; 30 | [XmlIgnore] 31 | public bool IsTransitioning { get; private set; } 32 | 33 | public static ScreenManager Instance 34 | { 35 | get 36 | { 37 | if (instance == null) 38 | { 39 | XmlManager xml = new XmlManager(); 40 | instance = xml.Load("Load/ScreenManager.xml"); 41 | } 42 | 43 | return instance; 44 | } 45 | } 46 | 47 | public void ChangeScreens(string screenName) 48 | { 49 | newScreen = (GameScreen)Activator.CreateInstance(Type.GetType("YoutubeRPG." + screenName)); 50 | Image.IsActive = true; 51 | Image.FadeEffect.Increase = true; 52 | Image.Alpha = 0.0f; 53 | IsTransitioning = true; 54 | } 55 | 56 | void Transition(GameTime gameTime) 57 | { 58 | if (IsTransitioning) 59 | { 60 | Image.Update(gameTime); 61 | if (Image.Alpha == 1.0f) 62 | { 63 | currentScreen.UnloadContent(); 64 | currentScreen = newScreen; 65 | xmlGameScreenManager.Type = currentScreen.Type; 66 | if (File.Exists(currentScreen.XmlPath)) 67 | currentScreen = xmlGameScreenManager.Load(currentScreen.XmlPath); 68 | currentScreen.LoadContent(); 69 | } 70 | else if (Image.Alpha == 0.0f) 71 | { 72 | Image.IsActive = false; 73 | IsTransitioning = false; 74 | } 75 | } 76 | } 77 | 78 | public ScreenManager() 79 | { 80 | Dimensions = new Vector2(640, 480); 81 | currentScreen = new SplashScreen(); 82 | xmlGameScreenManager = new XmlManager(); 83 | xmlGameScreenManager.Type = currentScreen.Type; 84 | currentScreen = xmlGameScreenManager.Load("Load/SplashScreen.xml"); 85 | } 86 | 87 | public void LoadContent(ContentManager Content) 88 | { 89 | this.Content = new ContentManager(Content.ServiceProvider, "Content"); 90 | currentScreen.LoadContent(); 91 | Image.LoadContent(); 92 | } 93 | 94 | public void UnloadContent() 95 | { 96 | currentScreen.UnloadContent(); 97 | Image.UnloadContent(); 98 | } 99 | 100 | public void Update(GameTime gameTime) 101 | { 102 | currentScreen.Update(gameTime); 103 | Transition(gameTime); 104 | } 105 | 106 | public void Draw(SpriteBatch spriteBatch) 107 | { 108 | currentScreen.Draw(spriteBatch); 109 | if (IsTransitioning) 110 | Image.Draw(spriteBatch); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /SplashScreen.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Serialization; 6 | 7 | using Microsoft.Xna.Framework; 8 | using Microsoft.Xna.Framework.Content; 9 | using Microsoft.Xna.Framework.Graphics; 10 | using Microsoft.Xna.Framework.Input; 11 | 12 | namespace YoutubeRPG 13 | { 14 | public class SplashScreen : GameScreen 15 | { 16 | public Image Image; 17 | 18 | public override void LoadContent() 19 | { 20 | base.LoadContent(); 21 | Image.LoadContent(); 22 | } 23 | 24 | public override void UnloadContent() 25 | { 26 | base.UnloadContent(); 27 | Image.UnloadContent(); 28 | } 29 | 30 | public override void Update(GameTime gameTime) 31 | { 32 | base.Update(gameTime); 33 | Image.Update(gameTime); 34 | 35 | if (InputManager.Instance.KeyPressed(Keys.Enter, Keys.Z)) 36 | ScreenManager.Instance.ChangeScreens("SplashScreen"); 37 | } 38 | 39 | public override void Draw(SpriteBatch spriteBatch) 40 | { 41 | Image.Draw(spriteBatch); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /XmlManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Serialization; 6 | using System.IO; 7 | 8 | namespace YoutubeRPG 9 | { 10 | public class XmlManager 11 | { 12 | public Type Type; 13 | 14 | public XmlManager() 15 | { 16 | Type = typeof(T); 17 | } 18 | 19 | public T Load(string path) 20 | { 21 | T instance; 22 | using (TextReader reader = new StreamReader(path)) 23 | { 24 | XmlSerializer xml = new XmlSerializer(Type); 25 | instance = (T)xml.Deserialize(reader); 26 | } 27 | return instance; 28 | } 29 | 30 | public void Save(string path, object obj) 31 | { 32 | using (TextWriter writer = new StreamWriter(path)) 33 | { 34 | XmlSerializer xml = new XmlSerializer(Type); 35 | xml.Serialize(writer, obj); 36 | } 37 | } 38 | } 39 | } 40 | --------------------------------------------------------------------------------