示例#1
0
void EffectManager::addEffect(const char* effectName, EffectInfo& effectInfo)
{
	effectInfo.m_configData = getEffectDataNyName(effectName);
	addEffect(effectInfo);
}
示例#2
0
void destroyFXDroid(DROID *psDroid, unsigned impactTime)
{
	for (int i = 0; i < 5; ++i)
	{
		iIMDShape *psImd = nullptr;

		int maxHorizontalScatter = TILE_UNITS / 4;
		int heightScatter = TILE_UNITS / 5;
		Vector2i horizontalScatter = iSinCosR(rand(), rand() % maxHorizontalScatter);

		Vector3i pos = (psDroid->pos + Vector3i(horizontalScatter, 16 + heightScatter)).xzy;
		switch (i)
		{
		case 0:
			switch (psDroid->droidType)
			{
			case DROID_DEFAULT:
			case DROID_CYBORG:
			case DROID_CYBORG_SUPER:
			case DROID_CYBORG_CONSTRUCT:
			case DROID_CYBORG_REPAIR:
			case DROID_WEAPON:
			case DROID_COMMAND:
				if (psDroid->numWeaps > 0)
				{
					if (psDroid->asWeaps[0].nStat > 0)
					{
						psImd = WEAPON_MOUNT_IMD(psDroid, 0);
					}
				}
				break;
			default:
				break;
			}
			break;
		case 1:
			switch (psDroid->droidType)
			{
			case DROID_DEFAULT:
			case DROID_CYBORG:
			case DROID_CYBORG_SUPER:
			case DROID_CYBORG_CONSTRUCT:
			case DROID_CYBORG_REPAIR:
			case DROID_WEAPON:
			case DROID_COMMAND:
				if (psDroid->numWeaps)
				{
					// get main weapon
					psImd = WEAPON_IMD(psDroid, 0);
				}
				break;
			default:
				break;
			}
			break;
		}
		if (psImd == nullptr)
		{
			psImd = getRandomDebrisImd();
		}
		// Tell the effect system that it needs to use this player's color for the next effect
		SetEffectForPlayer(psDroid->player);
		addEffect(&pos, EFFECT_GRAVITON, GRAVITON_TYPE_EMITTING_DR, true, psImd, getPlayerColour(psDroid->player), impactTime);
	}
}
示例#3
0
void PickableModel::onPicked() {
	mText->editString("Picked " + mName);
	addEffect(mPickedEffect);
}
 void addCheckButton(const char* label, float* zone) {
   addEffect(label, zone, 0, 0, 1);
 }
