コード例 #1
0
	void CCameraFeedbackNotifier::process(const std::shared_ptr<CMessage>& message) {
		//Ambas hacen lo mismo de momento, pero lo dejo separado por si luego queremos poner 
		//comportamientos distintos en función del daño
		switch( message->getMessageType() ) {
			case Message::DAMAGED: {
				std::shared_ptr<CMessageDamaged> damageMess = std::static_pointer_cast<CMessageDamaged>(message);
				CEntity* enemy = damageMess->getEnemy();
				if(enemy != NULL)
					damaged( enemy->getPosition() );
				
				break;
			}
			/*case Message::SET_REDUCED_DAMAGE: {
				damaged();
				break;
			}*/
			case Message::FLASH: {
				std::shared_ptr<CMessageFlash> flashMsg = std::static_pointer_cast<CMessageFlash>(message);
				_flashFactor = flashMsg->getFlashFactor();
				_flashVisible = true;
				_scene->setCompositorVisible(_flashEffect, true);
				break;
			}
		}
	} // process
コード例 #2
0
ファイル: CollisionManager.cpp プロジェクト: gbougard/NBK
		bool CCollisionManager::update()
		{
			CEntity *entity;
					

			for (entityIter=T_entities.begin(); entityIter!=T_entities.end(); ++entityIter)
			{
				entity = *entityIter;
				/*	
					Check entities with terrain end make proper response, 
					all 4 must be checked since we ce be in the corner.
				*/
				if (entity->isActive())
				{
					// 1. get logical position
					vector2i pos = CConversions::realToLogical(entity->getPosition());

					// 2. extract proper planes of nearby block					
					check(entity,pos+vector2i(0,-1));
					check(entity,pos+vector2i(0,1));
					check(entity,pos+vector2i(-1,0));
					check(entity,pos+vector2i(1,0));

					/* ? check(entity,pos+vector2i(1,1));
					check(entity,pos+vector2i(1,-1));
					check(entity,pos+vector2i(-1,-1));
					check(entity,pos+vector2i(-1,1)); ? */

					// just clamp entity to the bottom if we are below min level
					vector3f ePos = entity->getPosition();

					if (ePos[1]<CV_CAMERA_MIN_FPS_Y_POS)
					{
						ePos[1] = CV_CAMERA_MIN_FPS_Y_POS;
						entity->setPosition(ePos);
					}
				}
			}

			return true;
		}
コード例 #3
0
ファイル: CRenderWidget.cpp プロジェクト: Jirachi/Nyuu
//---------------------------------------------------------------------------
bool CRenderWidget::selectEntity(QGraphicsItem *item)
{
    if (mSelectionRects.contains(item))
    {
        return false;
    }

    clearSelection();

    if (!item)
    {
        return false;
    }

    QPen dashedPen;
    dashedPen.setStyle(Qt::DashLine);

    if (!mSelectedItems.contains(item))
    {
        mSelectedItems.push_back(item);
        mSelectionRects.push_back(mScene.addRect(item->pos().x(), item->pos().y(), item->boundingRect().width(), item->boundingRect().height(), dashedPen));

        emit itemSelected(item);

        CEntity* entity = Globals::getCurrentScene()->getEntityFromGraphicsView(mSelectedItems.first());

        if (entity)
        {
            mOriginalPosition = entity->getPosition();
        }


        return true;
    }

    return false;
}