public bool MultipleMelee(float damage, int amountTargets, List <Collider2D> enemies, Vector3 playerPosition) { AttackedEnemies.Clear(); if (!HasEnemies(enemies)) { return(false); } var closest = MultiClosestTarget(amountTargets, enemies, playerPosition); if (closest != null) { AttackedEnemies = closest; foreach (Collider2D coll in AttackedEnemies) { CharActions charActions = coll.GetComponent <CharActions>(); charActions.TakeDamage(damage); bool isCrit = Random.Range(0, 100) < 30; DamagePopup.Create(damageInfo, coll.transform.position, damage, isCrit); } return(true); } else { return(false); } }
public bool SingleMelee(float damage, List <Collider2D> enemies, Vector3 playerPosition) { AttackedEnemies.Clear(); if (!HasEnemies(enemies)) { return(false); } var closest = ClosestTarget(enemies, playerPosition); if (closest != null) { AttackedEnemies.Add(closest); CharActions charActions = closest.GetComponent <CharActions>(); charActions.TakeDamage(damage); bool isCrit = Random.Range(0, 100) < 30; DamagePopup.Create(damageInfo, closest.transform.position, damage, isCrit); return(true); } else { return(false); } }