private void TryToKill() { if (timeFinished && particlesFinished && soundFinished) { GobPool.Destroy(gameObject); } }
private void ShootBullet() { GameObject b = GobPool.Instantiate(bulletPrefab); Bullet bc = b.GetComponent <Bullet>(); b.transform.SetPositionAndRotation(gunBarrel.position, gunBarrel.rotation); bc.Start(); bc.Velocity = gunBarrel.forward * 30 + velocity; bc.wobble = 0; if (gunPower / maxGunPower > gunWaveThreshold) { bc.wobble = 0.5f; } if (gunPower / maxGunPower > gunSpreadThreshold) { bc.wobble = 1; b = GobPool.Instantiate(bulletPrefab); bc = b.GetComponent <Bullet>(); b.transform.SetPositionAndRotation(gunBarrel.position, gunBarrel.rotation * Quaternion.FromToRotation(Vector3.forward, new Vector3(0, 0.25f, 0.75f))); bc.Start(); bc.Velocity = b.transform.forward * 30 + velocity; bc.wobble = 0.5f; b = GobPool.Instantiate(bulletPrefab); bc = b.GetComponent <Bullet>(); b.transform.SetPositionAndRotation(gunBarrel.position, gunBarrel.rotation * Quaternion.FromToRotation(Vector3.forward, new Vector3(0, -0.25f, 0.75f))); bc.Start(); bc.Velocity = b.transform.forward * 30 + velocity; bc.wobble = 0.5f; } }
private void NonStaticCreateFx(int fxIndex, Vector3 position, Quaternion rotation) { var gob = GobPool.Instantiate(Fx[fxIndex]); gob.transform.position = position; gob.transform.rotation = rotation; }
public static void Clear() { foreach (var p in _instance.pool.Keys) { ClearPool(p); } _instance = null; }
void Start() { if (instance != null) { Clear(); } instance = this; pool = new Dictionary <string, Stack <GameObject> >(); }
void Update() { realPosition += Velocity * Time.deltaTime; transform.position = realPosition + (transform.up * wobble * Mathf.Sin((Time.time - startTime) * 50)); timer -= Time.deltaTime; if (timer < 0) { GobPool.Destroy(gameObject); } }
void SpawnBird() { GameObject gob = GobPool.Instantiate(birdPrefab); gob.transform.SetPositionAndRotation(transform.position, transform.rotation); BirdDriver bd = gob.GetComponent <BirdDriver>(); if (bd) { bd.Start(); } }
private void OnTriggerEnter(Collider other) { if (other.tag.Equals("PlayerBullet")) { GobPool.Destroy(other.gameObject); bossHP--; DataDump.SetInt("BossHP", bossHP); if (bossHP < 0) { Doomed(); } } }
public static void Destroy(GameObject o) { if (instance == null) { instance = GameObject.Find("GameDirector").GetComponent <GobPool>(); } if (!instance.pool.ContainsKey(o.tag)) { instance.pool.Add(o.tag, new Stack <GameObject>()); } instance.pool[o.tag].Push(o); o.SetActive(false); }
public static GameObject Instantiate(GameObject o) { if (instance == null) { instance = GameObject.Find("GameDirector").GetComponent <GobPool>(); } GameObject newObject = instance.pool.ContainsKey(o.tag) && instance.pool[o.tag].Count > 0 ? instance.pool[o.tag].Pop() : GameObject.Instantiate(o); newObject.SetActive(true); return(newObject); }
public static void Clear() { if (instance == null) { return; } foreach (var p in instance.pool.Values) { while (p.Count > 0) { Destroy(p.Pop()); } } instance.pool.Clear(); instance = null; }
private void OnTriggerEnter(Collider other) { if (other.tag.Equals("PlayerBullet")) { GobPool.Destroy(other.gameObject); DataDump.SetInt("BirdsKilled", DataDump.GetInt("BirdsKilled") + 1); var df = GobPool.Instantiate(deadFacade); df.transform.SetPositionAndRotation(transform.position, Quaternion.identity); Doomed(); } if (other.tag.Equals("Player")) { DataDump.SetInt("BirdsKilled", DataDump.GetInt("BirdsKilled") + 1); other.GetComponent <ShipDriver>().TakeDamage(1); var df = GobPool.Instantiate(deadFacade); df.transform.SetPositionAndRotation(transform.position, Quaternion.identity); Doomed(); } }
private void Update() { stateTimer -= Time.deltaTime; if (stateTimer < 0) { switch (state) { case State.Wave: stateTimer = 15; spawnWave.SetActive(true); spawnBomb.SetActive(false); state = State.Bombers; break; case State.Bombers: stateTimer = 15; spawnWave.SetActive(false); spawnBomb.SetActive(true); state = State.Rest; break; case State.Rest: stateTimer = 10; spawnWave.SetActive(false); spawnBomb.SetActive(false); state = State.Wave; break; } } if (hpSpawns * 100 > bossHP) { hpSpawns--; var gob = GobPool.Instantiate(hpDrop); gob.transform.SetPositionAndRotation(transform.position, transform.rotation); } }
void Start() { GobPool.Clear(); currentState = new IntroState(); currentState.OnEnter(); }
protected virtual void Doomed() { lifeTimer = 10; GobPool.Destroy(gameObject); }
public virtual void Doomed() { lifeTimer = 10; sentMessage = false; GobPool.Destroy(gameObject); }
private void Awake() { _instance = this.CheckSingleton(_instance); pool = new Dictionary <string, Stack <GameObject> >(); }