Beispiel #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");
        }
Beispiel #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);
        }
Beispiel #3
0
        public void PersistentValuesLoaded(int playerNumber, int number,
                                           int highScore, bool isUnlocked, bool isUnlockedAnimationShown, bool isBought)
        {
            //// Arrange
            PlayerPrefs.DeleteAll();
            GameItemTests.SetCommonPreferences(playerNumber, number, "C", highScore, isUnlocked, isUnlockedAnimationShown, isBought);
            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);

            //// Assert
            Assert.IsNotNull(player, "GameItem not setup.");
            Assert.AreEqual(highScore, gameItem.HighScore, "HighScore not set correctly");
            Assert.AreEqual(isBought, gameItem.IsBought, "IsBought not set correctly");
            if (isBought)
            {
                Assert.AreEqual(true, gameItem.IsUnlocked, "IsUnlocked not set correctly when bought");
            }
            else
            {
                Assert.AreEqual(isUnlocked, gameItem.IsUnlocked, "IsUnlocked not set correctly when not bought");
            }
            Assert.AreEqual(isUnlockedAnimationShown, gameItem.IsUnlockedAnimationShown, "IsUnlockedAnimationShown not set correctly");
        }
Beispiel #4
0
        public void PersistentValuesLoaded(string playerNumber, string number,
                                           int highScore, bool isUnlocked, bool isUnlockedAnimationShown, bool isBought,
                                           int starsWon, float timeBest, float progressBest)
        {
            //// Arrange
            PlayerPrefs.DeleteAll();
            PlayerPrefs.SetInt(string.Format("P{0}.L{1}.SW", playerNumber, number), starsWon);
            PlayerPrefs.SetFloat(string.Format("P{0}.L{1}.TimeBest", playerNumber, number), timeBest);
            PlayerPrefs.SetFloat(string.Format("P{0}.L{1}.ProgressBest", playerNumber, number), progressBest);
            GameItemTests.SetCommonPreferences(playerNumber, number, "L", highScore, isUnlocked, isUnlockedAnimationShown, isBought);
            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);

            //// Assert
            Assert.IsNotNull(player, "GameItem not setup.");
            Assert.AreEqual(highScore, gameItem.HighScore, "HighScore not set correctly");
            Assert.AreEqual(isBought, gameItem.IsBought, "IsBought not set correctly");
            if (isBought)
            {
                Assert.AreEqual(true, gameItem.IsUnlocked, "IsUnlocked not set correctly when bought");
            }
            else
            {
                Assert.AreEqual(isUnlocked, gameItem.IsUnlocked, "IsUnlocked not set correctly when not bought");
            }
            Assert.AreEqual(isUnlockedAnimationShown, gameItem.IsUnlockedAnimationShown, "IsUnlockedAnimationShown not set correctly");

            Assert.AreEqual(starsWon, gameItem.StarsWon, "StarsWon not set correctly");
            Assert.AreEqual(timeBest, gameItem.TimeBest, "TimeBest not set correctly");
            Assert.AreEqual(progressBest, gameItem.ProgressBest, "ProgressBest not set correctly");
        }