示例#1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        EnemyController  enemy  = col.GetComponent <EnemyController>();
        EnemyController1 enemy1 = col.GetComponent <EnemyController1>();
        EnemyController3 enemy3 = col.GetComponent <EnemyController3>();
        EnemyController4 enemy4 = col.GetComponent <EnemyController4>();
        EnemyController5 enemy5 = col.GetComponent <EnemyController5>();
        Destructible     des    = col.GetComponent <Destructible>();

        if (enemy != null)
        {
            enemy.TakeDamage(40);
        }
        else if (enemy1 != null)
        {
            enemy1.TakeDamage(40);
        }
        else if (enemy3 != null)
        {
            enemy3.TakeDamage(40);
        }
        else if (enemy4 != null)
        {
            enemy4.TakeDamage(40);
        }
        else if (enemy5 != null)
        {
            enemy5.TakeDamage(40);
        }
        else if (des != null)
        {
            des.TakeDamage(40);
        }
        Destroy(gameObject);
    }
示例#2
0
    private void OnAttack(Transform enemy)
    {
        //Attack Sound
        SoundManager.instance.PlaySE("AudioAttack");

        //Get Point
        gameManager.stagePoint += 150;

        //Reaction Force
        rigid.AddForce(Vector2.up * 3, ForceMode2D.Impulse);

        //Enemy Damage
        if (isStage3)
        {
            EnemyController3 enemyController = enemy.GetComponent <EnemyController3>();
            if (enemyController.health <= 1)
            {
                enemyController.OnDamaged();
            }
            else
            {
                enemyController.health -= 1;
            }
        }
        else
        {
            EnemyController enemyController = enemy.GetComponent <EnemyController>();
            if (enemyController.health <= 1)
            {
                enemyController.OnDamaged();
            }
            else
            {
                enemyController.health -= 1;
            }
        }
    }