Exemplo n.º 1
0
        /// <summary>
        /// Tracks mouse releases.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event data.</param>
        private void Window_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (Engine3D.Client.MouseX > Engine3D.Window.Width * 0.75)
            {
                return;
            }
            Game game = Engine.Source as Game;

            switch (e.Button)
            {
            case MouseButton.Left:
                Matrix4 m = Engine3D.MainView.PrimaryMatrix.Inverted();
                m.Transpose();
                float        x    = 2.0f * Engine3D.Client.MouseX / Engine3D.Window.Width - 1.0f;
                float        y    = 1.0f - 2.0f * Engine3D.Client.MouseY / Engine3D.Window.Height;
                Vector4      vIn  = new Vector4(x, y, 1, 1);
                Vector4      vOut = Vector4.Transform(m, vIn);
                float        mul  = 1.0f / vOut.W;
                Location     dir  = new Location(vOut.X * mul, vOut.Y * mul, vOut.Z * mul);
                ClientEntity ent  = Engine3D.PhysicsWorld.RayTraceSingle(Engine3D.MainCamera.Position, dir, 100);
                ent?.GetFirstSubType <BasicUnitProperty>()?.Select();
                break;

            case MouseButton.Right:
                break;
            }
        }