Esempio n. 1
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");
        }
Esempio n. 2
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");
        }