示例#5
0
// multiple turrets display removed the pointless mountRotation
void displayComponentObject(DROID *psDroid)
{
	Vector3i	position, rotation;
	int32_t		xShift,zShift;
	SDWORD		frame;
	PROPULSION_STATS	*psPropStats;
	UDWORD	tileX,tileY;
	MAPTILE	*psTile;
	SPACETIME st = interpolateObjectSpacetime((SIMPLE_OBJECT *)psDroid, graphicsTime);

	psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;

	leftFirst = angleDelta(player.r.y - st.rot.direction) <= 0;

	/* Push the matrix */
	pie_MatBegin();

	/* Get internal tile units coordinates */
	xShift = map_round(player.p.x);
	zShift = map_round(player.p.z);

	/* Mask out to tile_units resolution */
	pie_TRANSLATE(xShift,0,-zShift);

	/* Get the real position */
	position.x = (st.pos.x - player.p.x) - terrainMidX*TILE_UNITS;
	position.z = terrainMidY*TILE_UNITS - (st.pos.y - player.p.z);
	position.y = st.pos.z;

	if(psDroid->droidType == DROID_TRANSPORTER)
	{
		position.y += bobTransporterHeight();
	}

	/* Get all the pitch,roll,yaw info */
	rotation.y = -st.rot.direction;
	rotation.x = st.rot.pitch;
	rotation.z = st.rot.roll;

	/* Translate origin */
	pie_TRANSLATE(position.x,position.y,position.z);

	/* Rotate for droid */
	pie_MatRotY(rotation.y);
	pie_MatRotX(rotation.x);
	pie_MatRotZ(rotation.z);

	if( (gameTime-psDroid->timeLastHit < GAME_TICKS_PER_SEC) && psDroid->lastHitWeapon == WSC_ELECTRONIC)
	{
		objectShimmy( (BASE_OBJECT*) psDroid );
	}

	if (psDroid->lastHitWeapon == WSC_EMP &&
	    (gameTime - psDroid->timeLastHit < EMP_DISABLE_TIME))
	{
		Vector3i position;

		//add an effect on the droid
		position.x = st.pos.x + DROID_EMP_SPREAD;
		position.y = st.pos.z + rand()%8;
		position.z = st.pos.y + DROID_EMP_SPREAD;
		effectGiveAuxVar(90+rand()%20);
		addEffect(&position,EFFECT_EXPLOSION,EXPLOSION_TYPE_PLASMA,false,NULL,0);
	}

	if ((psDroid->visible[selectedPlayer] == UBYTE_MAX) || demoGetStatus())
	{
		//ingame not button object
		//should render 3 mounted weapons now
		displayCompObj(psDroid, false);
	}
	else
	{

		// make sure it's not over water.
		tileX = st.pos.x/TILE_UNITS;
		tileY = st.pos.y/TILE_UNITS;
		// double check it's on map
		if ( tileX < mapWidth && tileY < mapHeight )
		{
			psTile = mapTile(tileX,tileY);
			if (terrainType(psTile) != TER_WATER)
			{
				frame = gameTime/BLIP_ANIM_DURATION + psDroid->id; //visible[selectedPlayer];
				pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, WZCOL_WHITE, WZCOL_BLACK, pie_ADDITIVE, psDroid->visible[selectedPlayer] / 2);
				/* set up all the screen coords stuff - need to REMOVE FROM THIS LOOP */
			}
		}
	}
	pie_MatEnd();
}
示例#6
0
KartGFX::KartGFX(const AbstractKart *kart, RaceManager::KartType type, bool is_day)
{
    m_nitro_light = NULL;
    m_skidding_light_1 = NULL;
    m_skidding_light_2 = NULL;
    m_head_light = NULL;
    m_kart = kart;
    m_wheel_toggle = 0;
    m_skid_level = 0;
    
    //if(!UserConfigParams::m_graphical_effects)
    //{
    //    for(unsigned int i=0; i<KGFX_COUNT; i++)
    //        m_all_emitters.push_back(NULL);
    //    return;
    //}

    const KartModel *km = m_kart->getKartModel();
    const float length = km->getLength();

    scene::ISceneNode *node = m_kart->getNode();
    // Create nitro light
    core::vector3df location(0.0f, 0.5f, -0.5f*length - 0.05f);
#ifndef SERVER_ONLY
    if (CVS->isGLSL())
    {
        m_nitro_light = irr_driver->addLight(location, /*force*/ 0.4f,
                                             /*radius*/ 5.0f, 0.0f, 0.4f, 1.0f,
                                             false, node);
        m_nitro_light->setVisible(false);
    #ifdef DEBUG
        m_nitro_light->setName( ("nitro emitter (" + m_kart->getIdent()
                                                   + ")").c_str() );
    #endif
    
        // Create skidding lights
        // For the first skidding level
        m_skidding_light_1 = 
            irr_driver->addLight(core::vector3df(0.0f, 0.1f, -0.5f * length - 
                                 0.05f), /* force */ 0.3f, /*radius*/ 3.0f,
                                 1.0f, 0.6f, 0.0f, false, node);
        m_skidding_light_1->setVisible(false);
        m_skidding_light_1->setName(("skidding emitter 1 (" + m_kart->getIdent() 
                                                            + ")").c_str() );
    
        // For the second skidding level
        m_skidding_light_2 =
            irr_driver->addLight(core::vector3df(0.0f, 0.1f, -0.5f * length - 
                                 0.05f), /* force */0.4f, /*radius*/4.0f,
                                 1.0f, 0.0f, 0.0f, false, node);
        m_skidding_light_2->setVisible(false);
        m_skidding_light_2->setName(("skidding emitter 2 (" + m_kart->getIdent() 
                                                             + ")").c_str() );
    
        m_head_light = 
            irr_driver->addLight(core::vector3df(0.0f, 0.2f, 1.5f * length),
                                 /* force */ 0.5f, /*radius*/5.0f, 1.0f, 1.0f, 
                                 1.0f, false, node);
        m_head_light->setName( ("head light " + m_kart->getIdent() 
                                                             + ")").c_str() );
    
        m_head_light->setVisible(type == RaceManager::KT_PLAYER && !is_day);
    
        m_nitro_light->grab();
        m_skidding_light_1->grab();
        m_skidding_light_2->grab();
        m_head_light->grab();
    }
#endif

    // Create particle effects
    Vec3 rear_left(kart->getWheelGraphicsPosition(3).getX(), 0.05f,
                   kart->getWheelGraphicsPosition(3).getZ()-0.1f    );
    Vec3 rear_right(kart->getWheelGraphicsPosition(2).getX(), 0.05f,
                    kart->getWheelGraphicsPosition(2).getZ()-0.1f   );

    Vec3 rear_center(0, kart->getKartHeight()*0.35f, -0.35f*length);

    Vec3 rear_nitro_center(0, kart->getKartHeight()*0.2f, -0.1f*length);

    // FIXME Used to match the emitter as seen in blender
    const Vec3 delta(0, 0, 0.6f);
    Vec3 rear_nitro_right = km->getNitroEmittersPositon(0) + delta;
    Vec3 rear_nitro_left  = km->getNitroEmittersPositon(1) + delta;
    if (!km->hasNitroEmitters())
        rear_nitro_right = rear_nitro_left = rear_nitro_center;

    // Create all effects. Note that they must be created
    // in the order of KartGFXType.
    addEffect(KGFX_NITRO1,      "nitro.xml",       rear_nitro_right, true );
    addEffect(KGFX_NITRO2,      "nitro.xml",       rear_nitro_left,  true );
    addEffect(KGFX_NITROSMOKE1, "nitro-smoke.xml", rear_nitro_left,  false);
    addEffect(KGFX_NITROSMOKE2, "nitro-smoke.xml", rear_nitro_right, false);
    addEffect(KGFX_EXHAUST1,    "kart_exhaust.xml",rear_nitro_right, false );
    addEffect(KGFX_EXHAUST2,    "kart_exhaust.xml",rear_nitro_left,  false );
    addEffect(KGFX_ZIPPER,      "zipper_fire.xml", rear_center,      true );
    addEffect(KGFX_TERRAIN,     "smoke.xml",       Vec3(0, 0, 0),    false);
    addEffect(KGFX_SKID1L,      "skid1.xml",       rear_left,        true );
    addEffect(KGFX_SKID1R,      "skid1.xml",       rear_right,       true );
    addEffect(KGFX_SKID2L,      "skid2.xml",       rear_left,        true );
    addEffect(KGFX_SKID2R,      "skid2.xml",       rear_right,       true );
}   // KartGFX
示例#7
0
/* Remove a Feature and free it's memory */
bool destroyFeature(FEATURE *psDel)
{
	UDWORD			widthScatter,breadthScatter,heightScatter, i;
	EFFECT_TYPE		explosionSize;
	Vector3i pos;
	UDWORD			width,breadth;
	UDWORD			mapX,mapY;

	ASSERT_OR_RETURN(false, psDel != NULL, "Invalid feature pointer");

 	/* Only add if visible and damageable*/
	if(psDel->visible[selectedPlayer] && psDel->psStats->damageable)
	{
		/* Set off a destruction effect */
		/* First Explosions */
		widthScatter = TILE_UNITS/2;
		breadthScatter = TILE_UNITS/2;
		heightScatter = TILE_UNITS/4;
		//set which explosion to use based on size of feature
		if (psDel->psStats->baseWidth < 2 && psDel->psStats->baseBreadth < 2)
		{
			explosionSize = EXPLOSION_TYPE_SMALL;
		}
		else if (psDel->psStats->baseWidth < 3 && psDel->psStats->baseBreadth < 3)
		{
			explosionSize = EXPLOSION_TYPE_MEDIUM;
		}
		else
		{
			explosionSize = EXPLOSION_TYPE_LARGE;
		}
		for(i=0; i<4; i++)
		{
			pos.x = psDel->pos.x + widthScatter - rand()%(2*widthScatter);
			pos.z = psDel->pos.y + breadthScatter - rand()%(2*breadthScatter);
			pos.y = psDel->pos.z + 32 + rand()%heightScatter;
			addEffect(&pos,EFFECT_EXPLOSION,explosionSize,false,NULL,0);
		}

		if(psDel->psStats->subType == FEAT_SKYSCRAPER)
		{
			pos.x = psDel->pos.x;
			pos.z = psDel->pos.y;
			pos.y = psDel->pos.z;
			addEffect(&pos,EFFECT_DESTRUCTION,DESTRUCTION_TYPE_SKYSCRAPER,true,psDel->sDisplay.imd,0);
			initPerimeterSmoke(psDel->sDisplay.imd, pos);

			shakeStart();
		}

		/* Then a sequence of effects */
		pos.x = psDel->pos.x;
		pos.z = psDel->pos.y;
		pos.y = map_Height(pos.x,pos.z);
		addEffect(&pos,EFFECT_DESTRUCTION,DESTRUCTION_TYPE_FEATURE,false,NULL,0);

		//play sound
		// ffs gj
		if(psDel->psStats->subType == FEAT_SKYSCRAPER)
		{
			audio_PlayStaticTrack( psDel->pos.x, psDel->pos.y, ID_SOUND_BUILDING_FALL );
		}
		else
		{
			audio_PlayStaticTrack( psDel->pos.x, psDel->pos.y, ID_SOUND_EXPLOSION );
		}
	}

	if (psDel->psStats->subType == FEAT_SKYSCRAPER)
	{
		// ----- Flip all the tiles under the skyscraper to a rubble tile
		// smoke effect should disguise this happening
		mapX = map_coord(psDel->pos.x) - psDel->psStats->baseWidth/2;
		mapY = map_coord(psDel->pos.y) - psDel->psStats->baseBreadth/2;
		for (width = 0; width < psDel->psStats->baseWidth; width++)
		{
			for (breadth = 0; breadth < psDel->psStats->baseBreadth; breadth++)
			{
				MAPTILE *psTile = mapTile(mapX+width,mapY+breadth);
				// stops water texture chnaging for underwateer festures
				if (terrainType(psTile) != TER_WATER)
				{
					if (terrainType(psTile) != TER_CLIFFFACE)
					{
						/* Clear feature bits */
						psTile->texture = TileNumber_texture(psTile->texture) | RUBBLE_TILE;
					}
					else
					{
						/* This remains a blocking tile */
						psTile->psObject = NULL;
						auxClearBlocking(mapX + width, mapY + breadth, AIR_BLOCKED);  // Shouldn't remain blocking for air units, however.
						psTile->texture = TileNumber_texture(psTile->texture) | BLOCKING_RUBBLE_TILE;
					}
				}
			}
		}
	}

	removeFeature(psDel);
	return true;
}
示例#8
0
// -----------------------------------------------------------------
// Name : flash
// -----------------------------------------------------------------
void guiFrame::flash(float fFlashTime)
{
    guiFrameFlash * pEffect = new guiFrameFlash(FLASH_EFFECT_ID, fFlashTime);
    addEffect(pEffect);
    pEffect->setActive(true);
}
示例#9
0
// multiple turrets display removed the pointless mountRotation
void displayComponentObject(DROID *psDroid)
{
	Vector3i position, rotation;
	Spacetime st = interpolateObjectSpacetime(psDroid, graphicsTime);

	leftFirst = angleDelta(player.r.y - st.rot.direction) <= 0;

	/* Push the matrix */
	pie_MatBegin(true);

	/* Get the real position */
	position.x = st.pos.x - player.p.x;
	position.z = -(st.pos.y - player.p.z);
	position.y = st.pos.z;

	if (isTransporter(psDroid))
	{
		position.y += bobTransporterHeight();
	}

	/* Get all the pitch,roll,yaw info */
	rotation.y = -st.rot.direction;
	rotation.x = st.rot.pitch;
	rotation.z = st.rot.roll;

	/* Translate origin */
	pie_TRANSLATE(position.x, position.y, position.z);

	/* Rotate for droid */
	pie_MatRotY(rotation.y);
	pie_MatRotX(rotation.x);
	pie_MatRotZ(rotation.z);

	if (graphicsTime - psDroid->timeLastHit < GAME_TICKS_PER_SEC && psDroid->lastHitWeapon == WSC_ELECTRONIC)
	{
		objectShimmy((BASE_OBJECT *) psDroid);
	}

	if (psDroid->lastHitWeapon == WSC_EMP && graphicsTime - psDroid->timeLastHit < EMP_DISABLE_TIME)
	{
		Vector3i position;

		//add an effect on the droid
		position.x = st.pos.x + DROID_EMP_SPREAD;
		position.y = st.pos.z + rand() % 8;
		position.z = st.pos.y + DROID_EMP_SPREAD;
		effectGiveAuxVar(90 + rand() % 20);
		addEffect(&position, EFFECT_EXPLOSION, EXPLOSION_TYPE_PLASMA, false, NULL, 0);
	}

	if (psDroid->visible[selectedPlayer] == UBYTE_MAX)
	{
		//ingame not button object
		//should render 3 mounted weapons now
		displayCompObj(psDroid, false);
	}
	else
	{
		int frame = graphicsTime / BLIP_ANIM_DURATION + psDroid->id % 8192; // de-sync the blip effect, but don't overflow the int
		pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, WZCOL_WHITE, pie_ADDITIVE, psDroid->visible[selectedPlayer] / 2);
	}
	pie_MatEnd();
}
EffectManager::EffectManager()
{
	addEffect("SubEntity", "./media/effects/SimpleMeshEffect.vs", "./media/effects/SimpleMeshEffect.fs");
	addEffect("ParticleSystem", "./media/effects/ParticleEffect.vs", "./media/effects/ParticleEffect.fs");
}
示例#11
0
bool Condition::unserialize(PropStream& propStream)
{
	uint8_t attr_type;
	while(propStream.GET_UCHAR(attr_type) && attr_type != CONDITIONATTR_END.value()){

		if(attr_type == enums::CONDITIONATTRIBUTE_MECHANIC){
			int32_t value = 0;
			if(!propStream.GET_VALUE(value)){
				return false;
			}

			mechanicType = (MechanicType)value;
		}
		else if(attr_type == enums::CONDITIONATTRIBUTE_COMBAT){
			int32_t value = 0;
			if(!propStream.GET_VALUE(value)){
				return false;
			}

			combatType = (CombatType)value;
			return true;
		}
		else if(attr_type == enums::CONDITIONATTRIBUTE_TICKS){
			uint32_t value = 0;
			if(!propStream.GET_VALUE(value)){
				return false;
			}

			ticks = value;
		}
		else if(attr_type == enums::CONDITIONATTRIBUTE_NAME){
			std::string value;
			if(!propStream.GET_STRING(value)){
				return false;
			}

			name = value;
		}
		else if(attr_type == enums::CONDITIONATTRIBUTE_FLAGS){
			uint32_t value = 0;
			if(!propStream.GET_VALUE(value)){
				return false;
			}

			flags = value;
		}
		else if(attr_type == enums::CONDITIONATTRIBUTE_EFFECT){
			ConditionEffect effect;
			if(!effect.unserialize(propStream)){
				return false;
			}

			addEffect(effect);
		}
		else{
			return false;
		}
	}

	return true;
}
示例#12
0
bool EffectManager::editEffect(EffectsParameterList params, int duration, bool replaceEffect)
{
    int index = params.paramValue(QStringLiteral("kdenlive_ix")).toInt();
    QString tag =  params.paramValue(QStringLiteral("tag"));

    if (!params.paramValue(QStringLiteral("keyframes")).isEmpty() || replaceEffect || tag.startsWith(QLatin1String("ladspa")) || tag == QLatin1String("sox") || tag == QLatin1String("autotrack_rectangle")) {
        // This is a keyframe effect, to edit it, we remove it and re-add it.
        if (removeEffect(index, false)) {
            return addEffect(params, duration);
        }
    }

    // find filter
    int ct = 0;
    Mlt::Filter *filter = m_producer.filter(ct);
    while (filter) {
        if (filter->get_int("kdenlive_ix") == index) {
            break;
        }
        delete filter;
        ct++;
        filter = m_producer.filter(ct);
    }

    if (!filter) {
        qDebug() << "WARINIG, FILTER FOR EDITING NOT FOUND, ADDING IT! " << index << ", " << tag;
        // filter was not found, it was probably a disabled filter, so add it to the correct place...

        bool success = addEffect(params, duration);
        return success;
    }
    ct = 0;
    QString ser = filter->get("mlt_service");
    QList <Mlt::Filter *> filtersList;
    m_producer.lock();
    if (ser != tag) {
        // Effect service changes, delete effect and re-add it
        m_producer.detach(*filter);
        delete filter;
        // Delete all effects after deleted one
        filter = m_producer.filter(ct);
        while (filter) {
            if (filter->get_int("kdenlive_ix") > index) {
                filtersList.append(filter);
                m_producer.detach(*filter);
            }
            else ct++;
            delete filter;
            filter = m_producer.filter(ct);
        }

        // re-add filter
        doAddFilter(params, duration);
        m_producer.unlock();
        return true;
    }
    if (params.hasParam(QStringLiteral("kdenlive:sync_in_out"))) {
        if (params.paramValue(QStringLiteral("kdenlive:sync_in_out")) == QLatin1String("1")) {
            // This effect must sync in / out with parent clip
            //params.removeParam(QStringLiteral("sync_in_out"));
            Mlt::Producer prod(m_producer);
            filter->set_in_and_out(prod.get_in(), prod.get_out());
        } else {
            // Reset in/out properties
            filter->set("in", (char*)NULL);
            filter->set("out", (char*)NULL);
        }
    }

    for (int j = 0; j < params.count(); ++j) {
        filter->set(params.at(j).name().toUtf8().constData(), params.at(j).value().toUtf8().constData());
    }

    for (int j = 0; j < filtersList.count(); ++j) {
        m_producer.attach(*(filtersList.at(j)));
    }
    qDeleteAll(filtersList);
    m_producer.unlock();
    delete filter;
    return true;
}
示例#13
0
文件: Box.cpp 项目: jordan13game/Game
bool Box::check(Box *other,int dir)
{
    int u,d,l,r;
    PlayLayer *pLayer = (PlayLayer *)pSprite->getParent();
    u=d=l=r=0;
    int px=x;
    int py=y;
    if (pLayer->m_toRemove->containsObject(pLayer->getBoxAtPosXY(px,py)))
    {
        return true;
    }
    if (combo_type == COMBO_TYPE_ALL && other != NULL)
    {
        for (int i=0; i<GRID_WIDTH; i++)
        {
            for (int j=0; j<GRID_HEIGHT; j++)
            {
                Box *p = pLayer->getBoxAtPosXY(i,j);
                if (p->_type == other->_type)
                {
                    pLayer->addToRemove(p);
                }

            }

        }

        pLayer->addToRemove(this);
        return true;
    }

    for (int i = px + 1; i < GRID_WIDTH ; i++)
    {
        if (pLayer->getBoxAtPosXY(i,py)->_type == _type)
        {
            r++;
        }
        else break;
    }
    for (int i = px - 1; i >= 0 ; i--)
    {
        if (pLayer->getBoxAtPosXY(i,py)->_type == _type)
        {
            l++;
        }
        else break;
    }
    for (int i = py + 1; i < GRID_HEIGHT ; i++)
    {
        if (pLayer->getBoxAtPosXY(px,i)->_type == _type)
        {
            u++;
        }
        else break;
    }
    for (int i = py - 1; i >= 0 ; i--)
    {
        if (pLayer->getBoxAtPosXY(px,i)->_type == _type)
        {
            d++;
        }
        else break;
    }
    if ((l+r==4&&u+d==2)||(l+r==2&&u+d==4))
    {
        for (int i=0; i<GRID_WIDTH; i++)
        {
            for (int j=0; j<GRID_HEIGHT; j++)
            {
                pLayer->addToRemove(pLayer->getBoxAtPosXY(i,j));
            }

        }
        return true;
    }


    if ((l+r==3&&u+d==2)||(l+r==2&&u+d==3))
    {
        for (int i=-1; i<=1; i++)
        {
            for (int j=0; j<GRID_HEIGHT; j++)
            {
                pLayer->addToRemove(pLayer->getBoxAtPosXY(px+i,j));
            }
            for (int j=0; j<GRID_WIDTH; j++)
            {
                pLayer->addToRemove(pLayer->getBoxAtPosXY(j,py+i));
            }
        }
        return true;
    }

    if (l+r == 2 && u+d ==2)
    {
        for (int i=1; i<=r; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px+i,py));
        }
        for (int i=1; i<=l; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px-i,py));
        }
        for (int i=1; i<=u; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py+i));
        }
        for (int i=1; i<=d; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py-i));
        }
        addEffect(COMBO_TYPE_SQR);
        removeable = true;
        pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py));
        return true;
    }

    if (l+r >= 2 )
    {

        for (int i=1; i<=r; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px+i,py));
        }
        for (int i=1; i<=l; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px-i,py));
        }
        if (r+l>=4)
        {
            combo_type = COMBO_TYPE_ALL;
            _type = -2;
            pSprite->setTexture(CCTextureCache::sharedTextureCache()->addImage(BOX_NAME[8]));
            removeable = true;
        }
        else if (r+l==3)
        {
            addEffect(dir == HORIZON ? COMBO_TYPE_ROW : COMBO_TYPE_COL);
            removeable = true;
        }

        pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py));

        return true;
    }
    if (u+d >= 2 )
    {

        for (int i=1; i<=u; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py+i));
        }
        for (int i=1; i<=d; i++)
        {
            pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py-i));
        }

        if (u+d>=4)
        {
            combo_type = COMBO_TYPE_ALL;
            _type = -2;
            pSprite->setTexture(CCTextureCache::sharedTextureCache()->addImage(BOX_NAME[8]));
            removeable = true;
        }
        else if (u+d==3)
        {
            addEffect(dir == HORIZON ? COMBO_TYPE_ROW : COMBO_TYPE_COL);
            removeable = true;
        }
        pLayer->addToRemove(pLayer->getBoxAtPosXY(px,py));
        return true;
    }
    return false;
}
示例#14
0
void destroyFXDroid(DROID	*psDroid)
{
	UDWORD	i;
	iIMDShape	*psImd = NULL;
	SDWORD	widthScatter, breadthScatter, heightScatter;
	Vector3i pos;

	widthScatter = TILE_UNITS/4;
	breadthScatter = TILE_UNITS/4;
	heightScatter = TILE_UNITS/5;
	for(i=0; i<5; i++)
	{
		pos.x = psDroid->pos.x + widthScatter - rand()%(2*widthScatter);
		pos.z = psDroid->pos.y + breadthScatter - rand()%(2*breadthScatter);
		pos.y = psDroid->pos.z + 16 +heightScatter;
		switch(i)
		{
		case 0:
			switch(psDroid->droidType)
			{
			case DROID_DEFAULT:
			case DROID_CYBORG:
			case DROID_CYBORG_SUPER:
			case DROID_CYBORG_CONSTRUCT:
			case DROID_CYBORG_REPAIR:
			case DROID_WEAPON:
			case DROID_COMMAND:
				if (psDroid->numWeaps > 0)
				{
					if(psDroid->asWeaps[0].nStat > 0)
					{
						// Tell the effect system that it needs to use this player's color for the next effect
						SetEffectForPlayer(psDroid->player);
						psImd = WEAPON_MOUNT_IMD(psDroid, 0);
					}
				}
				else
				{
					psImd = getRandomDebrisImd();
				}
				break;
			default:
				psImd = getRandomDebrisImd();
				break;
			}
			break;
		case 1:
			switch(psDroid->droidType)
			{
			case DROID_DEFAULT:
			case DROID_CYBORG:
			case DROID_CYBORG_SUPER:
			case DROID_CYBORG_CONSTRUCT:
			case DROID_CYBORG_REPAIR:
			case DROID_WEAPON:
			case DROID_COMMAND:
				if(psDroid->numWeaps)
				{
					// get main weapon
					psImd = WEAPON_IMD(psDroid, 0);
				}
				else
				{
					psImd = getRandomDebrisImd();
				}
				break;
			default:
				psImd = getRandomDebrisImd();
				break;
			}
			break;
		case 2:
		case 3:
		case 4:
			psImd = getRandomDebrisImd();
			break;
		}
		if(psImd)
		{
			addEffect(&pos,EFFECT_GRAVITON,GRAVITON_TYPE_EMITTING_DR,true,psImd,getPlayerColour(psDroid->player));
		}
		else
		{
			addEffect(&pos,EFFECT_GRAVITON,GRAVITON_TYPE_EMITTING_DR,true,getRandomDebrisImd(),0);
		}
	}
}
 void addNumEntry(const char* label, float* zone, float init, float min, float max, float step) {
   addEffect(label, zone, min, init, max); // The INT effect format might not work. Need to go through the code first.
 }
