示例#1
0
bool Gameflow_SetMap(const char* filePath, int game_id, int level_id)
{
    level_info_t info;
    if(Gameflow_GetLevelInfo(&info, game_id, level_id))
    {
        level_id = (level_id <= info.num_levels) ? (level_id) : (1);
        if(!Gui_LoadScreenAssignPic(info.pic))
        {
            Gui_LoadScreenAssignPic("resource/graphics/legal");
        }
    }

    strncpy(global_gameflow.m_currentLevelPath, filePath, MAX_ENGINE_PATH);
    global_gameflow.m_currentGameID = game_id;
    global_gameflow.m_currentLevelID = level_id;

    return Engine_LoadMap(filePath);
}
示例#2
0
void Gameflow_Do()
{
    if(!gameflow_manager.NextAction)
        return;

    bool completed = true;

    for(int i = 0; i < TR_GAMEFLOW_MAX_ACTIONS; i++)
    {
        if(gameflow_manager.Actions[i].opcode == TR_GAMEFLOW_NOENTRY) continue;
        completed = false;

        switch(gameflow_manager.Actions[i].opcode)
        {
            case TR_GAMEFLOW_OP_LEVELCOMPLETE:
                // Switch level only when fade is complete AND all streams / sounds are unloaded!
                if((Gui_FadeCheck(FADER_LOADSCREEN) == GUI_FADER_STATUS_COMPLETE) && (!Audio_IsTrackPlaying()))
                {
                    const char* levelName;
                    const char* levelPath;
                    lua::tie(levelPath, levelName, gameflow_manager.CurrentLevelID) = engine_lua["getNextLevel"](int(gameflow_manager.CurrentGameID), int(gameflow_manager.CurrentLevelID), int(gameflow_manager.Actions[i].operand));
                    gameflow_manager.CurrentLevelName = levelName;
                    gameflow_manager.CurrentLevelPath = levelPath;
                    Engine_LoadMap(gameflow_manager.CurrentLevelPath);
                    gameflow_manager.Actions[i].opcode = TR_GAMEFLOW_NOENTRY;
                }
                else
                {
                    // If fadeout is in the process, we block level loading until it is complete.
                    // It is achieved by not resetting action marker and exiting the function instead.
                    continue;
                }   // end if(Gui_FadeCheck(FADER_LOADSCREEN))
                break;

            default:
                gameflow_manager.Actions[i].opcode = TR_GAMEFLOW_NOENTRY;
                break;  ///@FIXME: Implement all other gameflow opcodes here!
        }   // end switch(gameflow_manager.Operand)
    }

    if(completed) gameflow_manager.NextAction = false;    // Reset action marker!
}
示例#3
0
bool Gameflow_SetGameInternal(int game_id, int level_id)
{
    level_info_t info;
    if(Gameflow_GetLevelInfo(&info, game_id, level_id))
    {
        level_id = (level_id <= info.num_levels) ? (level_id) : (1);
        if(!Gui_LoadScreenAssignPic(info.pic))
        {
            Gui_LoadScreenAssignPic("resource/graphics/legal");
        }

        global_gameflow.m_currentGameID = game_id;
        global_gameflow.m_currentLevelID = level_id;
        strncpy(global_gameflow.m_currentLevelName, info.name, LEVEL_NAME_MAX_LEN);
        strncpy(global_gameflow.m_currentLevelPath, info.path, MAX_ENGINE_PATH);
        return Engine_LoadMap(info.path);
    }

    return false;
}