Beispiel #1
0
        public override void LoadContent()
        {
            font               = Game.Assets.Load <SpriteFont>("font");
            background         = Game.Assets.Load <Texture2D>("greenhills");
            backgroundPosition = new Vector2(0, -304);
            backgroundEffect   = SpriteEffects.FlipHorizontally;

#if WINDOWS
            if (File.Exists("lastsave.txt"))
            {
                FileStream   fs = new FileStream("lastsave.txt", FileMode.Open);
                StreamReader sr = new StreamReader(fs);

                lastsavename = sr.ReadLine();
                Console.WriteLine("Last save name is called: " + lastsavename);

                sr.Close();
                fs.Close();
            }
            else
            {
                Console.WriteLine("File not found");
            }
#endif

#if XBOX
            Save.GlobalData gd = new Save.GlobalData();
            gd.InitiateLoad(Game, "global");
            if (gd.Lastsave != null)
            {
                lastsavename = gd.Lastsave;
            }
#endif

            int xPos = Game.GraphicsDevice.Viewport.Width - 300;
            int yPos = Game.GraphicsDevice.Viewport.Height - 220;

            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "New Game", new Vector2(xPos, yPos), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Load Last Save", new Vector2(xPos, yPos + 30), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Level Select", new Vector2(xPos, yPos + 60), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Credits", new Vector2(xPos, yPos + 90), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Quit game", new Vector2(xPos, yPos + 120), font));

            base.LoadContent();
        }
Beispiel #2
0
        public override void LoadContent()
        {
            font = Game.Assets.Load<SpriteFont>("font");
            background = Game.Assets.Load<Texture2D>("greenhills");
            backgroundPosition = new Vector2(0, -304);
            backgroundEffect = SpriteEffects.FlipHorizontally;

            #if WINDOWS
            if (File.Exists("lastsave.txt"))
            {
                FileStream fs = new FileStream("lastsave.txt", FileMode.Open);
                StreamReader sr = new StreamReader(fs);

                lastsavename = sr.ReadLine();
                Console.WriteLine("Last save name is called: " + lastsavename);

                sr.Close();
                fs.Close();
            }
            else
            {
                Console.WriteLine("File not found");
            }
            #endif

            #if XBOX
            Save.GlobalData gd = new Save.GlobalData();
            gd.InitiateLoad(Game, "global");
            if (gd.Lastsave != null) lastsavename = gd.Lastsave;
            #endif

            int xPos = Game.GraphicsDevice.Viewport.Width - 300;
            int yPos = Game.GraphicsDevice.Viewport.Height - 220;

            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "New Game", new Vector2(xPos, yPos), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Load Last Save", new Vector2(xPos, yPos + 30), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Level Select", new Vector2(xPos, yPos + 60), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Credits", new Vector2(xPos, yPos + 90), font));
            entries.Add(new MenuObjects.MenuEntry(Game, SpriteBatch, "Quit game", new Vector2(xPos, yPos + 120), font));

            base.LoadContent();
        }
Beispiel #3
0
        public void InitiateSave(Game1 game, Vector3 playerPosition, float playerSize, VertexMultitextured[] terrain, Vector3[] modelRotation, bool[] modelActivated, string filename)
        {
            this.playerPosition = playerPosition;
            this.playerSize = playerSize;
            this.terrain = terrain;
            this.modelRotation = modelRotation;
            this.modelActivated = modelActivated;

            #if WINDOWS
            FileStream fs = new FileStream("lastsave.txt", FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            sw.WriteLine(filename);
            Console.WriteLine("Last save created with name: " + filename);

            sw.Close();
            fs.Close();
            #endif

            #if XBOX
            Save.GlobalData gd = new Save.GlobalData();
            gd.InitiateSave(game, filename, "global");
            #endif

            this.filename = filename + ".sav";
            try
            {
                device = null;
                StorageDevice.BeginShowSelector(SaveToDevice, null);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }