Esempio n. 1
0
        public static GameProgress FromString(string s)
        {
            GameProgress gp = new GameProgress();

            string[] p = s.Split(new char[] { ':' });
            if (!p[0].StartsWith("GPv"))
            {
                Debug.LogError("Failed to parse game progress from: " + s);
                return(gp);
            }

            gp.mPilotExp = System.Convert.ToInt32(p[1]);
            int i;

            for (i = 2; i < p.Length && i - 2 < LevelCount; i++)
            {
                gp.GetLevelProgress(i - 2).SetFromString(p[i]);
            }

            if (p[0].Equals("GPv3"))
            {
                double val = Double.Parse(p[p.Length - 1]);
                gp.mPlayingTime = TimeSpan.FromMilliseconds(val > 0f ? val : 0f);
            }
            else
            {
                gp.mPlayingTime = new TimeSpan();
            }

            gp.mLoadedTime = DateTime.Now;
            return(gp);
        }
Esempio n. 2
0
        public static GameProgress LoadFromDisk()
        {
            string s = PlayerPrefs.GetString(PlayerPrefsKey, "");

            if (s == null || s.Trim().Length == 0)
            {
                return(new GameProgress());
            }
            return(GameProgress.FromString(s));
        }
Esempio n. 3
0
        void ProcessCloudData(byte[] cloudData)
        {
            if (cloudData == null)
            {
                Debug.Log("No data saved to the cloud yet...");
                return;
            }
            Debug.Log("Decoding cloud data from bytes.");
            GameProgress progress = GameProgress.FromBytes(cloudData);

            Debug.Log("Merging with existing game progress.");
            mProgress.MergeWith(progress);
        }
Esempio n. 4
0
        public void MergeWith(GameProgress other)
        {
            int i;

            for (i = 0; i < LevelCount; i++)
            {
                if (mProgress[i].MergeWith(other.mProgress[i]))
                {
                    mDirty = true;
                }
            }
            if (other.mPilotExp > mPilotExp)
            {
                mPilotExp = other.mPilotExp;
                mDirty    = true;
            }
            if (other.mPlayingTime > mPlayingTime)
            {
                mPlayingTime = other.mPlayingTime;
            }
        }
 private GameManager()
 {
     mProgress = GameProgress.LoadFromDisk();
     mAutoSaveName = "Autosaved";
 }
Esempio n. 6
0
 private GameManager()
 {
     mProgress     = GameProgress.LoadFromDisk();
     mAutoSaveName = "Autosaved";
 }
Esempio n. 7
0
 public static GameProgress FromBytes(byte[] b)
 {
     return(GameProgress.FromString(System.Text.ASCIIEncoding.Default.GetString(b)));
 }
 public void MergeWith(GameProgress other)
 {
     int i;
     for (i = 0; i < LevelCount; i++)
     {
         if (mProgress[i].MergeWith(other.mProgress[i]))
         {
             mDirty = true;
         }
     }
     if (other.mPilotExp > mPilotExp)
     {
         mPilotExp = other.mPilotExp;
         mDirty = true;
     }
     if (other.mPlayingTime > mPlayingTime)
     {
         mPlayingTime = other.mPlayingTime;
     }
 }
 public static GameProgress FromString(string s)
 {
     GameProgress gp = new GameProgress();
     string[] p = s.Split(new char[] { ':' });
     if (!p[0].StartsWith("GPv"))
     {
         Debug.LogError("Failed to parse game progress from: " + s);
         return gp;
     }
     gp.mPilotExp = System.Convert.ToInt32(p[1]);
     int i;
     for (i = 2; i < p.Length && i - 2 < LevelCount; i++)
     {
         gp.GetLevelProgress(i - 2).SetFromString(p[i]);
     }
     if (p[0].Equals("GPv3"))
     {
         double val = Double.Parse(p[p.Length - 1]);
         gp.mPlayingTime = TimeSpan.FromMilliseconds(val > 0f ? val : 0f);
     }
     else
     {
         gp.mPlayingTime = new TimeSpan();
     }
     gp.mLoadedTime = DateTime.Now;
     return gp;
 }