void MapModel::tryTouchEnded(){ CCLOG("MapModel::tryTouchEnded()"); ResourceModel *rm = ResourceModel::getModel(); //@brief just click once CCLOG("ccpdist. %.2f\n", _pressLoc.distance(_touchLocation)); if (_pressLoc.distance(_touchLocation) < 6.5f){ TilePoint tileLoc = tileCoordForPosition(_touchLocationInGameLayer); for (int lr = 5; lr >= 0; lr--){ for (auto &building : _buildings) if (building->getID() == PFComponent::HQ_GID){ MapPoint coord = mapCoordForTilePoint(tileLoc, lr); if (coord == building->getCoord() && lr == building->getZ()){ CCLOG(">>@ The building belongs %s", building->getOwner().c_str()); char buffer[1000]; sprintf(buffer, ".%.0f-%.0f", coord.x, coord.y); string goMapStr = mapName + string(buffer) + ".tmx"; writeMapInfo(); SceneManager::goMapScreen(goMapStr, HUD_ID::DEFENSE); return; } } } } if (_selSprite){ bool forbid = false; if (_status == HUD_ID::ATTACK){ Rect backgroundRect = Rect(_background->getPositionX(), _background->getPositionY(), _background->getContentSize().width, _background->getContentSize().height); if (backgroundRect.containsPoint(_touchLocation)) forbid = true; } if (!forbid){ int isBuildableLevel = canBuildOnTilePosition(_touchLocationInGameLayer); if (~isBuildableLevel){ if (_status == HUD_ID::DEFENSE && PlayerManager::getInstance()->getCurPlayer()->canAddBuilding(selID)){ addBuilding(_touchLocationInGameLayer, isBuildableLevel); PlayerManager::getInstance()->getCurPlayer()->consumeResourceByBuilding(selID); } else if (_status == HUD_ID::ATTACK && PlayerManager::getInstance()->getCurPlayer()->canAddTroop(selID)){ addBuilding(_touchLocationInGameLayer, isBuildableLevel); PlayerManager::getInstance()->getCurPlayer()->consumeResourceByTroop(selID); //notify //send add building notify } } } _selGroups->removeAllChildren(); _selSprite = NULL; _selSpriteRange = NULL; showAllRange(false); } }
static void mapPslPair(struct psl *inPsl, struct mapAln *mapAln, FILE* outPslFh, FILE *mapInfoFh, FILE *mappingPslFh) /* map one pair of query and target PSL */ { struct psl* mappedPsl; if (inPsl->tSize != mapAln->psl->qSize) errAbort("Error: inPsl %s tSize (%d) != mapping alignment %s qSize (%d) (perhaps you need to specify -swapMap?)\n", inPsl->tName, inPsl->tSize, mapAln->psl->qName, mapAln->psl->qSize); mappedPsl = pslTransMap(mapOpts, inPsl, mapAln->psl); /* only output if blocks were actually mapped */ if (mappedPsl != NULL) { if (suffix != NULL) addQNameSuffix(mappedPsl); pslTabOut(mappedPsl, outPslFh); if (mapInfoFh != NULL) writeMapInfo(mapInfoFh, inPsl, mapAln, mappedPsl); if (mappingPslFh != NULL) pslTabOut(mapAln->psl, mappingPslFh); } pslFree(&mappedPsl); }