Exemplo n.º 1
0
        public void DieAfterIfItReceivesMoreDamageThanCurrentHP()
        {
            // Arrange
            var unit = new EnemyDog(null, null);

            // Act
            unit.ReciveAtack(unit.CurrentHealth + 1);

            // Assert
            Assert.IsTrue(unit.Dead);
        }
Exemplo n.º 2
0
        public void IsAliveIfDamageIsLessThanCurrentHP()
        {
            // Arrange
            var unit = new EnemyDog(null, null);

            // Act
            unit.ReciveAtack(unit.CurrentHealth - 1);

            // Assert
            Assert.IsFalse(unit.Dead);
        }
Exemplo n.º 3
0
        public void ShouldCorrectlyTakeDamage()
        {
            // Arrange
            var unit = new EnemyDog(null, null);

            double unitInitialHealth = unit.CurrentHealth;

            // Act
            unit.ReciveAtack(unitInitialHealth - 1);

            // Assert
            Assert.AreEqual(1, unit.CurrentHealth);
        }
Exemplo n.º 4
0
    private LevelBlock GenLoadedLevelBlock
        (int index, Vector2 pos, float scrollSpeed, float startOffset, float tileSize)
    {
        LevelBlock block = Instantiate(levelBlockPrefab, new Vector3(pos.x, pos.y, 0f), Quaternion.identity) as LevelBlock;

        block.type        = Scroller.ScrollType.Vertical;
        block.scrollSpeed = scrollSpeed;
        block.startOffset = startOffset;
        block.tileSize    = tileSize;

        BlockData blockData = levelData.blocks[index];

        block.bgTex     = backgroundTex[blockData.bgIndex];
        block.groundTex = blockData.ground ? groundTex : null;
        block.sideTex   = sideTex[blockData.sideIndex];

        foreach (var dogParam in blockData.dogs)
        {
            EnemyDog dog = Instantiate(enemyDogPrefab, new Vector3(pos.x + dogParam._posX, pos.y + dogParam._posY, 0f), Quaternion.identity) as EnemyDog;
            dog.wanderRange      = dogParam._wanderRange;
            dog.wanderFreq       = dogParam._wanderFreq;
            dog.wanderOffset     = dogParam._wanderOffset;
            dog.fallingAcc       = dogParam._fallingAcc;
            dog.maxFallingSpeed  = dogParam._maxFallingSpeed;
            dog.transform.parent = block.transform;
            block.enemyDogs.Add(dog);
        }

        foreach (var planeParam in blockData.planeParams)
        {
            AeroPlane pl = Instantiate(planePrefab, new Vector3(pos.x + planeParam._posX, pos.y + planeParam._posY, 0f), Quaternion.identity) as AeroPlane;
            pl.transform.parent = block.transform;
            pl.direction        = planeParam._direction;
            pl.flyDist          = planeParam._flyDist;
            pl.flySpeed         = planeParam._flySpeed;
            pl.waitTime         = planeParam._waitTime;
            pl.transform.parent = block.transform;
            block.enemyPlanes.Add(pl);
        }

        foreach (var powerUpParam in blockData.powerUpParams)
        {
            PowerUp pu = Instantiate(powerUpPrefab, new Vector3(pos.x + powerUpParam._posX, pos.y + powerUpParam._posY, 0f), Quaternion.identity) as PowerUp;
            pu.transform.parent = block.transform;
        }

        foreach (var birdParam in blockData.birdParams)
        {
            Bird bird = Instantiate(birdPrefab, new Vector3(pos.x + birdParam._posX, pos.y + birdParam._posY, 0f), Quaternion.identity) as Bird;
            bird.transform.parent = block.transform;
            bird.direction        = birdParam._direction;
            bird.flyDist          = birdParam._flyDist;
            bird.flySpeed         = birdParam._flySpeed;
            bird.waitTime         = birdParam._waitTime;
            bird.transform.parent = block.transform;
            block.birds.Add(bird);
        }

        foreach (var ufoParam in blockData.ufoParams)
        {
            Ufo ufo = Instantiate(ufoPrefab, new Vector3(pos.x + ufoParam._posX, pos.y + ufoParam._posY, 0f), Quaternion.identity) as Ufo;
            ufo.transform.parent   = block.transform;
            ufo.direction          = ufoParam._direction;
            ufo.flyDist            = ufoParam._flyDist;
            ufo.flySpeed           = ufoParam._flySpeed;
            ufo.waitTime           = ufoParam._waitTime;
            ufo.circularMoveRadius = ufoParam._circularMoveRadius;
            ufo.circularMoveFreq   = ufoParam._circularMoveFreq;
            ufo.transform.parent   = block.transform;
            block.ufos.Add(ufo);
        }

        foreach (var miscParam in blockData.miscParams)
        {
            var        miscPrefab = miscPrefabs[miscParam._type];
            GameObject misc       = Instantiate(miscPrefab, new Vector3(pos.x + miscParam._posX, pos.y + miscParam._posY, 0f), Quaternion.identity) as GameObject;
            misc.transform.localScale = Vector3.one * miscParam._size;
            misc.transform.parent     = block.transform;
            block.miscs.Add(misc);
        }

        block.PeriodOver += OnBlockEnd;
        return(block);
    }
 private void Start()
 {
     owner = transform.parent.gameObject.GetComponent<EnemyDog>();
     Debug.Assert(owner != null, "cannot find owner");
 }
 private void Start()
 {
     owner = transform.parent.gameObject.GetComponent <EnemyDog>();
     Debug.Assert(owner != null, "cannot find owner");
 }