Correction : Les robots se sauvegardent maintenant au changement de langue ou à l'ouverture de la page description Bonus, le robot sélectionné reste le même au changement de langue - Meilleure gestion de la vitesse du jeu (avec la vitesse du jeu qui s'applique aux sons) - Début de la mise en place des constantes du jeux de manière dynamique pour permettre une meilleure adaptation sur les différents types d'écran (téléphone, écran un peu plus carré ...)

master
clmaisonha 5 years ago
parent f79c676102
commit e064e963bb

File diff suppressed because one or more lines are too long

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

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

@ -5,7 +5,6 @@ class Bar extends HealthBar {
} else {
super(scene, name, width, height, x, y, categoryBar.valueMax, color, color, false);
}
console.log(value);
this.name = name;
this.scene = scene;
this.scene.input.on('pointerdown', this.doDrag, this);

@ -40,12 +40,8 @@ class Game extends ManageLang {
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 2, selectWord("LEVEL UNDEFINED", "NIVEAU INDEFINI"), style).setOrigin(0.5, 0.5);
return;
}
console.log(level);
this.loadSave(level);
this.gm.setEnemyRobotVisible(level.enemyVisible);
this.gm.setBonusVisible(level.bonusVisible);
this.loadSave(level);
this.doLine = false;
@ -63,8 +59,6 @@ class Game extends ManageLang {
this.scene.setVisible(true, 'GamingBoard');
this.gm.getMyTeam().drawRange();
this.setScore(0);
this.gm.getMyTeam().addEventScore(this.setScore, this);
}
@ -90,16 +84,33 @@ class Game extends ManageLang {
loadSave(level) {
this.loadBonus(level.lBonus);
this.loadTeam(level);
this.setRobotSelected(this.gm.getMyTeam().listRobot[0], level);
let myself = [];
this.gm.getMyTeam().listRobot.forEach(robot => myself.push(robot));
if (this.listRobot !== undefined) {
for (let i = 0; i < this.listRobot.length; i++) {
if (myself[i] !== undefined) {
this.listRobot[i].copy(myself[i]);
}
}
} else {
this.gm.getMyTeam().drawRange();
}
this.listRobot = myself;
if (this.iRobot === undefined) {
this.iRobot = 0;
}
this.setRobotSelected(this.listRobot[this.iRobot], this.iRobot, level, true);
this.gm.setEnemyRobotVisible(level.enemyVisible);
this.gm.setBonusVisible(level.bonusVisible);
}
setRobotSelected(robot, level) {
setRobotSelected(robot, iRobot = 0, level, force = false) {
this.iRobot = iRobot;
let tree;
let initStat;
if (this.robotSelected !== undefined && this.robotSelected !== robot && this.tree !== undefined && this.initStat !== undefined) {
if (!force && this.robotSelected !== undefined && this.robotSelected !== robot && this.tree !== undefined && this.initStat !== undefined) {
this.robotSelected.clearTint();
this.tree.sort();
this.robotSelected.setNodes(this.tree.getNode());
initStat = JSON.parse(this.initStat.getJson());
this.tree.destroy();
this.initStat.destroy();
@ -107,10 +118,6 @@ class Game extends ManageLang {
} else {
if (this.initStat !== undefined) {
initStat = JSON.parse(this.initStat.getJson());
robot.setDamage(this.initStat.lBar[0].value);
robot.setSpeedReload(this.initStat.lBar[1].value);
robot.setSpeed(this.initStat.lBar[2].value);
robot.setRange(this.initStat.lBar[3].value);
this.initStat.destroy();
} else {
initStat = level.initStat;
@ -131,7 +138,14 @@ class Game extends ManageLang {
}
}
loadTree(element, posX = CENTERX_TREE, posY = OFFY_TREE / 2) {
applyTree() {
if (this.tree !== undefined && this.robotSelected !== undefined) {
this.tree.sort();
this.robotSelected.setNodes(this.tree.getNode());
}
}
loadTree(element, posX = CENTERX_TREE, posY = OFFY_TREE_BEGIN) {
let tree;
if (element.x !== undefined && element.y !== undefined) {
tree = new RectangleNode(element.x, element.y, this, element.type, element.option);
@ -154,8 +168,8 @@ class Game extends ManageLang {
}
loadInitSave(element, team, ...stat) {
let width = 200;
let height = 30;
let height = HEIGHT_BAR;
let width = height * 7;
let initStat = new InitStat(this, OFFX_MAP + WIDTH_MAP + 5, OFFY_MAP, width, height, element.valueMax);
for (let i = 0; i < element.lBar.length; i++) {
@ -212,7 +226,6 @@ class Game extends ManageLang {
i += 1;
}
)
console.log(listRobot);
return listRobot;
}
@ -309,7 +322,7 @@ class Game extends ManageLang {
dragEnd() {
console.log("END DRAG");
this.applyTree();
this.doLine = false;
}
@ -324,13 +337,17 @@ class Game extends ManageLang {
resume() {
this.playBtn.line = 1;
this.playBtn.changeFrame(0);
this.tree.sort();
this.robotSelected.setNodes(this.tree.getNode());
//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();
/*
this.tryClick();
this.input.off('pointerdown');
this.input.on('pointerdown', () => {
this.selected = this.tree.getSelected();
this.tryClick();
});
this.input.off('drag');
this.input.off('dragstart');
this.input.off('dragend');*/
}
createButtons() {
@ -383,8 +400,6 @@ class Game extends ManageLang {
}
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 + '}';
@ -409,7 +424,7 @@ class Game extends ManageLang {
SPEED_GAME = 1;
this.speedBtn.line = 0;
}
this.gm.time.timeScale = SPEED_GAME;
this.speedBtn.changeFrame(1);
}

@ -26,7 +26,6 @@ class GamingBoard extends Phaser.Scene {
update(time, delta) {
if (!this.end && !this.paused) {
super.update(time, delta);
this.listTeam.forEach(team => {
if (!team.actualise(this.getEnemyRobotTeam(team))) {
this.listTeam.splice(this.listTeam.indexOf(team), 1);
@ -88,6 +87,7 @@ class GamingBoard extends Phaser.Scene {
pause() {
this.sound.pauseAll();
this.paused = true;
this.time.timeScale = 0;
}
resume() {
@ -95,6 +95,7 @@ class GamingBoard extends Phaser.Scene {
this.setRobotVisible(true);
this.setBonusVisible(true);
this.paused = false;
this.time.timeScale = SPEED_GAME;
}
addTeam(team) {
@ -135,11 +136,10 @@ class GamingBoard extends Phaser.Scene {
upShield() {
if (!this.paused)
this.listTeam.forEach(team => team.listRobot.forEach(robot => {
robot.addShield(SHIELD_PER_SECOND);
}));
this.time.addEvent({delay: 1000 / SPEED_GAME, callback: this.upShield, callbackScope: this});
this.listTeam.forEach(team => team.listRobot.forEach(robot => {
robot.addShield(SHIELD_PER_SECOND);
}));
this.time.addEvent({delay: 1000, callback: this.upShield, callbackScope: this});
}
}

@ -52,14 +52,15 @@ class Robot {
this.doEvent();
}
addEvent(eventClick, contextClick) {
addEvent(eventClick, contextClick, value) {
this.eventClick = eventClick;
this.contextClick = contextClick;
this.valueClick = value;
}
doEvent() {
if (this.eventClick !== undefined && this.contextClick !== undefined) {
this.eventClick.call(this.contextClick, this);
this.eventClick.call(this.contextClick, this, this.valueClick);
}
}
@ -141,7 +142,6 @@ class Robot {
decreaseSpeedBonus(amount) {
this.speedBonus -= amount;
console.log(this.speed);
}
advanceToTarget() {
@ -255,9 +255,9 @@ class Robot {
this.missile.setRotation(Math.atan2(this.y - this.target.y, this.x - this.target.x) - 3.14 / 2);
this.scene.sound.play('shot');
this.scene.sound.play('shot', {rate: SPEED_GAME});
let duration = this.calcDistance(this.target) * WIDTH_MAP / 1000 / SPEED_GAME;
let duration = this.calcDistance(this.target) * WIDTH_MAP / 1000;
this.scene.tweens.add({
targets: this.missile,
@ -269,7 +269,7 @@ class Robot {
});
this.scene.time.addEvent({
delay: SPEED_RELOAD / this.speedReload / SPEED_GAME,
delay: SPEED_RELOAD / this.speedReload,
callback: this.reload,
callbackScope: this
});
@ -305,7 +305,7 @@ class Robot {
onComplete: () => text.destroy()
})
this.scene.sound.play('hit');
this.scene.sound.play('hit', {rate: SPEED_GAME});
console.log('HIT');
if (diff > 0) {
@ -376,8 +376,10 @@ class Robot {
}
eraseRange() {
this.circleRange.clear();
this.circleRange = undefined;
if (this.circleRange !== undefined) {
this.circleRange.clear();
this.circleRange = undefined;
}
}
drawCircleRange() {
@ -433,4 +435,17 @@ class Robot {
json += ']}';
return json;
}
copy(robot) {
robot.lNode = this.lNode;
robot.damage = this.damage;
robot.speedReload = this.speedReload;
robot.speed = this.speed;
robot.range = this.range;
if (this.circleRange !== undefined) {
robot.drawRange();
} else {
robot.eraseRange();
}
}
}

@ -47,8 +47,10 @@ class Team {
}
addEvent(event, context) {
let value = 0;
this.listRobot.forEach(robot => {
robot.addEvent(event, context);
robot.addEvent(event, context, value);
value++;
});
}

@ -21,10 +21,22 @@ const COLOR_SELECTED = 0xEFD807;
const COLOR_MYSELF = 0x6666ff;
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;
const OFFX_MAP = WIDTH_WINDOW / 20;
const OFFY_MAP = (HEIGHT_WINDOW - WIDTH_MAP) / 2;
const CENTERX_TREE = WIDTH_WINDOW / 4 * 3;
var OFFY_MAP;
var WIDTH_MAP;
var OFFY_TREE_BEGIN;
var CENTERX_TREE;
if (WIDTH_WINDOW < HEIGHT_WINDOW) {
WIDTH_MAP = WIDTH_WINDOW * 0.8;
OFFY_MAP = WIDTH_MAP / 10;
OFFY_TREE_BEGIN = WIDTH_MAP + OFFY_MAP * 2;
CENTERX_TREE = WIDTH_WINDOW / 2;
} else {
WIDTH_MAP = HEIGHT_WINDOW * 0.8;
OFFY_MAP = (HEIGHT_WINDOW - WIDTH_MAP) / 2;
OFFY_TREE_BEGIN = HEIGHT_WINDOW / 5;
CENTERX_TREE = (WIDTH_WINDOW - (WIDTH_MAP + OFFX_MAP)) / 2 + (WIDTH_MAP + OFFX_MAP);
}
const OFFX_TREE = WIDTH_WINDOW / 10;
const OFFY_TREE = HEIGHT_WINDOW / 6;
const WIDTH_BUTTON = WIDTH_MAP / 10;
@ -32,6 +44,7 @@ const SCORE_HIT = 5;
const SCORE_KILL = 15;
const SCORE_BONUS = 4;
const HEIGHT_BAR = WIDTH_MAP / 20;
const HEIGHT_NODE = HEIGHT_WINDOW / 6;
const LIFE = 100;

@ -55,7 +55,7 @@
"name": "myself",
"speed": 3,
"speedReload": 1,
"range": 3,
"range": 1,
"damage": 5,
"lNode": [
{
@ -113,7 +113,7 @@
"name": "myself",
"speed": 3,
"speedReload": 1,
"range": 3,
"range": 1,
"damage": 5,
"lNode": [
{

@ -55,7 +55,7 @@
"name": "myself",
"speed": 3,
"speedReload": 1,
"range": 3,
"range": 1,
"damage": 5,
"lNode": [
{
@ -113,7 +113,7 @@
"name": "myself",
"speed": 3,
"speedReload": 1,
"range": 3,
"range": 1,
"damage": 5,
"lNode": [
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Loading…
Cancel
Save