示例#1
0
        public void PersistentValuesSaved(string playerNumber, string number,
                                          int highScore, bool isUnlocked, bool isUnlockedAnimationShown, bool isBought,
                                          int starsWon, float timeBest, float progressBest)
        {
            //// Arrange
            PlayerPrefs.DeleteAll();
            var gameConfiguration = ScriptableObject.CreateInstance <GameConfiguration>();
            var messenger         = new Messenger();
            var player            = ScriptableObject.CreateInstance <Player>();

            player.Initialise(gameConfiguration, null, messenger, playerNumber);

            //// Act
            var gameItem = ScriptableObject.CreateInstance <Level>();

            gameItem.Initialise(gameConfiguration, player, messenger, number);
            gameItem.Score = highScore; // score should set high score automatically which is saved
            //gameItem.HighScore = highScore;
            gameItem.IsUnlocked = isUnlocked;
            gameItem.IsUnlockedAnimationShown = isUnlockedAnimationShown;
            gameItem.IsBought = isBought;
            gameItem.StarsWon = starsWon;
            gameItem.TimeBest = timeBest;
            gameItem.Progress = progressBest; // progress should set ProgressBest automatically which is saved
            gameItem.UpdatePlayerPrefs();
            PlayerPrefs.Save();

            //// Assert
            Assert.IsNotNull(gameItem, "GameItem not setup.");
            GameItemTests.AssertCommonPreferences(playerNumber, number, "L", gameItem);
            Assert.AreEqual(starsWon, PlayerPrefs.GetInt(string.Format("P{0}.L{1}.SW", playerNumber, number), 0), "StarsWon not set correctly");
            Assert.AreEqual(timeBest, PlayerPrefs.GetFloat(string.Format("P{0}.L{1}.TimeBest", playerNumber, number), 0), "TimeBest not set correctly");
            Assert.AreEqual(progressBest, PlayerPrefs.GetFloat(string.Format("P{0}.L{1}.ProgressBest", playerNumber, number), 0), "ProgressBest not set correctly");
        }
示例#2
0
        public void PersistentValuesSaved(int playerNumber, int number,
                                          int highScore, bool isUnlocked, bool isUnlockedAnimationShown, bool isBought)
        {
            //// Arrange
            PlayerPrefs.DeleteAll();
            var gameConfiguration = ScriptableObject.CreateInstance <GameConfiguration>();
            var messenger         = new Messenger();
            var player            = ScriptableObject.CreateInstance <Player>();

            player.Initialise(gameConfiguration, null, messenger, playerNumber);

            //// Act
            var gameItem = ScriptableObject.CreateInstance <Character>();

            gameItem.Initialise(gameConfiguration, player, messenger, number);
            gameItem.Score = highScore; // score should set high score automatically which is saved
            //gameItem.HighScore = highScore;
            gameItem.IsUnlocked = isUnlocked;
            gameItem.IsUnlockedAnimationShown = isUnlockedAnimationShown;
            gameItem.IsBought = isBought;
            gameItem.UpdatePlayerPrefs();
            PlayerPrefs.Save();

            //// Assert
            Assert.IsNotNull(gameItem, "GameItem not setup.");
            GameItemTests.AssertCommonPreferences(playerNumber, number, "C", gameItem);
        }