示例#16
0
void SpellDiagramNode::setDiagram( int diagram )
{
	if( diagram >= m_spellDiagrams.size() )
		return; //out of bounds

	m_type = diagram;

	Json::Value& spellDiagram = m_spellDiagrams[m_type];
	Json::Value& effects = spellDiagram["effects"];
	Json::Value& mods = spellDiagram["mods"];

	prepareDiagram(effects.size(), mods.size());
	for( int i=0; i< effects.size(); i++)
	{
		float level = effects[i]["level"].asDouble();
		float x = effects[i]["x"].asDouble();
		float y = effects[i]["y"].asDouble();
		addEffect(i, size*x,size*y, level);
	}
	for( int i=0; i< mods.size(); i++)
	{
		float level = mods[i]["level"].asDouble();
		float x = mods[i]["x"].asDouble();
		float y = mods[i]["y"].asDouble();
		addMod(i, size*x,size*y, level);
	}


	/*
	CCDrawNode* pt = NULL;
	switch( m_type ) {


	case SD_05_SERPENTS_EYE:
		prepareDiagram(2,4);
		addEffect(0, -size*0.25,0, 3);
		addEffect(1,  size*0.25,0, 3);
		addMod(0, seT.x,seT.y, 3);
		addMod(1, seB.x,seB.y, 3);
		addMod(2, -size*0.5,0, 2);
		addMod(3,  size*0.5,0, 2);
		break;

	case SD_06_LESSER_TRIQUESTRA:
		prepareDiagram(4,6);
		addEffect(0, 0,size*0.02, 3);
		addEffect(1, 0,size*0.25, 3);
		addEffect(2, -size*0.25,-size*0.1, 3);
		addEffect(3,  size*0.25,-size*0.1, 3);
		addMod(0, -size*0.1667,size*0.1, 4);
		addMod(1,  size*0.1667,size*0.1, 4);
		addMod(2,  0,-size*0.15, 4);
		addMod(3, tA.x,tA.y, 2);
		addMod(4, tB.x,tB.y, 2);
		addMod(5, tC.x,tC.y, 2);
		break;

	case SD_07_COMPASS:
		prepareDiagram(4,5);
		addEffect(0, -size*0.25, size*0.25, 3);
		addEffect(1,  size*0.25, size*0.25, 3);
		addEffect(2,  size*0.25,-size*0.25, 3);
		addEffect(3, -size*0.25,-size*0.25, 3);

		addMod(0, 0,0, 4);
		addMod(1, 0, size*0.5, 3);
		addMod(2, size*0.5,0, 3);
		addMod(3, 0,-size*0.5, 3);
		addMod(4, -size*0.5,0, 3);
		break;

	case SD_08_FORTRESS:
		prepareDiagram(1,4);
		addEffect(0, 0,0, 4);
		addMod(0, -size*0.5, size*0.5, 2);
		addMod(1,  size*0.5, size*0.5, 2);
		addMod(2,  size*0.5,-size*0.5, 2);
		addMod(3, -size*0.5,-size*0.5, 2);
		break;

	case SD_09_DRAGONS_EYE:
		prepareDiagram(3,4);
		addEffect(0, 0,0, 2);
		addEffect(1, -size*0.375,0, 2);
		addEffect(2,  size*0.375,0, 2);

		addMod(0, seT.x,seT.y, 4);
		addMod(1, seB.x,seB.y, 4);
		addMod(2, -size*0.5,0, 2);
		addMod(3,  size*0.5,0, 2);
		break;

	case SD_10_SEEING_EYE:
		prepareDiagram(3,2);
		addEffect(0, 0,0, 2);
		addEffect(1, 0, size*0.375, 2);
		addEffect(2, 0,-size*0.375, 2);


		addMod(0, -size*0.5,0, 2);
		addMod(1,  size*0.5,0, 2);
		break;

	case SD_11_LEAF:
		prepareDiagram(6,7);
		addEffect(0, -size*0.075,size*0.02, 3);
		addEffect(1, -size*0.075,size*0.25, 3);
		addEffect(2,  size*0.075,size*0.02, 3);
		addEffect(3,  size*0.075,size*0.25, 3);
		addEffect(4, -size*0.25,-size*0.1, 3);
		addEffect(5,  size*0.25,-size*0.1, 3);
		addMod(0, -size*0.1667,size*0.1, 4);
		addMod(1,  size*0.1667,size*0.1, 4);
		addMod(2, 0,-size*0.15, 4);
		addMod(3, 0,size*0.15, 2);
		addMod(4, tA.x,tA.y, 2);
		addMod(5, tB.x,tB.y, 2);
		addMod(6, tC.x,tC.y, 2);

		break;
	
	case SD_12_GREATER_PYRAMID:
		prepareDiagram(4,3);
		addEffect(0, 0,0, 3);
		addEffect(1, -size*0.3,size*0.20, 3);
		addEffect(2,  size*0.3,size*0.20, 3);
		addEffect(3,  0,-size*0.35, 3);
		addMod(0, tA.x,tA.y, 4);
		addMod(1, tB.x,tB.y, 4);
		addMod(2, tC.x,tC.y, 4);
		break;

	case SD_13_GREATER_TRIQUETRA:
		prepareDiagram(7,6);
		addEffect(0, 0,size*0.02, 3);
		addEffect(1, 0,size*0.25, 3);
		addEffect(2, -size*0.25,-size*0.1, 3);
		addEffect(3,  size*0.25,-size*0.1, 3);


		addEffect(4, -size*0.3,size*0.20, 3);
		addEffect(5,  size*0.3,size*0.20, 3);
		addEffect(6,  0,-size*0.35, 3);

		addMod(0, -size*0.1667,size*0.1, 4);
		addMod(1,  size*0.1667,size*0.1, 4);
		addMod(2,  0,-size*0.15, 4);
		addMod(3, tA.x,tA.y, 4);
		addMod(4, tB.x,tB.y, 4);
		addMod(5, tC.x,tC.y, 4);
		break;

	default:
		prepareDiagram(0,0);
	}
	*/

	JsonEvent* evt = new JsonEvent("spellEditorUpdate");
	evt->json = getSpellDiagramJson();
	EventBus::game()->dispatch("spellEditorUpdate", evt);

}
示例#17
0
void CollapsibleGroup::dropEvent(QDropEvent *event)
{
    frame->setProperty("target", false);
    frame->setStyleSheet(frame->styleSheet());
    const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
    //event->acceptProposedAction();
    QDomDocument doc;
    doc.setContent(effects, true);
    QDomElement e = doc.documentElement();
    int ix = e.attribute("kdenlive_ix").toInt();
    if (ix == 0 || e.tagName() == "effectgroup") {
	if (e.tagName() == "effectgroup") {
	    // dropped a group on another group
	    QDomNodeList pastedEffects = e.elementsByTagName("effect");
	    if (pastedEffects.isEmpty() || m_subWidgets.isEmpty()) {
		// Buggy groups, should not happen
		event->ignore();
		return;
	    }
	    QList <int> pastedEffectIndexes;
	    QList <int> currentEffectIndexes;
	    EffectInfo pasteInfo;
	    pasteInfo.fromString(pastedEffects.at(0).toElement().attribute("kdenlive_info"));
	    if (pasteInfo.groupIndex == -1) {
		// Group dropped from effects list, add effect
		e.setAttribute("kdenlive_ix", m_subWidgets.last()->effectIndex());
		emit addEffect(e);
		event->setDropAction(Qt::CopyAction);
		event->accept();
		return;
	    }
	    // Moving group
	    for (int i = 0; i < pastedEffects.count(); i++) {
		pastedEffectIndexes << pastedEffects.at(i).toElement().attribute("kdenlive_ix").toInt();
	    }
	    for (int i = 0; i < m_subWidgets.count(); i++) {
		currentEffectIndexes << m_subWidgets.at(i)->effectIndex();
	    }
	    kDebug()<<"PASTING: "<<pastedEffectIndexes<<" TO "<<currentEffectIndexes;
	    if (pastedEffectIndexes.at(0) < currentEffectIndexes.at(0)) {
		// Pasting group after current one:
		emit moveEffect(pastedEffectIndexes, currentEffectIndexes.last(), pasteInfo.groupIndex, pasteInfo.groupName);
	    }
	    else {
		// Group moved before current one
		emit moveEffect(pastedEffectIndexes, currentEffectIndexes.first(), pasteInfo.groupIndex, pasteInfo.groupName);
	    }
	    event->setDropAction(Qt::MoveAction);
	    event->accept();
	    return;
	}
	// effect dropped from effects list, add it
	e.setAttribute("kdenlive_info", m_info.toString());
	if (!m_subWidgets.isEmpty()) {
	    e.setAttribute("kdenlive_ix", m_subWidgets.at(0)->effectIndex());
	}
	emit addEffect(e);
	event->setDropAction(Qt::CopyAction);
	event->accept();
	return;
    }
    if (m_subWidgets.isEmpty()) return;
    int new_index = m_subWidgets.last()->effectIndex();
    emit moveEffect(QList <int> () <<ix, new_index, m_info.groupIndex, m_title->text());
    event->setDropAction(Qt::MoveAction);
    event->accept();
}
示例#18
0
/* Moves one of the particles */
static void processParticle(ATPART *psPart)
{
	SDWORD	groundHeight;
	Vector3i pos;
	UDWORD	x, y;
	MAPTILE	*psTile;

	/* Only move if the game isn't paused */
	if (!gamePaused())
	{
		/* Move the particle - frame rate controlled */
		psPart->position.x += graphicsTimeAdjustedIncrement(psPart->velocity.x);
		psPart->position.y += graphicsTimeAdjustedIncrement(psPart->velocity.y);
		psPart->position.z += graphicsTimeAdjustedIncrement(psPart->velocity.z);

		/* Wrap it around if it's gone off grid... */
		testParticleWrap(psPart);

		/* If it's gone off the WORLD... */
		if (psPart->position.x < 0 || psPart->position.z < 0 ||
		    psPart->position.x > ((mapWidth - 1)*TILE_UNITS) ||
		    psPart->position.z > ((mapHeight - 1)*TILE_UNITS))
		{
			/* The kill it */
			psPart->status = APS_INACTIVE;
			return;
		}

		/* What height is the ground under it? Only do if low enough...*/
		if (psPart->position.y < 255 * ELEVATION_SCALE)
		{
			/* Get ground height */
			groundHeight = map_Height(psPart->position.x, psPart->position.z);

			/* Are we below ground? */
			if ((int)psPart->position.y < groundHeight
			    || psPart->position.y < 0.f)
			{
				/* Kill it and return */
				psPart->status = APS_INACTIVE;
				if (psPart->type == AP_RAIN)
				{
					x = map_coord(psPart->position.x);
					y = map_coord(psPart->position.z);
					psTile = mapTile(x, y);
					if (terrainType(psTile) == TER_WATER && TEST_TILE_VISIBLE(selectedPlayer, psTile))
					{
						pos.x = psPart->position.x;
						pos.z = psPart->position.z;
						pos.y = groundHeight;
						effectSetSize(60);
						addEffect(&pos, EFFECT_EXPLOSION, EXPLOSION_TYPE_SPECIFIED, true, getImdFromIndex(MI_SPLASH), 0);
					}
				}
				return;
			}
		}
		if (psPart->type == AP_SNOW)
		{
			if (rand() % 30 == 1)
			{
				psPart->velocity.z = (float)SNOW_SPEED_DRIFT;
			}
			if (rand() % 30 == 1)
			{
				psPart->velocity.x = (float)SNOW_SPEED_DRIFT;
			}
		}
	}
}
示例#19
0
// free up a feature with no visual effects
bool removeFeature(FEATURE *psDel)
{
	int		mapX, mapY, width, breadth, player;
	MESSAGE		*psMessage;
	Vector3i	pos;

	ASSERT_OR_RETURN(false, psDel != NULL, "Invalid feature pointer");
	ASSERT_OR_RETURN(false, !psDel->died, "Feature already dead");

	if(bMultiMessages && !ingame.localJoiningInProgress)
	{
		SendDestroyFeature(psDel);	// inform other players of destruction
		return true;  // Wait for our message before really destroying the feature.
	}

	//remove from the map data
	mapX = map_coord(psDel->pos.x) - psDel->psStats->baseWidth/2;
	mapY = map_coord(psDel->pos.y) - psDel->psStats->baseBreadth/2;
	for (width = 0; width < psDel->psStats->baseWidth; width++)
	{
		for (breadth = 0; breadth < psDel->psStats->baseBreadth; breadth++)
		{
			if (tileOnMap(mapX + width, mapY + breadth))
			{
				MAPTILE *psTile = mapTile(mapX + width, mapY + breadth);
	 
				if (psTile->psObject == (BASE_OBJECT *)psDel)
				{
					psTile->psObject = NULL;
					auxClearBlocking(mapX + width, mapY + breadth, FEATURE_BLOCKED | AIR_BLOCKED);
				}
			}
		}
	}

	if (psDel->psStats->subType == FEAT_GEN_ARTE || psDel->psStats->subType == FEAT_OIL_DRUM)
	{
		pos.x = psDel->pos.x;
		pos.z = psDel->pos.y;
		pos.y = map_Height(pos.x, pos.z) + 30;
		addEffect(&pos,EFFECT_EXPLOSION,EXPLOSION_TYPE_DISCOVERY,false,NULL,0);
		if (psDel->psStats->subType == FEAT_GEN_ARTE)
		{
			scoreUpdateVar(WD_ARTEFACTS_FOUND);
			intRefreshScreen();
		}
	}

	if (psDel->psStats->subType == FEAT_GEN_ARTE || psDel->psStats->subType == FEAT_OIL_RESOURCE)
	{
		for (player = 0; player < MAX_PLAYERS; player++)
		{
			psMessage = findMessage((MSG_VIEWDATA *)psDel, MSG_PROXIMITY, player);
			while (psMessage)
			{
				removeMessage(psMessage, player);
				psMessage = findMessage((MSG_VIEWDATA *)psDel, MSG_PROXIMITY, player);
			}
		}
	}

	debug(LOG_DEATH, "Killing off feature %s id %d (%p)", objInfo(psDel), psDel->id, psDel);
	killFeature(psDel);

	return true;
}
示例#20
0
// ////////////////////////////////////////////////////////////////////////////
// throw a party when you win!
bool multiplayerWinSequence(bool firstCall)
{
	static Position pos;
	Position pos2;
	static UDWORD last=0;
	float		rotAmount;
	STRUCTURE	*psStruct;

	if(firstCall)
	{
		pos  = cameraToHome(selectedPlayer,true);			// pan the camera to home if not already doing so
		last =0;

		// stop all research
		CancelAllResearch(selectedPlayer);

		// stop all manufacture.
		for(psStruct=apsStructLists[selectedPlayer];psStruct;psStruct = psStruct->psNext)
		{
			if (StructIsFactory(psStruct))
			{
				if (((FACTORY *)psStruct->pFunctionality)->psSubject)//check if active
				{
					cancelProduction(psStruct, ModeQueue);
				}
			}
		}
	}

	// rotate world
	if (MissionResUp && !getWarCamStatus())
	{
		rotAmount = graphicsTimeAdjustedIncrement(MAP_SPIN_RATE / 12);
		player.r.y += rotAmount;
	}

	if(last > gameTime)last= 0;
	if((gameTime-last) < 500 )							// only  if not done recently.
	{
		return true;
	}
	last = gameTime;

	if(rand()%3 == 0)
	{
		pos2=pos;
		pos2.x +=  (rand() % world_coord(8)) - world_coord(4);
		pos2.z +=  (rand() % world_coord(8)) - world_coord(4);

		if (pos2.x < 0)
			pos2.x = 128;

		if ((unsigned)pos2.x > world_coord(mapWidth))
			pos2.x = world_coord(mapWidth);

		if (pos2.z < 0)
			pos2.z = 128;

		if ((unsigned)pos2.z > world_coord(mapHeight))
			pos2.z = world_coord(mapHeight);

		addEffect(&pos2,EFFECT_FIREWORK,FIREWORK_TYPE_LAUNCHER,false,NULL,0);	// throw up some fire works.
	}

	// show the score..


	return true;
}
 void addToggleButton(const char* label, float* zone) {
   addEffect(label, zone, 0, 0, 1);
 }
