public void RemoveTransform(int index) { if (index >= 0 && index < LocalTransforms.Count) { LocalTransforms.RemoveAt(index); Rotations.RemoveAt(index); Tints.RemoveAt(index); } Primitive = new BatchBillboardPrimitive(graphicsDevice, SpriteSheet.GetTexture(), Width, Height, Frame, 1.0f, 1.0f, false, LocalTransforms, Tints, Colors); }
public void AddTransform(Matrix transform, float rotation, Color tint, Color color, bool rebuild) { LocalTransforms.Add(transform * Matrix.Invert(GlobalTransform)); Rotations.Add(rotation); Tints.Add(tint); Colors.Add(color); if (rebuild) { RebuildPrimitive(); } }
protected bool Equals(Frame otherFrame) { if (Layers.Count != otherFrame.Layers.Count || Tints.Count != otherFrame.Tints.Count) { return(false); } if (!Position.Equals(otherFrame.Position)) { return(false); } if (Layers.Where((t, i) => !t.Equals(otherFrame.Layers[i])).Any()) { return(false); } if (Tints.Where((t, i) => !t.Equals(otherFrame.Tints[i])).Any()) { return(false); } return(true); }
private void CreateBurst() { if (ParticleRegistrationCallback != null) { // Check if we have not set up any tints/fadepoints/emission offsets and put in some defaults if we have not if (Tints.Count < 1) { Tints.Add(Color.White); } if (_sortedFadePoints.Count < 1) { if (_fadePoints != null) { _sortedFadePoints = _fadePoints.OrderBy(fp => fp.X).ToList(); } else { _sortedFadePoints.Add(new Vector2(0.0f, 1.0f)); _sortedFadePoints.Add(new Vector2(1.0f, 0.0f)); } } if (EmissionPointOffsets.Count < 1) { EmissionPointOffsets.Add(Vector2.Zero); } for (int i = 0; i < _particlesPerBurst; i++) { Particle newParticle = new Particle(); newParticle.Duration = _lifespanRange.RandomValue; newParticle.WorldPosition = WorldPosition + EmissionPointOffsets[(int)Random.Generator.Next(EmissionPointOffsets.Count)]; newParticle.CameraPosition = CameraPosition; newParticle.Texture = ParticleTexture; newParticle.Frame = ParticleTexture.Bounds; newParticle.Origin = new Vector2(ParticleTexture.Width, ParticleTexture.Height) / 2.0f; newParticle.RenderDepth = RenderDepth; newParticle.Tint = Tints[(int)Random.Generator.Next(Tints.Count)] * _sortedFadePoints[0].Y; newParticle.FadePoints = _sortedFadePoints; newParticle.Visible = true; newParticle.Direction = Direction + Random.Generator.Next(-Spread, Spread); newParticle.Gravity = _gravity; newParticle.GravityAccelerator = _gravityAccelerator; newParticle.Speed = _speedLaunchRange.RandomValue; newParticle.SpeedDelta = _speedDeltaRange.RandomValue; newParticle.SpeedAccelerator = _speedAcceleratorRange.RandomValue; newParticle.Rotation = _rotationLaunchRange.RandomValue; newParticle.RotationDelta = _rotationDeltaRange.RandomValue; newParticle.RotationAccelerator = _rotationAcceleratorRange.RandomValue; newParticle.Scale = _scaleLaunchRange.RandomValue; newParticle.ScaleDelta = _scaleDeltaRange.RandomValue; newParticle.ScaleAccelerator = _scaleDeltaRange.RandomValue; ParticleRegistrationCallback(newParticle); } _burstCount = Math.Max(-1, _burstCount - 1); if ((_burstCount != 0) && (_timerRegistered)) { _burstTimer.NextActionDuration = _burstIntervalInMilliseconds; } } }