Пример #1
0
    // 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);
    }
Пример #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag(Types.s_sTag_Player) && GameGlobals.TestGameEvent(Types.s_iGE_ExitKey))
     {
         Messenger.Invoke(Types.s_sGF_CecconoidCompleted);
     }
 }
Пример #3
0
    public void Update()
    {
        if (GameGlobals.TestGameEvent(Types.s_iGE_FirstSpawners))
        {
            return;
        }

        // If we don't have objects...
        bool bHaveObjects = false;

        foreach (GameObject go in m_aRoomObjects)
        {
            if (null != go)
            {
                bHaveObjects = true;
            }
        }

        // Open the door and set the event...
        if (!bHaveObjects)
        {
            m_aDoorRight.Open();
            GameGlobals.SetGameEvent(Types.s_iGE_FirstSpawners);
        }
    }
Пример #4
0
 public override void OnRoomEnter()
 {
     base.OnRoomEnter();
     if (GameGlobals.TestGameEvent(Types.s_iGE_ExitKey))
     {
         m_gcExitBarrier.TurnOffInstant();
     }
 }
Пример #5
0
 public override void OnRoomEnter()
 {
     base.OnRoomEnter();
     if (!GameGlobals.TestGameEvent(Types.s_iGE_FirstBrains) && !m_gcDoorLeft.GetIsClosed())
     {
         TimerManager.AddTimer(Types.s_fDUR_DoorCloseDuration, CloseDoorsFirstEntry);
     }
 }
Пример #6
0
 public override void OnRoomEnter()
 {
     base.OnRoomEnter();
     if (GameGlobals.TestGameEvent(Types.s_iGE_Robotron2))
     {
         m_aDoorRight.CloseInstant();
         m_aBarrier.TurnOffInstant(true);
     }
 }
Пример #7
0
 public void OnSwitchFlip()
 {
     if (GameGlobals.TestGameEvent(Types.s_iGE_SimplePatrolRouteSwitch))
     {
         return;
     }
     GameGlobals.SetGameEvent(Types.s_iGE_SimplePatrolRouteSwitch);
     OpenAllDoors();
 }
Пример #8
0
    public void OnSwitchFlip()
    {
        if (GameGlobals.TestGameEvent(Types.s_iGE_AnotherSecretDoor))
        {
            return;
        }

        GameGlobals.SetGameEvent(Types.s_iGE_AnotherSecretDoor);
        m_aDoors[0].Open();
    }
Пример #9
0
    public override void OnRoomEnter()
    {
        if (GameGlobals.TestGameEvent(Types.s_iGE_FirstSpawners))
        {
            return;
        }

        base.OnRoomEnter();
        TimerManager.AddTimer(Types.s_fCAM_RoomTransitionDuration, CloseDoor);
    }
Пример #10
0
    public void OnSwitchFlip()
    {
        if (GameGlobals.TestGameEvent(Types.s_iGE_LaserIntroDoorToggled))
        {
            return;
        }

        GameGlobals.SetGameEvent(Types.s_iGE_LaserIntroDoorToggled);
        m_aDoors[0].Open();
    }
Пример #11
0
    public override void OnRoomEnter()
    {
        base.OnRoomEnter();

        if (!GameGlobals.TestGameEvent(Types.s_iGE_TopOfFallFirstEntry))
        {
            GameGlobals.SetGameEvent(Types.s_iGE_TopOfFallFirstEntry);
            TimerManager.AddTimer(Types.s_fPLAYER_RoomTransitionDuration, DelayedCloseDoor);
        }
        else
        {
            m_aDoors[0].CloseInstant();
        }
    }
Пример #12
0
    public override void OnRoomEnter()
    {
        GAssert.Assert(m_aDoors.Length > 0, "RC_LaserIntro: Door hasn't been setup in the editor");

        base.OnRoomEnter();

        if (GameGlobals.TestGameEvent(Types.s_iGE_AnotherSecretDoor))
        {
            m_aDoors[0].OpenInstant();
        }
        else
        {
            m_aDoors[0].CloseInstant();
        }
    }
Пример #13
0
    public override void OnRoomEnter()
    {
        GAssert.Assert(null != m_gcDoorway, "rc_EmptyRoom: Doorway for game event not setup!");
        base.OnRoomEnter();

        if (!GameGlobals.TestGameEvent(Types.s_iGE_PassedLaserIntroRoom))
        {
            TimerManager.AddTimer(Types.s_fDUR_RoomEntryDoorCloseDelay, DelayedCloseDoor);
            GameGlobals.SetGameEvent(Types.s_iGE_PassedLaserIntroRoom);
        }
        else
        {
            m_gcDoorway.CloseInstant();
        }
    }