示例#22
0
// multiple turrets display removed the pointless mountRotation
void displayComponentObject(DROID *psDroid, const glm::mat4 &viewMatrix)
{
	Vector3i position, rotation;
	Spacetime st = interpolateObjectSpacetime(psDroid, graphicsTime);

	leftFirst = angleDelta(player.r.y - st.rot.direction) <= 0;

	/* Get the real position */
	position.x = st.pos.x - player.p.x;
	position.z = -(st.pos.y - player.p.z);
	position.y = st.pos.z;

	if (isTransporter(psDroid))
	{
		position.y += bobTransporterHeight();
	}

	/* Get all the pitch,roll,yaw info */
	rotation.y = -st.rot.direction;
	rotation.x = st.rot.pitch;
	rotation.z = st.rot.roll;

	/* Translate origin */
	/* Rotate for droid */
	glm::mat4 modelMatrix = glm::translate(glm::vec3(position)) *
		glm::rotate(UNDEG(rotation.y), glm::vec3(0.f, 1.f, 0.f)) *
		glm::rotate(UNDEG(rotation.x), glm::vec3(1.f, 0.f, 0.f)) *
		glm::rotate(UNDEG(rotation.z), glm::vec3(0.f, 0.f, 1.f));

	if (graphicsTime - psDroid->timeLastHit < GAME_TICKS_PER_SEC && psDroid->lastHitWeapon == WSC_ELECTRONIC)
	{
		modelMatrix *= objectShimmy((BASE_OBJECT *) psDroid);
	}

	// now check if the projected circle is within the screen boundaries
	if(!clipDroidOnScreen(psDroid, viewMatrix * modelMatrix))
	{
		return;
	}

	if (psDroid->lastHitWeapon == WSC_EMP && graphicsTime - psDroid->timeLastHit < EMP_DISABLE_TIME)
	{
		Vector3i position;

		//add an effect on the droid
		position.x = st.pos.x + DROID_EMP_SPREAD;
		position.y = st.pos.z + rand() % 8;
		position.z = st.pos.y + DROID_EMP_SPREAD;
		effectGiveAuxVar(90 + rand() % 20);
		addEffect(&position, EFFECT_EXPLOSION, EXPLOSION_TYPE_PLASMA, false, nullptr, 0);
	}

	if (psDroid->visible[selectedPlayer] == UBYTE_MAX)
	{
		//ingame not button object
		//should render 3 mounted weapons now
		if (displayCompObj(psDroid, false, viewMatrix * modelMatrix))
		{
			// did draw something to the screen - update the framenumber
			psDroid->sDisplay.frameNumber = frameGetFrameNumber();
		}
	}
	else
	{
		int frame = graphicsTime / BLIP_ANIM_DURATION + psDroid->id % 8192; // de-sync the blip effect, but don't overflow the int
		if (pie_Draw3DShape(getImdFromIndex(MI_BLIP), frame, 0, WZCOL_WHITE, pie_ADDITIVE, psDroid->visible[selectedPlayer] / 2, viewMatrix * modelMatrix))
		{
			psDroid->sDisplay.frameNumber = frameGetFrameNumber();
		}
	}
}
 void addVerticalSlider(const char* label, float* zone, float init, float min, float max, float step) {
   addEffect(label, zone,  min, init, max);
 }
示例#24
0
void EffectsListView::slotEffectSelected()
{
    QDomElement effect = m_effectsList->currentEffect().cloneNode().toElement();
    if (!effect.isNull()) emit addEffect(effect);
}