void OnTriggerEnter2D(Collider2D col) { if (col.CompareTag("EnemyRanged")) { EnemyRangedHandler enemy = col.GetComponent <EnemyRangedHandler>(); enemy.KnockBack(1000000); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } if (enemy.switched == false) { StartCoroutine(enemy.SwapState(stunDuration)); } } if (col.CompareTag("Enemy")) { EnemyHandler enemy = col.GetComponent <EnemyHandler>(); enemy.KnockBack(1000000); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } if (enemy.switched == false) { StartCoroutine(enemy.SwapState(stunDuration)); } } if (col.CompareTag("EnemySlower")) { EnemySlowerHandler enemy = col.GetComponent <EnemySlowerHandler>(); enemy.KnockBack(1000000); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } if (enemy.switched == false) { StartCoroutine(enemy.SwapState(stunDuration)); } } }
IEnumerator AoE() { aoe = true; audioManager.Play("Explosion"); gameObject.GetComponent <ParticleSystem>().Play(); StartCoroutine(FadeTo(aoeCd, aoeFire)); Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(transform.position, attackRange * 4, whatIsEnemies); for (int i = 0; i < enemiesToDamage.Length; i++) { if (enemiesToDamage[i].gameObject.CompareTag("EnemyRanged")) { EnemyRangedHandler enemy = enemiesToDamage[i].GetComponent <EnemyRangedHandler>(); enemy.GetHealthSystem().Damage(aoeDmg); enemy.KnockBack(1000000); CreateText(Color.grey, new Vector3(enemy.transform.position.x, enemy.transform.position.y + 1), new Vector2(0, 5), "-" + aoeDmg); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } else if (enemiesToDamage[i].gameObject.CompareTag("Enemy")) { EnemyHandler enemy = enemiesToDamage[i].GetComponent <EnemyHandler>(); enemy.GetHealthSystem().Damage(aoeDmg); enemy.KnockBack(1000000); CreateText(Color.grey, new Vector3(enemy.transform.position.x, enemy.transform.position.y + 1), new Vector2(0, 5), "-" + aoeDmg); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } else if (enemiesToDamage[i].gameObject.CompareTag("EnemySlower")) { EnemySlowerHandler enemy = enemiesToDamage[i].GetComponent <EnemySlowerHandler>(); enemy.GetHealthSystem().Damage(aoeDmg); enemy.KnockBack(1000000); CreateText(Color.grey, new Vector3(enemy.transform.position.x, enemy.transform.position.y + 1), new Vector2(0, 5), "-" + aoeDmg); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } else if (enemiesToDamage[i].gameObject.CompareTag("Boss")) { BossHandler boss = enemiesToDamage[i].GetComponent <BossHandler>(); boss.GetHealthSystem().Damage(aoeDmg); CreateText(Color.grey, new Vector3(boss.transform.position.x, boss.transform.position.y + 1), new Vector2(0, 5), "-" + aoeDmg); if (boss.GetHealthSystem().GetHealthPercent() < 0.25) { boss.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } } yield return(new WaitForSeconds(aoeCd)); aoeFire.color = new Color(1, 1, 1, 1); aoe = false; }
private void HandleAttack() { if ((Input.GetButtonDown("Basic") || phoneAttack) && timeBtwAttack <= 0) { StartCoroutine(TmpBusy(0.1f)); animator.SetTrigger("Attack"); phoneAttack = false; Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, whatIsEnemies); if (enemiesToDamage.Length > 0) { audioManager.Play("SlashSuccess"); for (int i = 0; i < enemiesToDamage.Length; i++) { if (enemiesToDamage[i].gameObject.CompareTag("EnemyRanged")) { EnemyRangedHandler enemy = enemiesToDamage[i].GetComponent <EnemyRangedHandler>(); enemy.GetHealthSystem().Damage(basicAtkDmg); enemy.KnockBack(200000); CreateText(Color.grey, new Vector3(enemy.transform.position.x, enemy.transform.position.y + 1), new Vector2(0, 5), "-" + basicAtkDmg); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } else if (enemiesToDamage[i].gameObject.CompareTag("Enemy")) { EnemyHandler enemy = enemiesToDamage[i].GetComponent <EnemyHandler>(); enemy.GetHealthSystem().Damage(basicAtkDmg); enemy.KnockBack(200000); CreateText(Color.grey, new Vector3(enemy.transform.position.x, enemy.transform.position.y + 1), new Vector2(0, 5), "-" + basicAtkDmg); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } else if (enemiesToDamage[i].gameObject.CompareTag("EnemySlower")) { EnemySlowerHandler enemy = enemiesToDamage[i].GetComponent <EnemySlowerHandler>(); enemy.GetHealthSystem().Damage(basicAtkDmg); enemy.KnockBack(200000); CreateText(Color.grey, new Vector3(enemy.transform.position.x, enemy.transform.position.y + 1), new Vector2(0, 5), "-" + basicAtkDmg); if (enemy.GetHealthSystem().GetHealthPercent() < 0.25) { enemy.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } else if (enemiesToDamage[i].gameObject.CompareTag("Boss")) { BossHandler boss = enemiesToDamage[i].GetComponent <BossHandler>(); boss.GetHealthSystem().Damage(basicAtkDmg); CreateText(Color.grey, new Vector3(boss.transform.position.x, boss.transform.position.y + 1), new Vector2(0, 5), "-" + basicAtkDmg); if (boss.GetHealthSystem().GetHealthPercent() < 0.1) { boss.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); } } } } else { audioManager.Play("SlashFail"); } timeBtwAttack = startTimeBtwAttack; } else { phoneAttack = false; timeBtwAttack -= Time.deltaTime; } }