public DubstepGun(float xval, float yval) : base(xval, yval) { PlayBinding = new StateBinding("Playing"); _bio = "Plays generic dubstep loop and destroys everything"; _editorName = "Dubstep Gun"; ammo = LoopTimings.Length + Rando.Int(-5, 5); _ammoType = new ATGrenade(); _type = "gun"; sprite = new SpriteMap(DuckUtils.GetAsset("weapons/dubstep_gun.png"), 16, 16); sprite.AddAnimation("anim", Maths.IncFrameTimer() * 4f, true, 0, 1, 2, 3); sprite.SetAnimation("anim"); graphic = sprite; center = new Vec2(8f, 10f); sound = SFX.Get(DuckUtils.GetAsset("sounds/dubstep_sample.wav"), 1f, 0f, 0f, false); collisionOffset = new Vec2(-8f, -6f); collisionSize = new Vec2(16f, 11f); _barrelOffsetTL = new Vec2(16f, 6f); _fireSound = "pistolFire"; _kickForce = 3f; _holdOffset = new Vec2(-1f, 0f); loseAccuracy = 0.1f; maxAccuracyLost = 1f; physicsMaterial = PhysicsMaterial.Metal; }
public override bool Hit(Bullet bullet, Vec2 hitPos) { if (_equippedDuck == null || bullet.owner == duck || !bullet.isLocal) { return(false); } var particleEnd = hitPos + (bullet.travelDirNormalized * bullet.bulletSpeed * 3) + new Vec2(Rando.Float(-5f, 5f), Rando.Float(-5f, 5f)); for (int i2 = 0; i2 < 3; i2++) { Level.Add(DotParticle.New( hitPos.x + Rando.Float(-2f, 2f), hitPos.y + Rando.Float(-2f, 2f), () => particleEnd, bullet.color.Add(new Color( (byte)Rando.Int(-15, 15), (byte)Rando.Int(-15, 15), (byte)Rando.Int(-15, 15) )), 0.2f)); } SFX.Play("scimiSurge", 0.8f, Rando.Float(-0.2f, 0.2f)); return(true); }
public override void Update() { if (!this._created) { this._created = true; } if (this._sprite.frame > this._smokeFrame && !this._smoked) { int num = Graphics.effectsLevel == 2 ? Rando.Int(1, 4) : 1; for (int index = 0; index < num; ++index) { SmallSmoke smallSmoke = SmallSmoke.New(this.x + Rando.Float(-5f, 5f), this.y + Rando.Float(-5f, 5f)); smallSmoke.vSpeed = Rando.Float(0.0f, -0.5f); smallSmoke.xscale = smallSmoke.yscale = Rando.Float(0.2f, 0.7f); Level.Add((Thing)smallSmoke); } this._smoked = true; } if ((double)this._wait <= 0.0) { this.y += this.vSpeed; } if (!this._sprite.finished) { return; } Level.Remove((Thing)this); }
protected override void CreateExplosion(Vec2 pos) { float x = pos.x; float y = pos.y - 2f; Level.Add(new Frog(x, y, Rando.Double() < 0.5f)); int amount = Rando.Int(2, 4); for (int i = 0; i < amount; i++) { float deg = (float)i * 360f / amount + Rando.Float(-10f, 10f); float rad = Maths.DegToRad(deg); float xDir = (float)Math.Cos(rad); float yDir = (float)Math.Sin(rad); Frog thing = new Frog(x, y, xDir > 0); thing.hSpeed = xDir * 3; thing.vSpeed = yDir * yDir * -3 - 2; Level.Add(thing); } for (int i = 0; i < 3; i++) { Level.Add(SmallSmoke.New(x + Rando.Float(-8f, 8f), y + Rando.Float(-8f, 8f))); } }
private void Init(float xpos, float ypos, int offDir) { this.position.x = xpos; this.position.y = ypos; this.alpha = 1f; this._sprite.frame = Rando.Int(3); this._sprite.flipH = offDir < 0; this.center = new Vec2(16f, 8f); }
private void Init(float xpos, float ypos) { this.position.x = xpos; this.position.y = ypos; this.hSpeed = -4f - Rando.Float(3f); this.vSpeed = (float)-((double)Rando.Float(1.5f) + 1.0); this._sprite.frame = Rando.Int(4); this._bounceEfficiency = 0.3f; }
public override void EditorPropertyChanged(object property) { if ((int)this.style == -1) { (this.graphic as SpriteMap).frame = Rando.Int(3); } else { (this.graphic as SpriteMap).frame = this.style.value; } }
private void Init(float xpos, float ypos, Vec2 hitAngle, float killSpeed = 0.02f) { this.position.x = xpos; this.position.y = ypos; this.hSpeed = (float)(-(double)hitAngle.x * 2.0 * ((double)Rando.Float(1f) + 0.300000011920929)); this.vSpeed = (float)(-(double)hitAngle.y * 2.0 * ((double)Rando.Float(1f) + 0.300000011920929)) - Rando.Float(2f); this._bounceEfficiency = 0.6f; this.depth = new Depth(0.9f); this._killSpeed = killSpeed; this._color = new Color(byte.MaxValue, (byte)Rando.Int(180, (int)byte.MaxValue), (byte)0); }
public SnowDrift(float xpos, float ypos, int dir) : base(xpos, ypos) { this.style = new EditorProperty <int>(-1, (Thing)this, -1f, 3f, 1f); this.graphic = (Sprite) new SpriteMap("drifts", 16, 17); if ((int)this.style == -1) { (this.graphic as SpriteMap).frame = Rando.Int(3); } this.hugWalls = WallHug.Floor; this.center = new Vec2(8f, 14f); this.collisionSize = new Vec2(14f, 4f); this.collisionOffset = new Vec2(-7f, -2f); this.layer = Layer.Blocks; this.depth = new Depth(0.5f); }
public GlassDebris(bool rotate, float xpos, float ypos, float h, float v, int f, int tint = 0) : base(xpos, ypos) { this.hSpeed = h; this.vSpeed = v; this._sprite = new SpriteMap("windowDebris", 8, 8); this._sprite.frame = Rando.Int(7); this._sprite.color = Window.windowColors[tint] * 0.6f; this.graphic = (Sprite)this._sprite; this.center = new Vec2(4f, 4f); this._bounceEfficiency = 0.3f; if (!rotate) { return; } this.angle -= 1.57f; }
public static void Create(Thing owner, Vec2 pos, Config cfg) { if (cfg.Flash) { Graphics.FlashScreen(); } float x = pos.x; float y = pos.y - 2f; Level.Add(new ExplosionPart(x, y)); int amount = Rando.Int(1, 2); for (int i = 0; i < amount; i++) { float deg = (float)i * 360f / amount + Rando.Float(-10f, 10f); float rad = Maths.DegToRad(deg); float range = Rando.Float(12f, 20f); float xDir = (float)Math.Cos(rad); float yDir = (float)Math.Sin(rad); ExplosionPart thing = new ExplosionPart(x + xDir * range, y - yDir * range); Level.Add(thing); } for (int i = 0; i < 20; i++) { float deg = (float)i * 18f - 5f + Rando.Float(10f); float rad = Maths.DegToRad(deg); float xDir = (float)Math.Cos(rad); float yDir = (float)Math.Sin(rad); Bullet bullet = new Bullet(x + xDir * 6, y - yDir * 6, cfg.AmmoType.Invoke(), deg); bullet.firedFrom = owner; Level.Add(bullet); } SFX.Play(cfg.Sound); }
public Conveyor(float xpos, float ypos) : base(xpos, ypos) { this._sprite = new SpriteMap("stuff/conveyor", 14, 10); this._sprite.AddAnimation("convey", 0.1f, true, 0, 1, 2, 3, 4, 5, 6, 7); this._sprite.frame = Rando.Int(0, 7); this._sprite.SetAnimation("convey"); this.graphic = (Sprite)this._sprite; this.center = new Vec2(7f, 5f); this.collisionOffset = new Vec2(-7f, -4f); this.collisionSize = new Vec2(14f, 8f); this.depth = new Depth(0.5f); this._editorName = nameof(Conveyor); this.thickness = 100f; this.physicsMaterial = PhysicsMaterial.Metal; this.editorOffset = new Vec2(0.0f, 6f); this.hugWalls = WallHug.Floor; this._editorImageCenter = true; this._killImpact = ImpactedFrom.Top; }
public Flare(float xpos, float ypos, FlareGun owner, int numFlames = 8) : base(xpos, ypos) { this._sprite = new SpriteMap("smallFire", 16, 16); this._sprite.AddAnimation("burn", (float)(0.200000002980232 + (double)Rando.Float(0.2f)), true, 0, 1, 2, 3, 4); this._sprite.SetAnimation("burn"); this._sprite.imageIndex = Rando.Int(4); this.graphic = (Sprite)this._sprite; this.center = new Vec2(8f, 8f); this.collisionOffset = new Vec2(-4f, -2f); this.collisionSize = new Vec2(8f, 4f); this.depth = new Depth(-0.5f); this.thickness = 1f; this.weight = 1f; this.breakForce = 9999999f; this._owner = owner; this.weight = 0.5f; this.gravMultiplier = 0.7f; this._numFlames = numFlames; }
public override void Initialize() { base.Initialize(); if (Level.current is Editor || (Network.isActive && !isServerForObject)) { return; } var fuckingType = amTypes[Rando.Int(amTypes.Length - 1)]; if (Activator.CreateInstance(fuckingType, Editor.GetConstructorParameters(fuckingType)) is PhysicsObject newThing) { newThing.x = x; newThing.y = y; newThing.vSpeed = -2f; newThing.spawnAnimation = true; newThing.isSpawned = true; newThing.offDir = offDir; Level.Add(newThing); } Level.Remove(this); }
private void Init(float xpos, float ypos, DuckPersona who) { this.position.x = xpos; this.position.y = ypos; this.alpha = 1f; this.hSpeed = Rando.Float(6f) - 3f; this.vSpeed = (float)((double)Rando.Float(2f) - 1.0 - 1.0); this._sprite = who.featherSprite.CloneMap(); this._sprite.SetAnimation("feather"); this._sprite.frame = Rando.Int(3); if (Rando.Double() > 0.5) { this._sprite.flipH = true; } else { this._sprite.flipH = false; } this.graphic = (Sprite)this._sprite; this._rested = false; }
public TinyBubble(float xpos, float ypos, float startHSpeed, float minY, bool blue = false) : base(xpos, ypos) { this.alpha = 0.7f; this._minY = minY; this._gravMult = 0.0f; this.vSpeed = -Rando.Float(0.5f, 1f); this.hSpeed = startHSpeed; this.depth = new Depth(0.3f); SpriteMap spriteMap = new SpriteMap("tinyBubbles", 8, 8); if (blue) { spriteMap = new SpriteMap("tinyBlueBubbles", 8, 8); } spriteMap.frame = Rando.Int(0, 1); this.graphic = (Sprite)spriteMap; this.center = new Vec2(4f, 4f); this._waveSize = Rando.Float(0.1f, 0.3f); this.xscale = this.yscale = 0.1f; }
public ExplosionPart(float xpos, float ypos, bool doWait = true) : base(xpos, ypos) { this._sprite = new SpriteMap("explosion", 64, 64); this._sprite.AddAnimation("explode", 1f, false, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10); this._sprite.SetAnimation("explode"); this.graphic = (Sprite)this._sprite; this._sprite.speed = 0.4f + Rando.Float(0.2f); this.xscale = 0.5f + Rando.Float(0.5f); this.yscale = this.xscale; this.center = new Vec2(32f, 32f); this._wait = Rando.Float(1f); this._smokeFrame = Rando.Int(1, 3); this.depth = new Depth(1f); this.vSpeed = Rando.Float(-0.2f, -0.4f); if (doWait) { return; } this._wait = 0.0f; }
private void PlaySound(float vol = 1f, float pit = 0f) { this.function?.Invoke(); vol *= this.volume; pit += this.pitch; pit += Rando.Float(this.pitchVariationLow, this.pitchVariationHigh); if (pit < -1f) { pit = -1f; } if (pit > 1f) { pit = 1f; } if (this._sounds.Count > 0) { if (this.pitchBinding != null) { pit = (float)((byte)this.pitchBinding.value) / 255f; } string append = ""; if (this.appendBinding != null) { append = ((byte)this.appendBinding.value).ToString(); } //If previous sound is already playing, don't play another. //if (currentSound != null) // if (currentSound.State == Microsoft.Xna.Framework.Audio.SoundState.Playing) return; if (this._rareSounds.Count > 0 && Rando.Float(1f) > 0.9f) { currentSound = SFX.Play(this._rareSounds[Rando.Int(this._rareSounds.Count - 1)] + append, vol, pit, 0f, false); } else { currentSound = SFX.Play(this._sounds[Rando.Int(this._sounds.Count - 1)] + append, vol, pit, 0f, false); } } }
public MusicNote(float xpos, float ypos, Vec2 dir) : base(xpos, ypos) { this._sprite = new SpriteMap("notes", 8, 8); this._sprite.frame = Rando.Int(1); this._sprite.CenterOrigin(); int num1 = Rando.ChooseInt(0, 1, 2, 3); if (num1 == 0) { this._color = Color.Violet; } if (num1 == 1) { this._color = Color.SkyBlue; } if (num1 == 2) { this._color = Color.Wheat; } if (num1 == 4) { this._color = Color.GreenYellow; } this._dir = dir; float num2 = 1f; if ((double)Rando.Float(1f) <= 0.5) { num2 = -1f; } this._sin = new SinWave(0.03f + Rando.Float(0.1f), num2 * 6.283185f); this._size = 3f + Rando.Float(6f); this._speed = 0.8f + Rando.Float(1.4f); this.depth = new Depth(0.95f); this.scale = new Vec2(0.1f, 0.1f); }