public void Reset(AntEmitter aEmitter) { var center = _transform.position; var spawn = Preset.position; center.x = spawn.position.x + AntMath.RandomRangeFloat(spawn.rndToPositionX); center.y = spawn.position.y + AntMath.RandomRangeFloat(spawn.rndToPositionY); float lowerAngle = spawn.initialAngle + spawn.lowerAngle; float upperAngle = spawn.initialAngle + spawn.upperAngle; if (spawn.inheritRotation) { center = AntMath.RotatePointDeg(center, Vector2.zero, _particle.Effect.Angle); lowerAngle += _particle.Effect.Angle; upperAngle += _particle.Effect.Angle; } center.x += _particle.Effect.Position.x; center.y += _particle.Effect.Position.y; var pos = Vector2.zero; float curAngle; float dist = spawn.distance + AntMath.RandomRangeFloat(spawn.rndToDistance); if (spawn.strongOrder && spawn.countParticles > 0) { aEmitter.SpawnCount++; float step = Mathf.DeltaAngle(lowerAngle, upperAngle) / (spawn.countParticles - 1); curAngle = (lowerAngle + (step * aEmitter.SpawnCount)) * AntMath.RADIANS; pos.x = center.x + dist * Mathf.Cos(curAngle); pos.y = center.y + dist * Mathf.Sin(curAngle); if (aEmitter.SpawnCount >= spawn.countParticles) { aEmitter.SpawnCount = 0; } } else { curAngle = AntMath.RandomRangeFloat(lowerAngle, upperAngle) * AntMath.RADIANS; pos.x = center.x + dist * Mathf.Cos(curAngle); pos.y = center.y + dist * Mathf.Sin(curAngle); } if (spawn.rotate) { Angle = curAngle * AntMath.DEGREES; } _transform.position = pos; IsActive = false; // Выкл. обработку компонента. }
public void Process(float aDeltaTime) { if (_isPlaying) { if (_settings.isUpdatePosition) { _offset = _positionOffset; if (_positionOffset != Vector2.zero) { _offset = AntMath.RotatePointDeg(_positionOffset, _zeroPivot, _transform.rotation.eulerAngles.z); } _offset.x += _transform.position.x; _offset.y += _transform.position.y; _effect.Position = _offset; } if (_settings.isInheritAngle) { _effect.Angle = _transform.rotation.eulerAngles.z + _angle; } } }