bool DungeonLayer::init() { if (!Layer::init()) { return false; } this->setName(DUNGEON_LAYER_NAME); auto characterSprite = CharacterDiceSprite::create(); characterSprite->setDelegate(this); auto character = Game::getInstance()->getPlayer()->getCharacter(); character->setSprite(characterSprite); character->resetLife(); this->reset(); this->_setupEventHandlers(); return true; }
GLvoid CBlock::setType(GLint type) { if(this->type == CV_BLOCK_TYPE_UNCLAIMED_LAND_ID) CV_GAME_MANAGER->getLevelManager()->removeUnclaimedBlock(this); this->type=type; this->taken=false; disposeBlockObjects(); disposeDisplayLists(); // join all wall types into 1 if (type==CV_BLOCK_TYPE_WALL_0_ID || type==CV_BLOCK_TYPE_WALL_1_ID || type==CV_BLOCK_TYPE_WALL_2_ID || type==CV_BLOCK_TYPE_WALL_3_ID || type==CV_BLOCK_TYPE_WALL_4_ID) { this->type = CV_BLOCK_TYPE_WALL_ID; } if (this->type==CV_BLOCK_TYPE_EARTH_WITH_TORCH_PLATE_ID) { torch = true; this->type = CV_BLOCK_TYPE_EARTH_ID; } else if (this->type==CV_BLOCK_TYPE_WALL_WITH_TORCH_PLATE_ID) { torch = true; this->type = CV_BLOCK_TYPE_WALL_ID; } // tmp hack, since doors are not supported yet if (this->type==CV_BLOCK_TYPE_WOODEN_DOORS_ID || this->type==CV_BLOCK_TYPE_BRACED_DOORS_ID || this->type==CV_BLOCK_TYPE_IRON_DOORS_ID || this->type==CV_BLOCK_TYPE_MAGIC_DOORS_ID) { this->type=CV_BLOCK_TYPE_UNCLAIMED_LAND_ID; } // setup quick variables low = !(this->type==CV_BLOCK_TYPE_ROCK_ID || this->type==CV_BLOCK_TYPE_GOLD_ID || this->type==CV_BLOCK_TYPE_EARTH_ID || this->type==CV_BLOCK_TYPE_WALL_ID || this->type==CV_BLOCK_TYPE_GEM_ID || this->type==CV_BLOCK_TYPE_EARTH_WITH_TORCH_PLATE_ID || this->type==CV_BLOCK_TYPE_WALL_WITH_TORCH_PLATE_ID); water = (this->type==CV_BLOCK_TYPE_WATER_ID); lava = (this->type==CV_BLOCK_TYPE_LAVA_ID); room = low && !water && !lava && this->type!=CV_BLOCK_TYPE_CLAIMED_LAND_ID && this->type!=CV_BLOCK_TYPE_UNCLAIMED_LAND_ID; marked = false; if (roomIndex!=-1) { // if we were are a part of a room, we need to inform this room that we are being modified CV_GAME_MANAGER->getRoomManager()->getRoom(roomIndex)->removeBlock(this,true); } else if (finalized && room && roomIndex==-1) { // we are a room, notify the RoomManager CV_GAME_MANAGER->getRoomManager()->addRoomTile(this); } if(this->type == CV_BLOCK_TYPE_UNCLAIMED_LAND_ID) CV_GAME_MANAGER->getLevelManager()->addUnclaimedBlock(this); if(this->type == CV_BLOCK_TYPE_EARTH_ID) CV_GAME_MANAGER->getLevelManager()->addUnfortifiedBlock(this); if(this->type == CV_BLOCK_TYPE_WALL_ID) CV_GAME_MANAGER->getLevelManager()->removeUnfortifiedBlock(this); resetLife(); }