void PlayerInput_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space)
     {
         PressJump = true;
         Jump();
     }
     else if (e.KeyCode == Keys.T && e.Modifiers == Keys.Control)
     {
         NCamera      camera   = Program.game.GameWindow.ViewportControl.Viewport.Camera;
         Ray          mouseRay = camera.GetMouseRay(PlayerInput.MouseValueX, PlayerInput.MouseValueY);
         NCheckResult hit      = new NCheckResult();
         if (GameEngine.EngineInstance.CurrentLevel.LineCheck(out hit, mouseRay.Position, mouseRay.Position + mouseRay.Direction * camera.ZFar, LineCheckType.World))
         {
             this.Transport(GameEngine.EngineInstance.GameLevel, hit.location, true);
         }
     }
     else if (e.KeyCode == Keys.D1)
     {
         // todo: 测试释放技能
         ClientUseSkill(1909162191);
     }
     else if (e.KeyCode == Keys.D2)
     {
         ClientUseSkill(4020073455);
     }
     else if (e.KeyCode == Keys.D3)
     {
         ClientUseSkill(1525076748);
     }
     else if (e.KeyCode == Keys.D4)
     {
         ClientUseSkill(3299876908);
     }
 }
Ejemplo n.º 2
0
        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //在当前激活视图的中心粘贴已经复制或者剪切的对象
            int     x      = ActiveViewport.Width / 2;
            int     y      = ActiveViewport.Height / 2;
            NCamera camera = ActiveViewport.Viewport.Camera;

            NLevelEditorEngine.Instance.ActorEd.PasteCopyedActors(camera, x, y);
        }
Ejemplo n.º 3
0
 private void cbCameras_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbCameras.Items.Count == 0)
     {
         _camera             = null;
         _lastSelectedCamera = string.Empty;
         return;
     }
     _camera             = cbCameras.SelectedItem as NCamera;
     _lastSelectedCamera = _camera != null ? _camera.DisplayName : string.Empty;
     UpdateFormatList();
 }
Ejemplo n.º 4
0
        private void checkForCamera(NDeviceManager _devMan)
        {
            int count = _devMan.Devices.Count();

            if (count > 0)
            {
                camera = (NCamera)_devMan.Devices [0];
            }
            else
            {
                MessageBox.Show("No cameras found");
                Application.Exit();
            }
        }
Ejemplo n.º 5
0
 private void devMan_DeviceRemoved(object sender, NDeviceManagerDeviceEventArgs e)
 {
     if (cbCameras.InvokeRequired)
     {
         cbCameras.Invoke(new OnDeviceChange(devMan_DeviceRemoved), sender, e);
     }
     else
     {
         cbCameras.Items.Remove(e.Device);
         if (_camera == e.Device)
         {
             _camera = null;
             cbFormats.Items.Clear();
         }
     }
 }
        /// <summary>
        /// 处理玩家移动
        /// </summary>
        public void PlayerMove(float deltaTime, NCamera camera)
        {
            GameEngine engine = GameEngine.EngineInstance;

            if (TargetActor == null || engine == null)
            {
                return;
            }

            if (engine.CurrentLevel == null)
            {
                return;
            }

            KeyMove(camera);
            MouseMove(camera);
        }
        public void ClientUseSkill(UInt32 spellId)
        {
            NCamera      camera   = Program.game.GameWindow.ViewportControl.Viewport.Camera;
            Ray          mouseRay = camera.GetMouseRay(PlayerInput.MouseValueX, PlayerInput.MouseValueY);
            NCheckResult hit      = new NCheckResult();

            if (GameEngine.EngineInstance.CurrentLevel.LineCheck(out hit, mouseRay.Position, mouseRay.Position + mouseRay.Direction * camera.ZFar, LineCheckType.World))
            {
                C2S_CastSpell msg;
                msg.MessageId = C2S_CastSpell.Id;
                msg.SpellID   = spellId;
                msg.TargetId  = 0;
                msg.TargetPos = hit.location;
                msg.TimeStamp = NativeEngineHelper.GetTimeSeconds();
                msg.CastCount = 1;
                GameFrameManager.SendNetMessage <C2S_CastSpell>(msg);
            }
        }
