public void ReturnGameObjectToPool(RailShooterBullet go) { m_Pool.Add(go); go.gameObject.SetActive(false); go.transform.parent = transform; }
void OnTriggerEnter(Collider other) { RailShooterBullet bullet = other.GetComponent <RailShooterBullet>(); if (bullet) { bullet.Remove(); } float m_lifeToRemove = 0; if (other.tag == "Projectile") { m_lifeToRemove = m_lifeToRemoveProjectile; } else if (other.tag == "FlyEnemy") { m_lifeToRemove = m_lifeToRemoveFlyEnemy; } m_currentLife -= m_lifeToRemove; m_currentLife = m_currentLife > 0 ? m_currentLife : 0; float lifeValue = m_currentLife / m_lifeMax; SessionData.ResetMultiplicateur(); Color color = Color.white; if (m_currentLife <= m_lifeMax && m_currentLife >= ((m_lifeMax / 3) * 2)) { ColorUtility.TryParseHtmlString("#00FF17FF", out color); } else if (m_currentLife < ((m_lifeMax / 3) * 2) && m_currentLife >= ((m_lifeMax / 3))) { ColorUtility.TryParseHtmlString("#FF8E36FF", out color); } else { color = Color.red; } if (m_audio) { m_audio.Play(); } m_lifeBar.color = color; m_lifeBar.fillAmount = lifeValue; }
public RailShooterBullet GetGameObjectFromPool() { //resize if none left in pool if (m_Pool.Count == 0) { AddToPool(); } RailShooterBullet ret = m_Pool[0]; m_Pool.RemoveAt(0); ret.gameObject.SetActive(true); ret.transform.parent = null; return(ret); }