private void Attack() { Vector3 targetPosition = Player.Instance().transform.position; attackTimer = attackCooldown; Eyeshot eyeshot = FirstInactiveEyeshot(); eyeshot.target = targetPosition; eyeshot.Fire(); gameObject.GetComponent <AudioSource>().Play(); }
private Eyeshot FirstInactiveEyeshot() { foreach (GameObject g in projectiles) { if (!g.GetComponent <Rigidbody2D>().simulated) { g.GetComponent <Rigidbody2D>().simulated = true; g.GetComponent <SpriteRenderer>().enabled = true; return(g.GetComponent <Eyeshot>()); } } Eyeshot eyeshot = Instantiate(Resources.Load("Projectile/Eyeshot", typeof(Eyeshot)) as Eyeshot) as Eyeshot; projectiles.Add(eyeshot.gameObject); return(eyeshot); }