Ejemplo n.º 8
0
        private void UpdateCameraList()
        {
            comboBoxCameras.BeginUpdate();
            try
            {
                comboBoxCameras.Items.Clear();
                _deviceManager.Refresh();
                foreach (var device in _deviceManager.Devices)
                {
                    comboBoxCameras.Items.Add(device);
                }

                if (activeCamera != null && activeCamera.IsDisposed)
                {
                    activeCamera = null;
                }

                if (activeCamera == null && comboBoxCameras.Items.Count > 0)
                {
                    comboBoxCameras.SelectedIndex = 0;
                    comboBoxCameras.SelectedItem  = comboBoxCameras.Items[0];
                    btCaptureDevicePhoto.Enabled  = true;
                    buttonUseImage.Enabled        = false;
                    return;
                }

                if (activeCamera != null)
                {
                    comboBoxCameras.SelectedIndex = comboBoxCameras.Items.IndexOf(activeCamera);
                }
            }
            catch (Exception exp)
            {
                _errorLog.Append(exp + Environment.NewLine);
                comboBoxCameras.EndUpdate();
                buttonStopCapture.Enabled = btCaptureDevicePhoto.Enabled = false;
                MessageBox.Show(exp.ToString());
            }
        }
        /// <summary>
        /// 鼠标移动
        /// </summary>
        private void MouseMove(NCamera camera)
        {
            // 取鼠标射线点击Level中的Hit点
            if ((PlayerInput.ClickLocationX != 0 || PlayerInput.ClickLocationY != 0) && PlayerInput.IsKeyPressed(Keys.LButton))
            {
                Ray          mouseRay = camera.GetMouseRay(PlayerInput.ClickLocationX, PlayerInput.ClickLocationY);
                NCheckResult hit      = new NCheckResult();
                if (GameEngine.EngineInstance.CurrentLevel.LineCheck(out hit, mouseRay.Position, mouseRay.Position + mouseRay.Direction * camera.ZFar, LineCheckType.World))
                {
                    MoveTargetLocation = new Vector3(hit.location.x,
                                                     GameEngine.EngineInstance.CurrentLevel.GetWorldHeight(MoveTargetLocation.x, MoveTargetLocation.z),
                                                     hit.location.z);
                    moveTargetDirect = Vector3.Normalize(MoveTargetLocation - this.TargetActor.Location);
                    reachTarget      = false;
                }
            }

#if DEBUG
            GameViewportControl.debugInfos.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture,
                                                             "MoveTargetLocation: {0}\r\n", MoveTargetLocation.ToString()));
#endif

            if (!reachTarget)
            {
                // 朝向目标移动
                Vector3 dir = Vector3.Normalize(MoveTargetLocation - this.TargetActor.Location);
                if (ReachedDestination(this.TargetActor.Location, MoveTargetLocation) ||
                    Vector3.Dot(moveTargetDirect, dir) < 0)
                {
                    this.Acceleration = Vector3.Zero;
                    reachTarget       = true;
                }
                else
                {
                    this.Acceleration = dir;
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 鼠标移动
        /// </summary>
        private void MouseMove(GamePlayerInput playerInput, NCamera camera, GameEngine engine)
        {
            // 取鼠标射线点击Level中的Hit点
            if (playerInput.ClickLocationX != 0 || playerInput.ClickLocationY != 0)
            {
                Ray          mouseRay = camera.GetMouseRay(playerInput.ClickLocationX, playerInput.ClickLocationY);
                NCheckResult hit      = new NCheckResult();
                if (engine.CurrentLevel.LineCheck(out hit, mouseRay.Position, mouseRay.Position + mouseRay.Direction * camera.ZFar, LineCheckType.World))
                {
                    MoveTargetLocation = hit.location;
                    moveTargetDirect   = Vector3.Normalize(MoveTargetLocation - this.TargetActor.Location);
                    reachTarget        = false;
                }
            }

#if DEBUG
            GameViewportControl.debugInfos.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture,
                                                             "MoveTargetLocation: {0}\r\n", MoveTargetLocation.ToString()));
#endif

            if (!reachTarget)
            {
                // 朝向目标移动
                Vector3 dir = Vector3.Normalize(MoveTargetLocation - this.TargetActor.Location);
                if (ReachedDestination(this.TargetActor.Location, MoveTargetLocation) ||
                    Vector3.Dot(moveTargetDirect, dir) < 0)
                {
                    this.Acceleration = Vector3.Zero;
                    //this.Velocity = Vector3.Zero;
                    reachTarget = true;
                }
                else
                {
                    this.Acceleration = dir;
                }
            }
        }
