Ajout de beaucoup de sprites de boutons pour la création des actions - Création de AddNode qui est le père de AddCondition, AddAttack, AddMove - création des fonctions dans AddNde dans le but de simplifier la création des pages fils - Début de création des trois pages d'ajout d'action
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,55 @@
|
|||||||
|
class AddNode extends Phaser.Scene {
|
||||||
|
constructor(game, selected) {
|
||||||
|
super('AddNode');
|
||||||
|
this.game = game;
|
||||||
|
this.selected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
create() {
|
||||||
|
let height = HEIGHT_WINDOW / (4 / 3);
|
||||||
|
this.add.rectangle(0, 0, WIDTH_WINDOW, HEIGHT_WINDOW, 0x000000).setOrigin(0, 0).setAlpha(0.5);
|
||||||
|
this.add.rectangle(0, HEIGHT_WINDOW / 2, WIDTH_WINDOW, height, 0x35363A).setOrigin(0, 0.5);
|
||||||
|
this.createButtonCancel();
|
||||||
|
this.createButtonAdd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addButton(x, y, width, height, texture) {
|
||||||
|
let btn = this.add.image(x, y, texture).setOrigin(0.5, 0.5).setInteractive();
|
||||||
|
btn.on('pointerover', () => btn.setFrame(1));
|
||||||
|
btn.on('pointerout', () => btn.setFrame(0));
|
||||||
|
btn.displayHeight = height;
|
||||||
|
if (width === null) {
|
||||||
|
btn.scaleX = btn.scaleY;
|
||||||
|
} else {
|
||||||
|
btn.displayWidth = width;
|
||||||
|
}
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
|
||||||
|
addTitle(x, y, title) {
|
||||||
|
let sizeText = HEIGHT_WINDOW / 12;
|
||||||
|
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
|
||||||
|
this.add.text(x, y, title, style).setOrigin(0.5, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
createButtonCancel() {
|
||||||
|
this.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 15), null, HEIGHT_WINDOW / 9, 'cancel')
|
||||||
|
.on('pointerdown', () => this.cancel());
|
||||||
|
}
|
||||||
|
|
||||||
|
createButtonAdd() {
|
||||||
|
this.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 15), null, HEIGHT_WINDOW / 9, 'add')
|
||||||
|
.on('pointerdown', () => this.add());
|
||||||
|
}
|
||||||
|
|
||||||
|
add() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.scene.resume('Game');
|
||||||
|
this.scene.stop('AddNode');
|
||||||
|
this.game.scene.remove('AddNode');
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,16 @@
|
|||||||
class AddAttack extends Phaser.Scene {
|
class AddAttack extends AddNode {
|
||||||
constructor(game) {
|
constructor(game, selected) {
|
||||||
super('addNode');
|
super(game, selected);
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
this.add.rectangle(0, 0, WIDTH_WINDOW, HEIGHT_WINDOW, 0x000000).setOrigin(0, 0).setAlpha(0.5);
|
|
||||||
console.log("ATTACK");
|
console.log("ATTACK");
|
||||||
this.createButton();
|
super.create();
|
||||||
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, "ADD NODE : ATTACK");
|
||||||
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), "WHO ?");
|
||||||
|
super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
createButton() {
|
|
||||||
let x = WIDTH_WINDOW / 2;
|
|
||||||
let y = HEIGHT_WINDOW - 100;
|
|
||||||
this.cancelBtn = this.add.image(x, y, 'cancel').setOrigin(0.5, 0.5).setInteractive();
|
|
||||||
this.cancelBtn.on('pointerover', () => this.cancelBtn.setFrame(1));
|
|
||||||
this.cancelBtn.on('pointerout', () => this.cancelBtn.setFrame(0));
|
|
||||||
this.cancelBtn.on('pointerdown', () => this.cancel());
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel() {
|
|
||||||
this.scene.resume('Game');
|
|
||||||
this.scene.stop('addNode');
|
|
||||||
this.game.scene.remove('addNode');
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,28 +1,18 @@
|
|||||||
class AddCondition extends Phaser.Scene {
|
class AddCondition extends AddNode {
|
||||||
constructor(game) {
|
constructor(game, selected) {
|
||||||
super('addNode');
|
super(game, selected);
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
this.add.rectangle(0, 0, WIDTH_WINDOW, HEIGHT_WINDOW, 0x000000).setOrigin(0, 0).setAlpha(0.5);
|
super.create();
|
||||||
console.log("CONDITION");
|
console.log("CONDITION");
|
||||||
this.createButton();
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, "ADD NODE : CONDITION");
|
||||||
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), "WHO ?");
|
||||||
|
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot');
|
||||||
|
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'myself');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
createButton() {
|
|
||||||
let x = WIDTH_WINDOW / 2;
|
|
||||||
let y = HEIGHT_WINDOW - 100;
|
|
||||||
this.cancelBtn = this.add.image(x, y, 'cancel').setOrigin(0.5, 0.5).setInteractive();
|
|
||||||
this.cancelBtn.on('pointerover', () => this.cancelBtn.setFrame(1));
|
|
||||||
this.cancelBtn.on('pointerout', () => this.cancelBtn.setFrame(0));
|
|
||||||
this.cancelBtn.on('pointerdown', () => this.cancel());
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel() {
|
|
||||||
this.scene.resume('Game');
|
|
||||||
this.scene.stop('addNode');
|
|
||||||
this.game.scene.remove('addNode');
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,29 +1,20 @@
|
|||||||
class AddMove extends Phaser.Scene {
|
class AddMove extends AddNode {
|
||||||
constructor(game) {
|
constructor(game, selected) {
|
||||||
super('addNode');
|
super(game, selected);
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
this.add.rectangle(0, 0, WIDTH_WINDOW, HEIGHT_WINDOW, 0x000000).setOrigin(0, 0).setAlpha(0.5);
|
|
||||||
console.log("MOVE");
|
console.log("MOVE");
|
||||||
this.createButton();
|
super.create();
|
||||||
}
|
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, "ADD NODE : MOVE");
|
||||||
|
|
||||||
|
|
||||||
|
super.addTitle(WIDTH_WINDOW / 4, HEIGHT_WINDOW / (16 / 3), "FLEE OR MOVE ?");
|
||||||
|
super.addButton(WIDTH_WINDOW / 6, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'fleeFrom');
|
||||||
|
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'moveToward');
|
||||||
|
|
||||||
createButton() {
|
super.addTitle(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 3), "WHO ?");
|
||||||
let x = WIDTH_WINDOW / 2;
|
super.addButton(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot');
|
||||||
let y = HEIGHT_WINDOW - 100;
|
|
||||||
this.cancelBtn = this.add.image(x, y, 'cancel').setOrigin(0.5, 0.5).setInteractive();
|
|
||||||
this.cancelBtn.on('pointerover', () => this.cancelBtn.setFrame(1));
|
|
||||||
this.cancelBtn.on('pointerout', () => this.cancelBtn.setFrame(0));
|
|
||||||
this.cancelBtn.on('pointerdown', () => this.cancel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
|
||||||
this.scene.resume('Game');
|
|
||||||
this.scene.stop('addNode');
|
|
||||||
this.game.scene.remove('addNode');
|
|
||||||
}
|
|
||||||
}
|
}
|