On peut ajouter une condition à notre arbre d'action (uniquement une condition sur le bouclier pour le moment) - Modification de la classe Condition pour gérer les conditions sur les robots ennemis - On peut désormais ajouter une condition uniquement sur les actions qui acceptent les liens avec d'autres actions
parent
d451659c97
commit
8169ee92ae
File diff suppressed because one or more lines are too long
@ -1,19 +1,30 @@
|
|||||||
class AddCondition extends AddNode {
|
class AddCondition extends AddNode {
|
||||||
constructor(game, selected) {
|
constructor(father, game, selected) {
|
||||||
super(game, selected);
|
super(father, game, selected);
|
||||||
this.game = game;
|
|
||||||
this.selected = selected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
super.create();
|
super.create(this);
|
||||||
console.log("CONDITION");
|
console.log("CONDITION");
|
||||||
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, selectWord("ADD NODE : CONDITION", "AJOUTER ACTION : CONDITION"));
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, selectWord("ADD NODE : CONDITION", "AJOUTER ACTION : CONDITION"));
|
||||||
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
|
||||||
let c1 = new Category('target', true);
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)"));
|
||||||
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', c1);
|
let c1 = super.newCategory('target', true, true);
|
||||||
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'myself', c1);
|
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', c1, false);
|
||||||
|
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'myself', c1, true);
|
||||||
|
let c2 = super.newCategory('shield', true, true);
|
||||||
|
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), null, HEIGHT_WINDOW / 8, 'shield0', c2, 0);
|
||||||
|
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), null, HEIGHT_WINDOW / 8, 'shield33', c2, 1 / 3);
|
||||||
|
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 12), null, HEIGHT_WINDOW / 8, 'shield66', c2, 2 / 3);
|
||||||
|
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 12), null, HEIGHT_WINDOW / 8, 'shield100', c2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addNode() {
|
||||||
|
if (super.verifyCategory()) {
|
||||||
|
console.log(this.lCategory[0].getValue());
|
||||||
|
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));
|
||||||
|
super.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,22 +1,39 @@
|
|||||||
class Category {
|
class Category {
|
||||||
constructor(name = 'undefined', single = true) {
|
constructor(name = 'undefined', single = true, obligatory = true) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.single = single;
|
this.single = single;
|
||||||
this.lBtn = [];
|
this.lBtn = [];
|
||||||
|
this.lValue = [];
|
||||||
|
this.obligatory = obligatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(btn) {
|
add(btn, value) {
|
||||||
if (this.lBtn.length !== 0 && this.single) {
|
if (this.lBtn.length !== 0 && this.single) {
|
||||||
this.lBtn[0].clearTint();
|
this.lBtn[0].clearTint();
|
||||||
|
this.lValue = [];
|
||||||
this.lBtn = [];
|
this.lBtn = [];
|
||||||
}
|
}
|
||||||
|
this.lValue.push(value);
|
||||||
this.lBtn.push(btn);
|
this.lBtn.push(btn);
|
||||||
btn.tint = 0xEFD807;
|
btn.tint = 0xEFD807;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getValue() {
|
||||||
|
if (this.single) {
|
||||||
|
return this.lValue[0];
|
||||||
|
}
|
||||||
|
return this.lValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
validate() {
|
||||||
|
return !(this.lBtn.length === 0 && this.obligatory);
|
||||||
|
}
|
||||||
|
|
||||||
remove(btn) {
|
remove(btn) {
|
||||||
if (this.lBtn.indexOf(btn) !== -1) {
|
let id = this.lBtn.indexOf(btn);
|
||||||
this.lBtn.splice(this.lBtn.indexOf(btn), 1);
|
if (id !== -1) {
|
||||||
|
this.lBtn.splice(id, 1);
|
||||||
|
this.lValue.splice(id, 1);
|
||||||
}
|
}
|
||||||
btn.clearTint();
|
btn.clearTint();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue