Ejemplo n.º 1
0
        public IEnumerator ReleasePlatformTest()
        {
            GameObject     gameObject0    = new GameObject();
            MovingPlatform movingPlatform = gameObject0.AddComponent <MovingPlatform>();

            GameObject             gameObject1            = new GameObject();
            MovingPlatformProvider movingPlatformProvider = gameObject1.AddComponent <MovingPlatformProvider>();

            List <MovingPlatform> movingPlatformList = new List <MovingPlatform>();

            movingPlatformList.Add(movingPlatform);
            movingPlatformProvider.InjectDependencies(movingPlatformList);

            // Since there is only one platform in the list, it should return the same reference to the one added previously
            MovingPlatform randomMovingPlatform = movingPlatformProvider.GetRandomPlatform();

            movingPlatformProvider.ReleasePlatform(randomMovingPlatform); // Release it and then get another platform. Should return the same
            randomMovingPlatform = movingPlatformProvider.GetRandomPlatform();

            Assert.AreEqual(movingPlatform, randomMovingPlatform);

            yield return(null);
        }
    void SpawnPlatform()
    {
        MovingPlatform platform = _movingPlatformProvider.GetRandomPlatform();

        ResetPlatform(platform);

        platform.gameObject.SetActive(true);

        if (!_highScoreSurpassed && _spawnedPlatformsCount == _highScoreController.HighScore) // About to surpass current high score
        {
            platform.ChangeMaterial(_platformHighScoreMaterial);
            _highScoreSurpassed = true;
        }

        _spawnedPlatformsCount++;
    }
Ejemplo n.º 3
0
        public IEnumerator EmptyProviderTest()
        {
            GameObject             gameObject             = new GameObject();
            MovingPlatformProvider movingPlatformProvider = gameObject.AddComponent <MovingPlatformProvider>();

            List <MovingPlatform> movingPlatformList = new List <MovingPlatform>();

            movingPlatformProvider.InjectDependencies(movingPlatformList);

            // Since there are no platforms in the list, it should return a null reference withouth break.
            MovingPlatform randomMovingPlatform = movingPlatformProvider.GetRandomPlatform();

            Assert.AreEqual(null, randomMovingPlatform);

            yield return(null);
        }