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 / 1.5, HEIGHT_WINDOW / (16 / 5), 'myself', c1, true);
let c2 = super.newCategory('shield', true, true);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), 'shield0', c2, 0);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), 'shield33', c2, 1 / 3);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 12), 'shield66', c2, 2 / 3);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 12), 'shield100', c2, 1);
super.addButton(WIDTH_WINDOW / 8, HEIGHT_WINDOW / (16 / 9), 'shortRange', c2, [1 / 3, 'range']);
super.addButton(WIDTH_WINDOW / 4 * 1.5, HEIGHT_WINDOW / (16 / 9), 'mediumRange', c2, [2 / 3, 'range']);
super.addButton(WIDTH_WINDOW / 4, HEIGHT_WINDOW / (16 / 12), 'longRange', c2, [1, 'range']);
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() {
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();
}
}
modifyNode() {
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.shield = this.lCategory[1].getValue();
this.selected.rect.setFrame(this.selected.node.getFrame());
super.cancel();
}

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

@ -26,12 +26,7 @@ class Condition {
doCondition(robot) {
if (this.shieldFilter) {
if (this.shieldCondition(robot)) {
if (this.rangeFilter) {
return this.rangeCondition(robot);
}
return true;
}
return this.shieldCondition(robot);
} else if (this.rangeFilter) {
return this.rangeCondition(robot);
}
@ -39,11 +34,13 @@ class Condition {
}
rangeCondition(robot) {
if (robot.haveTarget()) {
if (this.myself) {
return true;
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;
}
@ -82,13 +79,18 @@ class Condition {
} else {
line = 1;
}
let shield = 0;
let image = 0;
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);
}
return line * 4 + shield;
}
return line * 7 + image;
}
getOptionJson() {
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.clickBin();
});
this.input.keyboard.on('keydown-E', () => {
this.clickPencil();
});
this.input.keyboard.on('keydown-ENTER', () => {
this.clickPlus();
});
}
update(time, delta) {
@ -269,24 +275,29 @@ class Game extends ManageLang {
}
clickPencil() {
if (this.selected !== null) {
console.log("PENCIL");
this.changeFrame(this.pencil, 0);
switch (this.selected.type) {
case 'attack':
this.father.scene.add('AddNode', new AddAttack(this.father, this, this.selected, false, this.selected.node.percentRange))
this.father.scene.add('AddNode', new AddAttack(this.father, this, this.selected, false, this.selected.node.percentRange));
break;
case 'move':
this.father.scene.add('AddNode', new AddMove(this.father, this, this.selected, this.selected.node.toward, this.selected.node.enemyBot))
this.father.scene.add('AddNode', new AddMove(this.father, this, this.selected, this.selected.node.toward, this.selected.node.enemyBot));
break;
case 'condition':
this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, this.selected.node.shield))
if (this.selected.node.shieldFilter) {
this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, [this.selected.node.shield, 'shield']));
} 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');
}
}
clickBin() {
@ -300,6 +311,7 @@ class Game extends ManageLang {
}
clickPlus() {
if (this.selected !== null && this.selected.canAddNode) {
console.log("PLUS");
this.father.scene.add('PlusNode', new PlusNode(this.father, this, this.selected));
@ -310,6 +322,7 @@ class Game extends ManageLang {
this.scene.pause('Game');
}
}
clickBack() {
console.log("BACK");

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

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

@ -37,7 +37,6 @@ class RectangleNode {
if (type.toString().toLowerCase() !== 'waria') {
this.rect.setFrame(this.node.getFrame());
}
this.option = option;
this.type = type;
this.rect.on('pointerdown', () => this.click());
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) {
this.xOrigin = x;
this.yOrigin = y;
@ -183,4 +166,20 @@ class RectangleNode {
}
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() {
this.verifyTarget();
for (let i = 0; i < this.lNode.length; i++) {
if (this.lNode[i].do(this)) {
break;

@ -28,7 +28,7 @@ class AddNode extends Phaser.Scene {
addButton(x, y, texture, category = new Category(), value) {
let btn = this.createButton(x, y, texture);
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.lastCategory = category;
this.click(btn, category, value);

Loading…
Cancel
Save