Création des images action Condition avec la portée - Correction de l'erreur de sauvegarde lors du changement de langue - Ajout de la possibilité de sélectionné la portée lors de la création d'une action Condition - Ajout du fonctionnement de la condition avec la portée lors du combat de robot - Correction d'une erreur lorsque le robot se dirigeait vers le bonus et que ça cible robot mourrait - Suppression du temps d'attente de 1 seconde à la mort du dernier robot (La page de fin apparait directement maintenant) - La touche "E" permet d'afficher la page d'edition de l'action sélectionnée - La touche "ENTER" permet d'afficher la page d'ajout d'action

master
clmaisonha 5 years ago
parent 29a70f9c78
commit 184fd823c3

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 84 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -13,23 +13,41 @@ class AddCondition extends AddNode {
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), 'enemyBot', c1, false); super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), 'enemyBot', c1, false);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), 'myself', c1, true); super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), 'myself', c1, true);
let c2 = super.newCategory('shield', true, true); let c2 = super.newCategory('shield', true, true);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), 'shield0', c2, 0); super.addButton(WIDTH_WINDOW / 8, HEIGHT_WINDOW / (16 / 9), 'shortRange', c2, [1 / 3, 'range']);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), 'shield33', c2, 1 / 3); super.addButton(WIDTH_WINDOW / 4 * 1.5, HEIGHT_WINDOW / (16 / 9), 'mediumRange', c2, [2 / 3, 'range']);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 12), 'shield66', c2, 2 / 3); super.addButton(WIDTH_WINDOW / 4, HEIGHT_WINDOW / (16 / 12), 'longRange', c2, [1, 'range']);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 12), 'shield100', c2, 1); let line = this.add.graphics();
line.lineStyle(10, 0xffffff, 1);
line.lineBetween(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 8), WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 13));
super.addButton(WIDTH_WINDOW / 8 * 5, HEIGHT_WINDOW / (16 / 9), 'shield0', c2, [0, 'shield']);
super.addButton(WIDTH_WINDOW / 8 * 7, HEIGHT_WINDOW / (16 / 9), 'shield33', c2, [1 / 3, 'shield']);
super.addButton(WIDTH_WINDOW / 8 * 5, HEIGHT_WINDOW / (16 / 12), 'shield66', c2, [2 / 3, 'shield']);
super.addButton(WIDTH_WINDOW / 8 * 7, HEIGHT_WINDOW / (16 / 12), 'shield100', c2, [1, 'shield']);
} }
addNode() { addNode() {
if (super.verifyCategory()) { if (super.verifyCategory()) {
this.selected.addRect(new RectangleNode(this.selected.getX(), this.selected.getY() + 200, this.gameR, 'condition', [this.lCategory[0].getValue(), true, false, this.lCategory[1].getValue(), 0])); if (this.lCategory[1].getValue()[1] === 'range') {
this.selected.addRect(new RectangleNode(this.selected.getX(), this.selected.getY() + 200, this.gameR, 'condition', [this.lCategory[0].getValue(), false, true, 0, this.lCategory[1].getValue()[0]]));
} else {
this.selected.addRect(new RectangleNode(this.selected.getX(), this.selected.getY() + 200, this.gameR, 'condition', [this.lCategory[0].getValue(), true, false, this.lCategory[1].getValue()[0], 0]));
}
super.cancel(); super.cancel();
} }
} }
modifyNode() { modifyNode() {
if (super.verifyCategory()) { if (super.verifyCategory()) {
this.selected.node.shieldFilter = false;
this.selected.node.rangeFilter = false;
if (this.lCategory[1].getValue()[1] === 'range') {
this.selected.node.rangeFilter = true;
this.selected.node.range = this.lCategory[1].getValue()[0];
} else {
this.selected.node.shieldFilter = true;
this.selected.node.shield = this.lCategory[1].getValue()[0];
}
this.selected.node.myself = this.lCategory[0].getValue(); this.selected.node.myself = this.lCategory[0].getValue();
this.selected.node.shield = this.lCategory[1].getValue();
this.selected.rect.setFrame(this.selected.node.getFrame()); this.selected.rect.setFrame(this.selected.node.getFrame());
super.cancel(); super.cancel();
} }

@ -25,4 +25,8 @@ class Attack {
getFrame() { getFrame() {
return this.percentRange * 3 - 1; return this.percentRange * 3 - 1;
} }
getOptionJson() {
return this.percentRange;
}
} }

@ -26,12 +26,7 @@ class Condition {
doCondition(robot) { doCondition(robot) {
if (this.shieldFilter) { if (this.shieldFilter) {
if (this.shieldCondition(robot)) { return this.shieldCondition(robot);
if (this.rangeFilter) {
return this.rangeCondition(robot);
}
return true;
}
} else if (this.rangeFilter) { } else if (this.rangeFilter) {
return this.rangeCondition(robot); return this.rangeCondition(robot);
} }
@ -39,11 +34,13 @@ class Condition {
} }
rangeCondition(robot) { rangeCondition(robot) {
if (this.myself) { if (robot.haveTarget()) {
return true; if (this.myself) {
return robot.calcDistance(robot.target) <= robot.range * RANGE * this.range;
} else {
return robot.target.calcDistance(robot) <= robot.target.range * RANGE * this.range;
}
} }
if (robot.haveTarget())
return robot.calcDistance(robot.target) <= this.range;
return false; return false;
} }
@ -82,13 +79,18 @@ class Condition {
} else { } else {
line = 1; line = 1;
} }
let shield = 0; let image = 0;
if (this.shieldFilter) { //shield if (this.shieldFilter) { //shield
shield = Math.floor(this.shield * 3); image = Math.floor(this.shield * 3);
} else {
if (this.rangeFilter) { //range
image = 4 + Math.floor(this.range * 3 - 1);
}
} }
if (this.rangeFilter) { //range return line * 7 + image;
}
} getOptionJson() {
return line * 4 + shield; return this.myself + ',' + this.shieldFilter + ',' + this.rangeFilter + ',' + this.shield + ',' + this.range;
} }
} }

