void OnCollisionEnter2D(Collision2D coll) { bool proceed = false; if (coll.gameObject.tag == "Alien") { proceed = true; } if (coll.gameObject.name == "Tank") { proceed = true; } if (proceed) { if (impactEffect != null) { SplashEffect impact = Instantiate <SplashEffect>(impactEffect); impact.gameObject.SetActive(true); impact.transform.position = transform.position; } world.audioSrc.PlayOneShot(impactSound); Destroy(gameObject); } }
void OnCollisionEnter(Collision collision) { if (collision.collider.gameObject == m_Bobber) { if (m_bobberEffectTimer == 0) { if (collision.relativeVelocity.sqrMagnitude > Mathf.Pow(m_SplashForce, 2.0f)) { GameObject splashInstance = Instantiate(m_SplashEffect, collision.transform.position, Quaternion.identity) as GameObject; SplashEffect splash = splashInstance.GetComponent <SplashEffect>(); if (splash != null) { splash.Splash(); } } GameObject bobberInstance = Instantiate(m_BobberEffect, collision.transform.position, Quaternion.identity) as GameObject; ParticleSystem ps = bobberInstance.GetComponent <ParticleSystem>(); if (ps != null) { ps.Play(); } Destroy(bobberInstance, 5f); m_bobberEffectTimer = m_bobberEffectDelay; } } }
private IEnumerator SplashWater() { SplashEffect.gameObject.SetActive(true); SplashEffect.gameObject.transform.position = this.gameObject.transform.position + SplashEffectOffset; SplashEffect.SetTrigger("splash"); Splash.Play(); this.SetVisible(false); yield return(0); }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Projectile" || coll.gameObject.tag == "AlienProjectile") { Projectile proj = coll.gameObject.GetComponent <Projectile>(); health -= proj.weapon.damage * world.settings.playerDamageFactor; } if (System.Object.ReferenceEquals(player.gameObject, coll.gameObject)) { SplashEffect blood = Instantiate <SplashEffect>(bloodEffect); blood.gameObject.SetActive(true); blood.transform.position = transform.position; Destroy(gameObject); } }
protected override void TakeAction() { foreach (GameObject obj in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()) { // Disable boss :D if (obj.tag == "Alien" && !obj.name.Contains("Boss")) { SplashEffect exp = Instantiate <SplashEffect>(explosion); exp.gameObject.SetActive(true); exp.transform.position = obj.transform.position; Destroy(obj); } } base.TakeAction(); }
protected override void Update() { rotationQuaternion = transform.rotation; if (experience >= experienceNeeded) { // LEVEL UP! level++; score += (int)(world.settings.scoreIncreaseFactor * 100.0f); experience -= experienceNeeded; CalcXpNeeded(); world.audioSrc.PlayOneShot(levelUpSound); hud.DisplayMessage(MessagePlacement.Center, "LEVEL UP!", 3.0f); hud.DisplayMessage(MessagePlacement.BottomLeft, "Monsters are getting stronger", 5.0f); foreach (Alien alien in world.genericAliens) { alien.maxHealth += 0.05f * alien.maxHealth; alien.velocity += 0.0005f * alien.velocity; alien.impactDamage += 0.05f * alien.impactDamage; Weapon[] weapons = alien.GetComponentsInChildren <Weapon>(); if (weapons != null) { foreach (Weapon wpn in weapons) { wpn.damage += 0.05f * wpn.damage; } } } } if (health > maxHealth) { health = maxHealth; } if (shield > maxShield) { shield = maxShield; } if (health == 0.0f) { SplashEffect exp = Instantiate <SplashEffect>(explodeEffect); exp.gameObject.SetActive(true); exp.transform.position = transform.position; world.audioSrc.PlayOneShot(explodeSound); world.audioSrc.PlayOneShot(deathSound); world.GameOver(); Destroy(gameObject); } if (health <= 50.0f) { if (Time.time >= particleElapsed + 0.1f) { int particleIndex = Random.Range(0, particleEffects.Length); ParticleEffect part = Instantiate <ParticleEffect>(particleEffects[particleIndex]); part.gameObject.SetActive(true); part.transform.position = transform.position + (Vector3)particleOffset; particleElapsed = Time.time; } } base.Update(); }
private void Start() { plane = GameObject.FindWithTag("Plane").GetComponent <PlaneManager>(); splasheffect = GameObject.FindWithTag("Splasher").GetComponent <SplashEffect>(); }