本文整理汇总了C#中ParticleEmitter.EmitParticles方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleEmitter.EmitParticles方法的具体用法?C# ParticleEmitter.EmitParticles怎么用?C# ParticleEmitter.EmitParticles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter.EmitParticles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpawnNew
/// <inheritdoc />
public override void SpawnNew(float dt, ParticleEmitter emitter)
{
var spawnerState = GetUpdatedState(dt, emitter);
if (spawnerState != SpawnerState.Active)
{
hasBegun = false;
return;
}
if (!hasBegun)
{
hasBegun = true;
oldPosition = emitter.CachedParticleSystem.Translation;
return;
}
var totalDistance = (emitter.CachedParticleSystem.Translation - oldPosition).Length();
oldPosition = emitter.CachedParticleSystem.Translation;
var toSpawn = spawnCount * totalDistance + carryOver;
var integerPart = (int)Math.Floor(toSpawn);
carryOver = toSpawn - integerPart;
emitter.EmitParticles(integerPart);
}
示例2: TestEmitter
public void TestEmitter()
{
var dummySystem = new ParticleSystem();
var emitter = new ParticleEmitter();
emitter.MaxParticlesOverride = 10;
emitter.ParticleLifetime = new Vector2(1, 1);
emitter.EmitParticles(5);
emitter.Update(0.016f, dummySystem);
Assert.That(emitter.LivingParticles, Is.EqualTo(5));
}
示例3: SpawnNew
/// <inheritdoc />
public override void SpawnNew(float dt, ParticleEmitter emitter)
{
var spawnerState = GetUpdatedState(dt, emitter);
if (spawnerState != SpawnerState.Active)
return;
var toSpawn = spawnCount * dt + carryOver;
var integerPart = (int)Math.Floor(toSpawn);
carryOver = toSpawn - integerPart;
emitter.EmitParticles(integerPart);
}
示例4: SpawnNew
/// <inheritdoc />
public unsafe override void SpawnNew(float dt, ParticleEmitter emitter)
{
if (isParentNameDirty)
{
RemoveControlGroup();
Parent = emitter.CachedParticleSystem?.GetEmitterByName(ParentName);
AddControlGroup();
isParentNameDirty = false;
}
var spawnerState = GetUpdatedState(dt, emitter);
if (spawnerState != SpawnerState.Active)
return;
// Get parent pool
if (Parent == null) return;
var parentPool = Parent.Pool;
var parentParticlesCount = parentPool.LivingParticles;
if (parentParticlesCount == 0) return;
var spawnControlGroup = GetSpawnControlField();
if (!spawnControlGroup.IsValid())
return;
ParticleSpawnTrigger?.PrepareFromPool(parentPool);
var randomSeedFieldParent = parentPool.GetField(ParticleFields.RandomSeed);
int totalParticlesToEmit = 0;
foreach (var parentParticle in parentPool)
{
uint particlesToEmit = 0;
ParticleChildrenAttribute childrenAttribute = (*((ParticleChildrenAttribute*)parentParticle[spawnControlGroup]));
var carryOver = childrenAttribute.CarryOver;
var parentEventTriggered = ParticleSpawnTrigger?.HasTriggered(parentParticle) ?? 0f;
if (parentEventTriggered > 0)
{
var particlesToEmitFloat = SpawnCount.X;
if (randomSeedFieldParent.IsValid())
{
var randSeed = parentParticle.Get(randomSeedFieldParent);
particlesToEmitFloat = (SpawnCount.X + (SpawnCount.Y - SpawnCount.X) * randSeed.GetFloat(0));
}
particlesToEmitFloat *= parentEventTriggered;
particlesToEmit = (uint) Math.Floor(particlesToEmitFloat + carryOver);
carryOver += (particlesToEmitFloat - particlesToEmit);
}
childrenAttribute.CarryOver = carryOver;
childrenAttribute.ParticlesToEmit = particlesToEmit;
totalParticlesToEmit += (int)particlesToEmit;
(*((ParticleChildrenAttribute*)parentParticle[spawnControlGroup])) = childrenAttribute;
}
emitter.EmitParticles(totalParticlesToEmit);
}