private Particle makeParticle() { return(new Particle(this.game, this.parent, GameMath.Vector3FromRotation(GlobalRandom.Angle(), GlobalRandom.Angle(), this.size) * new Vector3(1, 1, 0.5f), new Vector3(), color, GlobalRandom.NextFloat(0.8f, 1.2f) * this.size)); }
public void Explode(float percentage, Vector3 impulse, float randomImpulse) { var detachCount = randomCount(this.particles.Count * percentage); for (int j = 0; j < detachCount; j++) { var i = GlobalRandom.Next(particles.Count); var oldParticle = this.particles[i]; oldParticle.DetachFromParent(); oldParticle.FadeAway(GlobalRandom.NextFloat(0.2f, 0.5f)); oldParticle.Push(impulse + GameMath.Vector2FromRotation(GlobalRandom.Angle(), GlobalRandom.NextFloat(randomImpulse)).WithZ(0)); this.particles[i] = this.makeParticle(); } }
public void GrowCrystals() { foreach (var tile in this.tilemap) { var tilePosition = this.GetPosition(tile); var crystalCount = (int)(tile.Info.Lightness * 2 * GlobalRandom.NextFloat(4, 5.5f)); for (int i = 0; i < crystalCount; i++) { var dir = GameMath.Vector2FromRotation(GlobalRandom.Angle(), Settings.Game.Level.HexagonSide); var result = tile.Info.ShootRay(new Ray(Vector2.Zero, dir)); var position = result.Hit ? result.Point * GlobalRandom.NextFloat(0.8f, 0.9f) : dir *GlobalRandom.NextFloat(0.3f, 0.8f); new Crystal(game, tilePosition + position); } } }