Création des images pour les bonus (ventilateur, essence, fusée) en fonction de la valeur - Modification de l'image moveNode.png dans le but d'implémenter les bonus - Modification de l'ajout d'un déplacement pour implémenter le déplacement vers les bonus - Modification des classes action pour gérer plus simplement quelle frame sélectionné en fonction des paramètres de la classe - Meilleur gestion des sprites boutons dans la page Game - Ajout de la variable SPEED_GAME dans le but de gérer la vitesse du jeux - Ajout d'un bouton pour accélerer le jeux par deux

master
clmaisonha 5 years ago
parent c1509d8ccb
commit f2ec732f68

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

@ -1 +1 @@
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",new Game(e))}function chooseTarget(e,t){let n=2*WIDTH_MAP,a=[];return t.forEach(function(t){if(t!==e){let o=Math.hypot(t.x-e.x,t.y-e.y);n>=o&&(n>o&&(n=o,a=[]),a.push(t))}}),a.length>1?a[Math.floor(Math.random()*(a.length+1))]:a[0]}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase();const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,DURATION_DAMAGE=700,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,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"};let father=new Phaser.Game(config);father.scene.add("Boot",new Boot(father)),father.scene.start("Boot");
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",new Game(e))}function chooseTarget(e,t){let n=2*WIDTH_MAP,a=[];return t.forEach(function(t){if(t!==e){let o=Math.hypot(t.x-e.x,t.y-e.y);n>=o&&(n>o&&(n=o,a=[]),a.push(t))}}),a.length>1?a[Math.floor(Math.random()*(a.length+1))]:a[0]}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1;const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2,HEIGHT_BONUS=WIDTH_MAP/10,HEIGHT_DAMAGE=WIDTH_MAP/20,DURATION_DAMAGE=700;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("Boot",new Boot(father)),father.scene.start("Boot");

File diff suppressed because one or more lines are too long