@ -69,6 +69,12 @@ class Game extends ManageLang {
this.input.keyboard.on('keydown-DELETE', () => { this.input.keyboard.on('keydown-DELETE', () => {
this.clickBin(); this.clickBin();
}); });
this.input.keyboard.on('keydown-E', () => {
this.clickPencil();
});
this.input.keyboard.on('keydown-ENTER', () => {
this.clickPlus();
});
} }
update(time, delta) { update(time, delta) {
@ -269,24 +275,29 @@ class Game extends ManageLang {
} }
clickPencil() { clickPencil() {
console.log("PENCIL"); if (this.selected !== null) {
this.changeFrame(this.pencil, 0); console.log("PENCIL");
switch (this.selected.type) { this.changeFrame(this.pencil, 0);
case 'attack': switch (this.selected.type) {
this.father.scene.add('AddNode', new AddAttack(this.father, this, this.selected, false, this.selected.node.percentRange)) case 'attack':
break; this.father.scene.add('AddNode', new AddAttack(this.father, this, this.selected, false, this.selected.node.percentRange));
case 'move': break;
this.father.scene.add('AddNode', new AddMove(this.father, this, this.selected, this.selected.node.toward, this.selected.node.enemyBot)) case 'move':
break; this.father.scene.add('AddNode', new AddMove(this.father, this, this.selected, this.selected.node.toward, this.selected.node.enemyBot));
case 'condition': break;
this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, this.selected.node.shield)) case 'condition':
break; if (this.selected.node.shieldFilter) {
default: this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, [this.selected.node.shield, 'shield']));
return; } else {
this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, [this.selected.node.range, 'range']));
}
break;
default:
return;
}
this.scene.pause('Game');
this.scene.launch('AddNode');
} }
this.scene.pause('Game');
this.scene.launch('AddNode');
} }
clickBin() { clickBin() {
@ -300,15 +311,17 @@ class Game extends ManageLang {
} }
clickPlus() { clickPlus() {
console.log("PLUS"); if (this.selected !== null && this.selected.canAddNode) {
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));
this.scene.launch('PlusNode'); this.scene.launch('PlusNode');
this.changeFrame(this.plus, 0); this.changeFrame(this.plus, 0);
this.scene.pause('Game'); this.scene.pause('Game');
}
} }
clickBack() { clickBack() {

@ -47,7 +47,7 @@ class GamingBoard extends Phaser.Scene {
if (this.listRobot.length <= 1 && !this.end) { if (this.listRobot.length <= 1 && !this.end) {
this.end = true; this.end = true;
this.time.addEvent({delay: 1000, callback: this.finish, callbackScope: this}); this.finish();
} }
} }

@ -51,4 +51,8 @@ class Move {
frame += 1; frame += 1;
return frame; return frame;
} }
getOptionJson() {
return this.toward + ',' + this.enemyBot;
}
} }

