private void OnTriggerEnter2D(Collider2D collider) { if (!collider.isTrigger) { if (!enemyBullet) { if (collider.CompareTag("Enemy")) { EnemyStatus enemyStats = collider.GetComponent <EnemyStatus>(); enemyStats.health -= dmg; enemyStats.hit = true; enemyStats.knockBackDir = velocity.normalized; Destroy(gameObject); //Debug.Log("Knocked back"); } else if (collider.CompareTag("EnemyArcher")) { EnemyStatus1 enemyStats = collider.GetComponent <EnemyStatus1>(); enemyStats.health -= dmg; enemyStats.hit = true; enemyStats.knockBackDir = velocity.normalized; Destroy(gameObject); } else if (collider.CompareTag("EnemyBoss")) { BossStatus bs = collider.GetComponent <BossStatus>(); bs.hit = true; Destroy(gameObject); } else if (!collider.CompareTag("Player")) { Destroy(gameObject); } } else { if (collider.CompareTag("Player")) { PlayerStatus pstats = collider.GetComponentInParent <PlayerStatus>(); pstats.health -= dmg; pstats.stunnedByBoss = bossBullet; Destroy(gameObject); } else if (!collider.CompareTag("Enemy") && !collider.CompareTag("EnemyArcher") && !collider.CompareTag("EnemyBoss")) { Destroy(gameObject); } } } }
private void Awake() { thisStatus = GetComponent <EnemyStatus1>(); playerDetectCol = GetComponent <CircleCollider2D>(); enemyAnimController = GetComponent <EnemyAnimationController>(); if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); } if (bullet == null) { throw new System.Exception("BULLET PREFAB WAS NOT ADDED, CANNOT SHOOT"); } Bullets = GameObject.FindGameObjectWithTag("BulletsParent").GetComponent <Transform>(); }
private void ActionWippedEnemies(Vector3 wipDir) { RaycastHit2D[] hitInfo = new RaycastHit2D[16]; int numHits = Physics2D.RaycastNonAlloc(transform.position, wipDir, hitInfo, wipAttackRange, wipMask); //Debug.Log(numHits); for (int i = 0; i < numHits; i++) { if (hitInfo[i].collider.CompareTag("Enemy")) { EnemyStatus thisEnemyStatus = hitInfo[i].collider.GetComponent <EnemyStatus>(); thisEnemyStatus.wipped = true; //Debug.Log("Wipped Enemy"); } else if (hitInfo[i].collider.CompareTag("EnemyArcher")) { EnemyStatus1 thisEnemyStatus = hitInfo[i].collider.GetComponent <EnemyStatus1>(); thisEnemyStatus.wipped = true; } } }