예제 #1
0
void EnemySpawner::spawnCountOfEnemy(const SpawnerInfo& enemyToSpawnNow, GameData * _gameData )
{
	for(int i = enemyToSpawnNow.amount; i > 0; i --)
	{
		//EnemyCollection& enemysColl = _gameData->getEnemys();
		BaseCollection<ShipPrefab, EnemyObject>& enemiesCollection = _gameData->getEnemies();
		EnemyObject * tmpEnemy = _gameData->instantiateEnemy(enemyToSpawnNow.prefabID, AI_TYPE::fighter);
		Vector3 newPosition = myPosition + Vector3(200.0*(i-1), 0.0, 0.0);
		tmpEnemy->setPosition(newPosition);
		EffectObject * spawnEffect = _gameData->instantiateEffect(enemyToSpawnNow.spawnEffectID);
		spawnEffect->setPosition(newPosition);
	}
}
예제 #2
0
void LoginLayerUC::initLoadingEffect()
{
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("skill/loading.plist");
	AnimationManager::sharedAction()->ParseAnimation("loading");

	//loading贴图
	EffectObject* pLoadEffect = EffectObject::create("loading", BattleSpace::sPlayType::eRepeat);
	pLoadEffect->setPosition(VCENTER);
	pLoadEffect->setEffAnchorPoint(0.5f,0.5f);
	pLoadEffect->setScale(0.6f);
	this->addChild(pLoadEffect, 999);
	m_pLoading = pLoadEffect;
	m_pLoading->setVisible(false);
}
void ObjectStateUpdateSystem::createExplosionFor( GameObject_WithCollider * removedObject, GameData& mGameData )
{
	GameObjectType objectType = removedObject->getType();
	if (objectType == GameObjectType::effectObject)
	{
		return;
	}
	unsigned effectId = removedObject->getExpolsionEffectID();
	if (effectId == 0)
	{
		return; // Some objects may not have own explosion effect
	}
	EffectObject * effect = mGameData.instantiateEffect(effectId);
	effect->setPosition(removedObject->getPosition());
	effect->setOrientation(removedObject->getOrientation());
	return;
}
void ObjectStateUpdateSystem::updateObjectWithTTL( GameData &mGameData, TimeData &time )
{
	//deleting bullets when time to Live is up.
	GameCollectionIterator<Bullet> bulletIterator = mGameData.getBullets().getIterator();
	Bullet* bulletIt;
	while (bulletIterator.hasNext())
	{
		bulletIt = bulletIterator.getNext();

		bulletIt->getTTLComponent().decreaseTimeToLive(time.deltaTime);

	}



	GameCollectionIterator<EffectObject> effectIterator = mGameData.getEffects().getIterator();
	EffectObject* effectIt;
	while (effectIterator.hasNext())
	{
		effectIt = effectIterator.getNext();

		effectIt->getTTLComponent().decreaseTimeToLive(time.deltaTime);
	}
}
예제 #5
0
	KVOID BulletFactor::BindEffect( PropertySet kProp )
	{
		//////////////////////////////////////////////////////////////////////////
		// 加载特效
		KSTR sEffect;
		if (kProp.GetStrValue("$SpawnEffect",sEffect))
		{
			KFLOAT fTimes = -1.0f;
			kProp.GetFloatValue("$SpawnEffectTime",fTimes);

			EffectObject* pObj = AttachEffect(sEffect,fTimes);
			if (pObj)
			{	// 设置特效缩放
				KFLOAT fEfScale;
				if (kProp.GetFloatValue("$SpawnEffectScale",fEfScale))
				{
					pObj->SetScale(fEfScale);
				}
				pObj->SetUserData(1);
				pObj->SetCallbackObj(this);
			}
		}
		if (kProp.GetStrValue("$IdleEffect",sEffect))
		{
			KFLOAT fTimes = -1.0f;
			kProp.GetFloatValue("$IdleEffectTime",fTimes);

			EffectObject* pObj = AttachEffect(sEffect,fTimes);
			if (pObj)
			{	// 设置特效缩放
				KFLOAT fEfScale;
				if (kProp.GetFloatValue("$IdleEffectScale",fEfScale))
				{
					pObj->SetScale(fEfScale);
				}
				pObj->SetUserData(2);
				pObj->SetCallbackObj(this);
			}
		}
		if (kProp.GetStrValue("$DestroyEffect",sEffect))
		{
			KFLOAT fTimes = -1.0f;
			kProp.GetFloatValue("$DestroyEffectTime",fTimes);

			EffectObject* pObj = AttachEffect(sEffect,fTimes);
			if (pObj)
			{	// 设置特效缩放
				KFLOAT fEfScale;
				if (kProp.GetFloatValue("$DestroyEffectScale",fEfScale))
				{
					pObj->SetScale(fEfScale);
				}

				pObj->SetUserData(3);
				pObj->SetCallbackObj(this);
			}
		}
	}