void OnTriggerEnter2D(Collider2D other) { if (!mInvul && !incoming) { if (other.gameObject.name == "ShotgunBlastBlue(Clone)" || other.gameObject.name == "ShotgunBlastOrange(Clone)" || other.gameObject.name == "ShotgunBlastMul(Clone)" || other.gameObject.name == "ShotgunBlastChar(Clone)") { health -= 5f; Destroy(other.gameObject); Play(mHitLow, 1f, 1); //Orb explosion GameObject ex = Instantiate(explosion) as GameObject; ex.transform.position = transform.position; if (health <= 0) { explode(other.gameObject); } } if (other.gameObject.name == "WaveBlastBlue(Clone)" || other.gameObject.name == "WaveBlastOrange(Clone)" || other.gameObject.name == "WaveBlastMul(Clone)" || other.gameObject.name == "WaveBlastChar(Clone)") { //Debug.Log("WaveBlastPush"); /*Vector2 dir = other.transform.position - transform.position; * dir.Normalize();*/ WaveBlastBehavior wave = other.GetComponent <WaveBlastBehavior>(); rigidbody2D.AddForce(wave.mSpeed * wave.transform.up * wave.mForce); //other.gameObject.rigidbody2D.AddForce(mSpeed * transform.up * mForce); } } }
public void FireWaveBlast(Vector2 mousedir, GameObject ship, int powerLevel, bool grow, float displacement) { GameObject e = Instantiate(mWaveProjectile) as GameObject; WaveBlastBehavior waveBlast = e.GetComponent <WaveBlastBehavior>(); if (null != waveBlast) { if (powerLevel > 1) { waveBlast.SetNormalPowerLevel(powerLevel); } e.transform.position = ship.transform.position + ship.transform.up * displacement; if (grow) { e.transform.localScale += new Vector3(3.0f, 3.0f, 0.0f); } waveBlast.SetForwardDirection(mousedir); } Play(mWave, 1f, 1); }
public void FireChargedWaveBlast(Vector2 mousedir, GameObject ship, int powerLevel, float kWaveTotalChargeTime, bool grow, float displacement) { GameObject e = Instantiate(mWaveProjectile) as GameObject; WaveBlastBehavior waveBlast = e.GetComponent <WaveBlastBehavior>(); if (null != waveBlast) { if (powerLevel > 1) { waveBlast.SetChargedPowerLevel(powerLevel); } waveBlast.mSpeed += (waveBlast.mSpeed * kWaveTotalChargeTime) / 2.0f; waveBlast.mForce += kWaveTotalChargeTime * 10.0f; e.transform.localScale += new Vector3(kWaveTotalChargeTime * 2.5f, kWaveTotalChargeTime * 2.5f, 0.0f); if (grow) { e.transform.localScale += new Vector3(5.0f, 5.0f, 0.0f); } e.transform.position = ship.transform.position + ship.transform.up * displacement; waveBlast.SetForwardDirection(mousedir); Play(mWave, 1f, 1); } }