Créations d'image pour les actions - création de l'action condition - meilleur gestion des lignes entre les actions - Suppression de la page Tree (je l'ai regroupé avec RectangleNode) - Refonte complete sur la classe RectangleNode
parent
fa4d5bc7f3
commit
7cc554b7d3
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 4.6 KiB |
@ -1 +1 @@
|
|||||||
const COLOR_ATTACK=16711680,COLOR_MOVE=255,WIDTH_WINDOW=$(document).width()-30,HEIGHT_WINDOW=$(document).height()-30,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"},game=new Phaser.Game(config);game.scene.add("Boot",Boot),game.scene.add("Type",Type),game.scene.add("Game",new Game(game)),game.scene.start("Boot");
|
const COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,WIDTH_WINDOW=$(document).width()-30,HEIGHT_WINDOW=$(document).height()-30,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"},game=new Phaser.Game(config);game.scene.add("Boot",Boot),game.scene.add("Type",Type),game.scene.add("Game",new Game(game)),game.scene.start("Boot");
|
File diff suppressed because one or more lines are too long
@ -1,28 +0,0 @@
|
|||||||
class AttackRectangle extends Attack {
|
|
||||||
constructor(x, y, width, height, scene) {
|
|
||||||
super();
|
|
||||||
this.color = COLOR_ATTACK;
|
|
||||||
this.rect = new Phaser.GameObjects.Rectangle(scene, x, y, width, height, this.color);
|
|
||||||
this.line = scene.add.graphics();
|
|
||||||
}
|
|
||||||
|
|
||||||
getX() {
|
|
||||||
return this.rect.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
addLine(x, y) {
|
|
||||||
this.xOrigin = x;
|
|
||||||
this.yOrigin = y;
|
|
||||||
this.updateLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLine() {
|
|
||||||
if (this.xLine !== this.rect.x || this.yLine !== this.rect.y) {
|
|
||||||
this.xLine = this.rect.x;
|
|
||||||
this.yLine = this.rect.y;
|
|
||||||
this.line.clear();
|
|
||||||
this.line.lineStyle(10, 0xffffff, 1);
|
|
||||||
this.line.lineBetween(this.xOrigin, this.yOrigin, this.rect.x, this.rect.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
class MoveRectangle extends Move {
|
|
||||||
constructor(toward, x, y, width, height, scene) {
|
|
||||||
super(toward);
|
|
||||||
this.color = COLOR_MOVE;
|
|
||||||
this.rect = new Phaser.GameObjects.Rectangle(scene, x, y, width, height, this.color);
|
|
||||||
this.line = scene.add.graphics();
|
|
||||||
}
|
|
||||||
|
|
||||||
getX() {
|
|
||||||
return this.rect.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
addLine(x, y) {
|
|
||||||
this.xOrigin = x;
|
|
||||||
this.yOrigin = y;
|
|
||||||
this.updateLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLine() {
|
|
||||||
if (this.xLine !== this.rect.x || this.yLine !== this.rect.y) {
|
|
||||||
this.xLine = this.rect.x;
|
|
||||||
this.yLine = this.rect.y;
|
|
||||||
this.line.clear();
|
|
||||||
this.line.lineStyle(10, 0xffffff, 1);
|
|
||||||
this.line.lineBetween(this.xOrigin, this.yOrigin, this.rect.x, this.rect.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,98 @@
|
|||||||
|
class RectangleNode {
|
||||||
|
constructor(x, y, scene, type, ...option) {
|
||||||
|
switch (type.toString().toLowerCase()) {
|
||||||
|
case 'attack':
|
||||||
|
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'attackN');
|
||||||
|
this.node = new Attack();
|
||||||
|
this.canAddNode = false;
|
||||||
|
this.line = scene.add.graphics();
|
||||||
|
break;
|
||||||
|
case 'move' :
|
||||||
|
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'moveN');
|
||||||
|
this.node = new Move(option[0]);
|
||||||
|
this.canAddNode = false;
|
||||||
|
this.line = scene.add.graphics();
|
||||||
|
break;
|
||||||
|
case 'condition':
|
||||||
|
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'conditionN');
|
||||||
|
this.node = new Condition(option[0], option[1], option[2], option[3], option[4]);
|
||||||
|
this.canAddNode = true;
|
||||||
|
this.lRect = [];
|
||||||
|
this.scene = scene;
|
||||||
|
this.line = scene.add.graphics();
|
||||||
|
break;
|
||||||
|
case 'waria':
|
||||||
|
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'logoWaria');
|
||||||
|
this.canAddNode = true;
|
||||||
|
this.lRect = [];
|
||||||
|
this.scene = scene;
|
||||||
|
this.scene.add.existing(this.rect);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("Création d'un node echoué");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type.toString().toLowerCase() !== 'waria') {
|
||||||
|
}
|
||||||
|
this.rect.setOrigin(0.5, 0);
|
||||||
|
this.rect.displayHeight = HEIGHT_WINDOW / 6;
|
||||||
|
this.rect.scaleX = this.rect.scaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
getX() {
|
||||||
|
return this.rect.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
addRect(node) {
|
||||||
|
if (this.canAddNode === true) {
|
||||||
|
this.lRect.push(node);
|
||||||
|
this.addLine(node);
|
||||||
|
let rect = this.scene.add.existing(node.rect);
|
||||||
|
rect.setInteractive();
|
||||||
|
this.scene.input.setDraggable(rect);
|
||||||
|
if (this.node !== undefined) {
|
||||||
|
this.node.addNode(node.node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setLine(x, y) {
|
||||||
|
this.xOrigin = x;
|
||||||
|
this.yOrigin = y;
|
||||||
|
this.updateLine(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLine(force) {
|
||||||
|
if ((force === true || this.xLine !== this.rect.x || this.yLine !== this.rect.y) && this.line !== undefined) {
|
||||||
|
this.xLine = this.rect.x;
|
||||||
|
this.yLine = this.rect.y;
|
||||||
|
this.line.clear();
|
||||||
|
this.line.lineStyle(10, 0xffffff, 1);
|
||||||
|
this.line.lineBetween(this.xOrigin, this.yOrigin, this.rect.x, this.rect.y + this.rect.displayHeight / 10);
|
||||||
|
}
|
||||||
|
if (this.canAddNode === true) {
|
||||||
|
this.lRect.forEach(node => this.addLine(node));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addLine(node) {
|
||||||
|
node.setLine(this.rect.x, this.rect.y + this.rect.displayHeight * 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
getNodes() {
|
||||||
|
if (this.node === undefined) {
|
||||||
|
let lNodes = [];
|
||||||
|
this.lRect.forEach(function (element) {
|
||||||
|
if (element.node !== undefined) {
|
||||||
|
if (element.lRect !== undefined) {
|
||||||
|
element.node.clearNodes();
|
||||||
|
element.lRect.forEach(rect => element.node.addNode(rect.node));
|
||||||
|
}
|
||||||
|
lNodes.push(element.node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return lNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
class Tree {
|
|
||||||
constructor(x, y, scene) {
|
|
||||||
this.lNode = [];
|
|
||||||
this.scene = scene;
|
|
||||||
this.head = this.scene.add.image(x, y, 'logoWaria').setOrigin(0.5, 0.5);
|
|
||||||
this.head.displayHeight = HEIGHT_WINDOW / 4;
|
|
||||||
this.head.scaleX = this.head.scaleY;
|
|
||||||
}
|
|
||||||
|
|
||||||
addNode(node) {
|
|
||||||
this.lNode.push(node);
|
|
||||||
node.addLine(this.head.x, this.head.y + this.head.displayHeight / 2.2);
|
|
||||||
let rect = this.scene.add.existing(node.rect);
|
|
||||||
rect.setInteractive();
|
|
||||||
this.scene.input.setDraggable(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLines() {
|
|
||||||
this.lNode.forEach(node => node.updateLine());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue