void Scene::activatePicking(int x, int y) { _highlighted = NULL; unsigned char index[4] = {0x00, 0x00, 0x00, 0x00}; unsigned int id = 0; glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &index); bytesToUInt(index, &id); if(id) { for(int i = 0; i < (int)_sceneList.size(); i++) { Pickable * pickable = dynamic_cast<Pickable*>(_sceneList[i]); if(pickable) { PickablePnts * pkpts = dynamic_cast<PickablePnts*>(pickable); if(pkpts) { pkpts->reset(); } if(pickable->processPickingResult(id)) { _highlighted = pickable; } } } } }
/** * \brief Creates a pickable item with the specified subtype. * * This method acts like a constructor, except that it can return NULL in several cases: * - the treasure is saved and the player already has it, * or: * - the treasure is empty, * or: * - the item cannot be obtained by the hero yet. * * \param game the current game * \param name Unique name identifying the entity on the map or an empty string. * \param layer layer of the pickable item to create on the map * \param x x coordinate of the pickable item to create * \param y y coordinate of the pickable item to create * \param treasure the treasure to give * \param falling_height to make the item fall when it appears * \param force_persistent true to make the item stay forever (otherwise, the properties of the item * decide if it disappears after some time) * \return the pickable item created, or NULL */ Pickable* Pickable::create( Game& game, const std::string& name, Layer layer, int x, int y, Treasure treasure, FallingHeight falling_height, bool force_persistent) { treasure.ensure_obtainable(); // Don't create anything if there is no treasure to give. if (treasure.is_found() || treasure.is_empty()) { return NULL; } Pickable* pickable = new Pickable(name, layer, x, y, treasure); // Set the item properties. pickable->falling_height = falling_height; pickable->will_disappear = !force_persistent && treasure.get_item().get_can_disappear(); // Initialize the pickable item. pickable->initialize_sprites(); pickable->initialize_movement(); return pickable; }
Pickable *Pickable::Create(TCODZip &zip) { PickableType type = (PickableType) zip.getInt(); Pickable *pickable = NULL; switch(type) { case HEALER: pickable = new Healer(0); break; case LIGHTNING_BOLT: pickable = new LightningBolt(0, 0); break; case CONFUSER: pickable = new Confuser(0, 0); break; case FIREBALL: pickable = new Fireball(0, 0); break; } if (pickable != NULL) { pickable->Load(zip); } return pickable; }
Pickable* Pickable::Create(TCODZip& zip) { pickable_type type = (pickable_type)zip.getInt(); Pickable* pickable = nullptr; switch(type) { case PICKABLE_TYPE_HEALER: { pickable = new Healer(0); } break; case PICKABLE_TYPE_LIGHTNING_BOLT: { pickable = new LightningBolt(0, 0); } break; case PICKABLE_TYPE_FIREBALL: { pickable = new Fireball(0, 0); } break; } pickable->Load(zip); return(pickable); }
void BagManager::fillBag() { std::function<std::string(Actor*)> category_function = [&](Actor* a) { Pickable* p = a->getFeature<Pickable>(); return p ? PickableCategory2Str( p->getCategory() ) : ""; }; _bagMenu->fill<Actor>( Actor::Player->getFeature<Container>()->content(), getItemNameAndAmount, category_function); }
Pickable *Pickable::create(TCODZip &zip) { PickableType type = (PickableType)zip.getInt(); Pickable *pickable = NULL; switch(type) { case NONE: break; case HEALER: pickable = new Healer(0); break; case LIGHTNING_BOLT: pickable = new LightningBolt(0,0); break; case CONFUSER: pickable = new Confuser(0,0); break; case POISON: pickable = new Poison(0,0); break; case FIREBALL: pickable = new Fireball(0,0,0); break; case EQUIPMENT: pickable = new Equipment(); break; case WEAPON: pickable = new Weapon(); break; } pickable->load(zip); return pickable; }