private void ShootBolt(FInt rotation, int midX, int midY) { FInt r = FPRadians.Normalize(rotation); FInt velX = FInt.Create(Radians.GetXFromRotation((float)r.ToDouble(), (float)this.attSpeed.ToDouble())); FInt velY = FInt.Create(Radians.GetYFromRotation((float)r.ToDouble(), (float)this.attSpeed.ToDouble())); ProjectileEnemy projectile = ProjectileEnemy.Create(room, (byte)ProjectileEnemySubType.BoltBlue, FVector.Create(midX - 10, midY + 4), FVector.Create(velX, velY)); projectile.physics.SetGravity(FInt.Create(0)); projectile.rotation = (float)r.ToDouble(); }
public override void RunTick() { base.RunTick(); // Get Center Bounds int midX = this.posX + this.bounds.MidX; int midY = this.posY + this.bounds.MidY; // Only change behaviors every 16 frames. if (Systems.timer.frame16Modulus == 15) { this.WatchForCharacter(midX, midY); } // Check for any attack to make this round. if (this.charWatched is Character && this.attack.AttackThisFrame()) { // Get distance from Character, if applicable. int destX = this.charWatched is Character ? this.charWatched.posX + this.charWatched.bounds.MidX - 10 : midX; int destY = this.charWatched is Character ? this.charWatched.posY + this.charWatched.bounds.MidY - 10 : midY; int distance = FPTrigCalc.GetDistance(FVector.Create(midX, midY), FVector.Create(destX, destY)).RoundInt; if (distance < ViewDistance) { FInt rotation = FPRadians.GetRadiansBetweenCoords(midX, midY, destX, destY); this.rotation = (float)rotation.ToDouble(); if (this.attCount != 2) { this.ShootBolt(rotation, midX, midY); } if (this.attCount > 1) { this.ShootBolt(rotation + attSpread, midX, midY); this.ShootBolt(rotation - attSpread, midX, midY); } this.room.PlaySound(Systems.sounds.bolt, 0.6f, this.posX + 16, this.posY + 16); } } }
public static FInt Asin(FInt F) { bool isNegative = F < 0; F = Abs(F); if (F > FInt.OneF) { throw new ArithmeticException("Bad Asin Input:" + F.ToDouble()); } FInt f1 = mul(mul(mul(mul(new FInt(145103 >> FInt.SHIFT_AMOUNT, false), F) - new FInt(599880 >> FInt.SHIFT_AMOUNT, false), F) + new FInt(1420468 >> FInt.SHIFT_AMOUNT, false), F) - new FInt(3592413 >> FInt.SHIFT_AMOUNT, false), F) + new FInt(26353447 >> FInt.SHIFT_AMOUNT, false); FInt f2 = PI / new FInt(2, true) - (Sqrt(FInt.OneF - F) * f1); return(isNegative ? f2.Inverse : f2); }
public override void CollidePosRight(int posX) { FInt velX = this.physics.velocity.X; this.physics.touch.TouchRight(); this.physics.StopX(); this.physics.MoveToPosX(posX); // Bounce Back this.physics.velocity.X -= velX * bounceX; // Bounce sound when it's sufficiently high enough. if (velX > 2) { this.room.PlaySound(Systems.sounds.shellThud, (float)Math.Min(0.6f, velX.ToDouble() * 0.1f), this.posX + 16, this.posY + 16); } else { this.physics.velocity.X = FInt.Create(0); } }
public override void CollidePosDown(int posY) { FInt velY = this.physics.velocity.Y; this.physics.touch.TouchDown(); this.physics.StopY(); this.physics.MoveToPosY(posY); this.physics.velocity.X *= this.decelGround; this.physics.velocity.Y -= velY * bounceY; // Bounce sound when it's sufficiently high enough. if (velY > 2) { this.room.PlaySound(Systems.sounds.shellThud, (float)Math.Min(0.8f, velY.ToDouble() * 0.1f), this.posX + 16, this.posY + 16); } else { this.physics.velocity.Y = FInt.Create(0); } }