IEnumerator FireShots(int amoutOfShoots, Vector2 lookDirection, GameObject projectile, int waitingTimeBetwennShots) { float forceStrengh = 0.2f; for (int i = 0; i < amoutOfShoots; i++) { GameObject bullet = Instantiate(projectile, transform.position + new Vector3(1, 0, 0), projectile.transform.rotation); Rigidbody2D projectileRb = bullet.GetComponent <Rigidbody2D>(); projectileRb.AddForce(lookDirection.normalized * forceStrengh, ForceMode2D.Impulse); yield return(new WaitForSeconds(waitingTimeBetwennShots)); } OnDoneAttacking?.Invoke(this, EventArgs.Empty); }
public void MeleeAttack(GameCharacter target) { if (target == null) { return; } if (target.name == name) { return; } if (InMeleeAttackRadious(target.transform.position)) { currentState = State.Attacking; target.TakeDamage(statsSystem.MeleeDamge); OnDoneAttacking?.Invoke(this, EventArgs.Empty); onActionPointsChanged?.Invoke(this, EventArgs.Empty); } else { Debug.Log("Out of Range"); } }
public void AttackDone() { OnDoneAttacking?.Invoke(this, EventArgs.Empty); }