@ -37,7 +37,6 @@ class RectangleNode {
if (type.toString().toLowerCase() !== 'waria') { if (type.toString().toLowerCase() !== 'waria') {
this.rect.setFrame(this.node.getFrame()); this.rect.setFrame(this.node.getFrame());
} }
this.option = option;
this.type = type; this.type = type;
this.rect.on('pointerdown', () => this.click()); this.rect.on('pointerdown', () => this.click());
this.rect.setOrigin(0.5, 0); this.rect.setOrigin(0.5, 0);
@ -96,22 +95,6 @@ class RectangleNode {
} }
} }
getJson() {
let json = '{';
json += toJson("x", this.rect.x) + toJson("y", this.rect.y) + toJson("type", this.type);
json += '"option":[';
this.option.forEach(option => json += option + ',');
json = endLineJson(json) + '],';
if (this.canAddNode) {
json += '"lRect":[';
this.lRect.forEach(rect => json += rect.getJson() + ',');
json = endLineJson(json) + ']';
}
json = endLineJson(json);
json += '}';
return json;
}
setLine(x, y) { setLine(x, y) {
this.xOrigin = x; this.xOrigin = x;
this.yOrigin = y; this.yOrigin = y;
@ -183,4 +166,20 @@ class RectangleNode {
} }
return false; return false;
} }
getJson() {
let json = '{';
json += toJson("x", this.rect.x) + toJson("y", this.rect.y) + toJson("type", this.type);
if(this.node !==undefined){
json += '"option":[' + this.node.getOptionJson() + '],';
}
if (this.canAddNode) {
json += '"lRect":[';
this.lRect.forEach(rect => json += rect.getJson() + ',');
json = endLineJson(json) + ']';
}
json = endLineJson(json);
json += '}';
return json;
}
} }

@ -306,6 +306,7 @@ class Robot {
} }
read() { read() {
this.verifyTarget();
for (let i = 0; i < this.lNode.length; i++) { for (let i = 0; i < this.lNode.length; i++) {
if (this.lNode[i].do(this)) { if (this.lNode[i].do(this)) {
break; break;

@ -28,7 +28,7 @@ class AddNode extends Phaser.Scene {
addButton(x, y, texture, category = new Category(), value) { addButton(x, y, texture, category = new Category(), value) {
let btn = this.createButton(x, y, texture); let btn = this.createButton(x, y, texture);
btn.on('pointerdown', () => this.click(btn, category, value)); btn.on('pointerdown', () => this.click(btn, category, value));
if (category !== this.lastCategory && this.option.length > 0 && this.option[0] === value) { if (category !== this.lastCategory && this.option.length > 0 && (this.option[0] === value || (this.option[0].length > 0 && this.option[0][0] === value[0] && this.option[0][1] === value [1]))) {
this.option.splice(0, 1); this.option.splice(0, 1);
this.lastCategory = category; this.lastCategory = category;
this.click(btn, category, value); this.click(btn, category, value);

Loading…
Cancel
Save