void frame_MouseClick(GUIElement sender, MouseEventArgs e) { var player = (Player)ActiveMap.Player; var mdir = Vector2.Normalize(e.CurrentPosition - player.Position); var launchPort = player.Position + mdir * (player.Radius + 5); //launch stuff from slightly in front of player float launchVel = 300f + player.Velocity.Length(); var carrier = new DeviceTransporter(launchPort, 15); carrier.Velocity = launchVel * mdir; SpawnObject<Actor>(carrier); if (e.isClicked(MouseButtons.Left)) { var c = new Charge(50, 15); ActiveMap.AddObject(c); carrier.AddDevice(c); } if (e.isClicked(MouseButtons.Right)) { var s = new Sensor(60f); ActiveMap.AddObject(s); carrier.AddDevice(s); } }
private void releaseItem(Device device) { var player = (Player)ActiveMap.Player; var mdir = new Vector2((float)Math.Cos(player.Rotation + Math.PI / 2), (float)Math.Sin(player.Rotation + Math.PI / 2)); var launchPort = player.Position + mdir * (player.Radius + 5); //launch stuff from slightly in front of player float launchVel = 300f + player.Velocity.Length(); var carrier = new DeviceTransporter(launchPort, 15); carrier.Velocity = launchVel * mdir; carrier.AddDevice(device); SpawnObject<Actor>(carrier); SpawnObject<Device>(device); }