/// <summary> /// This function is used to process any mouse events, such as a change in cursor position, or clicks. /// </summary> /// <param name="x">The x position of the mouse on the screen.</param> /// <param name="y">The y position of the mouse on the screen.</param> /// <param name="mouseEvent">The event that occurred. Provides information on whether it was just a move, or whether something was clicked, etc.</param> /// <param name="wheelDelta"></param> private void ProcessMouseEvents(MouseEventArgs e) { switch(e.MouseEvent) { // If the event was the user left-clicking, then set the launcher into the Held state, which means we're getting ready to fire case MouseEvent.LeftButtonDown: { Vec3 relativePos = CurrentBoid.Position - Renderer.ScreenToWorld(e.X, e.Y); // Check if the player clicked on the active boid. if(CurrentBoid.LocalBoundingBox.Contains(ref relativePos) && remainingBoids.Any()) { CurrentBoid.Position = Position; CurrentBoid.Physics.Resting = true; state = LauncherState.Held; } } break; // When the left mouse button is released, that's treated as the fire signal // (provided the state is Held, of course, just as a sanity check) case MouseEvent.LeftButtonUp: { if(state == LauncherState.Held) { var playerCamera = Actor.Client as PlayerCamera; playerCamera.TargetEntity = CurrentBoid; Fire(Renderer.ScreenToWorld(e.X, e.Y)); } } break; case MouseEvent.Move: { var screenWorldPos = Renderer.ScreenToWorld(e.X, e.Y); Debug.DrawSphere(screenWorldPos, .3f, Color.Red, .1f); if(state == LauncherState.Held && (Math.Pow(screenWorldPos.Y - Position.Y, 2) + Math.Pow(screenWorldPos.Z - Position.Z, 2) - Math.Pow(MaxPullDistance, 2)) <= 0) { CurrentBoid.Position = Position - new Vec3(0, Position.Y - screenWorldPos.Y, Position.Z - screenWorldPos.Z); } } break; } }
private void ProcessMouseEvents(MouseEventArgs e) { switch(e.MouseEvent) { // TODO: Rotate camera view around the TargetEntity. case MouseEvent.RightButtonDown: break; } }
private void ProcessMouseEvents(MouseEventArgs e) { switch(e.MouseEvent) { case MouseEvent.LeftButtonDown: { if(AutomaticFire) m_leftFiring = true; ChargeWeapon(); } break; case MouseEvent.LeftButtonUp: { if(AutomaticFire) m_leftFiring = false; else FireLeft(); } break; } }