From 7c84238d96d48b54ef182b88d83fae52ebaab71a Mon Sep 17 00:00:00 2001 From: Croc-Prog-github <119326147+Croc-Prog-github@users.noreply.github.com> Date: Thu, 11 Jul 2024 17:55:02 +0200 Subject: [PATCH] 2 file edited --- .../BattleRoyal/bots/Movement-library.ts | 4 ++- game/GameMood/BattleRoyal/bots/bot1/bot1B.js | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/game/GameMood/BattleRoyal/bots/Movement-library.ts b/game/GameMood/BattleRoyal/bots/Movement-library.ts index 0995caa1..cc83d199 100644 --- a/game/GameMood/BattleRoyal/bots/Movement-library.ts +++ b/game/GameMood/BattleRoyal/bots/Movement-library.ts @@ -3,7 +3,9 @@ class MoverTS { constructor(element: HTMLElement) { this.element = element; - this.element.style.position = 'absolute'; // Imposta position: absolute + document.addEventListener('DOMContentLoaded', () => { + this.element.style.position = 'absolute'; // Imposta position: absolute + }) } achieve = { diff --git a/game/GameMood/BattleRoyal/bots/bot1/bot1B.js b/game/GameMood/BattleRoyal/bots/bot1/bot1B.js index 0f5d1064..14cf1288 100644 --- a/game/GameMood/BattleRoyal/bots/bot1/bot1B.js +++ b/game/GameMood/BattleRoyal/bots/bot1/bot1B.js @@ -1,5 +1,7 @@ -const bot1 = document.getElementById('bot1'); -const mover = new MoverTS(bot1); +document.addEventListener('DOMContentLoaded', () => { + const bot1 = document.getElementById('bot1'); + const mover = new MoverTS(bot1); +}) //Calcola la distanza tra i 2 elementi in argomento function getDistance(rect1, rect2) { @@ -36,16 +38,31 @@ function RadarMode() { //Cerca in un raggio di 100px gli id: player || PwUP } if (foundElement) { - console.info("Elemento più vicino trovato nel raggio: "+radius+"): ", foundElement.id); + console.info("Elemento più vicino trovato nel raggio: "+radius+"): " + foundElement.id); + return (foundElement.id); } else { console.warn("RadarMode(): Nessun elemento nel raggio di: "+radius+"px"); mover.glideAt(mover.getRandomX, mover.getRandomY, 3); // Va in una posizione a caso RadarMode(); + return false; } } document.addEventListener('DOMContentLoaded', () => { // Si sposta verso la cassa più vicina - mover.glideAtIdElement('PwUP', 3) + //mover.glideAtIdElement('PwUP', 3) + + RadarMode(); + switch (RadarMode()) { + case 'player': + + break; + case 'PwUP': + + break; + default: + console.warn("MainFlow: Nessun elemento definito rilevato da RadarMode()") + break; + } }) \ No newline at end of file