private Projectile WakeUp() { if (backupProjectiles.Count <= 2) { if (spawnMore) { backupProjectiles.Add(SpawnProjectile()); } } Projectile newProjectile = null; if (backupProjectiles.Count > 0) { newProjectile = backupProjectiles[0]; backupProjectiles.RemoveAt(0); newProjectile.gameObject.SetActive(true); newProjectile.Activate(); currentProjectiles.Add(newProjectile); } else { Debug.LogWarning("Projectile pool limit reached!"); } return(newProjectile); }
private Projectile PopFromPool() { Projectile p = pool[0]; pool.Remove(p); p.Activate(); return(p); }
public void Launch(Vector3 position, Vector3 direction) { GameObject shot = Instantiate(projectile); Projectile _projectile = shot.GetComponent <Projectile>(); _projectile.transform.position = position; _projectile.transform.eulerAngles = direction; _projectile.Activate(); _projectile.GetComponent <Rigidbody>().AddForce(0, 0, _projectile.speed); }
public override bool Trigger(float x, float y) { if (xMin < x && x < xMax) { if (yMin < y && y < yMax) { print("Pressed player button"); MyProjectile.Activate(TargetLocator.GetClosestMonster().transform.position, element); gameObject.GetComponent <SpriteRenderer>().color = Color.black; return(true); } } gameObject.GetComponent <SpriteRenderer>().color = Color.white; return(false); }
private Projectile WakeUp() { if (backupProjectiles.Count <= 2) { if (spawnMore) { backupProjectiles.Add(Spawn()); } } Projectile newProjectile = null; if (backupProjectiles.Count > 0) { newProjectile = backupProjectiles[0]; backupProjectiles.RemoveAt(0); newProjectile.gameObject.SetActive(true); newProjectile.Activate(); currentProjectiles.Add(newProjectile); } return(newProjectile); }
public override bool Use(Vector2 direction) { if (base.Use(direction)) { Projectile toShoot = null; // Decide which type of arrow to shoot if (empowered) { // Fetch an Empowered Arrow toShoot = RefProjectileManager.FetchEmpoweredArrow().GetComponent <EmpoweredArrow>(); // Play the sound SoundManager.PlaySoundEffect(SoundManager.SoundEffect.Weapon_Attack_1); // Turn off the empowerment setEmpowered(false); } else { // Fetch an Arrow toShoot = RefProjectileManager.FetchArrow().GetComponent <Arrow>(); // Play the sound SoundManager.PlaySoundEffect(SoundManager.SoundEffect.Weapon_Attack_3); } // Error Checking if (toShoot != null) { toShoot.Activate(firePoint, this, direction, Range * RefProjectileManager.GetComponent <TileMap>().TileSize); return(true); } } return(false); }
public void FireSpecificBullet(Vector2 source, Vector2 target, Projectile bullet) { bullet.Activate(source, target); }