// melee 90' angle infront of character with 1 range. public static Action <Vector3, GameObject> Melee(int damage) // this way of calculating the hit-cone infront of the target assume that all y-values in all positions is 0. { Action <Vector3, GameObject> retval = (targetPos, player) => { Vector3 playerForward = (targetPos - player.transform.position).normalized; IEnumerable <GameObject> enemiesInCone = VectorFun.getTagsInCone("Enemies", player.transform.position, playerForward, 10, 45); foreach (GameObject item in enemiesInCone) { Stats stat = item.GetComponent <Stats>(); stat.dealDamage(damage); } }; return(retval); }
void Casting() { if (castBar.enabled == false) { castBar.enabled = true; } if (timeCasting < castTime) { timeCasting = Time.deltaTime + timeCasting; castBar.fillAmount = timeCasting / castTime; castBarTime.text = Math.Floor(timeCasting) + " / " + castTime; } else { SetCurrentCooldown(index); timeCasting = 0f; castBar.enabled = false; isCasting = false; //Shoot projectile Vector3 targetCoordinates = VectorFun.GetMouseCoordinatesOnPlane(); currentSpell(targetCoordinates, gameObject); } }