public static EmitterSimple Knockout(RoomScene room, string spriteName, int posX, int posY, byte duration = 60) { int frame = Systems.timer.Frame; // Prepare Emnitter EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], spriteName, new Vector2(posX, posY), new Vector2(0, 0), 0.5f, frame + duration, frame + duration - 25); // Randomize Knockout Direction and Rotation Vector2 randVelocity = new Vector2( CalcRandom.FloatBetween(-4.5f, 4.5f), CalcRandom.FloatBetween(-5f, -11f) ); float rotSpeed = CalcRandom.FloatBetween(0.07f, 0.15f) * (CalcRandom.IntBetween(1, 100) >= 51 ? 1 : -1); // Add Knockout Particle emitter.AddParticle( new Vector2(posX, posY), randVelocity, 0, rotSpeed ); return(emitter); }
public void GenerateStars() { // Generate Random Stars for (byte starIndex = 0; starIndex < 200; starIndex++) { short posX = CalcRandom.ShortBetween(0, Systems.screen.screenWidth); short posY = CalcRandom.ShortBetween(0, Systems.screen.screenHeight); StarData star = new StarData(posX, posY, false); this.stars.Add(star); } // Generate Clusters for (byte clusterIndex = 0; clusterIndex < 3; clusterIndex++) { short clusX = CalcRandom.ShortBetween(50, (short)(Systems.screen.screenWidth - 50)); short clusY = CalcRandom.ShortBetween(50, (short)(Systems.screen.screenHeight - 50)); // Generate Random Stars for (byte starIndex = 0; starIndex < 35; starIndex++) { short posX = CalcRandom.ShortBetween((short)(clusX - 140), (short)(clusX + 140)); short posY = CalcRandom.ShortBetween((short)(clusY - 140), (short)(clusY + 140)); if (posX > 0 && posY > 0 && posX < Systems.screen.screenWidth && posY < Systems.screen.screenHeight) { StarData star = new StarData(posX, posY, false); this.stars.Add(star); } } } }
public MoonData(byte moonID) { this.sprite = PlanetInfo.Planets[(byte)moonID]; this.lat = (short)CalcRandom.IntBetween(-10, 19); this.speed = (float)CalcRandom.FloatBetween(0.15f, 0.8f); this.posX = (short)CalcRandom.IntBetween(-65, 65); this.posY = lat; this.front = true; }
public static ProjectileEarth Create(RoomScene room, byte subType, FVector pos, FVector velocity) { // Retrieve an available projectile from the pool. ProjectileEarth projectile = ProjectilePool.ProjectileEarth.GetObject(); projectile.ResetProjectile(room, subType, pos, velocity); projectile.AssignBoundsByAtlas(2, 2, -2, -2); projectile.spinRate = CalcRandom.FloatBetween(-0.07f, 0.07f); // Add the Projectile to Scene room.AddToScene(projectile, false); return(projectile); }
public static EndBounceParticle SetParticle(RoomScene room, Atlas atlas, string spriteName, Vector2 pos, int frameEnd, float bounceHeight = 3, float gravity = 0.5f, float rotateSpeed = 0.12f) { // Retrieve an available particle from the pool. EndBounceParticle particle = EndBounceParticle.endBouncePool.GetObject(); particle.atlas = atlas; particle.spriteName = spriteName; particle.pos = pos; particle.frameEnd = frameEnd; particle.gravity = gravity; particle.vel = new Vector2(CalcRandom.FloatBetween(-3, 3), CalcRandom.FloatBetween(-bounceHeight - 1.5f, -bounceHeight + 1.5f)); particle.rotationSpeed = CalcRandom.FloatBetween(-rotateSpeed, rotateSpeed); // Add the Particle to the Particle Handler room.particleHandler.AddParticle(particle); return(particle); }
public override void Destroy(DirCardinal dir = DirCardinal.None, GameObject obj = null) { base.Destroy(); EndBounceParticle particle = EndBounceParticle.SetParticle(this.room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], this.SpriteName, new Vector2(this.posX + this.bounds.Left - 2, this.posY + this.bounds.Top - 2), Systems.timer.Frame + 10, 3, 0.5f, 0.12f); if (dir == DirCardinal.Right || dir == DirCardinal.Left) { particle.vel.Y -= (float)CalcRandom.FloatBetween(0, 3); particle.vel.X = dir == DirCardinal.Right ? CalcRandom.FloatBetween(-3, 0) : CalcRandom.FloatBetween(0, 3); } else if (dir == DirCardinal.Down || dir == DirCardinal.Up) { particle.vel.Y = dir == DirCardinal.Down ? CalcRandom.FloatBetween(-4, -2) : CalcRandom.FloatBetween(-1, 1); particle.vel.X = (float)this.physics.velocity.X.ToDouble() * 0.35f + CalcRandom.FloatBetween(-1, 1); } this.room.PlaySound(Systems.sounds.shellThud, 0.4f, this.posX + 16, this.posY + 16); }
public static EmitterSimple BoxExplosion(RoomScene room, string spriteName, int posX, int posY, sbyte xSpread = 3, sbyte ySpread = 3, byte duration = 55) { int frame = Systems.timer.Frame; EmitterSimple emitter = EmitterSimple.NewEmitter(room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], spriteName, new Vector2(posX, posY), new Vector2(0, 0), 0.5f, frame + duration, frame + duration - 25); float radianUpLeft = -1.82f; // -5, -20 float radianUpRight = -1.32f; // 5, -20 // Launch Up-Left Particle emitter.AddParticle( new Vector2( posX - (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)), posY - (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f)) ), new Vector2( CalcRandom.FloatBetween(-0.25f, -1.5f), CalcRandom.FloatBetween(-9f, -13f) ), radianUpLeft + CalcRandom.FloatBetween(-0.6f, 0.6f), -0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f) ); // Launch Up-Right Particle emitter.AddParticle( new Vector2( posX + (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)), posY - (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f)) ), new Vector2( CalcRandom.FloatBetween(0.25f, 1.5f), CalcRandom.FloatBetween(-9f, -13f) ), radianUpRight + CalcRandom.FloatBetween(-0.6f, 0.6f), 0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f) ); // Launch Down-Left Particle emitter.AddParticle( new Vector2( posX - (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)), posY + (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f)) ), new Vector2( CalcRandom.FloatBetween(-0.25f, -1.5f), CalcRandom.FloatBetween(-4f, -7f) ), radianUpLeft + CalcRandom.FloatBetween(-0.6f, 0.6f), -0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f) ); // Launch Down-Right Particle emitter.AddParticle( new Vector2( posX + (int)Math.Floor(xSpread * CalcRandom.FloatBetween(0.5f, 2f)), posY + (int)Math.Floor(ySpread * CalcRandom.FloatBetween(0.5f, 2f)) ), new Vector2( CalcRandom.FloatBetween(0.25f, 1.5f), CalcRandom.FloatBetween(-4f, -7f) ), radianUpRight + CalcRandom.FloatBetween(-0.6f, 0.6f), 0.08f + CalcRandom.FloatBetween(-0.12f, 0.12f) ); return(emitter); }
public static void AddCloud(ParallaxHandler pxHandler, string spriteName, float parallaxDist, short width) { float xVel = CalcRandom.FloatBetween(-0.5f, 0.5f) * parallaxDist; // Randomize X-Velocity pxHandler.AddLoopingObject(spriteName, parallaxDist, ParallaxLoopFlag.Skyline, ParallaxLoopFlag.Top, xVel, width); }