public void OnCreditsBackButtonPressed() { MainMenu gc = GetComponent <MainMenu>(); GAssert.Assert(null != gc, "Unable to get main menu!"); gc.ShowMainMenu(); }
// Called by Doors, to initialise the transition of the player between rooms // public static void BeginRoomTransition(ref GameObject goRoomFrom, ref GameObject goRoomTo) { GAssert.Assert(null != goRoomTo, "BeginRoomTransition called from a Door that's not setup with two rooms!"); GameInstance gcGameInstance = GameInstance.Object; // Play Some Audio gcGameInstance.GetAudioManager().PlayAudio(EGameSFX._SFX_MISC_ROOM_TRANSITION); // Do the transition (Camera is responsible for calling Begin/EndRoomTransition!) { gcGameInstance.GetPlayerState().LockPlayer(); gcGameInstance.GetPlayerController().BeginRoomTransition(); gcGameInstance.GetGameCamera().BeginRoomTransition(goRoomTo.transform.position); ; } // NOTE: Order is important here! OnRoomEnter may want to calculate it's origin, which // will only be accurate AFTER Camera.BeginRoomTransition! // // Every room MUST have a room controller attached, even if there's no logic! // Doorways assume this, and it simplifies the logic here... // { m_gcActiveRoomController.OnRoomExit(); m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!"); m_gcActiveRoomController.OnRoomEnter(); } // The player takes longer to transition than the camera does, and we know the duration, so set a timer TimerManager.AddTimer(Types.s_fPLAYER_RoomTransitionDuration, EndRoomTransition); }
// Instantly set player's position to the given location. No error checking // public static void TeleportPlayer(Vector3 vNewPos, ref GameObject goRoomTo) { GameInstance gcGameInstance = GameInstance.Object; Messenger.Invoke(Types.s_sGF_BeginRoomTransition); // Transition (Camera is NOT responsible for calling Begin/EndRoomTransition!) { gcGameInstance.GetPlayerState().LockPlayer(); gcGameInstance.GetPlayerController().BeginTeleport(); gcGameInstance.GetGameCamera().BeginTeleport(goRoomTo.transform.position); } // Let the rooms cleanup... { m_gcActiveRoomController.OnRoomExit(); m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!"); m_gcActiveRoomController.OnRoomEnter(); } // Set player.. { gcGameInstance.GetPlayerState().UnlockPlayer(); gcGameInstance.GetPlayerController().EndTeleport(); GameInstance.Object.GetPlayerObject().transform.position = vNewPos; GameGlobals.s_vRoomTransitionTo = vNewPos; } Messenger.Invoke(Types.s_sGF_EndRoomTransition); }
// Called on first entry into a new scene (level), just after load. // Searches through every gameobject in the scene, so shouldn't be used in // any other circumstance! // // It is assumed that every scene will have an initial RoomController on a game // object called: "ROOM_SpawnRoom" // public static void TransitionToDefaultRoom() { // Flag for the pause/UI controls that we're in-game. // Order is important! OnRomEnter() might immediately set this back to false! // GNTODO: it probably does in all cases... Remove this when Cecconoid handles it properly m_bCanPause = true; // SUPER DUPER SLOW! GameObject goRoomTo = GameObject.Find(Types.s_sRC_DefaultRoomController); GAssert.Assert(null != goRoomTo, "GameInstance unable to find the default room controller in this level!"); // Init the first room! m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "No room controller on the default room gameobject!"); m_gcActiveRoomController.OnRoomEnter(); // Because there's always a transition in (Spawn Effect, of screen roll) Player reset needs to delay // The rc_RobotronController in Eugatron scene handles all this for us, though... if (GameInstance.Object.m_bIsCecconoid) { TimerManager.AddTimer(2f, EndTransitionToDefaultRoom); } }
public static void WarpPlayerToLevel2() { GameObject goRoomTo = GameObject.Find(Types.s_sRC_LevelTwoRoomController); GAssert.Assert(null != goRoomTo, "GameInstance unable to find the level 2 room controller!"); GameInstance gcGameInstance = GameInstance.Object; Messenger.Invoke(Types.s_sGF_BeginRoomTransition); // Transition (Camera is NOT responsible for calling Begin/EndRoomTransition!) { gcGameInstance.GetPlayerController().BeginTeleport(); gcGameInstance.GetGameCamera().BeginTeleport(goRoomTo.transform.position); } // Let the rooms cleanup... { m_gcActiveRoomController.OnRoomExit(); m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!"); m_gcActiveRoomController.OnRoomEnter(); } TimerManager.AddTimer(2f, EndWarpToLevel2); }
protected override void Init() { m_gcCanvasGroup = GetComponent <CanvasGroup>(); GAssert.Assert(null != m_gcCanvasGroup, "LerpCanvasGroupAlpha attached to a gameObjec that's missing a canvas group!" + gameObject.name); m_gcCanvasGroup.alpha = m_fStartAlpha; m_fEventTime = TimerManager.fGameTime; }
public void OnRoomEnter() { m_goPlayer = GameInstance.Object.GetPlayerObject(); GAssert.Assert(null != m_goPlayer, "Unable to get player object"); transform.position = m_vInitPosition; m_bIsActive = true; }
new void Awake() { m_gcRgdBdy = GetComponent <Rigidbody2D>(); m_gcCircCollider = GetComponent <CircleCollider2D>(); m_gcGameInstance = GameInstance.Object; GAssert.Assert(null != m_gcGameInstance, "Bullet, unable to get GameInstance!"); }
public void OnCollisionEnter2D(Collision2D col) { // Kill the enemy if we've hit them... if (col.gameObject.CompareTag(Types.s_sTag_Enemy)) { TrackHitPoints gc = col.gameObject.GetComponent <TrackHitPoints>(); if (null != gc) { gc.DoKilledByEnvironment(); } if (m_bKillEverything) { gc = GetComponent <TrackHitPoints>(); GAssert.Assert(null != gc, "DestroyObstacleOnImpact called on go without a TrackHitPoints componetn!"); gc.DoKilledByEnvironment(); } } // Kill the enemy bullet if we've hit them... if (col.gameObject.CompareTag(Types.s_sTag_EnemyBullets)) { Destroy(col.gameObject); if (m_bKillEverything) { TrackHitPoints gc = GetComponent <TrackHitPoints>(); GAssert.Assert(null != gc, "DestroyObstacleOnImpact called on go without a TrackHitPoints componetn!"); gc.DoKilledByEnvironment(); } } }
public void OnMuteSFXPressed(bool bState) { GameAudioManager gc = GameInstance.Object.GetAudioManager(); GAssert.Assert(null != gc, "Unable to get Audio Manager"); gc.MuteSFX(bState); }
protected new void Update() { base.Update(); if (m_bPlayerInRange) { // Start the movement MissleMovement gc = GetComponent <MissleMovement>(); GAssert.Assert(null != gc, "Unable to get missile movement component!"); gc.StartMovement(); // Start the animation Anim_PingPong gc2 = GetComponent <Anim_PingPong>(); if (null != gc2) { gc2.StartAnimation(); } // Change to the active material, if present SpriteRenderer gcRenderer = GetComponent <SpriteRenderer>(); if (null != m_gcActiveMaterial && null != gcRenderer) { gcRenderer.material = m_gcActiveMaterial; } // Work here is done... this.enabled = false; } }
public void OnNeverDropPressed(bool bState) { PlayerState gc = GameInstance.Object.GetPlayerState(); GAssert.Assert(null != gc, "Unable to get player state!"); gc.SetPlayerCanDrop(!bState); }
public void OnGiveSomePressed(bool bState) { PlayerState gc = GameInstance.Object.GetPlayerState(); GAssert.Assert(null != gc, "Unable to get player state!"); gc.SetPlayerInventorySome(bState); }
public void OnSFXSlider(float fVal) { GameAudioManager gc = GameInstance.Object.GetAudioManager(); GAssert.Assert(null != gc, "Unable to get Audio Manager"); gc.SetSFXVol(fVal); }
// 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); }
// Only react to player bullets, and even then, only if we're in the active room. // (The latter shouldn't ever happen, but just in case...) // public void OnCollisionEnter2D(Collision2D collision) { if (!collision.gameObject.CompareTag(Types.s_sTag_PlayerBullets) || m_iState == Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLIP || m_iState == Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLOP || m_iState == Types.ESWitchState._IDLE_INACTIVE) { return; } // Switch material SpriteRenderer sr = GetComponent <SpriteRenderer>(); GAssert.Assert(null != sr, "Switch: No sprite renderer attached to this object!"); sr.material = m_iM_Inactive; // Trigger all the objects that care about this switch. foreach (GameObject go in m_aResponders) { var aResponders = go.GetComponents <Types.IRoom_SwitchResponder>(); foreach (var gc in aResponders) { gc.OnSwitchFlip(); } } // Trigger some audio GameInstance.Object.GetAudioManager().PlayAudioAtLocation(transform.position, EGameSFX._SFX_SWITCH_TOGGLED); // One time switches just deactivate. No flip flops here... m_iState = Types.ESWitchState._IDLE_INACTIVE; this.enabled = false; }
// GameInstance will call this when the player passes through a doorway, // initiating the transition between two rooms... // // For us, it's the start of the little mini game, so we need to verify // our settings and then begin spawning in waves... // public override void OnRoomEnter() { // When the game is finished we set a GameEvent so this mini-game can't be repeated switch (m_iEvent) { case ERobotronEvents._RB1_IckleBaddies: m_iEventBitField = Types.s_iGE_RobotronTest; break; case ERobotronEvents._RB2_Enforcers: m_iEventBitField = Types.s_iGE_Robotron2; break; case ERobotronEvents._RB3_FloatingLaserBrains: m_iEventBitField = Types.s_iGE_Robotron3; break; case ERobotronEvents._RB4_LoadsaBaddies: m_iEventBitField = Types.s_iGE_Robotron4; break; case ERobotronEvents._RB5_CircularShotTwats: m_iEventBitField = Types.s_iGE_Robotron5; break; } // If we've already completed this room, do nothing! if (GameGlobals.TestGameEvent(m_iEventBitField)) { return; } // Spawn in the warning Prefab... if (null != m_goWarningPrefab) { Instantiate(m_goWarningPrefab, transform.position, Quaternion.identity); } // Validate what we need { GAssert.Assert(null != m_SpawnSet._goEnemyPrefab, "Robotron Room Controller has no Enemy Prefab Assigned!"); GAssert.Assert(null != m_SpawnSet._goSpawnInEffect, "Robotron Room Controller has Spawn In Effect"); GAssert.Assert(null != m_SpawnSet._goSpawnWarningEffect, "Robotron Room Controller has Spawn Warning Prefab"); GAssert.Assert(null != m_SpawnSet._goSpawnWarningEffectShort, "Robotron Room Controller missing spawn effect short"); } // Init any additional objects, these aren't tracked as part of the unlock sequence { foreach (GameObject go in m_aAdditionalObjects) { if (null == go) { continue; } go.SetActive(true); Types.IRoom_EnemyObject[] aGC = go.GetComponents <Types.IRoom_EnemyObject>(); foreach (Types.IRoom_EnemyObject gc in aGC) { gc.OnRoomEnter(); } } } m_vRoomOrigin = GameMode.GetRoomOrigin(); m_aRoomObjects = new GameObject[m_iEnemiesToSpawn * m_iNumberOfWaves]; m_bIsActive = true; // Wait for the door to shut before we kick things off... m_iTimerHandle = TimerManager.AddTimer(Types.s_fDUR_RoomEntryDoorCloseDelay + 0.35f, FinaliseRoomEntry); }
// Setup // virtual public void Start() { m_gcRgdBdy = GetComponent <Rigidbody2D>(); GAssert.Assert(null != m_gcRgdBdy, "Unable to get rigidbody!"); m_bIsActive = true; GetRandomPoint(); }
public void OnSettingsButtonPressed() { MainMenu gc = GetComponent <MainMenu>(); GAssert.Assert(null != gc, "Unable to get main menu!"); gc.ShowSettings(); }
private void Start() { // Re-Init the pad... m_PlayerActionsBindings = new PlayerActions(); m_PlayerActionsBindings.UI_Back.ClearInputState(); m_PlayerActionsBindings.UI_Confirm.ClearInputState(); m_PlayerActionsBindings.UI_Pause.ClearInputState(); m_gcHighScoreUI = GameInstance.Object.GetHighScoreCecconoid(); GAssert.Assert(null != m_gcHighScoreUI, "Unable to get reference to the high score ui!"); // Are we entering our initials? if (GameGlobals.s_bCEcconoidHighScoreEntryThisGo) { m_gcEntryInitial = m_gcHighScoreUI.GetTextEntry(m_iEntry); GAssert.Assert(null != m_gcEntryInitial, "gs_Eugatron_HighScore_In: Unable to get first text entry for initials"); m_iState = Types.EHighScoreMenuState._ENTER_NEW_INITIAL1; } else { m_gcHighScoreUI.OnShowTable(); m_iState = Types.EHighScoreMenuState._SHOW_TABLE; m_fEventTime = TimerManager.fGameTime + Types.s_fDUR_GameOverScreen; } }
public override void OnRoomEnter() { base.OnRoomEnter(); // Verify... { m_gcAudioManager = GameInstance.Object.GetAudioManager(); GAssert.Assert(null != m_gcAudioManager, "Unable to get audio manager"); m_gcRenderer = GetComponent <SpriteRenderer>(); GAssert.Assert(null != m_gcRenderer, "Unable to get sprite renderer!"); GAssert.Assert(null != m_goLaser, "Floating Laser properties not setup in editor!"); GAssert.Assert(null != m_WarmUpMat, "Floating Laser properties not setup in editor!"); GAssert.Assert(null != m_InactiveMat, "Floating Laser properties not setup in editor!"); GAssert.Assert(null != m_ActiveMat, "Floating Laser properties not setup in editor!"); } // Init LaserOff(false); m_bBehaviourCanUpdate = true; m_iState = ELaserState._IDLE_OFF; m_gcRenderer.material = m_InactiveMat; m_fNextEventTime = TimerManager.fGameTime + (m_fLaserInactiveTime - Types.s_fDUR_FloatingLaserWarmUp); // Warn Players that this level contains lasers... m_gcAudioManager.PlayAudio(EGameSFX._SFX_FLOATING_LASER_LEVEL_WARNING); }
// Why not use the Mixer Group here? // Because the Mixer group is under the Player's control, and acts as a final scaler // to whatever we do with the Audio Sources. // public System.Collections.IEnumerator FadeMusicOut(float fTime, bool bUseUITimer) { GAssert.Assert(null != m_gcActiveMusicAudioSource, "Music Game Object is missing an audio source component"); m_bCanFadeMusic = true; float fInitVol = m_gcActiveMusicAudioSource.volume; while (m_gcActiveMusicAudioSource.volume > 0) { if (!bUseUITimer) { m_gcActiveMusicAudioSource.volume -= TimerManager.fGameDeltaTime / fTime; } else { m_gcActiveMusicAudioSource.volume -= TimerManager.fUIDeltaTime / fTime; } if (m_bCanFadeMusic) { yield return(null); } else { break; } } StopMusic(); }
public void StartGame() { // Spawn the player offscreen. SetPlayerDefaults locks it and prevents movement. // Player Object remains in the persistent scene, so we don't need to care // about what happens between scene loads... { m_goPlayerObjectReference = GameInstance.Instantiate(m_goPlayerPrefab, new Vector3(100, 100, 0), Quaternion.identity); GAssert.Assert(null != m_goPlayerObjectReference, "Unable to instantiate Player Object"); m_gcPlayerState = m_goPlayerObjectReference.GetComponent <PlayerState>(); GAssert.Assert(null != m_gcPlayerState, "Unable to get Player State"); m_gcPlayerController = m_goPlayerObjectReference.GetComponent <PlayerController>(); GAssert.Assert(null != m_gcPlayerController, "Unable to get Player Controller"); m_gcPlayerInventory = m_goPlayerObjectReference.GetComponent <PlayerInventory>(); GAssert.Assert(null != m_gcPlayerInventory, "Unable to get Player Inventory!"); } // Set Game Defaults { Messenger.ClearAll(); TimerManager.SetDefaults(1.0f, 1.0f); m_gcPlayerInventory.SetDefaults(); m_gcPlayerState.SetDefaults(); m_gcGameCamera.SetDefaults(); GameGlobals.SetDefaults(); // Put the player in the correct position! // GNTODO: This needs to be loaded! // { // teleportPlayerToSpawnPoint... } } }
override public void OnRoomEnter() { OnInit(); SetCanFire(true, m_fInitialFireDelay); m_gcAnimator = GetComponent <Anim_FlickFrameOnRequest>(); GAssert.Assert(null != m_gcAnimator, "Unable to get flick frame animator!"); }
override public void DoSpawnPrefab() { // Disabled components can still be called. It's just the Unity functions that // don't run :) if (!this.enabled) { return; } // Quick dice roll to see if we should spawn anything at all... if (Random.Range(1f, 100f) < (100f - m_fSpawnPercentageChance)) { return; } // We been setup correctly? GAssert.Assert(m_aPrefabs.Length != 0, "No prefabs setup in SpawnPrefabRandom component"); Vector3 vPos = Vector3.zero; Vector2 vRand = Vector2.zero; // Pick a prefab m_goPrefab = m_aPrefabs[Random.Range(0, m_aPrefabs.Length - 1)]; // And spawn... for (int i = 0; i < m_fSpawnCount; ++i) { vPos = transform.position; vRand = Random.insideUnitCircle * m_fSpawnRadius; vPos.x += vRand.x; vPos.y += vRand.y; Instantiate(m_goPrefab, vPos, Quaternion.identity); } }
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); }
// Make sure we're setup correctly each time, rather than rely on the StartFunction... public override void StartAnimation() { m_iAnimCount = 0; m_iTimerHandle = 0; m_iDir = EAnimDirection._FORWARD; m_gcRenderer = GetComponent <SpriteRenderer>(); GAssert.Assert(m_aAnimationFrames.Length > 0, "PingPongFixedCount not setup!" + gameObject.name); }
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); }
// Start is called before the first frame update void Start() { GAssert.Assert(null != m_goPixelShatterPrefab, "No Prefab particle effect assigned... "); m_gcSprite = GetComponent <SpriteRenderer>().sprite; GAssert.Assert(null != m_gcSprite, "Sprite Renderer has no sprite assigned!"); m_fEventTime = TimerManager.fGameTime + m_fShatterDelay; }
// Setup with the references we need // protected void Awake() { m_gcRgdBdy = GetComponent <Rigidbody2D>(); m_gcCollider = GetComponent <BoxCollider2D>(); m_gcGameInstance = GameInstance.Object; GAssert.Assert(null != m_gcGameInstance, "Bullet, unable to get GameInstance!"); m_iDamageRemaining = (int)m_iBulletDamage; }