Exemplo n.º 1
0
    // 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;
    }
Exemplo n.º 2
0
    // On room exit, swap state to blockers, so any object alive during room transition
    // can't accidentally affect state...
    //
    public void OnRoomExit()
    {
        switch (m_iState)
        {
        case Types.ESWitchState._IDLE_INROOM_ACTIVE_FLIP: m_iState = Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLIP; break;

        case Types.ESWitchState._IDLE_INROOM_ACTIVE_FLOP: m_iState = Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLOP; break;
        }
    }
Exemplo n.º 3
0
    // If the player has died, disable the switch...
    //
    public void OnPlayerHasDied()
    {
        switch (m_iState)
        {
        case Types.ESWitchState._IDLE_INROOM_ACTIVE_FLIP: m_iState = Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLIP; break;

        case Types.ESWitchState._IDLE_INROOM_ACTIVE_FLOP: m_iState = Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLOP; break;
        }
    }
Exemplo n.º 4
0
    // On room enter, revert to the proper active states
    //
    public void OnRoomEnter()
    {
        // GNTODO: Is it likely for switch responders to be destroyed?
        //
        GAssert.Assert(m_aResponders.Length > 0, "Switch setup with no switch responders!");

        switch (m_iState)
        {
        case Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLIP: m_iState = Types.ESWitchState._IDLE_INROOM_ACTIVE_FLIP; break;

        case Types.ESWitchState._IDLE_EXROOM_ACTIVE_FLOP: m_iState = Types.ESWitchState._IDLE_INROOM_ACTIVE_FLOP; break;
        }
    }