Ejemplo n.º 1
0
    public void EnemyHealthLoweredWhenBulletHitsEnemy_Test()
    {
        // Temporarily commented out because of code refactoring

        // Arrange
        var enemyTriangle = new EnemyTriangle();
        var bullet        = new Bullet();

        enemyTriangle.health = 4; //original health of enemy
        bullet.damage        = 2; //damage dealt per bullet

        //Act
        enemyTriangle.Hit(bullet.damage);

        // Assert
        //the health of enemy is expected to be deducted by 1 when hit by a bullet
        Assert.True(enemyTriangle.health == 2);

        //Arrange
        var enemyOctagon = new EnemyOctagonPurple();

        enemyOctagon.health = 5;

        //Act
        enemyOctagon.Hit(bullet.damage);

        // Assert
        //the health of enemy is expected to be deducted by 1 when hit by a bullet
        Assert.True(enemyOctagon.health == 3);
    }
Ejemplo n.º 2
0
    public void HitTriangleTest2()
    {
        // Arrange
        var enemyTriangle = new EnemyTriangle();
        var bullet        = new Bullet();

        enemyTriangle.health = 5;
        bullet.damage        = 2;

        // Act
        enemyTriangle.Hit(bullet.damage);

        // Assert
        Assert.True(enemyTriangle.health == 3);
    }
Ejemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Shield shield = collision.GetComponent<Shield>();
        //if () 
        EnemyTriangle enemyTriangle = collision.GetComponent<EnemyTriangle>();
        if (enemyTriangle != null)
        {
            AudioSource.PlayClipAtPoint(hitSound, new Vector3(0, 0, -5));
            enemyTriangle.Hit(damage);
            Destroy(gameObject);
            return;
        }

        EnemyOctagonPurple enemyOctagonPurple = collision.GetComponent<EnemyOctagonPurple>();
        if (enemyOctagonPurple != null)
        {
            AudioSource.PlayClipAtPoint(hitSound, new Vector3(0, 0, -5));
            enemyOctagonPurple.Hit(damage);
            Destroy(gameObject);
            return;
        }

        EnemyHeartPink enemyHeartPink = collision.GetComponent<EnemyHeartPink>();
        if (enemyHeartPink != null)
        {
            AudioSource.PlayClipAtPoint(hitSound, new Vector3(0, 0, -5));
            enemyHeartPink.Hit(damage);
            Destroy(gameObject);
            return;
        }

        EnemyCircleMaroon enemyCircleMaroon = collision.GetComponent<EnemyCircleMaroon>();
        if (enemyCircleMaroon != null)
        {
            AudioSource.PlayClipAtPoint(hitSound, new Vector3(0, 0, -5));
            enemyCircleMaroon.Hit(damage);
            Destroy(gameObject);
            return;
        }
    }