Beispiel #1
0
        public static bool SaveGame(Upgrades upgrades)
        {
            string content = (upgrades.Motyka + ";" + upgrades.Nawoz + ";" + upgrades.Rolnik + ";" + upgrades.Opryski + ";" + upgrades.Traktor + ";" + upgrades.MotykaStaraCena + ";"
                              + upgrades.NawozStaraCena + ";" + upgrades.RolnikStaraCena + ";" + upgrades.OpryskiStaraCena + ";" + upgrades.TraktorStaraCena + ";" + upgrades.Pieniadze);

            byte[] text = Encoding.ASCII.GetBytes(content);
            File   path;
            File   file;

            OutputStream ofile;
            string       filename = "Angame.sav";

            try
            {
                path = Android.OS.Environment.ExternalStorageDirectory;
                file = new File(path.AbsolutePath + "/" + "Angame", filename);
                file.Mkdir();
                file.Delete();
                file.CreateNewFile();
                ofile = new FileOutputStream(file);
                ofile.Write(text);
                ofile.Close();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //sprawdzanie minionego czasu
            klatki++;
            if (klatki >= 60)
            {
                klatki -= 60;
                statusGry.Idle();
                zapis++;
            }
            if (zapis >= 5)
            {
                if (!Upgrades.SaveGame(statusGry))
                {
                    zapise = true;
                }
            }
            //sprawdzanie aktywnego okna
            switch (_state)
            {
            case Gamestate.Gameplay:

                UpdateGameplay(gameTime);
                break;

            case Gamestate.BuyScreen:
                UpdateBuyScreen(gameTime);
                break;
            }
        }