private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag(Types.s_sTag_Player)) { GameMode.AchievementUnlocked(m_iID); } }
// When the player dies: // - Drop inventory items // - Reset multiplier // - Decrement lives // - Trigger events so any message subscribers can react // public uint OnPlayerHasDied() { m_bPlayerMarkedForDeath = false; LockPlayer(); // Create the explosion Instantiate(m_goExplosionEffect, transform.position, Quaternion.identity); // Check for achievement ++m_iNumberOfDeaths; if (m_iNumberOfDeaths > 200) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._SweetBangBang); } else { Debug.Log("Sweet Bang Bang count: " + m_iNumberOfDeaths); } // Handle Inventory { GAssert.Assert(null != m_gcInventory, "Player Inventory not set!"); if (m_bCanDrop) { m_gcInventory.DropInventory(); m_gcInventory.GetPlayerOption().SetActive(false); } m_gcEquippedWeapon = m_gcInventory.GetEquippedWeapon(); m_fCachedMovementSpeed = m_fPlayerMovementSpeed + (m_fPlayerMovementSpeedPowerUp * m_gcInventory.GetSpeedMultiplier()); } // Update state { m_bIsAlive = false; m_iScoreMultiplier = 1; if (m_iLives > 0) { --m_iLives; } } // Tell the HUD things have changed... Messenger.Invoke(Types.s_sHUD_LivesUpdated); Messenger.Invoke(Types.s_sHUD_MultiplierUpdated); // Check for the achievement if (GameInstance.Object.m_bIsCecconoid && m_bIsFirstDeath) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._FirstDeath); m_bIsFirstDeath = false; } // Return lives count. GameMode / GameInstance decide what to do when the // player is out of lives. return(m_iLives); }
public bool AddMultiplier(uint iAmount) { if (!m_bCanAdd) { return(false); } m_iScoreMultiplier = MathUtil.Clamp(m_iScoreMultiplier + iAmount, 0, Types.s_iPLAYER_MaxMultiplier); Messenger.Invoke(Types.s_sHUD_MultiplierUpdated); // Check For Achievement { if (GameInstance.Object.m_bIsCecconoid && m_iScoreMultiplier >= 99 && !m_bCheckedFor99) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._99MultCecconoid); m_bCheckedFor99 = true; } else if (!GameInstance.Object.m_bIsCecconoid && m_iScoreMultiplier >= 50) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._50MultEugatron); m_bCheckedFor99 = true; } } return(true); }
public bool AddLives(uint iAmount) { if (!m_bCanAdd) { return(false); } // Make the sprite face the correct way... GameObject go = Instantiate(m_goLifeEffect, transform.position, Quaternion.identity); SpriteRenderer sr = go.GetComponent <SpriteRenderer>(); SpriteRenderer mySr = GetComponent <SpriteRenderer>(); if (null != sr && null != mySr) { sr.sprite = mySr.sprite; } // Add the life... m_iLives = MathUtil.Clamp(m_iLives + iAmount, 0, Types.s_iPLAYER_MaxLives); Messenger.Invoke(Types.s_sHUD_LivesUpdated); GameInstance.Object.GetAudioManager().PlayAudio(EGameSFX._SFX_PLAYER_EXTRA_LIFE); // Check for Achievement if (!GameInstance.Object.m_bIsCecconoid && m_iLives >= 10) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._10LevelsEugatron); } return(true); }
public IEnumerator RunCompletionSequence() { // Unlock the achievement GameMode.AchievementUnlocked(Types.EAchievementIdentifier._CompletedCecconoid); bool bSlowingDown = true; do { if (TimerManager.fGameDeltaScale > 0.01f) { TimerManager.SetGameTimeScale(TimerManager.fGameDeltaScale - 0.015f); } else { bSlowingDown = false; } yield return(new WaitForSeconds(0.1f)); } while (bSlowingDown); yield return(new WaitForSeconds(1f)); Instantiate(m_goScreenWhitener, transform.position + new Vector3(0f, 0f, -0.76f), Quaternion.identity); yield return(new WaitForSeconds(5f)); CompletionSequenceGetter aLines = GameInstance.Object.GetCompletionSequence(); GAssert.Assert(null != aLines, "Have the completion sequence lines been added to the game instance?"); aLines.OnShowInstant(); aLines.m_aTextLines[0].enabled = true; yield return(new WaitForSeconds(3.5f)); aLines.m_aTextLines[1].enabled = true; yield return(new WaitForSeconds(3.5f)); aLines.m_aTextLines[2].enabled = true; yield return(new WaitForSeconds(3.5f)); aLines.m_aTextLines[3].enabled = true; yield return(new WaitForSeconds(2.5f)); aLines.m_aTextLines[4].enabled = true; yield return(new WaitForSeconds(3.5f)); // Fade screen to black GameInstance.Object.HideHud(); Instantiate(m_goScreenDarkener, transform.position + new Vector3(0f, 0f, -0.80f), Quaternion.identity); yield return(new WaitForSeconds(2f)); aLines.OnHideInstant(); // Exit game... // Move camera off map, so there can be now glithces while we transiton //Vector3 vNewPos = transform.position + new Vector3(Types.s_fRoomBoundsX, 0f, 0f); //GameInstance.Object.GetGameCamera().WarpToPosition(ref vNewPos); Messenger.Invoke(Types.s_sGF_BeginExitGame); }
public void SpawnExitKey() { GAssert.Assert(null != m_goExitKeyPrefab, "Exit Key Prefab has not been setup in the editor!"); m_goSpawnedExitKey = Instantiate(m_goExitKeyPrefab, transform.position, Quaternion.identity); // Unlock the achievement GameMode.AchievementUnlocked(Types.EAchievementIdentifier._GotTheKey); }
public bool AddPowerUp(Types.EPowerUp iPowerUp) { GAssert.Assert(null != m_gcInventory, "Player Inventory not set!"); // Set the inventory state for the new pickup switch (iPowerUp) { case Types.EPowerUp._SHOT_DOUBLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Shot_Double); break; case Types.EPowerUp._SHOT_TRIPLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Shot_Triple); break; case Types.EPowerUp._LASER_SINGLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Laser_Single); break; case Types.EPowerUp._LASER_DOUBLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Laser_Double); break; case Types.EPowerUp._LASER_TRIPLE: m_gcInventory.SetInventoryItem(Types.s_iINV_Laser_Triple); break; case Types.EPowerUp._OPTION: m_gcInventory.SetInventoryItem(Types.s_iINV_Option); break; case Types.EPowerUp._SPEED1: m_gcInventory.SetInventoryItem(Types.s_iINV_Speed1); break; case Types.EPowerUp._SPEED2: m_gcInventory.SetInventoryItem(Types.s_iINV_Speed2); break; } // Update the weapon, in case we've upgraded... if (m_gcEquippedWeapon != m_gcInventory.GetEquippedWeapon()) { m_gcEquippedWeapon.SetCanFire(false); m_gcEquippedWeapon = m_gcInventory.GetEquippedWeapon(); } // Update the cached speed multiplier m_fCachedMovementSpeed = m_fPlayerMovementSpeed + (m_fPlayerMovementSpeedPowerUp * m_gcInventory.GetSpeedMultiplier()); // If this was the option, enable it! if (iPowerUp == Types.EPowerUp._OPTION) { m_gcInventory.GetPlayerOption().SetActive(true); } // In Eugatron pickups give you a little invulnerable period... if (!GameInstance.Object.m_bIsCecconoid && !m_bIsGod) { StartInvulnerablePeriod(); } // Check for Achievement if (m_gcInventory.IsFullPower() && GameInstance.Object.m_bIsCecconoid) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._FullPowerCecconoid); } // We've always added something... return(true); }
public bool AddScore(uint iScore) { if (!m_bCanAdd) { return(false); } // Do score... m_iScore = MathUtil.Clamp(m_iScore + (iScore * m_iScoreMultiplier), m_iScore, Types.s_iPLAYER_MaxScore); Messenger.Invoke(Types.s_sHUD_ScoreUpdated); // Check for extra life if we're in Eugatron if (!GameInstance.Object.m_bIsCecconoid) { m_iScoreToNextLife += (iScore * m_iScoreMultiplier); while (m_iScoreToNextLife > Types.s_iPLAYER_ExtraLifeScore) { m_iScoreToNextLife = MathUtil.Clamp(m_iScoreToNextLife - Types.s_iPLAYER_ExtraLifeScore, 0, 9999999); if (null != m_goLifeEffect) { AddLives(1); } } } // Check for Achievements if (m_iScore >= 1000000 && !m_bCheckedForAMillion) { m_bCheckedForAMillion = true; if (!GameInstance.Object.m_bIsCecconoid) { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._MillionInEugatron); } else { GameMode.AchievementUnlocked(Types.EAchievementIdentifier._MillionInCecconoid); } } return(true); }
// Check for the complete (death) of the wave, spawn rewards and unlock the player! // public virtual void Update() { // Early outs { if (GameGlobals.TestGameEvent(m_iEventBitField)) { return; } if (!m_bIsActive) { return; } if (m_iWaveNumber < m_iNumberOfWaves) { return; } } // If there are active gameObjects (we spawned them) then the player can't exit... bool bStillPlaying = false; foreach (GameObject go in m_aRoomObjects) { if (null != go) { bStillPlaying = true; } } if (!bStillPlaying) { // DeInit any additional objects { foreach (GameObject go in m_aAdditionalObjects) { if (null == go) { continue; } Types.IRoom_EnemyObject[] aGC = go.GetComponents <Types.IRoom_EnemyObject>(); foreach (Types.IRoom_EnemyObject gc in aGC) { gc.OnRoomExit(); } go.SetActive(false); } } // Spawn the rewards! foreach (GameObject go in m_aRewards) { if (null == go) { continue; } Vector2 vPos = Vector2.zero; Vector2 vDist = Vector2.zero; Vector2 vPlayerPos = GameInstance.Object.GetPlayerPosition(); bool bChecking = true; do { vPos = new Vector2(Random.Range(-m_vHalfRoomBounds.x + 0.25f, m_vHalfRoomBounds.x - 0.25f), Random.Range(-m_vHalfRoomBounds.y + 0.25f, m_vHalfRoomBounds.y - 0.25f)); vPos += m_vRoomOrigin; vDist = vPlayerPos - vPos; if (vDist.magnitude > m_fDistanceFromPlayer) { bChecking = false; } }while (bChecking); Instantiate(go, vPos, Quaternion.identity); if (null != m_goRewardEffect) { Instantiate(m_goRewardEffect, vPos, Quaternion.identity); } } // Play Audio GameInstance.Object.GetAudioManager().PlayAudio(EGameSFX._SFX_ROBOTRON_COMPLETE); // Add the achivement switch (m_iEvent) { case ERobotronEvents._RB1_IckleBaddies: GameMode.AchievementUnlocked(Types.EAchievementIdentifier._PartyLike2084); break; case ERobotronEvents._RB2_Enforcers: GameMode.AchievementUnlocked(Types.EAchievementIdentifier._SmashTV); break; case ERobotronEvents._RB3_FloatingLaserBrains: GameMode.AchievementUnlocked(Types.EAchievementIdentifier._TotalCarnage); break; case ERobotronEvents._RB4_LoadsaBaddies: /* The key will be delivered in this room */ break; case ERobotronEvents._RB5_CircularShotTwats: GameMode.AchievementUnlocked(Types.EAchievementIdentifier._Llamatron); break; } // Save event in GameGlobals... OpenAllDoors(); GameGlobals.SetGameEvent(m_iEventBitField); m_bIsActive = false; } }
public void AddAchievement() { GameMode.AchievementUnlocked(m_iAchievement); }
// The first room shows images for the controls, so we don't want to overwhelm // the player by firing the first entry achievement at the same time // So, now they've figured out how to move to the next room, wait for the // transition to end and give them a little present... // public void CheckForAchievement() { // Is this the first entry to the game? Achievement Unlocked! (This timer callback is only called in Cecconoid, see Eugatron room controller for the equiv...) GameMode.AchievementUnlocked(Types.EAchievementIdentifier._WelcomeToCecconoid); }