コード例 #1
0
ファイル: Actor.cpp プロジェクト: numeroband/lage
void Actor::walkToObject(Table objTable)
{
    Object *object = Object::fromTable(objTable);
    const SDL_Point &walk = object->walk();
    if (_engine->isDebug(Engine::kDebugWalkboxes))
    {
        std::cout << "walkToObject '" << object->name()
        << "': " << walk.x << "," << walk.y << std::endl;
    }
    walkTo(walk.x, walk.y);
}
コード例 #2
0
bool Input::translateGameInput() {

	if (_engineFlags & kEnginePauseJobs) {
		return false;
	}

	if (_hasDelayedAction) {
		// if walking is over, then take programmed action
		takeAction(_delayedActionZone);
		_hasDelayedAction = false;
		_delayedActionZone.reset();
		return true;
	}

	if (_mouseButtons == kMouseRightDown) {
		// right button down shows inventory
		enterInventoryMode();
		return true;
	}

	Common::Point mousePos;
	getAbsoluteCursorPos(mousePos);
	// test if mouse is hovering on an interactive zone for the currently selected inventory item
	ZonePtr z = _vm->hitZone(_activeItem._id, mousePos.x, mousePos.y);

	if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || (ACTIONTYPE(z) != kZoneCommand))) {
		walkTo(mousePos);
		return true;
	}

	trackMouse(z);
	if (!z) {
		return true;
	}

	if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || (ACTIONTYPE(z) == kZoneCommand))) {

		bool noWalk = z->_flags & kFlagsNoWalk;	// check the explicit no-walk flag
		if (_gameType == GType_BRA) {
			// action performed on object marked for self-use do not need walk in BRA
			noWalk |= ((z->_flags & kFlagsYourself) != 0);
		}

		if (noWalk) {
			takeAction(z);
		} else {
			// action delayed: if Zone defined a moveto position the character is programmed to move there,
			// else it will move to the mouse position
			_delayedActionZone = z;
			_hasDelayedAction = true;
			if (z->_moveTo.y != 0) {
				mousePos = z->_moveTo;
			}

			walkTo(mousePos);
		}

		_vm->beep();
		setArrowCursor();
		return true;
	}

	return true;
}