Retours v0.9.0 : fixes gameplay + Multiplayer sélectionnable + flèches compass
- IA ennemie : visionCheck BIDIRECTIONNEL (les ennemis spawnés dos au joueur ne le voyaient jamais — IDLE éternel, feedback 'n'attaquent plus') - Crash en pleine partie : director.numKills NPE après nullification (Defense fin de mission, listener non retiré) - Logo/Settings : depth 10 explicite sur le panneau + contenu 12 (le logo depth 5 passait DEVANT le panneau à depth 0) - Wall jump : condition dédiée SANS jumpCount==0 (impossible pour un humain : le saut initial comptait déjà 1) ; wall slide en anim 'jump' - EnemyCompass : 4 flèches pixel-art générées (palette du jeu, orientations par composante dominante) remplaçant le marqueur carré - Menu 6 options (limite levée) + entrée Multiplayer -> lobby avec sélecteur de serveur (préréglages 127.0.0.1 / 10.0.2.2 / 8bitwarframe.com, persist PlayerPrefs) et bouton LANCER (feedback : 'aucun moyen de le sélectionner, de mettre le serveur ou de jouer') - DesktopRenderUtils : ImageNotFoundError lisible (NPE obscure 'inputStream')
This commit is contained in:
parent
fb32501a3f
commit
76f8fa1d52
@ -14,6 +14,15 @@ public final class Transform extends Component {
|
||||
Transform parent;
|
||||
ArrayList<Transform> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Accès public aux enfants (lecture seule d'usage) : permet aux
|
||||
* composants du jeu (ex : SettingsMenu) d'ajuster des depths de rendu
|
||||
* sur toute une sous-arborescence sans connaître la structure interne.
|
||||
*/
|
||||
public java.util.List<Transform> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
Transform(GameObject gameObject) {
|
||||
this.gameObject = gameObject;
|
||||
position.setVector2ChangeListener(new Vector2ChangeListener() {
|
||||
|
||||
@ -122,8 +122,13 @@ public class DesktopRenderUtils implements RenderUtils {
|
||||
int texture = glGenTextures();
|
||||
|
||||
try {
|
||||
byte[] bytes = org.apache.commons.io.IOUtils
|
||||
.toByteArray(ClassLoader.getSystemResourceAsStream(path));
|
||||
java.io.InputStream rawStream = ClassLoader.getSystemResourceAsStream(path);
|
||||
if (rawStream == null) {
|
||||
// NPE obscure ("inputStream") avant : une image absente du
|
||||
// classpath (resources pas re-copiées) est signalée lisiblement.
|
||||
throw new ImageNotFoundError(path);
|
||||
}
|
||||
byte[] bytes = org.apache.commons.io.IOUtils.toByteArray(rawStream);
|
||||
ByteBuffer nativeData = ByteBuffer.allocateDirect(bytes.length);
|
||||
nativeData.put(bytes);
|
||||
nativeData.flip();
|
||||
|
||||
@ -236,8 +236,31 @@ public abstract class Behaviour {
|
||||
protected abstract void attack(Transform self, Transform target);
|
||||
|
||||
private void visionCheck() {
|
||||
RaycastHit hit = Physics.raycast(transform.position.offset(transform.scale.x > 0 ? 200 : 0, 100),
|
||||
new Vector2(transform.scale.x, 0), visionRange, visionLayerMaskTarget);
|
||||
/*
|
||||
* Vision BIDIRECTIONNELLE : le raycast d'origine ne testait QUE la
|
||||
* direction du regard (scale.x) — un ennemi spawné dos au joueur ne
|
||||
* le voyait JAMAIS (target = null -> IDLE éternel, feedback v0.9.0 :
|
||||
* "les ennemis n'attaquent plus et ne cherchent plus à aller taper
|
||||
* les joueurs", flagrant en Exterminate où les spawns se font des
|
||||
* deux côtés du joueur). On teste les deux directions et on garde le
|
||||
* hit le plus proche.
|
||||
*/
|
||||
RaycastHit right = Physics.raycast(
|
||||
transform.position.offset(transform.scale.x > 0 ? 200 : 0, 100),
|
||||
new Vector2(1, 0), visionRange, visionLayerMaskTarget);
|
||||
RaycastHit left = Physics.raycast(
|
||||
transform.position.offset(transform.scale.x > 0 ? 200 : 0, 100),
|
||||
new Vector2(-1, 0), visionRange, visionLayerMaskTarget);
|
||||
RaycastHit hit = null;
|
||||
if (right != null && left != null) {
|
||||
hit = right.transform.gameObject.transform.position.x - transform.position.x <
|
||||
Math.abs(left.transform.gameObject.transform.position.x - transform.position.x)
|
||||
? right : left;
|
||||
} else if (right != null) {
|
||||
hit = right;
|
||||
} else if (left != null) {
|
||||
hit = left;
|
||||
}
|
||||
if (hit == null) {
|
||||
target = null;
|
||||
targetIsObjective = false;
|
||||
|
||||
@ -3,58 +3,176 @@ package com.ezardlabs.lostsector.levels;
|
||||
import com.ezardlabs.dethsquare.Camera;
|
||||
import com.ezardlabs.dethsquare.GameObject;
|
||||
import com.ezardlabs.dethsquare.GuiText;
|
||||
import com.ezardlabs.dethsquare.PlayerPrefs;
|
||||
import com.ezardlabs.dethsquare.Input;
|
||||
import com.ezardlabs.dethsquare.Input.KeyCode;
|
||||
import com.ezardlabs.dethsquare.Level;
|
||||
import com.ezardlabs.dethsquare.LevelManager;
|
||||
import com.ezardlabs.dethsquare.PlayerPrefs;
|
||||
import com.ezardlabs.dethsquare.Screen;
|
||||
import com.ezardlabs.dethsquare.Script;
|
||||
import com.ezardlabs.dethsquare.TextureAtlas;
|
||||
import com.ezardlabs.dethsquare.Vector2;
|
||||
import com.ezardlabs.dethsquare.multiplayer.Matchmaker;
|
||||
import com.ezardlabs.dethsquare.multiplayer.Matchmaker.MatchmakingListener;
|
||||
import com.ezardlabs.dethsquare.multiplayer.MatchmakingGame;
|
||||
import com.ezardlabs.lostsector.objects.hud.TouchControls;
|
||||
import com.ezardlabs.dethsquare.util.GameLog;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/*
|
||||
* Lobby multijoueur : affiche le serveur configuré, permet de le CHANGER
|
||||
* (préréglages en cycle — feedback v0.9.0 : "y'a littérallement aucun moyen
|
||||
* de le sélectionner, de mettre le serveur ou de jouer") et de LANCER la
|
||||
* recherche de partie.
|
||||
*
|
||||
* Préréglages : 127.0.0.1 (serveur local), 10.0.2.2 (hôte vu depuis
|
||||
* l'émulateur), 8bitwarframe.com (serveur d'origine, mort). Le choix est
|
||||
* persisté en PlayerPrefs (mp_host/mp_port) et repris par MultiplayerLevel.
|
||||
* LS_MP_HOST/LS_MP_PORT (env) restent prioritaires pour le desktop (test).
|
||||
*
|
||||
* Interaction : TouchControls est attaché et MASQUÉ (aucun bouton de jeu
|
||||
* n'a de sens ici) mais son écoute "tap hors bouton = clic" reste active :
|
||||
* les libellés ci-dessous se cliquent comme les items du menu principal.
|
||||
*/
|
||||
public class MultiplayerLobbyLevel extends Level {
|
||||
private static final String[][] PRESETS = {
|
||||
{"127.0.0.1", "3000"},
|
||||
{"10.0.2.2", "3000"},
|
||||
{"8bitwarframe.com", "3000"},
|
||||
};
|
||||
private static final String TAG = "LS-MISSION";
|
||||
|
||||
private int presetIndex = 0;
|
||||
private GuiText serverText;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
GuiText guiText = new GuiText("Searching for game...",
|
||||
TextureAtlas.load("fonts/atlas.png", "fonts/atlas.txt"), 50);
|
||||
GameObject.instantiate(new GameObject("Searching", guiText),
|
||||
new Vector2(Screen.width / 2 - guiText.getWidth() / 2, Screen.height / 2 - 25));
|
||||
TouchControls.attach(); // EN PREMIER (ordre d'update) — écoute "clic"
|
||||
TouchControls.setButtonsVisible(false); // pas de boutons de jeu au lobby
|
||||
|
||||
GameObject.instantiate(new GameObject("Camera", new Camera(true)), new Vector2());
|
||||
|
||||
/*
|
||||
* Serveur de matchmaking configurable : l'équipe d'origine codait en
|
||||
* dur "8bitwarframe.com:3000" (serveur mort). Ordre de résolution :
|
||||
* 1. variable d'environnement LS_MP_HOST / LS_MP_PORT (test desktop :
|
||||
* `LS_MP_HOST=127.0.0.1 LS_MP_PORT=3000 gradlew run`) ;
|
||||
* 2. PlayerPrefs mp_host / mp_port (Android : éditable via run-as,
|
||||
* ou hôte du Mac = 10.0.2.2 depuis l'émulateur) ;
|
||||
* 3. défaut : serveur d'origine (si un jour il revit).
|
||||
*/
|
||||
String host = System.getenv("LS_MP_HOST");
|
||||
if (host == null || host.isEmpty()) {
|
||||
host = PlayerPrefs.getString("mp_host", "8bitwarframe.com");
|
||||
}
|
||||
int port;
|
||||
String portEnv = System.getenv("LS_MP_PORT");
|
||||
if (portEnv != null && !portEnv.isEmpty()) {
|
||||
port = Integer.parseInt(portEnv);
|
||||
} else {
|
||||
port = PlayerPrefs.getInt("mp_port", 3000);
|
||||
}
|
||||
GameLog.i("LS-MISSION", "Matchmaking : connexion à " + host + ":" + port);
|
||||
TextureAtlas font = TextureAtlas.load("fonts");
|
||||
|
||||
InetAddress ip = null;
|
||||
// Positions en unités GUI PURES (repère 1920x1080, comme le Menu) :
|
||||
// le repère est multiplié par refScale au rendu, indépendant de la
|
||||
// résolution réelle.
|
||||
GameObject.instantiate(new GameObject("Lobby Title", new GuiText("MULTIJOUEUR", font, 60)),
|
||||
new Vector2(660, 60));
|
||||
|
||||
// Affichage du serveur courant (PlayerPrefs, env prioritaire).
|
||||
String host = currentHost();
|
||||
int port = currentPort();
|
||||
serverText = new GuiText("Serveur: " + host + ":" + port, font, 40);
|
||||
GameObject.instantiate(new GameObject("Server Text", serverText), new Vector2(660, 300));
|
||||
|
||||
GameObject.instantiate(new GameObject("Server Change Hint",
|
||||
new GuiText("SERVEUR : changer de préréglage", font, 30)), new Vector2(660, 420));
|
||||
|
||||
GameObject.instantiate(new GameObject("Launch Hint",
|
||||
new GuiText("LANCER : chercher une partie", font, 30)), new Vector2(660, 530));
|
||||
|
||||
GameObject.instantiate(new GameObject("Back Hint",
|
||||
new GuiText("RETOUR : menu principal", font, 30)), new Vector2(660, 640));
|
||||
|
||||
GameObject.instantiate(new GameObject("Lobby Click Handler", new LobbyClicks()), new Vector2());
|
||||
}
|
||||
|
||||
/** Hôte courant : env (desktop/test) prioritaire, sinon PlayerPrefs. */
|
||||
private String currentHost() {
|
||||
String host = System.getenv("LS_MP_HOST");
|
||||
return host != null && !host.isEmpty() ? host : PlayerPrefs.getString("mp_host", PRESETS[0][0]);
|
||||
}
|
||||
|
||||
private int currentPort() {
|
||||
String portEnv = System.getenv("LS_MP_PORT");
|
||||
return portEnv != null && !portEnv.isEmpty() ? Integer.parseInt(portEnv)
|
||||
: PlayerPrefs.getInt("mp_port", Integer.parseInt(PRESETS[0][1]));
|
||||
}
|
||||
|
||||
/** Gestionnaire de clics du lobby (même modèle que Menu). */
|
||||
private class LobbyClicks extends Script {
|
||||
private TextureAtlas font;
|
||||
private long lastClick = 0;
|
||||
private boolean connecting = false;
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
runWhenPaused = true;
|
||||
font = TextureAtlas.load("fonts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (connecting) return;
|
||||
|
||||
/*
|
||||
* Zones cliquables en unités GUI ; la souris (Input.mousePosition)
|
||||
* est en PIXELS écran -> conversion mouse / refScale (identique au
|
||||
* rendu GUI : bounds = pos * refScale).
|
||||
*/
|
||||
float scale = Screen.width / 1920f;
|
||||
if (scale <= 0) return;
|
||||
float mouseX = Input.mousePosition.x / scale;
|
||||
float mouseY = Input.mousePosition.y / scale;
|
||||
RectF serverZone = rect(660, 420, 800, 50);
|
||||
RectF launchZone = rect(660, 530, 800, 50);
|
||||
RectF backZone = rect(660, 640, 800, 50);
|
||||
|
||||
boolean clicked = Input.getKeyDown(KeyCode.MOUSE_LEFT)
|
||||
&& serverText != null && hitZone(new Vector2(mouseX, mouseY), serverZone, launchZone, backZone);
|
||||
if (!clicked) return;
|
||||
|
||||
if (System.currentTimeMillis() - lastClick < 500) return;
|
||||
lastClick = System.currentTimeMillis();
|
||||
|
||||
Vector2 mouseGui = new Vector2(mouseX, mouseY);
|
||||
if (inZone(mouseGui, serverZone)) {
|
||||
presetIndex = (presetIndex + 1) % PRESETS.length;
|
||||
PlayerPrefs.setInt("mp_port", Integer.parseInt(PRESETS[presetIndex][1]));
|
||||
// putString : PlayerPrefs n'expose que getInt/setInt via les
|
||||
// back-ends actuels ? non — getString existe, on persiste l'hôte.
|
||||
PlayerPrefs.setString("mp_host", PRESETS[presetIndex][0]);
|
||||
serverText.setText("Serveur: " + PRESETS[presetIndex][0] + ":" + PRESETS[presetIndex][1]);
|
||||
GameLog.i(TAG, "Multiplayer : serveur préréglé -> " + PRESETS[presetIndex][0] + ":"
|
||||
+ PRESETS[presetIndex][1]);
|
||||
} else if (inZone(mouseGui, launchZone)) {
|
||||
connecting = true;
|
||||
launch();
|
||||
} else if (inZone(mouseGui, backZone)) {
|
||||
LevelManager.loadLevel("main_menu");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean inZone(Vector2 mouse, RectF zone) {
|
||||
return zone.contains(mouse.x, mouse.y);
|
||||
}
|
||||
|
||||
private RectF rect(float x, float y, float w, float h) {
|
||||
return new RectF(x, y, x + w, y + h);
|
||||
}
|
||||
|
||||
private boolean hitZone(Vector2 mouse, RectF... zones) {
|
||||
for (RectF z : zones) {
|
||||
if (z.contains(mouse.x, mouse.y)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Lance la recherche de partie sur le serveur sélectionné. */
|
||||
private void launch() {
|
||||
String host = currentHost();
|
||||
int port = currentPort();
|
||||
GameLog.i(TAG, "Multiplayer : recherche de partie sur " + host + ":" + port);
|
||||
InetAddress ip;
|
||||
try {
|
||||
ip = InetAddress.getByName(host);
|
||||
} catch (UnknownHostException e) {
|
||||
GameLog.e("LS-MISSION", "Matchmaking : hôte '" + host + "' introuvable");
|
||||
e.printStackTrace();
|
||||
GameLog.e(TAG, "Multiplayer : hôte '" + host + "' introuvable");
|
||||
return;
|
||||
}
|
||||
Matchmaker matchmaker = new Matchmaker(ip, port);
|
||||
matchmaker.findGame(new MatchmakingListener() {
|
||||
@ -71,8 +189,28 @@ public class MultiplayerLobbyLevel extends Level {
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
System.err.println(error);
|
||||
GameLog.e(TAG, "Multiplayer : " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Rect en unités GUI (bas-haut), miroir de TouchControls.Button.RectF. */
|
||||
private static class RectF {
|
||||
final float left, top, right, bottom;
|
||||
|
||||
RectF(float left, float top, float right, float bottom) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
boolean contains(float x, float y) {
|
||||
return x >= left && x <= right && y >= top && y <= bottom;
|
||||
}
|
||||
|
||||
boolean contains(Vector2 position) {
|
||||
return contains(position.x, position.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,17 @@ public class DefenseMission extends Mission {
|
||||
|
||||
@Override
|
||||
public void onEnemyKilled(Enemy enemy) {
|
||||
director.numKills++;
|
||||
/*
|
||||
* Null-check obligatoire : en fin de mission, director est
|
||||
* nullifié (destroy du GameObject Director) mais ce listener
|
||||
* reste enregistré — le moindre kill après la fin de mission
|
||||
* (drop, ennemi mourant en retard) provoquait un NPE fatale en
|
||||
* pleine partie (feedback v0.9.0 : "jeu instable qui plante
|
||||
* en pleine partie").
|
||||
*/
|
||||
if (director != null) {
|
||||
director.numKills++;
|
||||
}
|
||||
}
|
||||
});
|
||||
GameLog.i("LS-MISSION", "DefenseMission.load(): spawning Defense Director (director=" + director + ")");
|
||||
|
||||
@ -77,7 +77,15 @@ public class Player extends Script {
|
||||
*/
|
||||
Transition<State> wallSliding = new Transition<>(State.WALL_SLIDING, this::wallSlideCheck, () ->
|
||||
GameLog.d("LS-GAMEPLAY", "glisse murale : mur " + (wallContact > 0 ? "droite" : "gauche")));
|
||||
Transition<State> wallJumping = new Transition<>(State.JUMPING, this::jumpCheck, () -> {
|
||||
Transition<State> wallJumping = new Transition<>(State.JUMPING, () ->
|
||||
Input.getKeyDown(KeyCode.SPACE), () -> {
|
||||
/*
|
||||
* wallJumping utilise SA PROPRE condition (ESPACE uniquement, SANS
|
||||
* le check jumpCount == 0 de jumpCheck) : depuis un mur, le
|
||||
* jumpCount vaut déjà 1+ (le saut initial pour atteindre le mur) —
|
||||
* le check d'origine rendait le saut mural IMPOSSIBLE pour un
|
||||
* humain (feedback v0.9.0).
|
||||
*/
|
||||
gameObject.rigidbody.velocity.x = -wallContact * 18f;
|
||||
gameObject.rigidbody.velocity.y = -22f;
|
||||
jumpCount = 1; // le wall jump redonne un saut aérien
|
||||
@ -182,7 +190,10 @@ public class Player extends Script {
|
||||
* sprite dédié de glissade (limitation art).
|
||||
*/
|
||||
gameObject.rigidbody.velocity.y = 2.5f;
|
||||
gameObject.animator.play("fall");
|
||||
// "jump" : Frost accroché au mur (l'anim "fall" d'origine était
|
||||
// inadaptée — feedback v0.9.0 ; pas de sprite de glissade dédié,
|
||||
// limitation art).
|
||||
gameObject.animator.play("jump");
|
||||
ability1Check();
|
||||
break;
|
||||
case LANDING:
|
||||
|
||||
@ -6,31 +6,40 @@ import com.ezardlabs.dethsquare.GuiRenderer;
|
||||
import com.ezardlabs.dethsquare.Screen;
|
||||
import com.ezardlabs.dethsquare.Script;
|
||||
import com.ezardlabs.dethsquare.Vector2;
|
||||
import com.ezardlabs.dethsquare.graphics.Renderer;
|
||||
import com.ezardlabs.dethsquare.util.GameLog;
|
||||
|
||||
/*
|
||||
* Boussole d'ennemis (mission Exterminate, feedback v4.0.0 : "aucun
|
||||
* indicateur pour me montrer où les ennemis à tuer sont").
|
||||
* Boussole d'ennemis (mission Exterminate, feedback v0.9.0 : "l'indicateur
|
||||
* des ennemis est dégueu, fais une flèche pour que ce soit plus
|
||||
* compréhensible").
|
||||
*
|
||||
* Principe : l'ennemi VIVANT le plus proche du joueur est projeté en
|
||||
* coordonnées écran ; s'il est hors champ, un marqueur jaune est collé au
|
||||
* bord de l'écran dans sa direction ; s'il est visible, le marqueur
|
||||
* disparaît. Cible = l'ennemi le plus proche (il y en a exactement 15 en
|
||||
* Exterminate : le plus proche est celui à tuer ensuite).
|
||||
* coordonnées écran ; s'il est hors champ, une FLÈCHE jaune (sprite
|
||||
* pixel-art 16x16, 4 orientations générées dans la palette du jeu) est
|
||||
* collée au bord de l'écran dans sa direction — l'orientation est choisie
|
||||
* par composante dominante (le moteur ne supporte pas la rotation). S'il
|
||||
* est visible, la flèche disparaît. Cible = l'ennemi le plus proche (il y
|
||||
* en a exactement 15 en Exterminate : le plus proche est celui à tuer
|
||||
* ensuite).
|
||||
*
|
||||
* 100 % GUI (GuiRenderer, couche 2) : fonctionne identiquement sur desktop et
|
||||
* Android, indépendant de la caméra (pas de rotation disponible dans le
|
||||
* moteur, d'où un marqueur positionnel plutôt qu'une flèche orientée).
|
||||
* Android, indépendant de la caméra.
|
||||
*
|
||||
* Perimètre : Exterminate uniquement (attaché depuis ExterminateMission.load).
|
||||
* Périmètre : Exterminate uniquement (attaché depuis ExterminateMission.load).
|
||||
*/
|
||||
public class EnemyCompass extends Script {
|
||||
private static final String TAG = "LS-MISSION";
|
||||
private static final float MARGIN_PX = 30f; // marge entre le marqueur et le bord
|
||||
private static final float MARKER_SIZE = 26f; // px
|
||||
private static final float MARGIN_PX = 34f; // marge entre la flèche et le bord
|
||||
private static final float ARROW_SIZE = 40f; // px
|
||||
private static final String[] ARROW_PATHS = {
|
||||
"images/hud/arrows/arrow_right.png",
|
||||
"images/hud/arrows/arrow_left.png",
|
||||
"images/hud/arrows/arrow_down.png",
|
||||
"images/hud/arrows/arrow_up.png",
|
||||
};
|
||||
|
||||
private GuiRenderer marker;
|
||||
private String currentArrow = "";
|
||||
private GameObject player;
|
||||
|
||||
/** À instancier EN DERNIER dans le niveau (au-dessus des autres GUI). */
|
||||
@ -40,14 +49,11 @@ public class EnemyCompass extends Script {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
marker = new GuiRenderer("images/white.png", MARKER_SIZE, MARKER_SIZE);
|
||||
marker.setTint(1f, 0.85f, 0.2f, 0.9f); // jaune Warframe, très visible
|
||||
marker = new GuiRenderer(ARROW_PATHS[0], ARROW_SIZE, ARROW_SIZE);
|
||||
marker.setDepth(930); // au-dessus du HUD tactile (910)
|
||||
// Le GuiRenderer vit sur un GameObject DÉDIÉ : le script ne doit pas
|
||||
// partager son GO avec d'autres renderers (convention du moteur).
|
||||
gameObject.addComponent(marker);
|
||||
marker.enabled = false;
|
||||
GameLog.i(TAG, "EnemyCompass attaché");
|
||||
GameLog.i(TAG, "EnemyCompass attaché (flèches 4 directions)");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,8 +66,7 @@ public class EnemyCompass extends Script {
|
||||
return;
|
||||
}
|
||||
|
||||
// Joueur : référence du suivi (re-trouvé à chaque frame : le GO est
|
||||
// détruit/recréé à chaque mort/rechargement de mission).
|
||||
// Joueur : référence du suivi (re-trouvé à chaque mort/rechargement).
|
||||
if (player == null || !player.isActive()) {
|
||||
GameObject[] players = GameObject.findAllWithTag("player");
|
||||
player = players.length > 0 ? players[0] : null;
|
||||
@ -97,20 +102,38 @@ public class EnemyCompass extends Script {
|
||||
float ex = nearest.transform.position.x * Screen.scale - Camera.main.transform.position.x;
|
||||
float ey = nearest.transform.position.y * Screen.scale - Camera.main.transform.position.y;
|
||||
|
||||
float halfW = Screen.width / 2f;
|
||||
float halfH = Screen.height / 2f;
|
||||
boolean onScreen = ex >= -MARKER_SIZE && ex <= Screen.width + MARKER_SIZE &&
|
||||
ey >= -MARKER_SIZE && ey <= Screen.height + MARKER_SIZE;
|
||||
boolean onScreen = ex >= -ARROW_SIZE && ex <= Screen.width + ARROW_SIZE &&
|
||||
ey >= -ARROW_SIZE && ey <= Screen.height + ARROW_SIZE;
|
||||
if (onScreen) {
|
||||
// L'ennemi est (presque) à l'écran : pas besoin de boussole.
|
||||
marker.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Clamp du marqueur sur le bord de l'écran (marge MARGIN_PX).
|
||||
// Clamp de la flèche sur le bord de l'écran (marge MARGIN_PX).
|
||||
float mx = Math.max(MARGIN_PX, Math.min(Screen.width - MARGIN_PX, ex));
|
||||
float my = Math.max(MARGIN_PX, Math.min(Screen.height - MARGIN_PX, ey));
|
||||
|
||||
/*
|
||||
* Orientation par composante dominante (pas de rotation dans le
|
||||
* moteur) : la flèche pointe VERS l'ennemi, relativement au CENTRE de
|
||||
* l'écran.
|
||||
*/
|
||||
float dxFromCenter = ex - Screen.width / 2f;
|
||||
float dyFromCenter = ey - Screen.height / 2f;
|
||||
String arrow;
|
||||
if (Math.abs(dxFromCenter) >= Math.abs(dyFromCenter)) {
|
||||
arrow = ARROW_PATHS[dxFromCenter > 0 ? 0 : 1];
|
||||
} else {
|
||||
arrow = ARROW_PATHS[dyFromCenter > 0 ? 2 : 3];
|
||||
}
|
||||
if (!currentArrow.equals(arrow)) {
|
||||
// setImage recharge le sprite (cache loadImage par chemin ✓).
|
||||
marker.setImage(arrow, ARROW_SIZE, ARROW_SIZE);
|
||||
marker.setDepth(930);
|
||||
currentArrow = arrow;
|
||||
}
|
||||
|
||||
// Pixels écran -> unités GUI (repère GUI = pixels / refScale).
|
||||
float refScale = Screen.width / 1920f;
|
||||
if (refScale <= 0) return;
|
||||
|
||||
@ -41,6 +41,7 @@ public class MainMenu extends Menu {
|
||||
"Defend",
|
||||
"Exterminate",
|
||||
"Survival",
|
||||
"Multiplayer",
|
||||
"Settings",
|
||||
"Quit"
|
||||
};
|
||||
@ -52,6 +53,7 @@ public class MainMenu extends Menu {
|
||||
(menu, index, text) -> LevelManager.loadLevel("defense"),
|
||||
(menu, index, text) -> LevelManager.loadLevel("exterminate"),
|
||||
(menu, index, text) -> LevelManager.loadLevel("survival"),
|
||||
(menu, index, text) -> LevelManager.loadLevel("multiplayer_lobby"),
|
||||
new MenuAction() {
|
||||
@Override
|
||||
public void onMenuItemSelected(Menu menu, int index, String text) {
|
||||
|
||||
@ -50,8 +50,11 @@ public class Menu extends Script {
|
||||
this.offset = offset;
|
||||
this.startOpen = startOpen;
|
||||
|
||||
if (options.length < 2 || options.length > 5) {
|
||||
throw new IllegalArgumentException("You must supply between 2 and 5 options to the menu");
|
||||
// 6 options (feedback v0.9.0 : l'entrée Multiplayer n'avait aucun moyen
|
||||
// d'être sélectionnée) — la mise à l'échelle de start() absorbe la
|
||||
// hauteur supplémentaire (s=0.62 à 6 options, barres lisibles).
|
||||
if (options.length < 2 || options.length > 6) {
|
||||
throw new IllegalArgumentException("You must supply between 2 and 6 options to the menu");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,8 +26,15 @@ public class SettingsMenu extends Script {
|
||||
@Override
|
||||
public void start() {
|
||||
runWhenPaused = true;
|
||||
GameObject.instantiate(
|
||||
new GameObject("Settings Background", new GuiRenderer("images/menus/settings/base.png", 1200, 1000)),
|
||||
/*
|
||||
* Depth 10 explicite : à depth ÉGAL le tri GUI se fait sur l'ID de
|
||||
* texture (instable après destroyAll) — le logo (depth 5) passait
|
||||
* DEVANT ce panneau quand on entrait dans les Settings (feedback
|
||||
* v0.9.0). Le contenu du panneau est poussé à 12 par le walk ci-dessous.
|
||||
*/
|
||||
GuiRenderer backgroundRenderer = new GuiRenderer("images/menus/settings/base.png", 1200, 1000);
|
||||
backgroundRenderer.setDepth(10);
|
||||
GameObject.instantiate(new GameObject("Settings Background", backgroundRenderer),
|
||||
transform.position).transform.setParent(transform);
|
||||
|
||||
GameObject.instantiate(
|
||||
@ -41,6 +48,15 @@ public class SettingsMenu extends Script {
|
||||
GameObject.instantiate(new GameObject("Settings Tab Manager",
|
||||
new SettingsTabManager(new AudioSettingsTab(), new GraphicsSettingsTab(), new ControlsSettingsTab())),
|
||||
new Vector2(transform.position)).transform.setParent(transform);
|
||||
/*
|
||||
* Contenu du panneau au-dessus du fond (depth 12 > 10) :
|
||||
* getComponentsOfType(GuiRenderer) couvre toute la hiérarchie (le
|
||||
* walk enfants de Transform est package-private côté moteur).
|
||||
*/
|
||||
for (com.ezardlabs.dethsquare.GuiRenderer r : gameObject
|
||||
.getComponentsOfType(com.ezardlabs.dethsquare.GuiRenderer.class)) {
|
||||
r.setDepth(12);
|
||||
}
|
||||
gameObject.setActive(false);
|
||||
}
|
||||
|
||||
|
||||
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_down.png
Normal file
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_down.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 151 B |
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_left.png
Normal file
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_left.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 151 B |
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_right.png
Normal file
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_right.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 158 B |
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_up.png
Normal file
BIN
lost-sector/src/main/resources/images/hud/arrows/arrow_up.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 159 B |
Loading…
x
Reference in New Issue
Block a user