public void CreateBullet(Vector3 target, Vector3 source) { bulletIndex = bulletManager.GetBulletIndex(); if (bulletIndex == -1) { return; } bullet = bulletManager.bullets[bulletIndex].GetComponent <BulletLine>(); bulletManager.freeBullets[bulletIndex] = false; bullet.GetComponent <Renderer>().material = shooterObject.GetComponent <Renderer>().sharedMaterial; bullet.Show(target, source); StartCoroutine(BulletShowTimer()); }
protected override IEnumerator AttackCicle() { yield return(new WaitForSeconds(.5f)); offsetCicle = false; while (true) { spawnedBullets = new List <Bullet>(); m_animator.SetInteger("State", 1); for (int i = 0; i < bulletsPerCicle; i++) { GameObject bulletObject = pool.Get(); BulletLine bullet = bulletObject.GetComponent <BulletLine>(); if (bullet) { bulletObject.SetActive(true); Vector2 direction = RaposUtil.RotateVector(Vector3.up, i * (360 / bulletsPerCicle) + (offsetCicle ? (180 / bulletsPerCicle) : 0)); bulletObject.transform.rotation = Quaternion.Euler(Vector3.forward * (Vector2.SignedAngle(Vector2.up, direction) + 90)); bulletObject.transform.position = transform.position; InheritAnchorMovement inheritAnchorMovement = bullet.GetComponent <InheritAnchorMovement>(); if (inheritAnchorMovement != null) { inheritAnchorMovement.enabled = true; inheritAnchorMovement.Set(transform); } bullet.StartCoroutine(PositionBullet(bulletObject.transform, (Vector3)(direction * 1f))); spawnedBullets.Add(bullet); yield return(new WaitForSeconds(.03f)); } } yield return(new WaitForSeconds(.5f)); ReleaseBullets(); m_animator.SetInteger("State", 2); yield return(new WaitForSeconds(1)); offsetCicle = !offsetCicle; } }