void TreasureContainer::onInteraction(Player &player) { if(!m_empty) { player.giveHealth(100); m_empty = true; setImageIndex(1); } }
void AflSpriteMapImage::onDraw() { int i,j; if(!m_pAflSpriteMap || !getAflTexture()) return; AflD3DWorld* paflDevice = AflRenderUnit::getAflDevice(); AflDrawUnit* pSprite = m_pAflSpriteMap->getDrawSprite(); INT iTipWidth = getTipWidth(); INT iTipHeight = getTipHeight(); if(!iTipWidth || !iTipHeight) return; //接触判定表示用スプライトの作成 if((INT)pSprite->getImageWidth()-4 != getTipWidth() || (INT)pSprite->getImageHeight()-4 != getTipHeight()) { pSprite->delPolygon(); pSprite->createBox(2,2,getTipWidth()-4,getTipHeight()-4,0x88cc6666); pSprite->setZBuffer(false); pSprite->setClipper(m_pAflSpriteMap->getClipX(),m_pAflSpriteMap->getClipY(),m_pAflSpriteMap->getClipZ(), m_pAflSpriteMap->getClipWidth(),m_pAflSpriteMap->getClipHeight(),m_pAflSpriteMap->getClipDepth()); } //クリップ領域の指定 setClipper(m_pAflSpriteMap->getClipX(),m_pAflSpriteMap->getClipY(),m_pAflSpriteMap->getClipZ(), m_pAflSpriteMap->getClipWidth(),m_pAflSpriteMap->getClipHeight(),m_pAflSpriteMap->getClipDepth()); INT iLevel = m_iLevel; FLOAT fMapX = m_pAflSpriteMap->getMapX(); FLOAT fMapY = m_pAflSpriteMap->getMapY(); //描画範囲の設定 FLOAT fDrawWidth = m_pAflSpriteMap->getClipWidth(); FLOAT fDrawHeight = m_pAflSpriteMap->getClipHeight(); if(!fDrawWidth) fDrawWidth = paflDevice->getDeviceWidth(); if(!fDrawHeight) fDrawHeight = paflDevice->getDeviceHeight(); //ビットのスライド位置を設定 FLOAT fStartBitX = (INT)fMapX % iTipWidth; FLOAT fStartBitY = (INT)fMapY % iTipHeight; if(fMapX < 0) fStartBitX = iTipWidth + fStartBitX; if(fMapY < 0) fStartBitY = iTipHeight + fStartBitY; //描画開始マップパーツの設定 INT iMapX,iMapY; iMapX = (fMapX-fStartBitX) / iTipWidth; iMapY = (fMapY-fStartBitY) / iTipHeight; //描画パーツ数の設定 INT iCountX,iCountY; iCountX = (fDrawWidth+iTipWidth-1) / iTipWidth; iCountY = (fDrawHeight+iTipHeight-1) / iTipHeight; if(fStartBitX) iCountX++; if(fStartBitY) iCountY++; for(j=0;j<iCountY;j++) { for(i=0;i<iCountX;i++) { INT iIndex = m_pAflSpriteMap->getMapIndex(iLevel,iMapX+i,iMapY+j); //通常描画 if(iIndex > 0 || (iLevel == 0 && iIndex==0)) { //パーツの選択 setImageIndex(iIndex); //相対位置の設定 setRelativity(-fStartBitX+i*iTipWidth,-fStartBitY+j*iTipHeight,0); //描画 drawImage(fX,fY,fZ); } //接触判定用 if(m_pAflSpriteMap->isDrawCollide()) { bool bCollide = m_pAflSpriteMap->isMapCollide(iMapX+i,iMapY+j); if(bCollide) { pSprite->setRelativity(-fStartBitX+i*iTipWidth,-fStartBitY+j*iTipHeight,0); pSprite->drawImage(fX,fY,fZ-2); } } } } }