@ -1 +1 @@
class AddNode extends Phaser.Scene{constructor(e,t,s){super("AddNode"),this.father=e,this.gameR=t,this.selected=s,this.lCategory=[]}create(e){let t=HEIGHT_WINDOW/(4/3);this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,t,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(e)}addButton(e,t,s,n,i,r=new Category,a){let o=this.createButton(e,t,s,n,i);return o.on("pointerdown",()=>this.click(o,r,a)),o}createButton(e,t,s,n,i){let r=this.add.image(e,t,i).setOrigin(.5,.5).setInteractive();return r.on("pointerover",()=>r.setFrame(1)),r.on("pointerout",()=>r.setFrame(0)),r.displayHeight=n,null===s?r.scaleX=r.scaleY:r.displayWidth=s,r}click(e,t,s){e.isTinted?t.remove(e):t.add(e,s)}newCategory(e,t,s){let n=new Category(e,t,s);return this.lCategory.push(n),n}addTitle(e,t,s){let n={font:(HEIGHT_WINDOW/12).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(e,t,s,n).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"cancel").on("pointerdown",()=>this.cancel())}createButtonAdd(e){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"add").on("pointerdown",()=>e.addNode())}verifyCategory(){for(let e=0;e<this.lCategory.length;e++)if(!this.lCategory[e].validate())return!1;return!0}cancel(){this.scene.resume("Game"),this.scene.stop("AddNode"),this.father.scene.remove("AddNode")}}class Bonus extends Phaser.GameObjects.Image{constructor(e,t,s,n,i,r){super(t,s,n,i),this.setOrigin(.5,.5),t.add.existing(this),this.name=e,this.value=r,this.scene=t}}class Finish extends Phaser.Scene{constructor(e){super("Finish"),this.father=e}create(){this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,HEIGHT_WINDOW/2,3487290).setOrigin(0,.5)}addTitle(e){let t={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,e,t).setOrigin(.5,.5)}createButton(e,t){let s=this.add.image(e,HEIGHT_WINDOW/8*7,t).setOrigin(.5,.5).setInteractive();return s.on("pointerover",()=>s.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.displayHeight=HEIGHT_WINDOW/9,s.scaleX=s.scaleY,s}btnRetry(e){e.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(e){e.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(e){e.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Game"),this.father.scene.remove("Finish")}}
class AddNode extends Phaser.Scene{constructor(e,t,s){super("AddNode"),this.father=e,this.gameR=t,this.selected=s,this.lCategory=[]}create(e){let t=HEIGHT_WINDOW/(4/3);this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,t,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(e)}addButton(e,t,s,i,n,r=new Category,a){let o=this.createButton(e,t,s,i,n);return o.on("pointerdown",()=>this.click(o,r,a)),o}createButton(e,t,s,i,n){let r=this.add.image(e,t,n).setOrigin(.5,.5).setInteractive();return r.on("pointerover",()=>r.setFrame(1)),r.on("pointerout",()=>r.setFrame(0)),r.displayHeight=i,null===s?r.scaleX=r.scaleY:r.displayWidth=s,r}click(e,t,s){e.isTinted?t.remove(e):t.add(e,s)}newCategory(e,t,s){let i=new Category(e,t,s);return this.lCategory.push(i),i}addTitle(e,t,s){let i={font:(HEIGHT_WINDOW/12).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(e,t,s,i).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"cancel").on("pointerdown",()=>this.cancel())}createButtonAdd(e){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"add").on("pointerdown",()=>e.addNode())}verifyCategory(){for(let e=0;e<this.lCategory.length;e++)if(!this.lCategory[e].validate())return!1;return!0}cancel(){this.scene.resume("Game"),this.scene.stop("AddNode"),this.father.scene.remove("AddNode")}}class Bonus extends Phaser.GameObjects.Image{constructor(e,t,s,i,n,r){super(t,s,i,n),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,t.add.existing(this),this.name=e,this.value=r,this.scene=t}}class Finish extends Phaser.Scene{constructor(e){super("Finish"),this.father=e}create(){this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,HEIGHT_WINDOW/2,3487290).setOrigin(0,.5)}addTitle(e){let t={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,e,t).setOrigin(.5,.5)}createButton(e,t){let s=this.add.image(e,HEIGHT_WINDOW/8*7,t).setOrigin(.5,.5).setInteractive();return s.on("pointerover",()=>s.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.displayHeight=HEIGHT_WINDOW/9,s.scaleX=s.scaleY,s}btnRetry(e){e.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(e){e.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(e){e.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Game"),this.father.scene.remove("Finish")}}

@ -39,12 +39,12 @@ function chooseTarget(robot, list) {
var listBonus = [];
var LANG = navigator.language.substr(0, 2).toLowerCase();
var SPEED_GAME = 1;
const MYSELF = 'myself';
const SHIELD_PER_SECOND = 5;
const COLOR_ATTACK = 0xff0000;
const COLOR_MOVE = 0x0000ff;
const COLOR_CONDITION = 0x0e0e0e;
const DURATION_DAMAGE = 700;
const WIDTH_WINDOW = $(document).width() - 20;
const HEIGHT_WINDOW = $(document).height() - 20;
const WIDTH_MAP = WIDTH_WINDOW < HEIGHT_WINDOW ? WIDTH_WINDOW * 0.8 : HEIGHT_WINDOW * 0.8;
@ -53,6 +53,9 @@ const LIFE = 100;
const DAMAGE = 40;
const SHIELD = 100;
const RANGE = WIDTH_MAP / 2;
const HEIGHT_BONUS = WIDTH_MAP / 10;
const HEIGHT_DAMAGE = WIDTH_MAP / 20;
const DURATION_DAMAGE = 700;
var config = {

@ -12,12 +12,14 @@ class AddMove extends AddNode {
super.addButton(WIDTH_WINDOW / 6, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'fleeFrom', c1, false);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'moveToward', c1, true);
super.addTitle(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
super.addButton(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', super.newCategory('target', true, true), false);
let c2 = super.newCategory('target', true, true);
super.addButton(WIDTH_WINDOW / 6 * 4, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', c2, true);
super.addButton(WIDTH_WINDOW / 6 * 5, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'bonus', c2, 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.selected.addRect(new RectangleNode(this.selected.getX(), this.selected.getY() + 200, this.gameR, 'move', this.lCategory[0].getValue(), this.lCategory[1].getValue()));
super.cancel();
}
}

@ -21,4 +21,8 @@ class Attack {
}
return false;
}
getFrame() {
return this.percentRange * 3 - 1;
}
}

@ -1,6 +1,21 @@
class BonusSpeed extends Bonus {
constructor(name, scene, x, y, value, time) {
super(name, scene, x, y, 'play', value);
let bonus;
switch (value) {
case 1:
bonus = 'bonusSpeed0';
break;
case 2:
bonus = 'bonusSpeed1';
break;
case 3:
bonus = 'bonusSpeed2';
break;
default:
bonus = 'bonusSpeed2';
break;
}
super(name, scene, x, y, bonus, value);
this.time = time;
}

@ -30,6 +30,10 @@ class Boot extends Phaser.Scene {
this.loadImage('en', 'flags/', true);
this.loadImage('fr', 'flags/', true);
this.loadImage('bonusSpeed0', 'bonus/', true);
this.loadImage('bonusSpeed1', 'bonus/', true);
this.loadImage('bonusSpeed2', 'bonus/', true);
this.loadSprite('playLetter', 550, 150, 'buttons/');
this.loadSprite('cancel', 550, 150, 'buttons/');
this.loadSprite('add', 550, 150, 'buttons/');
@ -47,6 +51,7 @@ class Boot extends Phaser.Scene {
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('back', 200, 200, 'buttons/');
this.loadSprite('shortRange', 300, 150, 'buttons/');
@ -60,21 +65,22 @@ class Boot extends Phaser.Scene {
this.loadSprite('myself', 300, 150, 'buttons/');
this.loadSprite('enemyBot', 300, 150, 'buttons/');
this.loadSprite('bonus', 300, 150, 'buttons/');
this.loadSprite('moveToward', 300, 150, 'buttons/');
this.loadSprite('fleeFrom', 300, 150, 'buttons/');
this.loadSprite('attackNode', 180, 190, 'nodes/');
this.loadSprite('moveNode', 180, 190, 'nodes/');
this.loadSprite('conditionNode', 180, 190, 'nodes/');
this.loadSprite('attackNode', 180, 190, 'nodes/', true);
this.loadSprite('moveNode', 180, 190, 'nodes/', true);
this.loadSprite('conditionNode', 180, 190, 'nodes/', true);
this.loadImage('background');
this.loadImage('bullet');
this.loadImage('logoWaria');
this.loadImage('attack', 'nodes/');
this.loadImage('move', 'nodes/');
this.loadImage('condition', 'nodes/');
this.loadImage('attack', 'nodes/', true);
this.loadImage('move', 'nodes/', true);
this.loadImage('condition', 'nodes/', true);
}
create() {

@ -74,4 +74,21 @@ class Condition {
fleeFrom(robot) {
return robot.fleeFromTarget();
}
getFrame() {
let line;
if (this.myself) {
line = 0;
} else {
line = 1;
}
let shield = 0;
if (this.shieldFilter) { //shield
shield = Math.floor(this.shield * 3);
}
if (this.rangeFilter) { //range
}
return line * 4 + shield;
}
}

@ -33,8 +33,6 @@ class Game extends Phaser.Scene {
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, WIDTH_MAP * 0.9, 0x6666ff, this.gm, MYSELF));
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.2, WIDTH_MAP * 0.1, 0xff0000, this.gm));
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, 0xff0000, this.gm));
this.gm.listRobot[0].setSpeed(3);
}
update(time, delta) {
@ -44,6 +42,7 @@ class Game extends Phaser.Scene {
finish() {
console.log("FINISH");
SPEED_GAME = 1;
let winner;
if (this.gm.winner()) {
winner = new Winner(this.father);
@ -86,14 +85,15 @@ class Game extends Phaser.Scene {
pauseScene(btn) {
this.line = 0;
this.linePlay = 0;
this.changeFrame(btn, 0);
this.gm.pause();
}
resume() {
this.line = 1;
this.linePlay = 1;
const sortDesc = (a, b) => a.getX() - b.getX();
this.tree.lRect.sort(sortDesc);
this.tree.lRect.forEach(function (element) {
@ -107,8 +107,8 @@ class Game extends Phaser.Scene {
}
changeFrame(btn, bonus) {
btn.setFrame(this.line * 2 + bonus);
changeFrame(btn, column = 0, line = 0) {
btn.setFrame(column + line * 2);
}
createButton() {
@ -116,27 +116,38 @@ class Game extends Phaser.Scene {
let y = WIDTH_MAP + HEIGHT_WINDOW / 10 + 5;
let diffX = (HEIGHT_WINDOW / 10);
let width = HEIGHT_WINDOW / 15;
let play = this.add.sprite(x, y, 'play').setOrigin(1, 0).setInteractive();
let back = this.add.sprite(10, 10, 'back').setOrigin(0, 0).setInteractive();
this.pencil = this.add.sprite(x - diffX, y, 'pencil').setOrigin(1, 0).setInteractive().setVisible(false);
this.bin = this.add.sprite(x - diffX * 2, y, 'bin').setOrigin(1, 0).setInteractive().setVisible(false);
this.plus = this.add.sprite(x - diffX * 3, y, 'plus').setOrigin(1, 0).setInteractive().setVisible(false);
let play = this.add.sprite(x, y, 'play').setOrigin(1, 0).setInteractive();
let speed = this.add.sprite(x - diffX, y, 'speed').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);
this.linePlay = 0;
this.lineSpeed = 0;
this.line = 0;
play.displayHeight = play.displayWidth = width;
back.displayHeight = back.displayWidth = width;
play.displayHeight = play.displayWidth = width;
speed.displayHeight = speed.displayWidth = width;
this.pencil.displayHeight = this.pencil.displayWidth = width;
this.bin.displayHeight = this.bin.displayWidth = width;
this.plus.displayHeight = this.plus.displayWidth = width;
this.creatBtnOutAndOver(play);
play.on('pointerout', () => this.changeFrame(play, 0, this.linePlay));
play.on('pointerover', () => this.changeFrame(play, 1, this.linePlay));
speed.on('pointerout', () => this.changeFrame(speed, 0, this.lineSpeed));
speed.on('pointerover', () => this.changeFrame(speed, 1, this.lineSpeed));
this.creatBtnOutAndOver(back);
this.creatBtnOutAndOver(this.pencil);
this.creatBtnOutAndOver(this.bin);
this.creatBtnOutAndOver(this.plus);
play.on('pointerdown', () => this.clickPlay(play));
speed.on('pointerdown', () => this.clickSpeed(speed));
back.on('pointerdown', () => this.clickBack());
this.pencil.on('pointerdown', () => this.clickPencil());
this.bin.on('pointerdown', () => this.clickBin());
@ -158,7 +169,19 @@ class Game extends Phaser.Scene {
else
this.pauseScene(btn);
this.changeFrame(btn, 1);
this.changeFrame(btn, 1, this.linePlay);
}
clickSpeed(btn) {
if (SPEED_GAME === 1) {
SPEED_GAME = 2;
this.lineSpeed = 1;
} else {
SPEED_GAME = 1;
this.lineSpeed = 0;
}
this.changeFrame(btn, 1, this.lineSpeed);
}
clickPencil() {
@ -189,6 +212,7 @@ class Game extends Phaser.Scene {
clickBack() {
console.log("BACK");
SPEED_GAME = 1;
this.father.scene.stop('GamingBoard');
this.father.scene.remove('GamingBoard');

@ -89,7 +89,7 @@ class GamingBoard extends Phaser.Scene {
upShield() {
this.listRobot.forEach(robot => robot.addShield(SHIELD_PER_SECOND));
this.time.addEvent({delay: 1000, callback: this.upShield, callbackScope: this});
this.time.addEvent({delay: 1000 / SPEED_GAME, callback: this.upShield, callbackScope: this});
}
}

@ -40,4 +40,15 @@ class Move {
fleeFrom(robot, target = robot.target) {
return robot.fleeFrom(target);
}
getFrame() {
let frame;
if (this.toward)
frame = 0;
else
frame = 2;
if (!this.enemyBot)
frame += 1;
return frame;
}
}

@ -6,19 +6,12 @@ class RectangleNode {
this.node = new Attack(option[0]);
this.canAddNode = false;
this.line = scene.add.graphics();
console.log(this.node.percentRange * 3);
this.rect.setFrame(this.node.percentRange * 3 - 1);
break;
case 'move' :
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'moveNode');
this.node = new Move(option[0], option[1]);
this.canAddNode = false;
this.line = scene.add.graphics();
if (option[0] === true) {
this.rect.setFrame(0);
} else {
this.rect.setFrame(2);
}
break;
case 'condition':
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'conditionNode');
@ -27,20 +20,7 @@ class RectangleNode {
this.lRect = [];
this.scene = scene;
this.line = scene.add.graphics();
let line;
if (option[0]) {
line = 0;
} else {
line = 1;
}
let shield = 0;
if (option[1] === true) { //shield
shield = Math.floor(option[3] * 3);
}
if (option[2] === true) { //range
}
this.rect.setFrame(line * 4 + shield);
break;
case 'waria':
this.rect = new Phaser.GameObjects.Image(scene, x, y, 'logoWaria').setInteractive();
@ -54,6 +34,7 @@ class RectangleNode {
return;
}
if (type.toString().toLowerCase() !== 'waria') {
this.rect.setFrame(this.node.getFrame());
}
this.rect.on('pointerdown', () => this.click());
this.rect.setOrigin(0.5, 0);

@ -149,8 +149,8 @@ class Robot {
let diffX = target.x - this.x;
let diffY = target.y - this.y;
let hypot = Math.hypot(diffX, diffY);
velocity[0] = diffX / hypot * WIDTH_MAP / 1000 * SPEED * this.speed;
velocity[1] = diffY / hypot * WIDTH_MAP / 1000 * SPEED * this.speed;
velocity[0] = diffX / hypot * WIDTH_MAP / 1000 * SPEED * this.speed * SPEED_GAME;
velocity[1] = diffY / hypot * WIDTH_MAP / 1000 * SPEED * this.speed * SPEED_GAME;
return velocity;
}
@ -184,7 +184,7 @@ class Robot {
this.scene.sound.play('shot');
let duration = this.calcDistance(this.target) * WIDTH_MAP / 1000;
let duration = this.calcDistance(this.target) * WIDTH_MAP / 1000 / SPEED_GAME;
this.scene.tweens.add({
targets: this.missile,
@ -195,7 +195,11 @@ class Robot {
onComplete: () => this.finishAttack(target, percentBonus)
});
this.scene.time.addEvent({delay: Phaser.Math.Between(1000, 3000), callback: this.reload, callbackScope: this});
this.scene.time.addEvent({
delay: Phaser.Math.Between(1000 / SPEED_GAME, 3000 / SPEED_GAME),
callback: this.reload,
callbackScope: this
});
}
finishAttack(target, percentBonus) {
@ -212,7 +216,7 @@ class Robot {
beAttack(damage) {
let diff = this.shield.decrease(damage);
let style = {font: '40px stencil', fill: "#ffff00"};
let style = {font: HEIGHT_DAMAGE.toString() + 'px stencil', fill: "#ffff00"};
let text = this.scene.add.text(this.x, this.y, damage.toString(), style).setOrigin(0, 1);
this.scene.tweens.add({

@ -2,6 +2,8 @@ class Bonus extends Phaser.GameObjects.Image {
constructor(name, scene, x, y, texture, value) {
super(scene, x, y, texture);
this.setOrigin(0.5, 0.5);
this.displayHeight = HEIGHT_BONUS;
this.scaleX = this.scaleY;
scene.add.existing(this);
this.name = name;
this.value = value;

Loading…
Cancel
Save