Example #1
0
void CameraZone::Update() {
	_was_camera_inside = _camera_inside;
	_was_player_sprite_inside = _player_sprite_inside;

	VirtualSprite* camera = MapMode::CurrentInstance()->GetCamera();
	if (camera == NULL) {
		_camera_inside = false;
	}
	// Camera must share a context with the zone and be within its borders
	else if ((_active_contexts & camera->GetContext()) && (IsInsideZone(camera->x_position, camera->y_position) == true)) {
		_camera_inside = true;
	}
	else {
		_camera_inside = false;
	}

	VirtualSprite* player = MapMode::CurrentInstance()->GetPlayerSprite();
	if (player == NULL) {
		_player_sprite_inside = false;
	}
	// Camera must share a context with the zone and be within its borders
	else if ((_active_contexts & player->GetContext()) && (IsInsideZone(player->x_position, player->y_position) == true)) {
		_player_sprite_inside = true;
	}
	else {
		_player_sprite_inside = false;
	}
}
Example #2
0
void CameraZone::Update() {
	_was_camera_inside = _camera_inside;

	// Update only if camera is on a real sprite
	if (MapMode::CurrentInstance()->IsCameraOnVirtualFocus()) {
		return;
	}

	VirtualSprite* camera = MapMode::CurrentInstance()->GetCamera();
	if (camera == NULL) {
		_camera_inside = false;
	}
	// Camera must share a context with the zone and be within its borders
	else if ((_active_contexts & camera->GetContext())
			&& (IsInsideZone(camera->GetXPosition(), camera->GetYPosition()))) {
		_camera_inside = true;
	}
	else {
		_camera_inside = false;
	}
}
Example #3
0
void MapMode::Update()
{
    // Update the map frame coords
    // NOTE: It's done before handling pause so that the frame is updated at
    // least once before setting the pause mode, avoiding a crash.
    _UpdateMapFrame();

    // Process quit and pause events unconditional to the state of map mode
    if(InputManager->QuitPress()) {
        ModeManager->Push(new PauseMode(true));
        return;
    } else if(InputManager->PausePress()) {
        ModeManager->Push(new PauseMode(false));
        return;
    } else if(InputManager->MinimapPress()) {
        //! Toggles the minimap view as requested by the user.
        GlobalManager->ShowMinimap(!GlobalManager->ShouldShowMinimap());
        return;
    }

    _dialogue_icon.Update();

    // Call the map script's update function
    if(_update_function.is_valid())
        ScriptCallFunction<void>(_update_function);

    // Update all animated tile images
    _tile_supervisor->Update();
    _object_supervisor->Update();
    _object_supervisor->SortObjects();

    switch(CurrentState()) {
    case STATE_SCENE:
    case STATE_DIALOGUE:
        // Fade out the gui alpha
        if (_gui_alpha > 0.0f)
            _gui_alpha -= SystemManager->GetUpdateTime() * 0.005;
        break;
    default:
        // Fade in the gui alpha if necessary
        if (_gui_alpha < 1.0f)
            _gui_alpha += SystemManager->GetUpdateTime() * 0.005;
        break;
    }

    // Update the active state of the map
    switch(CurrentState()) {
    case STATE_EXPLORE:
        _UpdateExplore();
        break;
    case STATE_SCENE:
        // Nothing
        break;
    case STATE_DIALOGUE:
        _dialogue_supervisor->Update();
        break;
    case STATE_TREASURE:
        _camera->moving = false;
        _treasure_supervisor->Update();
        break;
    default:
        IF_PRINT_WARNING(MAP_DEBUG) << "map was set in an unknown state: "
                                    << CurrentState() << std::endl;
        ResetState();
        break;
    }

    // ---------- (4) Update the camera timer
    _camera_timer.Update();

    // ---------- (5) Update all active map events
    _event_supervisor->Update();

    //update collision camera
    if (_show_minimap && _minimap && (CurrentState() == STATE_EXPLORE)
            && GlobalManager->ShouldShowMinimap())
        _minimap->Update(_camera, _gui_alpha);

    GameMode::Update();
    // Updates portraits along with other visuals.
    _status_effect_supervisor.UpdatePortraits();

    // Updates the debug info if needed
    if(!VideoManager->DebugInfoOn())
        return;

    // Camera map coordinates
    VirtualSprite *cam = GetCamera();
    if(!cam)
        return;
    float x_pos = cam->GetXPosition();
    float y_pos = cam->GetYPosition();
    std::ostringstream coord_txt;
    coord_txt << "Camera position: " << x_pos << ", " << y_pos;
    _debug_camera_position.SetText(coord_txt.str());
} // void MapMode::Update()