Modification des bonus Bouclier pour avoir un meilleur visuel => On voit désormais le bonus bouclier avec la couleur qui lui appartient, si l'on prend plusieurs bonus, les couleurs des différents boucliers sont bien visible - Création du fonctionnement de position random des robots au chargement du niveau (les positions sont randoms si "robotRandomPosition" = true dans le fichier json du niveau) - Ajout de la possiblité d'afficher ou non les robots ennemis et/ou les bonus depuis les variables "enemyVisible" et "bonusVisible" du fichier json du niveau - Les positions initiales des robots se sauvegardent si elles sont random dans le but de pouvoir relancer le niveau, changer de langue ...

master
clmaisonha 5 years ago
parent ac88349e39
commit 5a464071cc

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
{"tree":{"type":"waria","lRect":[{"type":"move","option":[true,false]},{"type":"attack","option":[0.3333333333333333]},{"type":"condition","option":[true,true,false,0.3333333333333333,0],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":2,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":3,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":3,"valueMax":5,"color":255,"colorMin":255},{"value":2,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.1,"y":0.1,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"shield","number":0,"x":0.5,"y":0.5}]} {"enemyVisible":true,"bonusVisible":true,"robotRandomPosition":true,"tree":{"type":"waria","lRect":[{"type":"move","option":[true,false]},{"type":"attack","option":[0.3333333333333333]},{"type":"condition","option":[true,true,false,0.3333333333333333,0],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":2,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":3,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":3,"valueMax":5,"color":255,"colorMin":255},{"value":2,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.1,"y":0.1,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"shield","number":0,"x":0.5,"y":0.5}]}

@ -1 +1 @@
{"tree":{"type":"waria","lRect":[{"type":"condition","option":[true,true,false,0.3333333333333333,0],"lRect":[{"type":"move","option":[true,false]}]},{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":0,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":5,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.1,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.7,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.5,"y":0.4,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.7,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.9,"y":0.2,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"speed","number":0,"x":0.5,"y":0.5},{"style":"attack","number":2,"x":0.7,"y":0.7},{"style":"shield","number":0,"x":0.2,"y":0.9},{"style":"shield","number":1,"x":0.8,"y":0.4},{"style":"shield","number":2,"x":0.2,"y":0.2}]} {"enemyVisible":false,"bonusVisible":true,"robotRandomPosition":true,"tree":{"type":"waria","lRect":[{"type":"condition","option":[true,true,false,0.3333333333333333,0],"lRect":[{"type":"move","option":[true,false]}]},{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":0,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":5,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.1,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.7,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.5,"y":0.4,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.7,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.9,"y":0.2,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"speed","number":0,"x":0.5,"y":0.5},{"style":"attack","number":2,"x":0.7,"y":0.7},{"style":"shield","number":0,"x":0.2,"y":0.9},{"style":"shield","number":1,"x":0.8,"y":0.4},{"style":"shield","number":2,"x":0.2,"y":0.2}]}

@ -1 +1 @@
{"tree":{"type":"waria","lRect":[{"type":"attack","option":[0.3333333333333333]},{"type":"condition","option":[false,false,true,0.3333333333333333,1],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"move","option":[true,false]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":5,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":0,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.5,"y":0.1,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"speed","number":0,"x":0.5,"y":0.5}]} {"enemyVisible":false,"bonusVisible":true,"robotRandomPosition":false,"tree":{"type":"waria","lRect":[{"type":"attack","option":[0.3333333333333333]},{"type":"condition","option":[false,false,true,0.3333333333333333,1],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"move","option":[true,false]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":5,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":0,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.5,"y":0.1,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"speed","number":0,"x":0.5,"y":0.5}]}

@ -1 +1 @@
{"lSpeedBonus":[{"name":{"en":"SPEED BRONZE","fr":"VITESSE BRONZE"},"texture":"bonusSpeed0","value":2,"time":6000},{"name":{"en":"SPEED SILVER","fr":"VITESSE ARGENT"},"texture":"bonusSpeed1","value":3,"time":4000},{"name":{"en":"SPEED GOLD","fr":"VITESSE OR"},"texture":"bonusSpeed2","value":4,"time":2000}],"lAttackBonus":[{"name":{"en":"ATTACK BRONZE","fr":"ATTAQUE BRONZE"},"texture":"bonusAttack0","value":2},{"name":{"en":"ATTACK SILVER","fr":"ATTAQUE ARGENT"},"texture":"bonusAttack1","value":3},{"name":{"en":"ATTACK GOLD","fr":"ATTAQUE OR"},"texture":"bonusAttack2","value":4}],"lShieldBonus":[{"name":{"en":"SHIELD BRONZE","fr":"BOUCLIER BRONZE"},"texture":"bonusShield0","value":75,"time":15000,"color":8021041},{"name":{"en":"SHIELD SILVER","fr":"BOUCLIER ARGENT"},"texture":"bonusShield1","value":125,"time":10000,"color":10066083},{"name":{"en":"SHIELD GOLD","fr":"BOUCLIER OR"},"texture":"bonusShield2","value":200,"time":5000,"color":13093166}]} {"lSpeedBonus":[{"name":{"en":"BRONZE SPEED","fr":"VITESSE BRONZE"},"texture":"bonusSpeed0","value":2,"time":6000},{"name":{"en":"SILVER SPEED","fr":"VITESSE ARGENT"},"texture":"bonusSpeed1","value":3,"time":4000},{"name":{"en":"GOLD SPEED","fr":"VITESSE OR"},"texture":"bonusSpeed2","value":4,"time":2000}],"lAttackBonus":[{"name":{"en":"BRONZE ATTACK","fr":"ATTAQUE BRONZE"},"texture":"bonusAttack0","value":2},{"name":{"en":"SILVER ATTACK","fr":"ATTAQUE ARGENT"},"texture":"bonusAttack1","value":3},{"name":{"en":"GOLD ATTACK","fr":"ATTAQUE OR"},"texture":"bonusAttack2","value":4}],"lShieldBonus":[{"name":{"en":"BRONZE SHIELD","fr":"BOUCLIER BRONZE"},"texture":"bonusShield0","value":75,"time":15000,"color":8021041},{"name":{"en":"SILVER SHIELD","fr":"BOUCLIER ARGENT"},"texture":"bonusShield1","value":125,"time":10000,"color":10066083},{"name":{"en":"GOLD SHIELD","fr":"BOUCLIER OR"},"texture":"bonusShield2","value":200,"time":5000,"color":13093166}]}

@ -0,0 +1,17 @@
class BonusHealth {
constructor(value, color) {
this.value = value;
this.color = color;
}
decrease(amount) {
this.value -= amount;
let diff = 0;
if (this.value < 0) {
diff = -this.value;
this.value = 0;
}
return diff;
}
}

@ -6,11 +6,11 @@ class BonusShield extends Bonus {
} }
useOn(robot, scene) { useOn(robot, scene) {
let oldColor = robot.shield.color; let bonus = new BonusHealth(this.value, this.color);
robot.shield.increaseValueMax(this.value, this.color); robot.shield.addBonus(bonus);
scene.time.addEvent({ scene.time.addEvent({
delay: this.time, delay: this.time,
callback: () => robot.shield.decreaseValueMax(this.value, oldColor) callback: () => robot.shield.removeBonus(bonus)
}); });
} }
} }

@ -55,7 +55,7 @@ class Condition {
} }
verifyShield(target) { verifyShield(target) {
return target.shield.value / target.shield.valueMax <= this.shield; return target.shield.getValue() / target.shield.valueMax <= this.shield;
} }

@ -4,6 +4,7 @@ class Game extends ManageLang {
super.addOtherScenes('GamingBoard'); super.addOtherScenes('GamingBoard');
SPEED_GAME = 1; SPEED_GAME = 1;
this.level = level; this.level = level;
this.listPositionRobotInit = [];
} }
preload() { preload() {
@ -22,13 +23,7 @@ class Game extends ManageLang {
} }
this.load.json('level', 'public/json/' + this.level + '.json'); this.load.json('level', 'public/json/' + this.level + '.json');
this.gm = new GamingBoard(this); this.createGamingBoard();
if (this.father.scene.getIndex('GamingBoard') !== -1) {
this.father.scene.remove('GamingBoard');
}
this.father.scene.add('GamingBoard', this.gm);
this.scene.launch('GamingBoard');
this.scene.pause('GamingBoard');
} }
create() { create() {
@ -42,19 +37,18 @@ class Game extends ManageLang {
if (this.tree !== undefined && this.initStat !== undefined) { if (this.tree !== undefined && this.initStat !== undefined) {
let tree = this.tree.getJson(true); let tree = this.tree.getJson(true);
tree = JSON.parse(tree); level.tree = JSON.parse(tree);
let initStat = this.initStat.getJson(true); let initStat = this.initStat.getJson(true);
initStat = JSON.parse(initStat); level.initStat = JSON.parse(initStat);
this.loadSave(tree, initStat, level.robots, level.lBonus);
} else {
this.loadSave(level.tree, level.initStat, level.robots, level.lBonus);
} }
this.loadSave(level.tree, level.initStat, level.robots, level.lBonus, level.robotRandomPosition);
this.doLine = false; this.gm.setEnemyRobotVisible(level.enemyVisible);
this.gm.setBonusVisible(level.bonusVisible);
this.selected = null;
this.doLine = false;
this.createButton(); this.createButton();
@ -67,6 +61,8 @@ class Game extends ManageLang {
this.input.keyboard.on('keydown-ENTER', () => { this.input.keyboard.on('keydown-ENTER', () => {
this.clickPlus(); this.clickPlus();
}); });
this.scene.setVisible(true, 'GamingBoard');
} }
update(time, delta) { update(time, delta) {
@ -75,10 +71,20 @@ class Game extends ManageLang {
this.tree.updateLine(); this.tree.updateLine();
} }
createGamingBoard() {
this.gm = new GamingBoard(this);
if (this.father.scene.getIndex('GamingBoard') !== -1) {
this.father.scene.remove('GamingBoard');
}
this.father.scene.add('GamingBoard', this.gm);
this.scene.launch('GamingBoard');
this.scene.pause('GamingBoard');
}
loadSave(tree, initStat, robot, lBonus) { loadSave(tree, initStat, robot, lBonus, robotRandomPosition) {
this.loadBonus(lBonus); this.loadBonus(lBonus);
this.loadRobot(robot); this.loadRobot(robot, robotRandomPosition);
this.initStat = this.loadInitSave(initStat); this.initStat = this.loadInitSave(initStat);
this.tree = this.loadTree(tree); this.tree = this.loadTree(tree);
} }
@ -117,12 +123,25 @@ class Game extends ManageLang {
return initStat; return initStat;
} }
loadRobot(element = []) { loadRobot(element = [], randomPosition = false) {
let i = 0;
element.forEach(robot => { element.forEach(robot => {
let lNode = []; let lNode = [];
robot.lNode.forEach(node => lNode.push(this.loadNode(node))); robot.lNode.forEach(node => lNode.push(this.loadNode(node)));
this.gm.addRobot(new Robot(WIDTH_MAP * robot.height, WIDTH_MAP * robot.width, WIDTH_MAP * robot.x, WIDTH_MAP * robot.y, this.gm, robot.name, robot.speed, robot.speedReload, robot.range, robot.damage, lNode)); if (randomPosition) {
}) if (this.listPositionRobotInit[i] === undefined) {
robot.x = Math.random() * ((1 - robot.width / 2) - robot.width / 2) + robot.width / 2;
robot.y = Math.random() * ((1 - robot.height / 2) - robot.height / 2) + robot.height / 2;
this.listPositionRobotInit[i] = new Position(robot.x, robot.y);
} else {
robot.x = this.listPositionRobotInit[i].x;
robot.y = this.listPositionRobotInit[i].y;
}
}
this.gm.addRobot(new Robot(WIDTH_MAP * robot.height, WIDTH_MAP * robot.width, WIDTH_MAP * robot.x, WIDTH_MAP * robot.y, this.gm, robot.name, robot.speed, robot.speedReload, robot.range, robot.damage, lNode));
i += 1;
}
)
} }
loadNode(element) { loadNode(element) {
@ -190,7 +209,7 @@ class Game extends ManageLang {
this.tryClick(); this.tryClick();
this.selected = this.tree.getSelected(); this.selected = this.tree.getSelected();
if (this.selected === null) if (this.selected === undefined)
return; return;
if (this.selected !== this.tree) { if (this.selected !== this.tree) {
@ -357,7 +376,7 @@ class Game extends ManageLang {
} }
clickPencil() { clickPencil() {
if (this.selected !== null) { if (this.selected !== undefined) {
console.log("PENCIL"); console.log("PENCIL");
switch (this.selected.type) { switch (this.selected.type) {
case 'attack': case 'attack':
@ -382,7 +401,7 @@ class Game extends ManageLang {
} }
clickBin() { clickBin() {
if (this.selected !== null) { if (this.selected !== undefined) {
console.log("BIN"); console.log("BIN");
this.tree.delete(this.selected); this.tree.delete(this.selected);
@ -392,7 +411,7 @@ class Game extends ManageLang {
} }
clickPlus() { clickPlus() {
if (this.selected !== null && this.selected.canAddNode) { if (this.selected !== undefined && this.selected.canAddNode) {
console.log("PLUS"); console.log("PLUS");
this.father.scene.add('PlusNode', new PlusNode(this.father, this, this.selected)); this.father.scene.add('PlusNode', new PlusNode(this.father, this, this.selected));
@ -431,9 +450,9 @@ class Game extends ManageLang {
this.pencil.setVisible(false); this.pencil.setVisible(false);
this.bin.setVisible(false); this.bin.setVisible(false);
this.plus.setVisible(false); this.plus.setVisible(false);
if (this.selected != null) { if (this.selected != undefined) {
this.selected.deselect(); this.selected.deselect();
this.selected = null; this.selected = undefined;
} }
} }
} }

@ -11,6 +11,7 @@ class GamingBoard extends Phaser.Scene {
this.cameras.main.setViewport(OFFX_MAP, OFFY_MAP, WIDTH_MAP, WIDTH_MAP); this.cameras.main.setViewport(OFFX_MAP, OFFY_MAP, WIDTH_MAP, WIDTH_MAP);
this.sound.add('shot'); this.sound.add('shot');
this.sound.add('hit'); this.sound.add('hit');
this.scene.setVisible(false, 'GamingBoard');
} }
create() { create() {
@ -47,6 +48,22 @@ class GamingBoard extends Phaser.Scene {
} }
} }
setRobotVisible(boolean = true) {
this.listRobot.forEach(robot => robot.setVisible(boolean));
}
setEnemyRobotVisible(boolean = true) {
let myself = this.getMyRobot();
this.listRobot.forEach(robot => {
if (robot !== myself)
robot.setVisible(boolean)
});
}
setBonusVisible(boolean = true) {
listBonus.forEach(bonus => bonus.setVisible(boolean));
}
finish() { finish() {
this.pause(); this.pause();
this.father.finish(); this.father.finish();
@ -64,6 +81,8 @@ class GamingBoard extends Phaser.Scene {
resume() { resume() {
this.scene.resume('GamingBoard'); this.scene.resume('GamingBoard');
this.sound.resumeAll(); this.sound.resumeAll();
this.setRobotVisible(true);
this.setBonusVisible(true);
} }
addRobot(robot) { addRobot(robot) {

@ -0,0 +1,6 @@
class Position {
constructor(x, y) {
this.x = x;
this.y = y;
}
}

@ -56,7 +56,7 @@ class RectangleNode {
} }
} }
} }
return null; return undefined;
} }
click() { click() {

@ -9,7 +9,6 @@ class Robot {
this.y = y; this.y = y;
this.life = new HealthBar(scene, selectWord("LIFE", "VIE"), this.width * 2, this.width / 3, this.x, this.y - this.width, LIFE, 0x008000); this.life = new HealthBar(scene, selectWord("LIFE", "VIE"), this.width * 2, this.width / 3, this.x, this.y - this.width, LIFE, 0x008000);
this.shield = new HealthBar(scene, selectWord("SHIELD", "BOUCLIER"), this.width * 2, this.width / 3, this.x, this.y - this.width * 1.5, SHIELD, 0x0000FF); this.shield = new HealthBar(scene, selectWord("SHIELD", "BOUCLIER"), this.width * 2, this.width / 3, this.x, this.y - this.width * 1.5, SHIELD, 0x0000FF);
this.circleRange = null;
this.canAttack = true; this.canAttack = true;
this.missile = new Missile(scene, 'bullet', this.width / 5, this.width / 4); this.missile = new Missile(scene, 'bullet', this.width / 5, this.width / 4);
@ -46,7 +45,7 @@ class Robot {
} }
click() { click() {
if (this.circleRange === null) { if (this.circleRange === undefined) {
this.drawRange(); this.drawRange();
} else { } else {
this.eraseRange(); this.eraseRange();
@ -314,7 +313,7 @@ class Robot {
die() { die() {
if (this.life.value === 0) { if (this.life.value === 0) {
if (this.circleRange !== null) if (this.circleRange !== undefined)
this.circleRange.destroy(); this.circleRange.destroy();
this.circle.destroy(); this.circle.destroy();
this.shield.destroy(); this.shield.destroy();
@ -349,11 +348,11 @@ class Robot {
eraseRange() { eraseRange() {
this.circleRange.clear(); this.circleRange.clear();
this.circleRange = null; this.circleRange = undefined;
} }
drawCircleRange() { drawCircleRange() {
if (this.circleRange !== null) { if (this.circleRange !== undefined) {
this.circleRange.clear(); this.circleRange.clear();
@ -382,4 +381,13 @@ class Robot {
cleanNodes() { cleanNodes() {
this.lNode = []; this.lNode = [];
} }
setVisible(boolean) {
this.circle.setVisible(boolean);
this.life.setVisible(boolean);
this.shield.setVisible(boolean);
if (this.circleRange !== undefined) {
this.circleRange.setVisible(boolean);
}
}
} }

@ -8,6 +8,7 @@ class HealthBar {
this.value = valueMax; this.value = valueMax;
this.color = color; this.color = color;
this.colorMin = colorMin; this.colorMin = colorMin;
this.bonus = [];
this.draw(); this.draw();
@ -22,6 +23,19 @@ class HealthBar {
this.setY(y); this.setY(y);
} }
addBonus(bonus) {
if (bonus.value > 0) {
this.bonus.push(bonus);
}
console.log(this.bonus);
this.draw();
}
removeBonus(bonus) {
this.bonus.splice(this.bonus.indexOf(bonus), 1);
this.draw();
}
setValue(value) { setValue(value) {
if (value < 0) { if (value < 0) {
value = 0; value = 0;
@ -35,6 +49,12 @@ class HealthBar {
} }
} }
getValue() {
let value = this.value;
this.bonus.forEach(bonus => value += bonus.value);
return value;
}
setValueMax(valueMax = this.valueMax) { setValueMax(valueMax = this.valueMax) {
if (valueMax <= 0) { if (valueMax <= 0) {
return; return;
@ -44,20 +64,17 @@ class HealthBar {
this.setValue(this.value + diff); this.setValue(this.value + diff);
} }
increaseValueMax(amount = 0, color = this.color) {
this.color = color;
this.setValueMax(this.valueMax + amount);
}
decreaseValueMax(amount = 0, color = this.color) {
this.color = color;
this.setValueMax(this.valueMax - amount);
}
decrease(amount) { decrease(amount) {
this.value -= amount; let diff = amount;
this.bonus.forEach(bonus => {
let diff = 0; diff = bonus.decrease(amount);
if (diff > 0) {
this.bonus.splice(this.bonus.indexOf(bonus), 1);
}
});
this.value -= diff;
diff = 0;
if (this.value < 0) { if (this.value < 0) {
diff = -this.value; diff = -this.value;
this.value = 0; this.value = 0;
@ -68,10 +85,6 @@ class HealthBar {
return diff; return diff;
} }
getBar() {
return this.bar;
}
increase(amount) { increase(amount) {
this.value += amount; this.value += amount;
if (this.value > this.valueMax) { if (this.value > this.valueMax) {
@ -104,6 +117,9 @@ class HealthBar {
this.bar.fillStyle(0xffffff); this.bar.fillStyle(0xffffff);
this.bar.fillRect(2, 2, this.width - 4, this.height - 4); this.bar.fillRect(2, 2, this.width - 4, this.height - 4);
let valueMax = this.valueMax;
this.bonus.forEach(bonus => valueMax += bonus.value);
let percent = this.value / this.valueMax; let percent = this.value / this.valueMax;
if (percent < 1 / 3) { if (percent < 1 / 3) {
@ -112,9 +128,21 @@ class HealthBar {
this.bar.fillStyle(this.color); this.bar.fillStyle(this.color);
} }
let d = Math.floor(percent * (this.width - 4)); percent = this.value / valueMax;
let d = percent * (this.width - 4);
this.bar.fillRect(2, 2, d, this.height - 4); this.bar.fillRect(2, 2, d, this.height - 4);
let x = d + 2;
this.bonus.forEach(bonus => {
let percent = bonus.value / valueMax;
this.bar.fillStyle(bonus.color);
let width = percent * (this.width - 4);
this.bar.fillRect(x, 2, width, this.height - 4);
x += width;
});
} }
destroy() { destroy() {
@ -129,4 +157,9 @@ class HealthBar {
json += '}'; json += '}';
return json; return json;
} }
setVisible(boolean) {
this.bar.setVisible(boolean);
this.nameText.setVisible(boolean);
}
} }

@ -1,4 +1,7 @@
{ {
"enemyVisible": true,
"bonusVisible": true,
"robotRandomPosition": true,
"tree": { "tree": {
"type": "waria", "type": "waria",
"lRect": [ "lRect": [

@ -1,4 +1,7 @@
{ {
"enemyVisible": false,
"bonusVisible": true,
"robotRandomPosition": true,
"tree": { "tree": {
"type": "waria", "type": "waria",
"lRect": [ "lRect": [

@ -1,4 +1,7 @@
{ {
"enemyVisible": false,
"bonusVisible": true,
"robotRandomPosition": false,
"tree": { "tree": {
"type": "waria", "type": "waria",
"lRect": [ "lRect": [

@ -2,7 +2,7 @@
"lSpeedBonus": [ "lSpeedBonus": [
{ {
"name": { "name": {
"en": "SPEED BRONZE", "en": "BRONZE SPEED",
"fr": "VITESSE BRONZE" "fr": "VITESSE BRONZE"
}, },
"texture": "bonusSpeed0", "texture": "bonusSpeed0",
@ -11,7 +11,7 @@
}, },
{ {
"name": { "name": {
"en": "SPEED SILVER", "en": "SILVER SPEED",
"fr": "VITESSE ARGENT" "fr": "VITESSE ARGENT"
}, },
"texture": "bonusSpeed1", "texture": "bonusSpeed1",
@ -20,7 +20,7 @@
}, },
{ {
"name": { "name": {
"en": "SPEED GOLD", "en": "GOLD SPEED",
"fr": "VITESSE OR" "fr": "VITESSE OR"
}, },
"texture": "bonusSpeed2", "texture": "bonusSpeed2",
@ -31,7 +31,7 @@
"lAttackBonus": [ "lAttackBonus": [
{ {
"name": { "name": {
"en": "ATTACK BRONZE", "en": "BRONZE ATTACK",
"fr": "ATTAQUE BRONZE" "fr": "ATTAQUE BRONZE"
}, },
"texture": "bonusAttack0", "texture": "bonusAttack0",
@ -39,7 +39,7 @@
}, },
{ {
"name": { "name": {
"en": "ATTACK SILVER", "en": "SILVER ATTACK",
"fr": "ATTAQUE ARGENT" "fr": "ATTAQUE ARGENT"
}, },
"texture": "bonusAttack1", "texture": "bonusAttack1",
@ -47,7 +47,7 @@
}, },
{ {
"name": { "name": {
"en": "ATTACK GOLD", "en": "GOLD ATTACK",
"fr": "ATTAQUE OR" "fr": "ATTAQUE OR"
}, },
"texture": "bonusAttack2", "texture": "bonusAttack2",
@ -57,7 +57,7 @@
"lShieldBonus": [ "lShieldBonus": [
{ {
"name": { "name": {
"en": "SHIELD BRONZE", "en": "BRONZE SHIELD",
"fr": "BOUCLIER BRONZE" "fr": "BOUCLIER BRONZE"
}, },
"texture": "bonusShield0", "texture": "bonusShield0",
@ -67,7 +67,7 @@
}, },
{ {
"name": { "name": {
"en": "SHIELD SILVER", "en": "SILVER SHIELD",
"fr": "BOUCLIER ARGENT" "fr": "BOUCLIER ARGENT"
}, },
"texture": "bonusShield1", "texture": "bonusShield1",
@ -77,7 +77,7 @@
}, },
{ {
"name": { "name": {
"en": "SHIELD GOLD", "en": "GOLD SHIELD",
"fr": "BOUCLIER OR" "fr": "BOUCLIER OR"
}, },
"texture": "bonusShield2", "texture": "bonusShield2",

Loading…
Cancel
Save