예제 #1
0
파일: Upgrades.cs 프로젝트: Kucheu/Angame
        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);
        }
예제 #2
0
파일: Game1.cs 프로젝트: Kucheu/Angame
        /// <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;
            }
        }