private void Start() { game = GetComponent <Player>().game; canShoot = true; game.AddMouseEvent(InputEventType.Continious, 0, shoot); game.AddSimpleInputEvent(InputEventType.OnBegin, KeyCode.R, reload); //Bullet Factory Bullet.Factory = () => { return(Instantiate( bulletPrefab, Vector3.zero, Quaternion.identity, game.BulletParent.transform)); }; //Bullet Pool game.PlayerBulletPool = new Pool <GameObject>( 50, Bullet.Factory, Bullet.InitializeBullet, Bullet.DeactivateBullet, true); //Método de reemplazo para Destroy() Bullet.OnDeactivate = game.PlayerBulletPool.ReturnObjectToPool; game.UpdateBullets(bulletCount, maxBullets); }
IEnumerator reloading() { isReloading = true; anim.SetTrigger("Reload"); canShoot = false; yield return(new WaitForSeconds(1.4f)); bulletCount = maxBullets; canShoot = true; isReloading = false; game.UpdateBullets(bulletCount, maxBullets); }