public override void Update() { base.Update(); if (!OnCamera) { var offX = Left > FP.Width || Right < 0; var offY = Top > FP.Height || Bottom < 0; if (offX && offY) { World.Remove(this); } } var l = new List <Entity>(); CollideInto(Player.Collision, X, Y, l); foreach (var p in l) { var player = p as Player; if (player != owner) { if (player.Rebounding) { World.BroadcastMessage(CameraManager.Message.Shake, 10.0f, 0.5f); Mixer.Hit1.Play(); var angle = FP.Angle(player.X, player.Y, owner.X, owner.Y); FP.AngleXY(ref direction.X, ref direction.Y, angle, 1); owner = player; } } if (player != owner) { if (!player.Invincible) { World.BroadcastMessage(CameraManager.Message.Shake, 10.0f, 0.5f); Mixer.Hit1.Play(); var force = ForceMultiplier * Fist.BASE_PUNCH_FORCE; var dir = direction.Normalized(); player.OnMessage(PhysicsBody.Message.Impulse, force * dir.X, force * dir.Y); } } } image.Angle = FP.Angle(0, 0, direction.X, direction.Y); direction.Normalize(FistSpeed); var rainbow = World.Add(new RainbowTrail(X, Y, direction, image.Scale, FistSpeed, Layer)); X += direction.X; Y += direction.Y; }
public CommandWheel(CommandData[] commands) { commands = commands?.Where(x => GameEvent.checkDependanciesAndRestrictions(x.Dependancies))?.ToArray(); if (commands == null) { //World.Remove(this); return; } this.commands = commands; lastMouse = new Point(Mouse.ScreenX, Mouse.ScreenY); //Make the wheel wheel = new Image(Library.GetTexture("./content/UI/CommandWheel/Wheel.png")); wheel.CenterOrigin(); X = Mouse.ScreenX; Y = Mouse.ScreenY; Layer = Utility.WHEEL_UI_LAYER; AddComponent(wheel); //Add commands gcommands = new Graphiclist(); if (this.commands != null && this.commands.Length > 0) { int deg = -90, deginc = 360 / this.commands.Length; foreach (var c in this.commands) { Image img = new Image(Library.GetTexture("./content/UI/CommandWheel/" + c.Name + ".png")); img.CenterOrigin(); img.Y = -wheel.Height / 2 + img.Height / 2; FP.AngleXY(ref img.X, ref img.Y, deg, wheel.Height / 2 - img.Height / 2); commandImages.Add(c, img); deg += deginc; gcommands.Add(img); } } AddComponent(gcommands); ClampHorizontal(0, FP.Width, 100); ClampVertical(0, FP.Height, 100); }
public override void Added() { base.Added(); var config = Library.GetConfig <BulletConfig>("config/upgrades/bullets.ini"); BulletCount = config.Count; Lifetime = config.Lifetime; var mode = config.Mode; while (mode == BulletConfig.BulletMode.Random) { mode = FP.Choose.Enum <BulletConfig.BulletMode>(); } for (int i = 0; i < BulletCount; i++) { var vec = new Vector2f(); if (mode == BulletConfig.BulletMode.Radial) { var angle = FP.Scale(i, 0, BulletCount, 0, 360); angle += 45; if ((angle %= 360) < 0) { angle += 360; } FP.AngleXY(ref vec.X, ref vec.Y, angle, 1); } else { vec.X = FP.Scale(i, 0, BulletCount - 1, -1, 1); vec.Y = -1; } bullets.Add(new Bullet(vec, owner)); } }