Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        void game_MouseClick(GUIElement sender, MouseEventArgs e)
        {
            if (e.isClicked(MouseButtons.Left))
            {
                //// This code sets of a charge by clicking on the asteroid that contains it, so multiple chargs can be set
                //// Good for debugging
                //activeCharge = null;
                //var bodies =
                //    PhysicsManager.QTbodies.Query(
                //        new Region(e.CurrentPosition.X - Asteroid.MaxRadius, e.CurrentPosition.X + Asteroid.MaxRadius,
                //            e.CurrentPosition.Y - Asteroid.MaxRadius, e.CurrentPosition.Y + Asteroid.MaxRadius));
                //foreach (IRigidBody body in bodies)
                //    if (body is Asteroid)
                //    {
                //        var astr = (Asteroid)body;
                //        if (MathUtils.Distance(astr.Position, e.CurrentPosition) < astr.Radius)
                //        {
                //            activeCharge = (Charge)astr.GetDevices().FirstOrDefault<Device>(x => x is Charge);
                //            break;
                //        }
                //    }
                //// End of above code block

                if (activeCharge == null)
                {
                    activeCharge = PlayerProfile.ReleaseCharge(0);
                    if (activeCharge == null)
                        this.Write("No Charges Left!");
                    else
                    {
                        releaseItem(activeCharge);
                        this.Write("Charges Left: {0}", PlayerProfile.ChargesLeft);
                    }
                }
                else
                {
                    activeCharge.Detonate();
                    activeCharge = null;
                }
            }
            else if (e.isClicked(MouseButtons.Right))
            {
                var sensor = PlayerProfile.ReleaseSensor(0);
                if (sensor == null)
                    this.Write("No Sensors Left!");
                else
                {
                    releaseItem(sensor);
                    this.Write("Sensors Left: {0}", PlayerProfile.SensorsLeft);
                }
            }
        }