예제 #1
0
            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);
            }
예제 #2
0
            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");
                }
            }
예제 #3
0
 public void AttackDone()
 {
     OnDoneAttacking?.Invoke(this, EventArgs.Empty);
 }