Example #1
0
 /** Get the key bound to a player action (enum GUI::PlayerAction)*/
 std::string getKeyBinding(int Enum_value)
 {
     InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
     DeviceConfig* config = device->getConfiguration();
     PlayerAction ScriptAction = (PlayerAction)Enum_value;
     irr::core::stringw control = config->getBindingAsString(ScriptAction);
     std::string key = StringUtils::wideToUtf8(control);
     return key;
 }
void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
{
    if (!m_action_active) return;

    if (m_action == "garage")
    {
        m_action_active = false;

        new RacePausedDialog(0.8f, 0.6f);
        //dynamic_cast<OverWorld*>(World::getWorld())->scheduleSelectKart();
    }
    //action trigger near big doors in the overword to notify players that they'll open once they finish all the challenges
    else if (m_action == "big_door")
    {
        m_action_active = false;

        Track* m_track = World::getWorld()->getTrack();
        unsigned int unlocked_challenges = m_track->getNumOfCompletedChallenges();
        std::vector<OverworldChallenge> m_challenges = m_track->getChallengeList();

        // allow ONE unsolved challenge : the last one
        if (unlocked_challenges < m_challenges.size() - 1)
        {
            new TutorialMessageDialog(_("Complete all challenges to unlock the big door!"), true);
        }
    }
    else if (m_action == "tutorial_drive")
    {
        //if (World::getWorld()->getPhase() == World::RACE_PHASE)
        {
            m_action_active = false;
            //World::getWorld()->getRaceGUI()->clearAllMessages();

            InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
            DeviceConfig* config = device->getConfiguration();
            irr::core::stringw accel = config->getBindingAsString(PA_ACCEL);
            irr::core::stringw left = config->getBindingAsString(PA_STEER_LEFT);
            irr::core::stringw right = config->getBindingAsString(PA_STEER_RIGHT);

            new TutorialMessageDialog(_("Accelerate with <%s> and steer with <%s> and <%s>", accel, left, right),
                                      false);
        }
    }
    else if (m_action == "tutorial_bananas")
    {
        m_action_active = false;

        new TutorialMessageDialog(_("Avoid bananas!"), true);
    }
    else if (m_action == "tutorial_giftboxes")
    {
        m_action_active = false;
        InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
        DeviceConfig* config = device->getConfiguration();
        irr::core::stringw fire = config->getBindingAsString(PA_FIRE);

        new TutorialMessageDialog(_("Collect gift boxes, and fire the weapon with <%s> to blow away these boxes!", fire),
                                true);
    }
    else if (m_action == "tutorial_backgiftboxes")
    {
        m_action_active = false;
        InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
        DeviceConfig* config = device->getConfiguration();
        irr::core::stringw fire = config->getBindingAsString(PA_FIRE);
        
        new TutorialMessageDialog(_("Press <B> to look behind, to fire the weapon with <%s> while pressing <B> to to fire behind!", fire),
                                  true);
    }
    else if (m_action == "tutorial_nitro_collect")
    {
        m_action_active = false;

        new TutorialMessageDialog(_("Collect nitro bottles (we will use them after the curve)"),
                                  true);
    }
    else if (m_action == "tutorial_nitro_use")
    {
        m_action_active = false;
        InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
        DeviceConfig* config = device->getConfiguration();
        irr::core::stringw nitro = config->getBindingAsString(PA_NITRO);

        new TutorialMessageDialog(_("Use the nitro you collected by pressing <%s>!", nitro),
                                 true);
    }
    else if (m_action == "tutorial_rescue")
    {
        m_action_active = false;
        InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
        DeviceConfig* config = device->getConfiguration();
        irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE);

        new TutorialMessageDialog(_("Oops! When you're in trouble, press <%s> to be rescued", rescue),
                                  false);
    }
    else if (m_action == "tutorial_skidding")
    {
        m_action_active = false;
        //World::getWorld()->getRaceGUI()->clearAllMessages();

        InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
        DeviceConfig* config = device->getConfiguration();
        irr::core::stringw skid = config->getBindingAsString(PA_DRIFT);


        new TutorialMessageDialog(_("Accelerate and press the <%s> key while turning to skid. Skidding for a short while can help you turn faster to take sharp turns.", skid),
                                 true);
    }
    else if (m_action == "tutorial_skidding2")
    {
        m_action_active = false;
        World::getWorld()->getRaceGUI()->clearAllMessages();

        new TutorialMessageDialog(_("Note that if you manage to skid for several seconds, you will receive a bonus speedup as a reward!"),
                                true);
    }
    else if (m_action == "tutorial_endmessage")
    {
        m_action_active = false;
        World::getWorld()->getRaceGUI()->clearAllMessages();

        new TutorialMessageDialog(_("You are now ready to race. Good luck!"),
                                  true);
    }
    else if (m_action == "tutorial_exit")
    {
        World::getWorld()->scheduleExitRace();
        return;
    }
    else
        Log::warn("TrackObject", "Unknown action '%s'", m_action.c_str());
}