Ejemplo n.º 11
0
 private void comboBoxCameras_SelectedIndexChanged(object sender, EventArgs e)
 {
     activeCamera = comboBoxCameras.SelectedItem as NCamera;
 }
Ejemplo n.º 12
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                activeCamera = (NCamera)e.Argument;
                activeCamera.StartCapturing();
                while (activeCamera.IsCapturing)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        activeCamera.StopCapturing();
                    }

                    if (activeCamera != null && activeCamera.IsCapturing)
                    {
                        using (NImage image = activeCamera.GetFrame())
                        {
                            video = image.ToBitmap();

                            using (NLExtractor extractor = new NLExtractor())
                            {
                                // convert image to grayscale
                                NGrayscaleImage grayscale = (NGrayscaleImage)NImage.FromImage(NPixelFormat.Grayscale, 0, image);
                                extractor.MaxRecordsPerTemplate = 1;
                                // detect all faces that are suitable for face recognition in the image
                                NleFace[] faces = extractor.DetectFaces(grayscale);
                                //NleDetectionDetails[] detectionDetails
                                facedetectdetails = new NleDetectionDetails[faces.Length];
                                for (int i = 0; i < facedetectdetails.Length; i++)
                                {
                                    facedetectdetails[i] = extractor.DetectFacialFeatures(grayscale, faces[i]);
                                }
                                facesView.DrawConfidenceForEyes = true;
                                facesView.DrawFaceConfidence    = true;
                                facesView.DetectionDetails      = facedetectdetails;

                                for (int i = 0; i < facedetectdetails.Length; i++)
                                {
                                    faceAvailabilityStatus = facedetectdetails[i].FaceAvailable;
                                }
                                if (facesView.DrawConfidenceForEyes == true & facesView.DrawFaceConfidence == true)
                                {
                                    faceAvailabilityStatus = true;
                                }
                                else
                                {
                                    faceAvailabilityStatus = false;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                //   MessageBox.Show("Error Capturing Image - Close and re-open browser window");
                // Logger.LogError(exp.ToString());
                //errorLog.Append(exp.ToString() + Environment.NewLine);
                e.Cancel = true;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 处理玩家移动
        /// </summary>
        public void PlayerMove(float deltaTime, GameEngine engine, GamePlayerInput playerInput, NCamera camera)
        {
            if (TargetActor == null || engine == null)
            {
                return;
            }

            if (engine.CurrentLevel == null)
            {
                return;
            }

            KeyMove(playerInput);
            MouseMove(playerInput, camera, engine);

#if DEBUG
            GameViewportControl.debugInfos.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture,
                                                             "CurrentMovementType: {0} Acceleration: {1} Velocity: {2} \r\n",
                                                             CurrentMovementType.ToString(),
                                                             Acceleration.ToString(),
                                                             Velocity.ToString()));
#endif
        }
Ejemplo n.º 14
0
 private void devMan_DeviceRemoved(object sender, NDeviceManagerDeviceEventArgs e)
 {
     if (cbCameras.InvokeRequired)
     {
         cbCameras.Invoke(new OnDeviceChange(devMan_DeviceRemoved), sender, e);
     }
     else
     {
         cbCameras.Items.Remove(e.Device);
         if (_camera == e.Device)
         {
             _camera = null;
             cbFormats.Items.Clear();
         }
     }
 }
Ejemplo n.º 15
0
 private void cbCameras_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbCameras.Items.Count == 0)
     {
         _camera = null;
         _lastSelectedCamera = string.Empty;
         return;
     }
     _camera = cbCameras.SelectedItem as NCamera;
     _lastSelectedCamera = _camera != null ? _camera.DisplayName : string.Empty;
     UpdateFormatList();
 }
 /// <summary>
 /// 键盘移动
 /// </summary>
 private void KeyMove(NCamera camera)
 {
     this.Walk = PlayerInput.IsKeyPressed(Keys.ShiftKey);
 }