mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 22:56:15 +01:00
kamera
This commit is contained in:
parent
eb19e290bb
commit
8821602728
@ -1,59 +1,60 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.input.InputManager;
|
||||
import com.jme3.input.KeyInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
|
||||
/**
|
||||
* Handhabt die Eingaben für die Kamera.
|
||||
*/
|
||||
public class CameraInputHandler {
|
||||
|
||||
private CameraController cameraController; // Kamera-Controller
|
||||
|
||||
/**
|
||||
* Konstruktor für den CameraInputHandler.
|
||||
*
|
||||
* @param cameraController Der Kamera-Controller, der gesteuert werden soll.
|
||||
* @param inputManager Der InputManager, um Eingaben zu registrieren.
|
||||
*/
|
||||
public CameraInputHandler(CameraController cameraController, InputManager inputManager) {
|
||||
if (cameraController == null || inputManager == null) {
|
||||
throw new IllegalArgumentException("CameraController und InputManager dürfen nicht null sein");
|
||||
}
|
||||
this.cameraController = cameraController;
|
||||
|
||||
// Mappings für Kamerasteuerung
|
||||
inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1)); // Modus 1
|
||||
inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2)); // Modus 2
|
||||
inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3)); // Modus 3
|
||||
|
||||
// Listener für die Kameramodi
|
||||
inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam");
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener für die Kamerasteuerung.
|
||||
*/
|
||||
private final ActionListener actionListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed) return;
|
||||
|
||||
// Umschalten der Kamera-Modi basierend auf der Eingabe
|
||||
switch (name) {
|
||||
case "FocusCurrentPlayer" -> {
|
||||
cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER);
|
||||
System.out.println("Kameramodus: Fokus auf aktuellen Spieler");
|
||||
}
|
||||
case "FocusSelf" -> {
|
||||
cameraController.setMode(CameraController.CameraMode.FOCUS_SELF);
|
||||
System.out.println("Kameramodus: Fokus auf eigene Figur");
|
||||
}
|
||||
case "FreeCam" -> {
|
||||
cameraController.setMode(CameraController.CameraMode.FREECAM);
|
||||
System.out.println("Kameramodus: Freie Kamera");
|
||||
}
|
||||
default -> System.err.println("Unbekannter Kameramodus: " + name);
|
||||
}
|
||||
};
|
||||
}
|
||||
//package pp.monopoly.client.gui;
|
||||
//
|
||||
//import com.jme3.input.InputManager;
|
||||
//import com.jme3.input.KeyInput;
|
||||
//import com.jme3.input.controls.ActionListener;
|
||||
//import com.jme3.input.controls.KeyTrigger;
|
||||
//
|
||||
///**
|
||||
// * Handhabt die Eingaben für die Kamera.
|
||||
// */
|
||||
//public class CameraInputHandler {
|
||||
//
|
||||
// private CameraController cameraController; // Kamera-Controller
|
||||
//
|
||||
// /**
|
||||
// * Konstruktor für den CameraInputHandler.
|
||||
// *
|
||||
// * @param cameraController Der Kamera-Controller, der gesteuert werden soll.
|
||||
// * @param inputManager Der InputManager, um Eingaben zu registrieren.
|
||||
// */
|
||||
// public CameraInputHandler(CameraController cameraController, InputManager inputManager) {
|
||||
// if (cameraController == null || inputManager == null) {
|
||||
// throw new IllegalArgumentException("CameraController und InputManager dürfen nicht null sein");
|
||||
// }
|
||||
// this.cameraController = cameraController;
|
||||
//
|
||||
// // Mappings für Kamerasteuerung
|
||||
// inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1)); // Modus 1
|
||||
// inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2)); // Modus 2
|
||||
// inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3)); // Modus 3
|
||||
//
|
||||
// // Listener für die Kameramodi
|
||||
// inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ActionListener für die Kamerasteuerung.
|
||||
// */
|
||||
// private final ActionListener actionListener = (name, isPressed, tpf) -> {
|
||||
// if (!isPressed) return;
|
||||
//
|
||||
// // Umschalten der Kamera-Modi basierend auf der Eingabe
|
||||
// switch (name) {
|
||||
// case "FocusCurrentPlayer" -> {
|
||||
// cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER);
|
||||
// System.out.println("Kameramodus: Fokus auf aktuellen Spieler");
|
||||
// }
|
||||
// case "FocusSelf" -> {
|
||||
// cameraController.setMode(CameraController.CameraMode.FOCUS_SELF);
|
||||
// System.out.println("Kameramodus: Fokus auf eigene Figur");
|
||||
// }
|
||||
// case "FreeCam" -> {
|
||||
// cameraController.setMode(CameraController.CameraMode.FREECAM);
|
||||
// System.out.println("Kameramodus: Freie Kamera");
|
||||
// }
|
||||
// default -> System.err.println("Unbekannter Kameramodus: " + name);
|
||||
// }
|
||||
// };
|
||||
//}
|
||||
//
|
Loading…
Reference in New Issue
Block a user