Suppression des images en double dans assets - Modification de moveNode.png dans le but d'intégrer le visuel des différents bonus (attaque, bouclier, vitesse) - Modiciation du constructor des pages d'ajout et de modification d'une action pour une gestion plus simple - Lors d'une modification ou d'un ajout d'une action déplacement, il est dorénavant possible de sélectionner le type de bonus (attaque, bouclier, vitesse) - Création d'une claase Button dans le but de gérer plus simplement et raccourcir la création d'un bouton tel que play, pause, mute, vitesse du jeu ... - Ajout d'un bouton description bonus - Modification du chargement des images dans le but de ne pas recharger des images inutilement lors d'un chanegement de langue (les images qui n'ont pas d'écriture)

master
clmaisonha 5 years ago
parent 5a464071cc
commit 2c5c939af5

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 76 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
{"enemyVisible":false,"bonusVisible":true,"robotRandomPosition":true,"tree":{"type":"waria","lRect":[{"type":"condition","option":[true,true,false,0.3333333333333333,0],"lRect":[{"type":"move","option":[true,false]}]},{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":0,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":5,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.1,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.7,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.5,"y":0.4,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.7,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.9,"y":0.2,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"speed","number":0,"x":0.5,"y":0.5},{"style":"attack","number":2,"x":0.7,"y":0.7},{"style":"shield","number":0,"x":0.2,"y":0.9},{"style":"shield","number":1,"x":0.8,"y":0.4},{"style":"shield","number":2,"x":0.2,"y":0.2}]}
{"enemyVisible":false,"bonusVisible":true,"robotRandomPosition":true,"tree":{"type":"waria","lRect":[{"type":"condition","option":[true,true,false,0.3333333333333333,0],"lRect":[{"type":"move","option":[true,false,"speed"]}]},{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":0,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":5,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]},{"height":0.1,"width":0.1,"x":0.1,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.7,"y":0.1,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.5,"y":0.4,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.3,"y":0.7,"name":"enemy","speed":1,"speedReload":1,"range":5,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]},{"height":0.1,"width":0.1,"x":0.9,"y":0.2,"name":"enemy","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[{"name":"condition","option":[true,true,false,0.5,0],"lNode":[{"name":"move","option":[false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}],"lBonus":[{"style":"speed","number":0,"x":0.5,"y":0.5},{"style":"attack","number":2,"x":0.7,"y":0.7},{"style":"shield","number":0,"x":0.2,"y":0.9},{"style":"shield","number":1,"x":0.8,"y":0.4},{"style":"shield","number":2,"x":0.2,"y":0.2}]}

@ -1,6 +1,11 @@
class AddAttack extends AddNode {
constructor(father, game, selected, ...option) {
super(father, game, selected, option);
constructor(father, game, selected, add = true) {
if (!add) {
super(father, game, selected, [false, selected.node.percentRange]);
} else {
super(father, game, selected);
}
}
create() {
@ -8,7 +13,7 @@ class AddAttack extends AddNode {
super.create();
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, selectWord("ADD NODE : ATTACK", "AJOUTER ACTION : ATTAQUE"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS", "FILTRES CIBLES"));
super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 5), 'enemyBot', super.newCategory('target', true, true), false);
let c2 = super.newCategory('range', true, true);

@ -1,6 +1,15 @@
class AddCondition extends AddNode {
constructor(father, game, selected, ...option) {
super(father, game, selected, option);
constructor(father, game, selected, add = true) {
if (!add) {
if (selected.node.shieldFilter) {
super(father, game, selected, [selected.node.shield, 'shield']);
} else {
super(father, game, selected, [selected.node.shield, 'range']);
}
} else {
super(father, game, selected);
}
}
create() {
@ -8,7 +17,7 @@ class AddCondition extends AddNode {
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 / 3), selectWord("WHO ?", "QUI ?"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS", "FILTRES CIBLES"));
let c1 = super.newCategory('target', true, true);
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);

@ -1,6 +1,10 @@
class AddMove extends AddNode {
constructor(father, game, selected, ...option) {
super(father, game, selected, option);
constructor(father, game, selected, add = true) {
if (!add) {
super(father, game, selected, [selected.node.toward, selected.node.enemyBot, selected.node.typeBonus]);
} else {
super(father, game, selected);
}
}
create() {
@ -14,12 +18,27 @@ class AddMove extends AddNode {
super.addTitle(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
let c2 = super.newCategory('target', true, true);
super.addButton(WIDTH_WINDOW / 6 * 4, HEIGHT_WINDOW / (16 / 5), 'enemyBot', c2, true);
super.addButton(WIDTH_WINDOW / 6 * 5, HEIGHT_WINDOW / (16 / 5), 'bonus', c2, false);
let btn = super.addButton(WIDTH_WINDOW / 6 * 5, HEIGHT_WINDOW / (16 / 5), 'bonus', c2, false);
let title = super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("WHAT BONUS ? (OPTIONAL)", "QUEL BONUS ? (FACULTATIF)"));
let c3 = super.newCategory('target', true, false);
let speed = super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), 'bonusSpeed', c3, "speed");
let attack = super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), 'bonusAttack', c3, "attack");
let shield = super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 12), 'bonusShield', c3, "shield");
c2.addEvent(() => this.clickBonus(btn, title, speed, attack, shield));
this.clickBonus(btn, title, speed, attack, shield);
}
clickBonus(btn, ...others) {
if (btn.isTinted) {
others.forEach(other => other.setVisible(true));
} else {
others.forEach(other => other.setVisible(false));
}
}
addNode() {
if (super.verifyCategory()) {
this.selected.addRect(new RectangleNode(this.selected.getX(), this.selected.getY() + 200, this.gameR, 'move', [this.lCategory[0].getValue(), this.lCategory[1].getValue()]));
this.selected.addRect(new RectangleNode(this.selected.getX(), this.selected.getY() + 200, this.gameR, 'move', [this.lCategory[0].getValue(), this.lCategory[1].getValue(), this.lCategory[2].getValue()]));
super.cancel();
}
}
@ -28,6 +47,7 @@ class AddMove extends AddNode {
if (super.verifyCategory()) {
this.selected.node.toward = this.lCategory[0].getValue();
this.selected.node.enemyBot = this.lCategory[1].getValue();
this.selected.node.typeBonus = this.lCategory[2].getValue();
this.selected.rect.setFrame(this.selected.node.getFrame());
super.cancel();
}

@ -1,6 +1,6 @@
class BonusAttack extends Bonus {
constructor(name, texture, value) {
super(name, texture, value);
super(name, texture, value, "attack");
}
useOn(robot) {

@ -1,6 +1,6 @@
class BonusShield extends Bonus {
constructor(name, texture, value, time, color) {
super(name, texture, value);
super(name, texture, value, "shield");
this.time = time;
this.color = color;
}

@ -1,6 +1,6 @@
class BonusSpeed extends Bonus {
constructor(name = "", texture, value, time) {
super(name, texture, value);
super(name, texture, value, "speed");
this.time = time;
}

@ -0,0 +1,20 @@
class Button extends Phaser.GameObjects.Sprite {
constructor(scene, x, y, width, height, texture, fn, line = 0, visible = true) {
super(scene, x, y, texture);
this.name = texture;
this.setInteractive().setVisible(visible);
this.displayHeight = height;
this.displayWidth = width;
this.line = line;
this.on('pointerout', () => this.changeFrame(0));
this.on('pointerover', () => this.changeFrame(1));
this.on('pointerdown', fn);
this.changeFrame(0);
scene.add.existing(this);
}
changeFrame(column = 0) {
this.setFrame(column + this.line * 2);
}
}

@ -7,17 +7,6 @@ class Category {
this.obligatory = obligatory;
}
add(btn, value) {
if (this.lBtn.length !== 0 && this.single) {
this.lBtn[0].clearTint();
this.lValue = [];
this.lBtn = [];
}
this.lValue.push(value);
this.lBtn.push(btn);
btn.tint = 0xEFD807;
}
getValue() {
if (this.single) {
return this.lValue[0];
@ -29,6 +18,22 @@ class Category {
return !(this.lBtn.length === 0 && this.obligatory);
}
addEvent(fn) {
this.event = fn;
}
add(btn, value) {
if (this.lBtn.length !== 0 && this.single) {
this.lBtn[0].clearTint();
this.lValue = [];
this.lBtn = [];
}
this.lValue.push(value);
this.lBtn.push(btn);
btn.tint = 0xEFD807;
this.oneChange();
}
remove(btn) {
let id = this.lBtn.indexOf(btn);
if (id !== -1) {
@ -36,5 +41,12 @@ class Category {
this.lValue.splice(id, 1);
}
btn.clearTint();
this.oneChange();
}
oneChange() {
if (this.event !== undefined) {
this.event();
}
}
}

@ -50,7 +50,7 @@ class Game extends ManageLang {
this.doLine = false;
this.createButton();
this.createButtons();
this.input.keyboard.on('keydown-DELETE', () => {
this.clickBin();
@ -90,14 +90,14 @@ class Game extends ManageLang {
}
loadTree(element, posX = CENTERX_TREE, posY = OFFY_TREE / 2) {
let tree;
if (element.x !== undefined && element.y !== undefined) {
let tree = new RectangleNode(element.x, element.y, this, element.type, element.option);
tree = new RectangleNode(element.x, element.y, this, element.type, element.option);
if (element.lRect !== undefined && element.lRect.length > 0) {
element.lRect.forEach(rect => tree.addRect(this.loadTree(rect)))
}
return tree;
} else {
let tree = new RectangleNode(posX, posY, this, element.type, element.option);
tree = new RectangleNode(posX, posY, this, element.type, element.option);
if (element.lRect !== undefined && element.lRect.length > 0) {
let nbRect = element.lRect.length;
let x = posX - (OFFX_TREE / 2) * (nbRect - 1);
@ -107,8 +107,8 @@ class Game extends ManageLang {
x += OFFX_TREE;
});
}
return tree;
}
return tree;
}
loadInitSave(element) {
@ -213,11 +213,11 @@ class Game extends ManageLang {
return;
if (this.selected !== this.tree) {
this.pencil.setVisible(true);
this.bin.setVisible(true);
this.pencilBtn.setVisible(true);
this.binBtn.setVisible(true);
}
if (this.selected.canAddNode) {
this.plus.setVisible(true);
this.plusBtn.setVisible(true);
}
}
@ -241,90 +241,48 @@ class Game extends ManageLang {
pauseScene() {
this.linePlay = 0;
this.changeFrame(this.play, 0);
this.playBtn.line = 0;
this.playBtn.changeFrame(0);
this.gm.pause();
}
resume() {
this.linePlay = 1;
this.playBtn.line = 1;
this.playBtn.changeFrame(0);
let sortDesc = (a, b) => a.getX() - b.getX();
this.tree.sort(sortDesc);
this.tree.sort();
this.gm.modifyNodes(this.tree.getNode());
this.gm.modifyValue(this.initStat.lBar[0].value, this.initStat.lBar[1].value, this.initStat.lBar[2].value, this.initStat.lBar[3].value);
this.gm.resume();
}
changeFrame(btn, column = 0, line = 0) {
btn.setFrame(column + line * 2);
}
createButton() {
createButtons() {
let x = WIDTH_MAP + OFFX_MAP;
let y = WIDTH_MAP + OFFY_MAP + 5;
let width = WIDTH_BUTTON;
let diffX = width * 1.1;
let back = this.add.sprite(10, 10, 'back').setOrigin(0, 0).setInteractive();
this.play = this.add.sprite(x, y, 'play').setOrigin(1, 0).setInteractive();
let speed = this.add.sprite(x - diffX, y, 'speed').setOrigin(1, 0).setInteractive();
let save = this.add.sprite(WIDTH_WINDOW, y, 'save').setOrigin(1, 0).setInteractive();
this.pencil = this.add.sprite(x - diffX * 2, y, 'pencil').setOrigin(1, 0).setInteractive().setVisible(false);
this.bin = this.add.sprite(x - diffX * 3, y, 'bin').setOrigin(1, 0).setInteractive().setVisible(false);
this.plus = this.add.sprite(x - diffX * 4, y, 'plus').setOrigin(1, 0).setInteractive().setVisible(false);
let mute = this.add.sprite(x - diffX * 5, y, 'mute').setOrigin(1, 0).setInteractive();
this.linePlay = 0;
let line = 0;
new Button(this, 10, 10, width, width, 'back', () => this.clickBack()).setOrigin(0, 0);
new Button(this, WIDTH_WINDOW - diffX, y, width, width, 'bonusBtn', () => this.clickBonus()).setOrigin(1, 0);
new Button(this, WIDTH_WINDOW, y, width, width, 'save', () => this.clickSave()).setOrigin(1, 0);
this.playBtn = new Button(this, x, y, width, width, 'play', () => this.clickPlay()).setOrigin(1, 0);
if (SPEED_GAME === 1) {
this.lineSpeed = 0;
line = 0;
} else {
this.lineSpeed = 1;
line = 1;
}
this.changeFrame(speed, 0, this.lineSpeed);
this.speedBtn = new Button(this, x - diffX, y, width, width, 'speed', () => this.clickSpeed(), line).setOrigin(1, 0);
this.pencilBtn = new Button(this, x - diffX * 2, y, width, width, 'pencil', () => this.clickPencil(), 0, false).setOrigin(1, 0);
this.binBtn = new Button(this, x - diffX * 3, y, width, width, 'bin', () => this.clickBin(), 0, false).setOrigin(1, 0);
this.plusBtn = new Button(this, x - diffX * 4, y, width, width, 'plus', () => this.clickPlus(), 0, false).setOrigin(1, 0);
if (this.father.sound.mute) {
this.lineMute = 1;
line = 1;
} else {
this.lineMute = 0;
}
this.changeFrame(mute, 0, this.lineMute);
back.displayHeight = back.displayWidth = width;
save.displayHeight = save.displayWidth = width;
this.play.displayHeight = this.play.displayWidth = width;
speed.displayHeight = speed.displayWidth = width;
mute.displayHeight = mute.displayWidth = width;
this.pencil.displayHeight = this.pencil.displayWidth = width;
this.bin.displayHeight = this.bin.displayWidth = width;
this.plus.displayHeight = this.plus.displayWidth = width;
this.play.on('pointerout', () => this.changeFrame(this.play, 0, this.linePlay));
this.play.on('pointerover', () => this.changeFrame(this.play, 1, this.linePlay));
speed.on('pointerout', () => this.changeFrame(speed, 0, this.lineSpeed));
speed.on('pointerover', () => this.changeFrame(speed, 1, this.lineSpeed));
mute.on('pointerout', () => this.changeFrame(mute, 0, this.lineMute));
mute.on('pointerover', () => this.changeFrame(mute, 1, this.lineMute));
this.creatBtnOutAndOver(save);
this.creatBtnOutAndOver(back);
this.creatBtnOutAndOver(this.pencil);
this.creatBtnOutAndOver(this.bin);
this.creatBtnOutAndOver(this.plus);
this.play.on('pointerdown', () => this.clickPlay());
speed.on('pointerdown', () => this.clickSpeed(speed));
back.on('pointerdown', () => this.clickBack());
mute.on('pointerdown', () => this.clickMute(mute));
save.on('pointerdown', () => this.clickSave());
this.pencil.on('pointerdown', () => this.clickPencil());
this.bin.on('pointerdown', () => this.clickBin());
this.plus.on('pointerdown', () => this.clickPlus());
line = 0;
}
this.muteBtn = new Button(this, x - diffX * 5, y, width, width, 'mute', () => this.clickMute(), line).setOrigin(1, 0);
this.input.on('pointerdown', () => this.clickNode());
this.input.on('drag', this.doDrag);
@ -332,26 +290,22 @@ class Game extends ManageLang {
this.input.on('dragend', () => this.dragEnd());
}
creatBtnOutAndOver(btn) {
btn.on('pointerout', () => this.changeFrame(btn, 0));
btn.on('pointerover', () => this.changeFrame(btn, 1));
}
clickSave() {
clickBonus() {
this.father.scene.stop('GamingBoard');
this.father.scene.remove('GamingBoard');
this.father.scene.add('Description', new Description(this.father, this));
this.scene.start('Description');
}
/*
clickSave() {
let sortDesc = (a, b) => a.getX() - b.getX();
this.tree.sort(sortDesc);
let tree = this.tree.getJson();
let initStat = this.initStat.getJson();
let json = '{' + '"tree":' + tree + ',"initStat":' + initStat + '}';
console.log(json);
*/
}
clickPlay() {
@ -360,19 +314,19 @@ class Game extends ManageLang {
else
this.pauseScene();
this.changeFrame(this.play, 1, this.linePlay);
this.playBtn.changeFrame(1);
}
clickSpeed(btn) {
clickSpeed() {
if (SPEED_GAME === 1) {
SPEED_GAME = 2;
this.lineSpeed = 1;
this.speedBtn.line = 1;
} else {
SPEED_GAME = 1;
this.lineSpeed = 0;
this.speedBtn.line = 0;
}
this.changeFrame(btn, 1, this.lineSpeed);
this.speedBtn.changeFrame(1);
}
clickPencil() {
@ -380,17 +334,13 @@ class Game extends ManageLang {
console.log("PENCIL");
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));
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, false));
break;
case 'condition':
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']));
}
this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, false));
break;
default:
return;
@ -405,7 +355,7 @@ class Game extends ManageLang {
console.log("BIN");
this.tree.delete(this.selected);
this.changeFrame(this.bin, 0);
this.binBtn.changeFrame(0);
this.tryClick();
}
}
@ -418,7 +368,7 @@ class Game extends ManageLang {
this.scene.launch('PlusNode');
this.changeFrame(this.plus, 0);
this.plusBtn.changeFrame(0);
this.scene.pause('Game');
}
@ -433,23 +383,22 @@ class Game extends ManageLang {
this.father.scene.start('Type');
}
clickMute(btn) {
clickMute() {
console.log("MUTE");
if (this.father.sound.mute) {
this.father.sound.mute = false;
this.lineMute = 0;
this.muteBtn.line = 0
} else {
this.father.sound.mute = true;
this.lineMute = 1;
this.muteBtn.line = 1;
}
this.changeFrame(btn, 1, this.lineMute);
this.muteBtn.changeFrame(1);
}
tryClick() {
this.pencil.setVisible(false);
this.bin.setVisible(false);
this.plus.setVisible(false);
this.pencilBtn.setVisible(false);
this.binBtn.setVisible(false);
this.plusBtn.setVisible(false);
if (this.selected != undefined) {
this.selected.deselect();
this.selected = undefined;

@ -62,14 +62,15 @@ class LoadFile extends Phaser.Scene {
this.loadSprite('flag', 269, 262, 'buttons/');
this.loadSprite('map', 269, 262, 'buttons/');
this.loadSprite('play', 100, 100, 'buttons/');
this.loadSprite('bin', 100, 100, 'buttons/');
this.loadSprite('plus', 100, 100, 'buttons/');
this.loadSprite('pencil', 100, 100, 'buttons/');
this.loadSprite('speed', 100, 100, 'buttons/');
this.loadSprite('mute', 100, 100, 'buttons/');
this.loadSprite('save', 100, 100, 'buttons/');
this.loadSprite('back', 200, 200, 'buttons/');
this.loadSprite('play', 100, 100, 'buttons/', true);
this.loadSprite('bin', 100, 100, 'buttons/', true);
this.loadSprite('plus', 100, 100, 'buttons/', true);
this.loadSprite('pencil', 100, 100, 'buttons/', true);
this.loadSprite('speed', 100, 100, 'buttons/', true);
this.loadSprite('mute', 100, 100, 'buttons/', true);
this.loadSprite('save', 100, 100, 'buttons/', true);
this.loadSprite('bonusBtn', 100, 100, 'buttons/', true);
this.loadSprite('back', 200, 200, 'buttons/', true);
this.loadSprite('shortRange', 300, 150, 'buttons/');
this.loadSprite('mediumRange', 300, 150, 'buttons/');
@ -80,6 +81,11 @@ class LoadFile extends Phaser.Scene {
this.loadSprite('shield66', 300, 150, 'buttons/');
this.loadSprite('shield100', 300, 150, 'buttons/');
this.loadSprite('bonusShield', 300, 150, 'buttons/');
this.loadSprite('bonusSpeed', 300, 150, 'buttons/');
this.loadSprite('bonusAttack', 300, 150, 'buttons/');
this.loadSprite('myself', 300, 150, 'buttons/');
this.loadSprite('enemyBot', 300, 150, 'buttons/');
this.loadSprite('bonus', 300, 150, 'buttons/');
@ -126,6 +132,9 @@ class LoadFile extends Phaser.Scene {
}
loadSprite(name, width, height, folder = '', force = false) {
if (this.textures.exists(name) && force) {
return;
}
this.deleteLoad(name);
if (force) {
this.load.spritesheet(name, 'assets/' + folder + name + '.png', {
@ -133,7 +142,7 @@ class LoadFile extends Phaser.Scene {
frameHeight: height
});
} else {
this.load.spritesheet(name, 'assets/' + LANG + '/' + folder + name + '.png', {
this.load.spritesheet(name, 'assets/lang/' + LANG + '/' + folder + name + '.png', {
frameWidth: width,
frameHeight: height
});
@ -141,11 +150,14 @@ class LoadFile extends Phaser.Scene {
}
loadImage(name, folder = '', force = false) {
if (this.textures.exists(name) && force) {
return;
}
this.deleteLoad(name);
if (force) {
this.load.image(name, 'assets/' + folder + name + '.png');
} else {
this.load.image(name, 'assets/' + LANG + '/' + folder + name + '.png');
this.load.image(name, 'assets/lang/' + LANG + '/' + folder + name + '.png');
}
}

@ -1,7 +1,8 @@
class Move {
constructor(toward, enemyBot = true) { //true = move toward / false = flee from
constructor(toward, enemyBot = true, typeBonus) { //true = move toward / false = flee from
this.toward = toward;
this.enemyBot = enemyBot;
this.typeBonus = typeBonus;
}
do(robot) {
@ -14,7 +15,8 @@ class Move {
}
}
} else {
let bonusTarget = chooseTarget(robot, listBonus);
let bonusTarget = chooseTarget(robot, this.getListBonus());
if (bonusTarget !== undefined) {
let ret;
if (this.toward === true) {
@ -33,9 +35,21 @@ class Move {
return false;
}
getListBonus() {
if (this.typeBonus !== undefined) {
let l = [];
listBonus.forEach(bonusView => {
if (bonusView.bonus.type === this.typeBonus) {
l.push(bonusView);
}
});
return l;
}
return listBonus;
}
moveToward(robot, target = robot.target) {
return robot.advanceTo(target);
}
fleeFrom(robot, target = robot.target) {
@ -47,13 +61,29 @@ class Move {
if (this.toward)
frame = 0;
else
frame = 2;
frame = 5;
if (!this.enemyBot)
switch (this.typeBonus) {
case "speed":
frame += 2;
break;
case "attack":
frame += 3;
break;
case "shield":
frame += 4;
break;
default:
frame += 1;
}
return frame;
}
getOptionJson() {
return this.toward + ',' + this.enemyBot;
let json = this.toward + ',' + this.enemyBot + '';
if (this.typeBonus !== undefined) {
json += ',"' + this.typeBonus + '"';
}
return json;
}
}

@ -9,7 +9,7 @@ class RectangleNode {
break;
case 'move' :
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'moveNode');
this.node = new Move(option[0], option[1]);
this.node = new Move(option[0], option[1], option[2]);
this.canAddNode = false;
this.line = scene.add.graphics();
break;
@ -132,7 +132,7 @@ class RectangleNode {
return this.node;
}
sort(sortDesc) {
sort(sortDesc = (a, b) => a.getX() - b.getX()) {
if (this.canAddNode) {
this.lRect.sort(sortDesc);
this.lRect.forEach(function (element) {

@ -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 || (this.option[0].length > 0 && this.option[0][0] === value[0] && this.option[0][1] === value [1]))) {
if (category !== this.lastCategory && this.option.length > 0 && (this.option[0] === value || (this.option[0] !== undefined && 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);
@ -65,7 +65,7 @@ class AddNode extends Phaser.Scene {
}
addTitle(x, y, title) {
this.add.text(x, y, title, this.style).setOrigin(0.5, 0.5);
return this.add.text(x, y, title, this.style).setOrigin(0.5, 0.5);
}
createButtonCancel() {

@ -1,7 +1,8 @@
class Bonus {
constructor(name, texture, value) {
constructor(name, texture, value, type) {
this.texture = texture;
this.name = name;
this.value = value;
this.type = type;
}
}

@ -19,7 +19,8 @@
"type": "move",
"option": [
true,
false
false,
"speed"
]
}
]

Loading…
Cancel
Save