// Update is called once per frame void Update() { if (TimerManager.fGameTime > m_fEventTime) { SpriteToParticleSystem.ExplodeSprite(transform.position, m_fShatterVelocity, m_goPixelShatterPrefab, m_gcSprite, m_iPixelShatterTTL); GetComponent <SpriteRenderer>().enabled = false; Destroy(gameObject); } }
// Room Controllers can call this to fake a death :D public virtual void PlayDeathEffects() { // Move particles closer to camera, so they appear over everything Vector3 vPos = transform.position; vPos.z = Types.s_fPOS_FrontLayerZ; // Spawn the effects if (m_bPixelShatter) { SpriteToParticleSystem.ExplodeSprite(transform.position, Types.s_fVEL_PixelShatterVelocity, m_goPixelShatterPrefab, m_gcSprite, m_iPixelShatterTTL); } if (m_bPlaySFXOnDeath) { GameInstance.Object.GetAudioManager().PlayAudioAtLocation(transform.position, m_iSFX_Explosion); } if (m_bSpawnExplosionEffect && null != m_goExplosionPrefab) { Instantiate(m_goExplosionPrefab, transform.position, Quaternion.identity); } }
public void Explode() { // Create the explosion if (null != m_goExplosionPrefab) { Instantiate(m_goExplosionPrefab, transform.position, Quaternion.identity); } SpriteToParticleSystem.ExplodeSprite(transform.position, Types.s_fVEL_PixelShatterVelocity, m_goPixelShatterPrefab, GetComponent <SpriteRenderer>().sprite, m_iPixelShatterTTL); // Play audio and add shake. Mines always add maxium shake... GameInstance gi = GameInstance.Object; gi.GetAudioManager().PlayAudioAtLocation(transform.position, m_iSFX_Explosion); gi.GetGameCamera().AddShake(1.0f); // Spawn the Spikes, if we have any { GameObject go = null; Vector3 vTraj = Vector3.zero; BulletMovement gcMovement = null; float fAngle = m_fAngleOffsetRadians; for (int i = 0; i < m_iSpikeCount; ++i) { vTraj = new Vector3(Mathf.Sin(fAngle), Mathf.Cos(fAngle), 0f); go = Instantiate(m_goSpike, transform.position + (vTraj * m_fSpawnOffset), Quaternion.identity); gcMovement = go.GetComponent <BulletMovement>(); if (null != gcMovement) { gcMovement.InitBullet(vTraj, Types.s_fVEL_MineSpikeMovementVelocity, false); } fAngle += (2 * Mathf.PI) / m_iSpikeCount; } } // And die... Destroy(gameObject); }
// Because we can call to kill an object immediately, we've split it out from the collision function // public override void DoOnImpactFromPlayer(uint iDamage, bool bIsPlayerOption = false, bool bPlayerPhysicalCollision = false) { if (m_bUpdateLoop || bIsPlayerOption) { return; } GameInstance gi = GameInstance.Object; GAssert.Assert(null != gi, "Unable to get Game Instance!"); m_iHitPointsRemaining = (int)MathUtil.Clamp(m_iHitPointsRemaining - (int)iDamage, 0, Types.s_iPLAYER_MaxDamage); if (m_iHitPointsRemaining <= 0) { // Turn off the sprite and collider (Bespoke to the heart) GetComponent <SpriteRenderer>().enabled = false; GetComponent <PolygonCollider2D>().enabled = false; // Move particles closer to camera, so they appear over everything Vector3 vPos = transform.position; vPos.z = Types.s_fPOS_FrontLayerZ; // Spawn the effects if (m_bPixelShatter) { SpriteToParticleSystem.ExplodeSprite(transform.position, Types.s_fVEL_PixelShatterVelocity, m_goPixelShatterPrefab, m_gcSprite, m_iPixelShatterTTL); } if (m_bPlaySFXOnDeath) { GameInstance.Object.GetAudioManager().PlayAudioAtLocation(transform.position, m_iSFX_Explosion); } if (m_bSpawnExplosionEffect && null != m_goExplosionPrefab) { Instantiate(m_goExplosionPrefab, transform.position, Quaternion.identity); } // Add optionals AddScore gcScore = GetComponent <AddScore>(); if (null != gcScore) { gcScore.AddScoreToPlayer(); } AddCameraShake gcShake = GetComponent <AddCameraShake>(); if (null != gcShake) { gcShake.AddShakeToCamera(); } SpawnPrefab[] aPrefabSpawns = GetComponents <SpawnPrefab>(); if (aPrefabSpawns.Length > 0) { for (int i = 0; i < aPrefabSpawns.Length; ++i) { aPrefabSpawns[i].DoSpawnPrefab(); } } m_bUpdateLoop = true; GameMode.BeginCompletionSequence(); } // Didn't die? Play the impact ting audio... if (m_bPlaySFXOnHit) { gi.GetAudioManager().PlayAudioAtLocation(transform.position, m_iSFX_Impact); } }