예제 #1
0
TreasureObject::TreasureObject(const std::string& treasure_name,
                               MapObjectDrawLayer layer,
                               const std::string& closed_animation_file,
                               const std::string& opening_animation_file,
                               const std::string& open_animation_file) :
    PhysicalObject(layer)
{
    _object_type = TREASURE_TYPE;
    _events_triggered = false;
    _is_opening = false;

    _treasure_name = treasure_name;
    if(treasure_name.empty())
        PRINT_WARNING << "Empty treasure name found. The treasure won't function normally." << std::endl;

    _treasure = new vt_map::private_map::MapTreasureContent();

    // Dissect the frames and create the closed, opening, and open animations
    vt_video::AnimatedImage closed_anim, opening_anim, open_anim;

    closed_anim.LoadFromAnimationScript(closed_animation_file);
    if(!opening_animation_file.empty())
        opening_anim.LoadFromAnimationScript(opening_animation_file);
    open_anim.LoadFromAnimationScript(open_animation_file);

    // Set the collision rectangle according to the dimensions of the first frame
    SetCollPixelHalfWidth(closed_anim.GetWidth() / 2.0f);
    SetCollPixelHeight(closed_anim.GetHeight());

    // Apply the zoom ratio on the animations.
    ScaleToMapZoomRatio(closed_anim);
    ScaleToMapZoomRatio(opening_anim);
    ScaleToMapZoomRatio(open_anim);

    AddAnimation(closed_anim);
    AddAnimation(opening_anim);
    AddAnimation(open_anim);

    _LoadState();
}
예제 #2
0
Halo::Halo(const std::string& filename,
           float x, float y,
           const vt_video::Color& color):
    MapObject(NO_LAYER_OBJECT) // This is a special object
{
    _color = color;
    _tile_position.x = x;
    _tile_position.y = y;

    _object_type = HALO_TYPE;
    _collision_mask = NO_COLLISION;

    if(!_animation.LoadFromAnimationScript(filename))
        PRINT_WARNING << "Couldn't load the Halo animation " << filename << " properly." << std::endl;

    // Setup the image collision for the display update
    SetImgPixelHalfWidth(_animation.GetWidth() / 2.0f);
    SetImgPixelHeight(_animation.GetHeight());

    ScaleToMapZoomRatio(_animation);

    // Auto-registers to the object supervisor for later deletion handling
    MapMode::CurrentInstance()->GetObjectSupervisor()->AddHalo(this);
}
예제 #3
0
MapMode::MapMode(const std::string& data_filename, const std::string& script_filename, uint32 stamina) :
    GameMode(MODE_MANAGER_MAP_MODE),
    _activated(false),
    _map_data_filename(data_filename),
    _map_script_filename(script_filename),
    _tile_supervisor(nullptr),
    _object_supervisor(nullptr),
    _event_supervisor(nullptr),
    _dialogue_supervisor(nullptr),
    _treasure_supervisor(nullptr),
    _camera_x_in_map_corner(false),
    _camera_y_in_map_corner(false),
    _camera(nullptr),
    _virtual_focus(nullptr),
    _delta_x(0),
    _delta_y(0),
    _pixel_length_x(-1.0f),
    _pixel_length_y(-1.0f),
    _running_enabled(true),
    _unlimited_stamina(false),
    _show_gui(true),
    _run_stamina(stamina),
    _gui_alpha(0.0f),
    _music_audio_state(AUDIO_STATE_UNLOADED),
    _music_audio_sample(0),
    _minimap(nullptr),
    _show_minimap(false),
    _menu_enabled(true),
    _save_points_enabled(true),
    _status_effects_enabled(true)
{
    _current_instance = this;

    ResetState();
    PushState(STATE_EXPLORE);

    // Load the miscellaneous map graphics.
    _dialogue_icon.LoadFromAnimationScript("data/entities/emotes/dialogue_icon.lua");
    ScaleToMapZoomRatio(_dialogue_icon);

    // Load the save point animation files.
    AnimatedImage anim;
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point3.lua");
    active_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point2.lua");
    active_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point1.lua");
    inactive_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point2.lua");
    inactive_save_point_animations.push_back(anim);

    // Transform the animation size to correspond to the map zoom ratio.
    for(uint32 i = 0; i < active_save_point_animations.size(); ++i)
        ScaleToMapZoomRatio(active_save_point_animations[i]);

    for(uint32 i = 0; i < inactive_save_point_animations.size(); ++i)
        ScaleToMapZoomRatio(inactive_save_point_animations[i]);

    _tile_supervisor = new TileSupervisor();
    _object_supervisor = new ObjectSupervisor();
    _event_supervisor = new EventSupervisor();
    _dialogue_supervisor = new MapDialogueSupervisor();
    _treasure_supervisor = new TreasureSupervisor();

    _intro_timer.Initialize(4000, 0);
    _intro_timer.EnableAutoUpdate(this);

    _camera_timer.Initialize(0, 1);

    // Create the camera virtual focus, used to display random map locations.
    // NOTE: Deleted by the Object supervisor.
    _virtual_focus = new VirtualSprite(NO_LAYER_OBJECT);
    _virtual_focus->SetPosition(0.0f, 0.0f);
    _virtual_focus->SetMovementSpeed(NORMAL_SPEED);
    _virtual_focus->SetCollisionMask(NO_COLLISION);
    _virtual_focus->SetVisible(false);

    if(!_Load()) {
        BootMode *BM = new BootMode();
        ModeManager->PopAll();
        ModeManager->Push(BM);
        return;
    }

    // Once the minimap file has been set (in the load function),
    // we can create the minimap
    if(_show_minimap)
        _CreateMinimap();

    GlobalMedia& media = GlobalManager->Media();
    _stamina_bar_background = media.GetStaminaBarBackgroundImage();
    _stamina_bar = media.GetStaminaBarImage();
    _stamina_bar_infinite_overlay = media.GetStaminaInfiniteImage();

    // Init the script component.
    GetScriptSupervisor().Initialize(this);

    //! Init the camera position text style
    _debug_camera_position.SetStyle(TextStyle("title22", Color::white, VIDEO_TEXT_SHADOW_DARK));
}