コード例 #1
0
ファイル: FixedSpawnTest.cs プロジェクト: LukasKez/OPP-tankai
        public void TestSpawnedTypeFirst()
        {
            FixedSpawn     fixedSpawn = new FixedSpawn();
            GameObjectStub gameObject = new GameObjectStub();

            fixedSpawn.Spawn(gameObject);
            Assert.AreEqual(0, fixedSpawn.getCurrentType());
        }
コード例 #2
0
        public void TestWithNullContainer()
        {
            IAdapter adapter = new ObstacleAdapter(null);

            GameObjectStub stub = new GameObjectStub();

            adapter.SetFields(stub);
        }
コード例 #3
0
        public void TestWithBadAdapterContainer()
        {
            AdapterContainer adapterContainer = new AdapterContainer();

            adapterContainer.SetGameObject(null);

            IAdapter adapter = new ObstacleAdapter(adapterContainer);

            GameObjectStub stub = new GameObjectStub();

            adapter.SetFields(stub);
        }
コード例 #4
0
        public void TestInstantiateAndDestroy()
        {
            GameLevel gameLevel = GameState.Instance.gameLevel;

            GameObjectStub gameObject = new GameObjectStub();

            GameObject.Instantiate(gameObject);

            gameLevel.Update(0);
            Assert.AreEqual(1, GameState.Instance.gameLevel.Find <GameObjectStub>().Count);

            gameObject.Destroy();
            gameLevel.Update(0);
            Assert.AreEqual(0, GameState.Instance.gameLevel.Find <GameObjectStub>().Count);
        }
コード例 #5
0
ファイル: FixedSpawnTest.cs プロジェクト: LukasKez/OPP-tankai
        public void TestRandomnessOfPowerUp()
        {
            FixedSpawn     fixedSpawn = new FixedSpawn();
            GameObjectStub gameObject = new GameObjectStub();
            int            timesOfPermamentPowerup = 0;

            for (int i = 0; i < 1000; i++)
            {
                var powerUp = fixedSpawn.Spawn(gameObject);
                if (powerUp.GetType() == typeof(PermanentAttack) || powerUp.GetType() == typeof(PermanentDefense) || powerUp.GetType() == typeof(PermanentHealth) || powerUp.GetType() == typeof(PermanentSpeed))
                {
                    timesOfPermamentPowerup++;
                }
            }
            Assert.IsTrue(timesOfPermamentPowerup >= 450 && timesOfPermamentPowerup <= 550);
        }
コード例 #6
0
        public void TestGameObjectInstantiateAndDestroyWithParent()
        {
            GameLevel gameLevel = GameState.Instance.gameLevel;

            GameObjectStub parent = new GameObjectStub();
            GameObjectStub child  = new GameObjectStub();

            GameObject.Instantiate(parent);
            GameObject.Instantiate(child, parent);

            gameLevel.Update(0);
            Assert.AreEqual(2, GameState.Instance.gameLevel.Find <GameObjectStub>().Count);

            parent.Destroy();
            gameLevel.Update(0);
            Assert.AreEqual(0, GameState.Instance.gameLevel.Find <GameObjectStub>().Count);
        }
コード例 #7
0
        public void TestGameObjectTransform()
        {
            GameObjectStub parent = new GameObjectStub();
            GameObjectStub child  = new GameObjectStub();

            GameObject.Instantiate(child, parent);

            parent.transform.position = Vector2.One;
            Assert.AreEqual(Vector2.One, child.transform.WorldPosition);

            parent.transform.rotation = 180;
            child.transform.position  = Vector2.One;
            Assert.AreEqual(Vector2.Zero, child.transform.WorldPosition);

            child.transform.WorldPosition = -Vector2.One;
            Assert.AreEqual(Vector2.Zero, child.transform.position);

            child.transform.WorldRotation = 0;
            Assert.AreEqual(-180, child.transform.rotation);
        }