Beispiel #1
0
bool Game_Character::IsPassable(int x, int y, int d) const {
	if (d > 3) {
		int dx = (d == UpRight || d == DownRight) - (d == DownLeft || d == UpLeft);
		int dy = (d == DownRight || d == DownLeft) - (d == UpRight || d == UpLeft);
		return ((IsPassable(x, y, -dx + 2) && IsPassable(x + dx, y, dy + 1)) ||
			(IsPassable(x, y, dy + 1) && IsPassable(x, y + dy, -dx + 2)));
	}

	int new_x = Game_Map::RoundX(x + (d == Right ? 1 : d == Left ? -1 : 0));
	int new_y = Game_Map::RoundY(y + (d == Down ? 1 : d == Up ? -1 : 0));

	if (!Game_Map::IsValid(new_x, new_y))
		return false;

	if (GetThrough()) return true;

	if (!Game_Map::IsPassable(x, y, d, this))
		return false;

	if (!Game_Map::IsPassable(new_x, new_y, (d + 2) % 4, this))
		return false;

	if (Main_Data::game_player->IsInPosition(new_x, new_y)
		&& !Main_Data::game_player->GetThrough() && !GetSpriteName().empty()
		&& GetLayer() == RPG::EventPage::Layers_same) {
			return false;
	}

	return true;
}
Beispiel #2
0
bool Game_Character::IsPassable(int x, int y, int d) const {
	int new_x = x + (d == RPG::EventPage::Direction_right ? 1 : d == RPG::EventPage::Direction_left ? -1 : 0);
	int new_y = y + (d == RPG::EventPage::Direction_down ? 1 : d == RPG::EventPage::Direction_up ? -1 : 0);

	if (Player::debug_flag && (this == Main_Data::game_player.get())
		&& Input::IsPressed(Input::DEBUG_THROUGH)) {
			return true;
	}

	if (!Game_Map::IsValid(new_x, new_y))
		return false;

	if (through) return true;

	if (!Game_Map::IsPassable(x, y, d, this))
		return false;

	if (!Game_Map::IsPassable(new_x, new_y, (d + 2) % 4, this))
		return false;

	if (Main_Data::game_player->GetX() == new_x && Main_Data::game_player->GetY() == new_y
		&& !Main_Data::game_player->GetThrough() && !GetSpriteName().empty() 
		&& GetLayer() != RPG::EventPage::Layers_above) {
			return false;
	}

	return true;
}
Beispiel #3
0
void Game_Character::SetGraphic(const std::string& name, int index) {
	if (GetSpriteName() != name || GetSpriteIndex() != index) {
		SetSpriteName(name);
		SetSpriteIndex(index);
		tile_id = 0;
		pattern = RPG::EventPage::Frame_middle;
	}
}
Beispiel #4
0
bool Game_Character::IsLandable(int x, int y) const
{
	if (!Game_Map::IsValid(x, y))
		return false;

	if (GetThrough()) return true;

	if (!Game_Map::IsLandable(x, y, this))
		return false;

	if (GetLayer() == RPG::EventPage::Layers_same && Main_Data::game_player->IsInPosition(x, y)) {
		if (!Main_Data::game_player->GetThrough() && !GetSpriteName().empty() && (this != Main_Data::game_player.get())) {
			return false;
		}
	}

	return true;
}
Beispiel #5
0
bool Game_Character::IsLandable(int x, int y) const
{
	if (!Game_Map::IsValid(x, y))
		return false;

	if (through) return true;

	if (!Game_Map::IsLandable(x, y, this))
		return false;

	if (Main_Data::game_player->GetX() == x && Main_Data::game_player->GetY() == y) {
		if (!Main_Data::game_player->GetThrough() && !GetSpriteName().empty() && (this != Main_Data::game_player.get())) {
			return false;
		}
	}

	return true;
}