Ajout du score sous le jeu et sur la page de Fin - Modification des bonus dans le but d'intéger le score - Lorsqu'un robot reçoit des dommages, il ajoute du score à l'équipe du robot qui lui a causé ces dommages - Modification de la gestion des stats initiales qui sont dorénavant directement lié avec les robots => Par exemple, la modification de la portée sera vue en temps réel sur nos robots

master
clmaisonha 5 years ago
parent f4772e9f16
commit 1ea0a1fe39

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

@ -0,0 +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,"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"]]},"listTeam":[{"name":"myTeam","robots":[{"height":0.1,"width":0.1,"x":0.9,"y":0.9,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]}]},{"name":"enemyTeam","robots":[{"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]}]}]},{"name":"enemyTeam","robots":[{"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":[true,false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}]},{"name":"enemyTeam","robots":[{"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":[true,false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}]},{"name":"enemyTeam","robots":[{"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":[true,false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}]},{"name":"enemyTeam","robots":[{"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":[true,false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}]},{"name":"enemyTeam","robots":[{"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":[true,false]}]},{"name":"attack","option":[]},{"name":"move","option":[true]}]}]},{"name":"enemyTeam","robots":[{"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":[true,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}]}

@ -0,0 +1 @@
{"enemyVisible":false,"bonusVisible":true,"robotRandomPosition":false,"tree":{"type":"waria","lRect":[{"type":"attack","option":[0.3333333333333333]},{"type":"condition","option":[false,false,true,0.3333333333333333,1],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"move","option":[true,false]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":5,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":0,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":0,"valueMax":5,"color":255,"colorMin":255},{"value":5,"valueMax":5,"color":32768,"colorMin":32768}],"lText":[["DAMAGE","DEGATS"],["R.S","RECHARGEMENT"],["SPEED","VITESSE"],["RANGE","PORTEE"]]},"listTeam":[{"name":"myTeam","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.3,"y":0.5,"name":"myself","speed":3,"speedReload":1,"range":3,"damage":5,"lNode":[]}]},{"name":"enemyTeam","robots":[{"height":0.1,"width":0.1,"x":0.5,"y":0.1,"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]}]},{"height":0.1,"width":0.1,"x":0.1,"y":0.9,"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}]}

@ -16,6 +16,12 @@ class Bar extends HealthBar {
this.categoryBar.setValueOf(this, value);
}
addEvent(event, context) {
this.event = event;
this.context = context;
this.doEvent();
}
doDrag() {
let pointer = this.scene.input;
if (pointer.x >= this.bar.x - 10 && pointer.x <= this.bar.x + this.width + 10 && pointer.y >= this.bar.y && pointer.y <= this.bar.y + this.height) {
@ -39,8 +45,18 @@ class Bar extends HealthBar {
this.setValWithX(this.scene.input.x);
}
doEvent() {
if (this.event !== undefined && this.context !== undefined) {
this.event.call(this.context, this.value);
}
}
setValWithX(posX) {
let oldValue = this.value;
this.categoryBar.setValueOf(this, Math.round((posX - this.bar.x) / this.width * this.valueMax));
if (oldValue !== this.value) {
this.doEvent();
}
}
draw() {

@ -4,6 +4,7 @@ class BonusAttack extends Bonus {
}
useOn(robot) {
super.useOn(robot);
robot.setAttackBonus(this.value);
}
}

@ -6,6 +6,7 @@ class BonusShield extends Bonus {
}
useOn(robot, scene) {
super.useOn(robot);
let bonus = new BonusHealth(this.value, this.color);
robot.shield.addBonus(bonus);
scene.time.addEvent({

@ -5,6 +5,7 @@ class BonusSpeed extends Bonus {
}
useOn(robot, scene) {
super.useOn(robot);
robot.increaseSpeedBonus(this.value - 1);
scene.time.addEvent({delay: this.time, callback: () => robot.decreaseSpeedBonus(this.value - 1)});
}

@ -5,7 +5,7 @@ class Game extends ManageLang {
SPEED_GAME = 1;
this.level = level;
this.listPositionRobotInit = [];
this.score = 0;
this.scoreText = 0;
}
preload() {
@ -35,6 +35,9 @@ class Game extends ManageLang {
let level = this.cache.json.get('level');
if (level === undefined) {
console.log("ERROR : LEVEL UNDEFINED");
new Button(this, 10, 10, WIDTH_BUTTON, WIDTH_BUTTON, 'back', () => this.clickBack()).setOrigin(0, 0);
let style = {font: '50px stencil', fill: "#e2e2e2"};
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 2, selectWord("LEVEL UNDEFINED", "NIVEAU INDEFINI"), style).setOrigin(0.5, 0.5);
return;
}
@ -66,6 +69,11 @@ class Game extends ManageLang {
});
this.scene.setVisible(true, 'GamingBoard');
this.gm.getMyTeam().drawRange();
this.setScore(0);
this.gm.getMyTeam().addEventScore(this.setScore, this);
}
update(time, delta) {
@ -122,10 +130,20 @@ class Game extends ManageLang {
for (let i = 0; i < element.lBar.length; i++) {
initStat.addBar(element.lBar[i].value, element.lBar[i].valueMax, element.lBar[i].color, element.lText[i]);
}
this.gm.modifyValue(initStat.lBar[0].value, initStat.lBar[1].value, initStat.lBar[2].value, initStat.lBar[3].value);
let myTeam = this.gm.getMyTeam();
initStat.lBar[0].addEvent(myTeam.setDamage, myTeam);
initStat.lBar[1].addEvent(myTeam.setSpeedReload, myTeam);
initStat.lBar[2].addEvent(myTeam.setSpeed, myTeam);
initStat.lBar[3].addEvent(myTeam.setRange, myTeam);
return initStat;
}
log(text) {
console.log(text);
}
loadTeam(level) {
if (level.listTeam !== undefined) {
let init = 0;
@ -137,7 +155,7 @@ class Game extends ManageLang {
loadT(name = MY_TEAM, freeForAll, robots, robotRandomPosition, init = 0) {
let t = new Team(name, freeForAll);
t.listRobot = this.loadRobot(robots, robotRandomPosition, init);
this.loadRobot(robots, robotRandomPosition, init).forEach(robot => t.addRobot(robot));
this.gm.addTeam(t);
return t.listRobot.length;
}
@ -214,9 +232,9 @@ class Game extends ManageLang {
console.log("FINISH");
let winner;
if (this.gm.winner()) {
winner = new Winner(this.father, this);
winner = new Winner(this.father, this, this.score);
} else {
winner = new Looser(this.father, this);
winner = new Looser(this.father, this, this.score);
}
this.father.scene.add('Finish', winner);
@ -274,7 +292,7 @@ class Game extends ManageLang {
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.modifyValue(this.initStat.lBar[0].value, this.initStat.lBar[1].value, this.initStat.lBar[2].value, this.initStat.lBar[3].value);
this.gm.resume();
}
@ -307,7 +325,7 @@ class Game extends ManageLang {
let style = {font: (width / 2).toString() + 'px stencil', fill: "#e2e2e2"};
this.score = this.add.text(OFFX_MAP, y, "SCORE : " + this.score, style).setOrigin(0, 0);
this.scoreText = this.add.text(OFFX_MAP, y, "SCORE : " + this.scoreText, style).setOrigin(0, 0);
this.input.on('pointerdown', () => this.clickNode());
this.input.on('drag', this.doDrag);
@ -316,7 +334,8 @@ class Game extends ManageLang {
}
setScore(score) {
this.score.setText("SCORE : " + this.score);
this.score = score
this.scoreText.setText("SCORE : " + this.score);
}
clickBonus() {

@ -1,6 +1,6 @@
class Looser extends Finish {
constructor(father, game) {
super(father, game);
constructor(father, game, score) {
super(father, game, score);
}
create() {

@ -31,6 +31,8 @@ class Robot {
this.setX(this.x);
this.setY(this.y);
this.team = undefined;
}
addScene(scene) {
@ -257,7 +259,7 @@ class Robot {
}
finishAttack(target, percentBonus) {
if (target.beAttack(this.damage * this.attackBonus * DAMAGE * percentBonus)) {
if (target.beAttack(this.damage * this.attackBonus * DAMAGE * percentBonus, this.team)) {
this.setTarget(null);
}
this.missile.setVisible(false);
@ -270,7 +272,7 @@ class Robot {
this.canAttack = true;
}
beAttack(damage) {
beAttack(damage, team) {
let diff = this.shield.decrease(damage);
let style = {font: HEIGHT_DAMAGE.toString() + 'px stencil', fill: "#ffff00"};
@ -293,9 +295,19 @@ class Robot {
console.log("Shield Broken");
this.life.decrease(diff);
}
this.addScore(team)
return this.die();
}
addScore(team) {
if (team !== undefined) {
team.addScore(SCORE_HIT);
if (this.life.value === 0) {
team.addScore(SCORE_KILL);
}
}
}
isTargetInRange(percentRange = 1) {
if (this.haveTarget()) {
return this.calcDistance(this.target) <= this.range * RANGE * percentRange;

@ -6,8 +6,21 @@ class Team {
this.score = 0;
}
addEventScore(event, context) {
this.eventScore = event;
this.context = context;
}
addScore(score) {
this.score += score;
if (this.eventScore !== undefined && this.context !== undefined) {
this.eventScore.call(this.context, this.score);
}
}
addRobot(robot) {
this.listRobot.push(robot);
robot.team = this;
}
readAll() {
@ -34,14 +47,42 @@ class Team {
}
modifyValue(damage, speedReload, speed, range) {
this.setSpeed(speed);
this.setRange(range);
this.setSpeedReload(speedReload);
this.setDamage(damage);
}
setRange(range) {
this.listRobot.forEach(robot => {
robot.setSpeed(speed);
robot.setRange(range);
});
}
setSpeed(speed) {
this.listRobot.forEach(robot => {
robot.setSpeed(speed);
});
}
setSpeedReload(speedReload) {
this.listRobot.forEach(robot => {
robot.setSpeedReload(speedReload);
});
}
setDamage(damage) {
this.listRobot.forEach(robot => {
robot.setDamage(damage);
});
}
drawRange() {
this.listRobot.forEach(robot => {
robot.drawRange();
});
}
modifyNodes(lNodes) {
this.listRobot.forEach(robot => {
robot.cleanNodes();

@ -27,6 +27,9 @@ const CENTERX_TREE = WIDTH_WINDOW / 4 * 3;
const OFFX_TREE = WIDTH_WINDOW / 10;
const OFFY_TREE = HEIGHT_WINDOW / 6;
const WIDTH_BUTTON = WIDTH_MAP / 10;
const SCORE_HIT = 5;
const SCORE_KILL = 15;
const SCORE_BONUS = 4;
const HEIGHT_NODE = HEIGHT_WINDOW / 6;

@ -1,6 +1,6 @@
class Winner extends Finish {
constructor(father, game) {
super(father, game);
constructor(father, game, score) {
super(father, game, score);
}
create() {

@ -5,4 +5,8 @@ class Bonus {
this.value = value;
this.type = type;
}
useOn(robot) {
robot.team.addScore(SCORE_BONUS);
}
}

@ -1,8 +1,9 @@
class Finish extends Phaser.Scene {
constructor(father, game) {
constructor(father, game, score) {
super('Finish');
this.father = father;
this.gameSave = game;
this.score = score;
}
create() {
@ -13,7 +14,9 @@ class Finish extends Phaser.Scene {
addTitle(title) {
let sizeText = HEIGHT_WINDOW / 6;
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 2, title, style).setOrigin(0.5, 0.5);
let text = this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 2, title, style).setOrigin(0.5, 0.5);
style = {font: (sizeText / 2).toString() + 'px stencil', fill: "#e2e2e2"};
this.add.text(WIDTH_WINDOW / 2, text.y + text.displayHeight, "SCORE : " + this.score.toString(), style).setOrigin(0.5, 0.5);
}
createButton(x, texture) {

Loading…
Cancel
Save