Пример #14
0
    public override void OnRoomEnter()
    {
        GAssert.Assert(m_aDoors.Length > 0, "RC_LaserIntro: Door hasn't been setup in the editor");

        base.OnRoomEnter();

        if (GameGlobals.TestGameEvent(Types.s_iGE_SimplePatrolRouteSwitch))
        {
            OpenAllDoorsInstant();
        }
        else
        {
            TimerManager.AddTimer(Types.s_fDUR_DoorCloseDuration, CloseAllDoors);
        }
    }
Пример #15
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag(Types.s_sTag_Player) && GameGlobals.TestGameEvent(Types.s_iGE_Robotron4))
        {
            PlayerState gcPS = GameInstance.Object.GetPlayerState();
            GAssert.Assert(null != gcPS, "Unable to get the player state!");
            gcPS.LockPlayer();
            gcPS.DespawnExitKey();

            GAssert.Assert(null != m_goSpawnEffectPrefab, "Spawn effect prefab not set in editor!");
            Instantiate(m_goSpawnEffectPrefab, collision.transform.position + new Vector3(0f, 0f, -1.5f), Quaternion.identity);

            TimerManager.AddTimer(1.5f, BeginWarpToLevel2);
        }
    }
Пример #16
0
    public override void OnRoomEnter()
    {
        GAssert.Assert(m_aDoors.Length > 0, "RC_LaserIntro: Door hasn't been setup in the editor");

        base.OnRoomEnter();

        if (GameGlobals.TestGameEvent(Types.s_iGE_LaserIntroDoorToggled))
        {
            m_aDoors[0].OpenInstant();
        }
        else
        {
            m_aDoors[0].CloseInstant();
        }

        TimerManager.AddTimer(Types.s_fDUR_RoomEntryDoorCloseDelay, CheckForAchievement);
    }
Пример #17
0
    public override void OnRoomEnter()
    {
        // Has this room been completed before?
        if (GameGlobals.TestGameEvent(Types.s_iGE_SwarmKilled))
        {
            m_gcSwarm.OnRoomExit();
            m_gcBarrier.TurnOffInstant(true);
            m_gcDoorLeft.CloseInstant();
            m_gcDoorBottom.CloseInstant();
            return;
        }



        m_gcBarrier.OnRoomEnter();
        m_gcSwarm.OnRoomEnter();
        MoveTowardPlayer_RoomObject gc = m_gcSwarm.GetComponent <MoveTowardPlayer_RoomObject>();

        if (null != gc)
        {
            gc.OnRoomEnter();
        }

        // First Entry, just shuffle them out of the bottom of the screen
        if (!GameGlobals.TestGameEvent(Types.s_iGE_Robotron2))
        {
            m_gcDoorRight.CloseInstant();
            if (!m_gcDoorLeft.GetIsClosed())
            {
                TimerManager.AddTimer(Types.s_fDUR_RoomEntryDoorCloseDelay, CloseDoorsFirstEntry);
            }
            m_bCheckSwarmHealth = false;
            m_gcSwarm.gameObject.GetComponent <MoveTowardPlayer_RoomObject>().enabled = false;
        }
        // Second entry, lock them in until they kill the swarm...
        else
        {
            m_gcBarrier.TurnOffInstant(true);
            m_gcDoorLeft.CloseInstant();
            m_gcDoorRight.CloseInstant();
            m_gcSwarm.gameObject.GetComponent <MoveTowardPlayer_RoomObject>().enabled = true;
            TimerManager.AddTimer(Types.s_fDUR_RoomEntryDoorCloseDelay, CloseDoorSecondEntry);
            m_bCheckSwarmHealth = true;
        }
    }
Пример #18
0
    void Update()
    {
        if (!GameGlobals.TestGameEvent(Types.s_iGE_FirstBrains))
        {
            // If we don't have objects...
            bool bHaveObjects = false;
            foreach (GameObject go in m_aRoomObjects)
            {
                if (null != go)
                {
                    bHaveObjects = true;
                }
            }

            // ...Open the door and set the event.
            if (!bHaveObjects)
            {
                m_gcDoorLeft.Open();
                GameGlobals.SetGameEvent(Types.s_iGE_FirstBrains);
            }
        }
    }
Пример #19
0
    // 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;
        }
    }