public BackgroundParticle(BackgroundParticle source, float px, float py, Direction4 dir) { OriginX = source.OriginX; OriginY = source.OriginY; X = px; Y = py; Fraction = source.Fraction; RemainingPower = source.RemainingPower - 1; Direction = dir; }
private void AddParticle(BackgroundParticle p, int x, int y, bool ignoreBlockedSpawns = false) { if (p.RemainingPower <= 0) return; if (blockedGridPoints[x, y].Any() && !ignoreBlockedSpawns) return; switch (p.Direction) { case Direction4.North: if (y <= 0) return; p.TravelSection = particlesVertical[x, y - 1]; p.TravelSection.Add(p); break; case Direction4.East: if (x >= TILE_COUNT_X) return; p.TravelSection = particlesHorizontal[x, y]; p.TravelSection.Add(p); break; case Direction4.South: if (y >= TILE_COUNT_Y) return; p.TravelSection = particlesVertical[x, y]; p.TravelSection.Add(p); break; case Direction4.West: if (x <= 0) return; p.TravelSection = particlesHorizontal[x - 1, y]; p.TravelSection.Add(p); break; } Particles.Add(p); }
private void MergeParticles(BackgroundParticle a, BackgroundParticle b) { if (a.RemainingPower > b.RemainingPower) RemoveParticle(a); else RemoveParticle(b); }
private void RemoveParticles(BackgroundParticle a, BackgroundParticle b) { if (a.Fraction == b.Fraction) { RemoveParticle(a); RemoveParticle(b); } else if (a.RemainingPower < b.RemainingPower) { RemoveParticle(a); b.RemainingPower -= a.RemainingPower; } else if (a.RemainingPower > b.RemainingPower) { RemoveParticle(b); a.RemainingPower -= b.RemainingPower; } else { RemoveParticle(a); RemoveParticle(b); } }
private void RemoveParticle(BackgroundParticle p) { p.Alive = false; p.TravelSection.Remove(p); Particles.Remove(p); }
private void ColorGridCell(GameTime gameTime, BackgroundParticle p, int x, int y) { if (x < -1) return; if (y < -1) return; if (x > TILE_COUNT_X) return; if (y > TILE_COUNT_Y) return; var power = gameTime.GetElapsedSeconds() * GRID_ADAPTION_SPEED * p.PowerPercentage; ColorGridCellDirect(p.Fraction, x, y, power); }