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

master
clmaisonha 5 years ago
parent 9a062269ce
commit c09719f2f6

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

@ -13,6 +13,7 @@
<body> <body>
<div id='all'></div> <div id='all'></div>
<script src="public/js/AddNode.js"></script>
<script src="public/js/class.min.js"></script> <script src="public/js/class.min.js"></script>
<script src="public/js/app.min.js"></script> <script src="public/js/app.min.js"></script>
</body> </body>

@ -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');
}
}

File diff suppressed because one or more lines are too long

@ -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');
}
} }

@ -45,6 +45,22 @@ class Boot extends Phaser.Scene {
this.load.spritesheet('plus', 'assets/buttons/plus.png', {frameWidth: 100, frameHeight: 100}); this.load.spritesheet('plus', 'assets/buttons/plus.png', {frameWidth: 100, frameHeight: 100});
this.load.spritesheet('pencil', 'assets/buttons/pencil.png', {frameWidth: 100, frameHeight: 100}); this.load.spritesheet('pencil', 'assets/buttons/pencil.png', {frameWidth: 100, frameHeight: 100});
this.load.spritesheet('cancel', 'assets/buttons/cancel.png', {frameWidth: 550, frameHeight: 150}); this.load.spritesheet('cancel', 'assets/buttons/cancel.png', {frameWidth: 550, frameHeight: 150});
this.load.spritesheet('add', 'assets/buttons/add.png', {frameWidth: 550, frameHeight: 150});
this.load.spritesheet('shortRange', 'assets/buttons/shortRange.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('mediumRange', 'assets/buttons/mediumRange.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('longRange', 'assets/buttons/longRange.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('shield0', 'assets/buttons/shield0.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('shield33', 'assets/buttons/shield33.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('shield66', 'assets/buttons/shield66.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('shield100', 'assets/buttons/shield100.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('myself', 'assets/buttons/myself.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('enemyBot', 'assets/buttons/enemyBot.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('moveToward', 'assets/buttons/moveToward.png', {frameWidth: 300, frameHeight: 150});
this.load.spritesheet('fleeFrom', 'assets/buttons/fleeFrom.png', {frameWidth: 300, frameHeight: 150});
} }
create() { create() {

@ -7,8 +7,6 @@ class Game extends Phaser.Scene {
preload() { preload() {
this.gm = new GamingBoard(); this.gm = new GamingBoard();
this.game.scene.add('GamingBoard', this.gm); this.game.scene.add('GamingBoard', this.gm);
this.game.scene.add('PlusNode', new PlusNode(this.game));
} }
create() { create() {
@ -155,6 +153,7 @@ class Game extends Phaser.Scene {
clickPlus() { clickPlus() {
console.log("PLUS"); console.log("PLUS");
this.game.scene.add('PlusNode', new PlusNode(this.game, this.selected));
this.scene.launch('PlusNode'); this.scene.launch('PlusNode');

@ -1,7 +1,8 @@
class PlusNode extends Phaser.Scene { class PlusNode extends Phaser.Scene {
constructor(game) { constructor(game, selected) {
super('PlusNode'); super('PlusNode');
this.game = game; this.game = game;
this.selected = selected;
} }
create() { create() {
@ -37,18 +38,18 @@ class PlusNode extends Phaser.Scene {
click(action) { click(action) {
switch (action.toString()) { switch (action.toString()) {
case 'attack': case 'attack':
this.game.scene.add('addNode', new AddAttack(this.game)) this.game.scene.add('AddNode', new AddAttack(this.game, this.selected))
break; break;
case 'move': case 'move':
this.game.scene.add('addNode', new AddMove(this.game)) this.game.scene.add('AddNode', new AddMove(this.game, this.selected))
break; break;
case 'condition': case 'condition':
this.game.scene.add('addNode', new AddCondition(this.game)) this.game.scene.add('AddNode', new AddCondition(this.game, this.selected))
break; break;
} }
this.scene.launch('addNode'); this.scene.launch('AddNode');
this.scene.stop('PlusNode'); this.scene.stop('PlusNode');
console.log(action.toString()); this.game.scene.remove('PlusNode');
} }
createButton() { createButton() {
@ -63,5 +64,6 @@ class PlusNode extends Phaser.Scene {
cancel() { cancel() {
this.scene.resume('Game'); this.scene.resume('Game');
this.scene.stop('PlusNode'); this.scene.stop('PlusNode');
this.game.scene.remove('PlusNode');
} }
} }
Loading…
Cancel
Save