diff --git a/Code/public/js/level2.min.js b/Code/public/js/level2.min.js index 8062f5e..0ea9edf 100644 --- a/Code/public/js/level2.min.js +++ b/Code/public/js/level2.min.js @@ -1 +1 @@ -class AddAttack extends AddNode{constructor(t,e,s,i=!0){i?super(t,e,s):super(t,e,s,[!1,s.node.percentRange])}create(){console.log("ATTACK"),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","FILTRES CIBLES")),super.addButton(WIDTH_WINDOW/2,HEIGHT_WINDOW/3.2,"enemyBot",super.newCategory("target",!0,!0),!1);let t=super.newCategory("range",!0,!0);super.addButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/9),"shortRange",t,1/3),super.addButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/9),"mediumRange",t,2/3),super.addButton(WIDTH_WINDOW/2,HEIGHT_WINDOW/(16/12),"longRange",t,1)}addNode(){super.verifyCategory()&&(this.selected.addRect(new RectangleNode(this.selected.getX(),this.selected.getY()+200,this.gameR,"attack",[this.lCategory[1].getValue()])),super.cancel())}modifyNode(){super.verifyCategory()&&(this.selected.node.percentRange=this.lCategory[1].getValue(),this.selected.rect.setFrame(this.selected.node.getFrame()),super.cancel())}}class AddCondition extends AddNode{constructor(t,e,s,i=!0){i?super(t,e,s):s.node.shieldFilter?super(t,e,s,[s.node.shield,"shield"]):super(t,e,s,[s.node.shield,"range"])}create(){super.create(),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","FILTRES CIBLES"));let t=super.newCategory("target",!0,!0);super.addButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/3.2,"enemyBot",t,!1),super.addButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/3.2,"myself",t,!0);let e=super.newCategory("shield",!0,!0);super.addButton(WIDTH_WINDOW/8,HEIGHT_WINDOW/(16/9),"shortRange",e,[1/3,"range"]),super.addButton(WIDTH_WINDOW/4*1.5,HEIGHT_WINDOW/(16/9),"mediumRange",e,[2/3,"range"]),super.addButton(WIDTH_WINDOW/4,HEIGHT_WINDOW/(16/12),"longRange",e,[1,"range"]);let s=this.add.graphics();s.lineStyle(10,16777215,1),s.lineBetween(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,WIDTH_WINDOW/2,HEIGHT_WINDOW/(16/13)),super.addButton(WIDTH_WINDOW/8*5,HEIGHT_WINDOW/(16/9),"shield0",e,[0,"shield"]),super.addButton(WIDTH_WINDOW/8*7,HEIGHT_WINDOW/(16/9),"shield33",e,[1/3,"shield"]),super.addButton(WIDTH_WINDOW/8*5,HEIGHT_WINDOW/(16/12),"shield66",e,[2/3,"shield"]),super.addButton(WIDTH_WINDOW/8*7,HEIGHT_WINDOW/(16/12),"shield100",e,[1,"shield"])}addNode(){super.verifyCategory()&&("range"===this.lCategory[1].getValue()[1]?this.selected.addRect(new RectangleNode(this.selected.getX(),this.selected.getY()+200,this.gameR,"condition",[this.lCategory[0].getValue(),!1,!0,0,this.lCategory[1].getValue()[0]])):this.selected.addRect(new RectangleNode(this.selected.getX(),this.selected.getY()+200,this.gameR,"condition",[this.lCategory[0].getValue(),!0,!1,this.lCategory[1].getValue()[0],0])),super.cancel())}modifyNode(){super.verifyCategory()&&(this.selected.node.shieldFilter=!1,this.selected.node.rangeFilter=!1,"range"===this.lCategory[1].getValue()[1]?(this.selected.node.rangeFilter=!0,this.selected.node.range=this.lCategory[1].getValue()[0]):(this.selected.node.shieldFilter=!0,this.selected.node.shield=this.lCategory[1].getValue()[0]),this.selected.node.myself=this.lCategory[0].getValue(),this.selected.rect.setFrame(this.selected.node.getFrame()),super.cancel())}}class AddMove extends AddNode{constructor(t,e,s,i=!0){i?super(t,e,s):super(t,e,s,[s.node.toward,s.node.enemyBot,s.node.typeBonus])}create(){console.log("MOVE"),super.create(),super.addTitle(WIDTH_WINDOW/2,HEIGHT_WINDOW/16,selectWord("ADD NODE : MOVE","AJOUTER ACTION : DEPLACEMENT")),super.addTitle(WIDTH_WINDOW/4,HEIGHT_WINDOW/(16/3),selectWord("FLEE OR MOVE ?","RECULER OU AVANCER ?"));let t=super.newCategory("direction",!0,!0);super.addButton(WIDTH_WINDOW/6,HEIGHT_WINDOW/3.2,"fleeFrom",t,!1),super.addButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/3.2,"moveToward",t,!0),super.addTitle(WIDTH_WINDOW/4*3,HEIGHT_WINDOW/(16/3),selectWord("WHO ?","QUI ?"));let e=super.newCategory("target",!0,!0);super.addButton(WIDTH_WINDOW/6*4,HEIGHT_WINDOW/3.2,"enemyBot",e,!0);let s=super.addButton(WIDTH_WINDOW/6*5,HEIGHT_WINDOW/3.2,"bonus",e,!1),i=super.addTitle(WIDTH_WINDOW/2,HEIGHT_WINDOW/(16/7),selectWord("WHAT BONUS ? (OPTIONAL)","QUEL BONUS ? (FACULTATIF)")),h=super.newCategory("target",!0,!1),a=super.addButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/9),"bonusSpeed",h,"speed"),n=super.addButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/9),"bonusAttack",h,"attack"),o=super.addButton(WIDTH_WINDOW/2,HEIGHT_WINDOW/(16/12),"bonusShield",h,"shield");e.addEvent(()=>this.clickBonus(s,i,a,n,o)),this.clickBonus(s,i,a,n,o)}clickBonus(t,...e){t.isTinted?e.forEach(t=>t.setVisible(!0)):e.forEach(t=>t.setVisible(!1))}addNode(){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.lCategory[2].getValue()])),super.cancel())}modifyNode(){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())}}class Attack{constructor(t=1){t>1/3?t>2/3?(t=1,this.percentBonus=1):(t=2/3,this.percentBonus=1.5):(t=1/3,this.percentBonus=2),this.percentRange=t}do(t){return!(!t.haveTarget()||!t.isTargetInRange(this.percentRange))&&t.attackTarget(this.percentBonus)}getFrame(){return 3*this.percentRange-1}getOptionJson(){return this.percentRange}}class Bar extends HealthBar{constructor(t,e="",s,i,h,a,n,o=new CategoryBar,r=1,l){super(t,e,s,i,h,a,void 0!==l?l:o.valueMax,n,n,!1),this.name=e,this.scene=t,this.scene.input.on("pointerdown",this.doDrag,this);let d={font:i.toString()+"px stencil",fill:"#e2e2e2"};this.text=this.scene.add.text(this.bar.x+this.width+10,this.bar.y,this.value.toString(),d).setOrigin(0,0),this.categoryBar=o,this.setValue(0),this.categoryBar.setValueOf(this,r)}doDrag(){let t=this.scene.input;t.x>=this.bar.x-10&&t.x<=this.bar.x+this.width+10&&t.y>=this.bar.y&&t.y<=this.bar.y+this.height&&(this.scene.pauseScene(),this.clickOn())}clickOn(){this.onMove(),this.scene.input.on("pointermove",()=>this.onMove()),this.scene.input.on("pointerup",()=>this.stopClick())}stopClick(){this.scene.input.off("pointermove"),this.scene.input.off("pointerup")}onMove(){this.setValWithX(this.scene.input.x)}setValWithX(t){this.categoryBar.setValueOf(this,Math.round((t-this.bar.x)/this.width*this.valueMax))}draw(){super.draw();let t=this.value/this.valueMax*this.width-5;this.bar.fillStyle(9868950),this.bar.fillRect(t,0,10,this.height),void 0!==this.text&&this.text.setText(this.value+1)}}class BonusAttack extends Bonus{constructor(t,e,s){super(t,e,s,"attack")}useOn(t){t.setAttackBonus(this.value)}}class BonusHealth{constructor(t,e){this.value=t,this.color=e}decrease(t){this.value-=t;let e=0;return this.value<0&&(e=-this.value,this.value=0),e}}class BonusShield extends Bonus{constructor(t,e,s,i,h){super(t,e,s,"shield"),this.time=i,this.color=h}useOn(t,e){let s=new BonusHealth(this.value,this.color);t.shield.addBonus(s),e.time.addEvent({delay:this.time,callback:()=>t.shield.removeBonus(s)})}}class BonusSpeed extends Bonus{constructor(t="",e,s,i){super(t,e,s,"speed"),this.time=i}useOn(t,e){t.increaseSpeedBonus(this.value-1),e.time.addEvent({delay:this.time,callback:()=>t.decreaseSpeedBonus(this.value-1)})}}class BonusView extends Phaser.GameObjects.Image{constructor(t,e,s,i){super(t,e,s,i.texture),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,t.add.existing(this),this.bonus=i}useOn(t){this.bonus.useOn(t,this.scene),this.destroy()}}class Boot extends ManageLang{constructor(t){super("Boot",t)}create(){super.create();this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/3,"WARIA",{font:"200px stencil",fill:"#e2e2e2"}).setOrigin(.5,.5);let t=this.add.sprite(WIDTH_WINDOW/2,HEIGHT_WINDOW/3*2,"playLetter").setInteractive();t.on("pointerout",()=>t.setFrame(0)),t.on("pointerover",()=>t.setFrame(1)),t.on("pointerdown",()=>this.clickPlay(t))}clickPlay(t){console.log("Play"),this.father.scene.add("Type",new Type(this.father)),this.scene.start("Type")}}class Button extends Phaser.GameObjects.Sprite{constructor(t,e,s,i,h,a,n,o=0,r=!0){super(t,e,s,a),this.name=a,this.setInteractive().setVisible(r),this.displayHeight=h,this.displayWidth=i,this.line=o,this.on("pointerout",()=>this.changeFrame(0)),this.on("pointerover",()=>this.changeFrame(1)),this.on("pointerdown",n),this.changeFrame(0),t.add.existing(this)}changeFrame(t=0){this.setFrame(t+2*this.line)}}class Category{constructor(t="undefined",e=!0,s=!0){this.name=t,this.single=e,this.lBtn=[],this.lValue=[],this.obligatory=s}getValue(){return this.single?this.lValue[0]:this.lValue}validate(){return!(0===this.lBtn.length&&this.obligatory)}addEvent(t){this.event=t}add(t,e){0!==this.lBtn.length&&this.single&&(this.lBtn[0].clearTint(),this.lValue=[],this.lBtn=[]),this.lValue.push(e),this.lBtn.push(t),t.tint=15718407,this.oneChange()}remove(t){let e=this.lBtn.indexOf(t);-1!==e&&(this.lBtn.splice(e,1),this.lValue.splice(e,1)),t.clearTint(),this.oneChange()}oneChange(){void 0!==this.event&&this.event()}}class CategoryBar{constructor(t=VALUE_MAX_BAR,e=1){this.startValue=e,this.valueMax=t,this.point=this.valueMax}addPoint(t){if(this.point+=t,this.point<0){let t=this.point;return this.point=0,t}return this.point>this.valueMax&&(this.point=this.valueMax),0}setValueOf(t,e){let s=e-t.value,i=t.value;this.point>=s?t.setValue(e):t.setValue(t.value+this.point),this.addPoint(i-t.value),this.draw()}addText(t,e,s,i,h){this.text=e;let a={font:h.toString()+"px stencil",fill:"#e2e2e2"};this.textScene=t.add.text(s,i,this.text,a).setOrigin(0,0),this.draw()}setTextPos(t,e){this.textScene.setX(t),this.textScene.setY(e)}setText(t){this.text=t,this.draw()}draw(){this.textScene.setText(this.text+this.point)}}class Condition{constructor(t,e=!1,s=!1,i,h){this.shieldFilter=e,this.rangeFilter=s,this.shield=i,this.range=h,this.myself=t,this.lNode=[]}addNode(t){this.lNode.push(t)}do(t){if(this.doCondition(t))for(let e=0;es.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.on("pointerdown",()=>this.return()),s.displayHeight=HEIGHT_WINDOW/10,s.scaleX=s.scaleY,this.loadBonus()}loadBonus(){this.width=WIDTH_WINDOW/3-20,this.height=HEIGHT_WINDOW/4;let t=0;this.createList(lShieldBonus,t,!0),t=WIDTH_WINDOW/3,this.createList(lSpeedBonus,t,!1),t=WIDTH_WINDOW/1.5,this.createList(lAttackBonus,t,!1)}createList(t,e,s=!0){let i=50;this.createCategoryBonus(e,i,this.width,this.height*t.length),t.forEach(t=>{let h="";void 0!==t.time&&(h=" - "+selectWord("TIME","TEMPS")+" : "+t.time/1e3);let a="";if(void 0!==t.value){let e="x";s&&(e="+"),a="BONUS : "+e+t.value}this.createBonusDescription(e,i,this.width,this.height,t.texture,t.name,a+h),i+=this.height})}createCategoryBonus(t,e,s,i){t+=10,e+=10,this.add.rectangle(t,e,s,i,8816262).setOrigin(0,0)}createBonusDescription(t,e,s,i,h,a,n){t+=20,e+=20,s-=20,i-=20,this.add.rectangle(t,e,s,i,16777215).setOrigin(0,0);let o=this.add.image(t+5,e+5,h).setOrigin(0,0);o.displayHeight=100,o.scaleX=o.scaleY;let r={font:o.displayHeight/2-a.length+"px stencil",fill:"#000000"};this.add.text(t+o.displayWidth+10,e+5+o.displayHeight/2,a.toString(),r).setOrigin(0,.5),r.font=i/6+"px stencil",this.add.text(t+5,e+o.displayHeight+(i-o.displayHeight)/2,n.toString(),r).setOrigin(0,.5)}return(){this.father.scene.start("Game"),this.father.scene.remove("Description")}}function selectWord(t,e){switch(LANG){case"fr":return e;default:return t}}function newGame(t,e,s=new Game(t,e)){-1!==t.scene.getIndex("Game")&&t.scene.remove("Game"),t.scene.add("Game",s)}function chooseTarget(t,e){let s=2*WIDTH_MAP,i=[];return e.forEach(function(e){if(e!==t){let h=Math.hypot(e.x-t.x,e.y-t.y);s>=h&&(s>h&&(s=h,i=[]),i.push(e))}}),i.length>1?i[Math.floor(Math.random()*(i.length+1))]:i[0]}function toJson(t,e,s=!1){let i;switch(typeof e){case"string":i='"'+t.toString()+'":"'+e+'"';break;default:i='"'+t.toString()+'":'+e}return s||(i+=","),i}function endLineJson(t){return t.length>0&&","===t[t.length-1]&&(t=t.substr(0,t.length-1)),t}class Game extends ManageLang{constructor(t,e="level1"){super("Game",t),super.addOtherScenes("GamingBoard"),SPEED_GAME=1,this.level=e,this.listPositionRobotInit=[]}preload(){let t,e={font:"100px stencil",fill:"#e2e2e2"};this.load.on("start",()=>{(t=this.add.text(.5*WIDTH_WINDOW,.5*HEIGHT_WINDOW,selectWord("LEVEL LOADING ...","CHARGEMENT DU NIVEAU ..."),e).setOrigin(.5,.5)).alpha=.5}),this.load.on("complete",()=>{t.destroy()}),this.cache.json.exists("level")&&this.cache.json.remove("level"),this.load.json("level","public/json/"+this.level+".json"),this.createGamingBoard()}create(){super.create();let t=this.cache.json.get("level");if(void 0!==t){if(void 0!==this.tree&&void 0!==this.initStat){let e=this.tree.getJson(!0);t.tree=JSON.parse(e);let s=this.initStat.getJson(!0);t.initStat=JSON.parse(s)}this.loadSave(t.tree,t.initStat,t.robots,t.lBonus,t.robotRandomPosition),this.gm.setEnemyRobotVisible(t.enemyVisible),this.gm.setBonusVisible(t.bonusVisible),this.doLine=!1,this.createButtons(),this.input.keyboard.on("keydown-DELETE",()=>{this.clickBin()}),this.input.keyboard.on("keydown-E",()=>{this.clickPencil()}),this.input.keyboard.on("keydown-ENTER",()=>{this.clickPlus()}),this.scene.setVisible(!0,"GamingBoard")}else console.log("ERROR : LEVEL UNDEFINED")}update(t,e){super.update(t,e),this.doLine&&this.tree.updateLine()}createGamingBoard(){this.gm=new GamingBoard(this),-1!==this.father.scene.getIndex("GamingBoard")&&this.father.scene.remove("GamingBoard"),this.father.scene.add("GamingBoard",this.gm),this.scene.launch("GamingBoard"),this.scene.pause("GamingBoard")}loadSave(t,e,s,i,h){this.loadBonus(i),this.loadRobot(s,h),this.initStat=this.loadInitSave(e),this.tree=this.loadTree(t)}loadTree(t,e=CENTERX_TREE,s=OFFY_TREE/2){let i;if(void 0!==t.x&&void 0!==t.y)i=new RectangleNode(t.x,t.y,this,t.type,t.option),void 0!==t.lRect&&t.lRect.length>0&&t.lRect.forEach(t=>i.addRect(this.loadTree(t)));else if(i=new RectangleNode(e,s,this,t.type,t.option),void 0!==t.lRect&&t.lRect.length>0){let h=t.lRect.length,a=e-OFFX_TREE/2*(h-1),n=s+OFFY_TREE;t.lRect.forEach(t=>{i.addRect(this.loadTree(t,a,n)),a+=OFFX_TREE})}return i}loadInitSave(t){let e=new InitStat(this,OFFX_MAP+WIDTH_MAP+5,OFFY_MAP,200,30,10);for(let s=0;s{let i=[];t.lNode.forEach(t=>i.push(this.loadNode(t))),e&&(void 0===this.listPositionRobotInit[s]?(t.x=Math.random()*(1-t.width/2-t.width/2)+t.width/2,t.y=Math.random()*(1-t.height/2-t.height/2)+t.height/2,this.listPositionRobotInit[s]=new Position(t.x,t.y)):(t.x=this.listPositionRobotInit[s].x,t.y=this.listPositionRobotInit[s].y)),this.gm.addRobot(new Robot(WIDTH_MAP*t.height,WIDTH_MAP*t.width,WIDTH_MAP*t.x,WIDTH_MAP*t.y,this.gm,t.name,t.speed,t.speedReload,t.range,t.damage,i)),s+=1})}loadNode(t){let e;switch(t.name){case"condition":e=new Condition(t.option[0],t.option[1],t.option[2],t.option[3],t.option[4]);break;case"move":e=new Move(t.option[0],t.option[1]);break;case"attack":e=new Attack(t.option[0]);break;default:return}return void 0!==t.lNode&&t.lNode.forEach(t=>e.addNode(this.loadNode(t))),e}loadBonus(t=[]){t.forEach(t=>{this.gm.addBonus(this.loadB(t))})}loadB(t){let e;switch(t.style){case"speed":e=lSpeedBonus[t.number];break;case"attack":e=lAttackBonus[t.number];break;case"shield":e=lShieldBonus[t.number];break;default:return null}return new BonusView(this.gm,t.x*WIDTH_MAP,t.y*WIDTH_MAP,e)}finish(){let t;console.log("FINISH"),t=this.gm.winner()?new Winner(this.father,this):new Looser(this.father,this),this.father.scene.add("Finish",t),this.scene.pause("Game"),this.scene.launch("Finish")}clickNode(){this.tryClick(),this.selected=this.tree.getSelected(),void 0!==this.selected&&(this.selected!==this.tree&&(this.pencilBtn.setVisible(!0),this.binBtn.setVisible(!0)),this.selected.canAddNode&&this.plusBtn.setVisible(!0))}doDrag(t,e,s,i){e.setX(s),e.setY(i)}dragStart(){console.log("START DRAG"),this.doLine=!0,this.pauseScene()}dragEnd(){console.log("END DRAG"),this.doLine=!1}pauseScene(){this.playBtn.line=0,this.playBtn.changeFrame(0),this.gm.pause()}resume(){this.playBtn.line=1,this.playBtn.changeFrame(0),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()}createButtons(){let t=WIDTH_MAP+OFFX_MAP,e=WIDTH_MAP+OFFY_MAP+5,s=WIDTH_BUTTON,i=1.1*s,h=0;new Button(this,10,10,s,s,"back",()=>this.clickBack()).setOrigin(0,0),new Button(this,WIDTH_WINDOW-i,e,s,s,"bonusBtn",()=>this.clickBonus()).setOrigin(1,0),new Button(this,WIDTH_WINDOW,e,s,s,"save",()=>this.clickSave()).setOrigin(1,0),this.playBtn=new Button(this,t,e,s,s,"play",()=>this.clickPlay()).setOrigin(1,0),h=1===SPEED_GAME?0:1,this.speedBtn=new Button(this,t-i,e,s,s,"speed",()=>this.clickSpeed(),h).setOrigin(1,0),this.pencilBtn=new Button(this,t-2*i,e,s,s,"pencil",()=>this.clickPencil(),0,!1).setOrigin(1,0),this.binBtn=new Button(this,t-3*i,e,s,s,"bin",()=>this.clickBin(),0,!1).setOrigin(1,0),this.plusBtn=new Button(this,t-4*i,e,s,s,"plus",()=>this.clickPlus(),0,!1).setOrigin(1,0),h=this.father.sound.mute?1:0,this.muteBtn=new Button(this,t-5*i,e,s,s,"mute",()=>this.clickMute(),h).setOrigin(1,0),this.input.on("pointerdown",()=>this.clickNode()),this.input.on("drag",this.doDrag),this.input.on("dragstart",()=>this.dragStart()),this.input.on("dragend",()=>this.dragEnd())}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(){this.tree.sort((t,e)=>t.getX()-e.getX());let t='{"tree":'+this.tree.getJson()+',"initStat":'+this.initStat.getJson()+"}";console.log(t)}clickPlay(){this.scene.isPaused("GamingBoard")?this.resume():this.pauseScene(),this.playBtn.changeFrame(1)}clickSpeed(){1===SPEED_GAME?(SPEED_GAME=2,this.speedBtn.line=1):(SPEED_GAME=1,this.speedBtn.line=0),this.speedBtn.changeFrame(1)}clickPencil(){if(void 0!==this.selected){switch(console.log("PENCIL"),this.selected.type){case"attack":this.father.scene.add("AddNode",new AddAttack(this.father,this,this.selected,!1));break;case"move":this.father.scene.add("AddNode",new AddMove(this.father,this,this.selected,!1));break;case"condition":this.father.scene.add("AddNode",new AddCondition(this.father,this,this.selected,this.selected.node.myself,!1));break;default:return}this.scene.pause("Game"),this.scene.launch("AddNode")}}clickBin(){void 0!==this.selected&&(console.log("BIN"),this.tree.delete(this.selected),this.binBtn.changeFrame(0),this.tryClick())}clickPlus(){void 0!==this.selected&&this.selected.canAddNode&&(console.log("PLUS"),this.father.scene.add("PlusNode",new PlusNode(this.father,this,this.selected)),this.scene.launch("PlusNode"),this.plusBtn.changeFrame(0),this.scene.pause("Game"))}clickBack(){console.log("BACK"),this.father.scene.stop("GamingBoard"),this.father.scene.remove("GamingBoard"),this.father.scene.stop("Game"),this.father.scene.start("Type")}clickMute(){console.log("MUTE"),this.father.sound.mute?(this.father.sound.mute=!1,this.muteBtn.line=0):(this.father.sound.mute=!0,this.muteBtn.line=1),this.muteBtn.changeFrame(1)}tryClick(){this.pencilBtn.setVisible(!1),this.binBtn.setVisible(!1),this.plusBtn.setVisible(!1),void 0!=this.selected&&(this.selected.deselect(),this.selected=void 0)}}class GamingBoard extends Phaser.Scene{constructor(t){super("GamingBoard"),this.listRobot=[],listBonus=[],this.father=t,this.end=!1}preload(){this.cameras.main.setViewport(OFFX_MAP,OFFY_MAP,WIDTH_MAP,WIDTH_MAP),this.sound.add("shot"),this.sound.add("hit"),this.scene.setVisible(!1,"GamingBoard")}create(){let t=this.add.image(0,0,"background").setOrigin(0,0);t.alpha=.3,t.displayWidth=WIDTH_MAP,t.displayHeight=WIDTH_MAP,this.time.addEvent({delay:2e3,callback:this.upShield,callbackScope:this})}update(t,e){if(super.update(t,e),!this.end){this.listRobot.forEach(function(t){t.read()});for(let t=0;te.setVisible(t))}setEnemyRobotVisible(t=!0){let e=this.getMyRobot();this.listRobot.forEach(s=>{s!==e&&s.setVisible(t)})}setBonusVisible(t=!0){listBonus.forEach(e=>e.setVisible(t))}finish(){this.pause(),this.father.finish()}winner(){return void 0!==this.getMyRobot()}pause(){this.scene.pause("GamingBoard"),this.sound.pauseAll()}resume(){this.scene.resume("GamingBoard"),this.sound.resumeAll(),this.setRobotVisible(!0),this.setBonusVisible(!0)}addRobot(t){this.listRobot.push(t)}addBonus(t){listBonus.push(t)}modifyNodes(t){let e=this.getMyRobot();return void 0!==e&&(e.cleanNodes(),t.forEach(t=>e.addNode(t)),!0)}modifyValue(t,e,s,i){let h=this.getMyRobot();return void 0!==h&&(h.setSpeed(s),h.setRange(i),h.setSpeedReload(e),h.setDamage(t),!0)}getMyRobot(){for(let t=0;tt.addShield(SHIELD_PER_SECOND)),this.time.addEvent({delay:1e3/SPEED_GAME,callback:this.upShield,callbackScope:this})}}class InitStat{constructor(t,e,s,i,h,a){this.scene=t,this.posX=e,this.posY=s,this.width=i,this.height=h,this.category=new CategoryBar(a),this.lBar=[],this.lText=[],this.category.addText(this.scene,selectWord("TOKENS : ","JETONS : "),this.posX,this.posY,this.height)}addBar(t,e,s,i){this.lText.push(i),this.lBar.push(new Bar(this.scene,selectWord(i[0],i[1]),this.width,this.height,this.posX,this.posY,s,this.category,t,e)),this.posY+=1.5*this.height,this.category.setTextPos(this.posX,this.posY)}getJson(){let t="{";return t+='"lBar":[',this.lBar.forEach(e=>t+=e.getJson()+","),t=endLineJson(t)+"],",t+='"lText":[',this.lText.forEach(e=>{t+="[",e.forEach(e=>{t+='"'+e+'",'}),t=endLineJson(t),t+="],"}),t=endLineJson(t),t+="]",t+="}"}}class LoadFile extends Phaser.Scene{constructor(t,e,s){super("LoadFile"),this.father=t,this.son=s,this.nameSon=e,this.father.scene.pause(this.nameSon),this.father.scene.stop(this.nameSon),this.father.scene.remove("LoadFile")}preload(){let t=this.add.graphics(),e=this.add.graphics(),s=WIDTH_WINDOW/2-160,i=HEIGHT_WINDOW/2-25;e.fillStyle(2236962,.8),e.fillRect(s,i,320,50),this.load.on("progress",function(e){t.clear(),t.fillStyle(16777215,1),t.fillRect(s+10,i+10,300*e,30)}),this.load.on("complete",()=>{t.destroy(),e.destroy()}),this.load.audio("shot","assets/sounds/shot.ogg"),this.load.audio("hit","assets/sounds/hit.ogg"),this.loadImage("en","flags/",!0),this.loadImage("fr","flags/",!0),this.loadImage("bonusSpeed0","bonus/",!0),this.loadImage("bonusSpeed1","bonus/",!0),this.loadImage("bonusSpeed2","bonus/",!0),this.loadImage("bonusAttack0","bonus/",!0),this.loadImage("bonusAttack1","bonus/",!0),this.loadImage("bonusAttack2","bonus/",!0),this.loadImage("bonusShield0","bonus/",!0),this.loadImage("bonusShield1","bonus/",!0),this.loadImage("bonusShield2","bonus/",!0),this.loadImage("enemy","robots/"),this.loadSprite("playLetter",550,150,"buttons/"),this.loadSprite("cancel",550,150,"buttons/"),this.loadSprite("add",550,150,"buttons/"),this.loadSprite("modify",550,150,"buttons/"),this.loadSprite("home",550,150,"buttons/"),this.loadSprite("next",550,150,"buttons/"),this.loadSprite("retry",550,150,"buttons/"),this.loadSprite("duel",269,262,"buttons/"),this.loadSprite("last",269,262,"buttons/"),this.loadSprite("team",269,262,"buttons/"),this.loadSprite("flag",269,262,"buttons/"),this.loadSprite("map",269,262,"buttons/"),this.loadSprite("play",100,100,"buttons/",!0),this.loadSprite("bin",100,100,"buttons/",!0),this.loadSprite("plus",100,100,"buttons/",!0),this.loadSprite("pencil",100,100,"buttons/",!0),this.loadSprite("speed",100,100,"buttons/",!0),this.loadSprite("mute",100,100,"buttons/",!0),this.loadSprite("save",100,100,"buttons/",!0),this.loadSprite("bonusBtn",100,100,"buttons/",!0),this.loadSprite("back",200,200,"buttons/",!0),this.loadSprite("shortRange",300,150,"buttons/"),this.loadSprite("mediumRange",300,150,"buttons/"),this.loadSprite("longRange",300,150,"buttons/"),this.loadSprite("shield0",300,150,"buttons/"),this.loadSprite("shield33",300,150,"buttons/"),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/"),this.loadSprite("moveToward",300,150,"buttons/"),this.loadSprite("fleeFrom",300,150,"buttons/"),this.loadSprite("attackNode",180,190,"nodes/",!0),this.loadSprite("moveNode",180,190,"nodes/",!0),this.loadSprite("conditionNode",180,190,"nodes/",!0),this.loadImage("background","others/",!0),this.loadImage("bullet","others/",!0),this.loadImage("logoWaria","others/",!0),this.loadImage("attack","nodes/",!0),this.loadImage("move","nodes/",!0),this.loadImage("condition","nodes/",!0),this.cache.json.exists("listBonus")&&(this.cache.json.remove("listBonus"),lSpeedBonus=[],lShieldBonus=[],lAttackBonus=[]),this.load.json("listBonus","public/json/listBonus.json")}create(){this.loadBonus(),-1===this.father.scene.getIndex(this.nameSon)&&this.father.scene.add(this.nameSon,this.son),this.father.scene.start(this.nameSon)}loadBonus(){let t=this.cache.json.get("listBonus");void 0!==t&&(t.lSpeedBonus.forEach(t=>lSpeedBonus.push(new BonusSpeed(selectWord(t.name.en,t.name.fr),t.texture,t.value,t.time))),t.lShieldBonus.forEach(t=>lShieldBonus.push(new BonusShield(selectWord(t.name.en,t.name.fr),t.texture,t.value,t.time,t.color))),t.lAttackBonus.forEach(t=>lAttackBonus.push(new BonusAttack(selectWord(t.name.en,t.name.fr),t.texture,t.value))))}loadSprite(t,e,s,i="",h=!1){this.textures.exists(t)&&h||(this.deleteLoad(t),h?this.load.spritesheet(t,"assets/"+i+t+".png",{frameWidth:e,frameHeight:s}):this.load.spritesheet(t,"assets/lang/"+LANG+"/"+i+t+".png",{frameWidth:e,frameHeight:s}))}loadImage(t,e="",s=!1){this.textures.exists(t)&&s||(this.deleteLoad(t),s?this.load.image(t,"assets/"+e+t+".png"):this.load.image(t,"assets/lang/"+LANG+"/"+e+t+".png"))}deleteLoad(t){this.textures.exists(t)&&this.textures.remove(t)}}class Looser extends Finish{constructor(t,e){super(t,e)}create(){super.create(),super.addTitle(selectWord("GAME OVER","PARTIE PERDUE")),super.btnRetry(super.createButton(WIDTH_WINDOW/3,"retry")),super.btnHome(super.createButton(WIDTH_WINDOW/1.5,"home"))}}class Missile extends Phaser.GameObjects.Image{constructor(t,e,s,i){super(t,0,0,e),this.visible=!1,this.setOrigin(.5,.5),this.setScale(.02)}}class Move{constructor(t,e=!0,s){this.toward=t,this.enemyBot=e,this.typeBonus=s}do(t){if(this.enemyBot){if(t.verifyTarget())return!0===this.toward?this.moveToward(t):this.fleeFrom(t)}else{let e=chooseTarget(t,this.getListBonus());if(void 0!==e){let s;return(s=!0===this.toward?this.moveToward(t,e):this.fleeFrom(t,e))||(e.useOn(t),listBonus.splice(listBonus.indexOf(e),1),t.target=null),!0}}return!1}getListBonus(){if(void 0!==this.typeBonus){let t=[];return listBonus.forEach(e=>{e.bonus.type===this.typeBonus&&t.push(e)}),t}return listBonus}moveToward(t,e=t.target){return t.advanceTo(e)}fleeFrom(t,e=t.target){return t.fleeFrom(e)}getFrame(){let t;if(t=this.toward?0:5,!this.enemyBot)switch(this.typeBonus){case"speed":t+=2;break;case"attack":t+=3;break;case"shield":t+=4;break;default:t+=1}return t}getOptionJson(){let t=this.toward+","+this.enemyBot;return void 0!==this.typeBonus&&(t+=',"'+this.typeBonus+'"'),t}}class PlusNode extends Phaser.Scene{constructor(t,e,s){super("PlusNode"),this.father=t,this.gameR=e,this.selected=s}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),this.createNode(),this.createButton()}createNode(){let t=WIDTH_WINDOW/2,e=HEIGHT_WINDOW/2,s=WIDTH_WINDOW/3,i=HEIGHT_WINDOW/10,h={font:(i/1.5).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(t-s,e-i,selectWord("ATTACK","ATTAQUE"),h).setOrigin(.5,.5),this.add.text(t,e-i,selectWord("MOVE","DEPLACEMENT"),h).setOrigin(.5,.5),this.add.text(t+s,e-i,selectWord("CONDITION","CONDITION"),h).setOrigin(.5,.5);let a=this.add.sprite(t-s,e+i,"attack").setOrigin(.5,.5).setInteractive().on("pointerdown",()=>this.click("attack"));a.displayHeight=2*i,a.scaleX=a.scaleY,(a=this.add.sprite(t,e+i,"move").setOrigin(.5,.5).setInteractive().on("pointerdown",()=>this.click("move"))).displayHeight=2*i,a.scaleX=a.scaleY,(a=this.add.sprite(t+s,e+i,"condition").setOrigin(.5,.5).setInteractive().on("pointerdown",()=>this.click("condition"))).displayHeight=2*i,a.scaleX=a.scaleY}click(t){switch(t.toString()){case"attack":this.father.scene.add("AddNode",new AddAttack(this.father,this.gameR,this.selected));break;case"move":this.father.scene.add("AddNode",new AddMove(this.father,this.gameR,this.selected));break;case"condition":this.father.scene.add("AddNode",new AddCondition(this.father,this.gameR,this.selected))}this.scene.launch("AddNode"),this.scene.stop("PlusNode"),this.father.scene.remove("PlusNode")}createButton(){let t=WIDTH_WINDOW/2,e=HEIGHT_WINDOW-100,s=this.add.image(t,e,"cancel").setOrigin(.5,.5).setInteractive();s.on("pointerover",()=>s.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.on("pointerdown",()=>this.cancel()),s.displayHeight=HEIGHT_WINDOW/10,s.scaleX=s.scaleY}cancel(){this.scene.resume("Game"),this.scene.stop("PlusNode"),this.father.scene.remove("PlusNode")}}class Position{constructor(t,e){this.x=t,this.y=e}}class RectangleNode{constructor(t,e,s,i,h=[]){switch(i.toString().toLowerCase()){case"attack":this.rect=new Phaser.GameObjects.Image(s,t,e,"attackNode"),this.node=new Attack(h[0]),this.canAddNode=!1,this.line=s.add.graphics();break;case"move":this.rect=new Phaser.GameObjects.Image(s,t,e,"moveNode"),this.node=new Move(h[0],h[1],h[2]),this.canAddNode=!1,this.line=s.add.graphics();break;case"condition":this.rect=new Phaser.GameObjects.Image(s,t,e,"conditionNode"),this.node=new Condition(h[0],h[1],h[2],h[3],h[4]),this.canAddNode=!0,this.lRect=[],this.scene=s,this.line=s.add.graphics();break;case"waria":this.rect=new Phaser.GameObjects.Image(s,t,e,"logoWaria").setInteractive(),this.canAddNode=!0,this.lRect=[],this.scene=s,this.scene.add.existing(this.rect),this.scene.input.setDraggable(this.rect);break;default:return void console.log("Création d'un node echoué")}"waria"!==i.toString().toLowerCase()&&this.rect.setFrame(this.node.getFrame()),this.type=i,this.rect.on("pointerdown",()=>this.click()),this.rect.setOrigin(.5,0),this.rect.displayHeight=HEIGHT_NODE,this.rect.scaleX=this.rect.scaleY}getSelected(){if(this.rect.isTinted)return this;if(this.canAddNode)for(let t=0;tthis.addLine(t))}addLine(t){t.setLine(this.rect.x,this.rect.y+.9*this.rect.displayHeight)}getNode(){if(void 0===this.node){let t=[];return this.lRect.forEach(function(e){t.push(e.getNode())}),t}return this.canAddNode&&(this.node.clearNodes(),this.lRect.forEach(t=>this.node.addNode(t.getNode()))),this.node}sort(t=((t,e)=>t.getX()-e.getX())){this.canAddNode&&(this.lRect.sort(t),this.lRect.forEach(function(e){e.canAddNode&&e.sort(t)}))}destroy(){this.line.destroy(),this.rect.destroy(),void 0!==this.lRect&&this.lRect.forEach(t=>t.destroy())}delete(t){let e=this.lRect.indexOf(t);if(-1!==e)return this.lRect.splice(e,1),t.destroy(),!0;for(let e=0;ee+=s.getJson(t)+","),e=endLineJson(e)+"]"),e=endLineJson(e),e+="}"}}class Robot{constructor(t,e,s,i,h,a="enemy",n=SPEED_BEGIN,o=SPEED_RELOAD_BEGIN,r=RANGE_BEGIN,l=DAMAGE_BEGIN,d=[]){this.speedBonus=1,this.attackBonus=1,this.name=a,this.height=t,this.width=e,this.x=s,this.y=i,this.life=new HealthBar(h,selectWord("LIFE","VIE"),2*this.width,this.width/3,this.x,this.y-this.width,LIFE,32768),this.shield=new HealthBar(h,selectWord("SHIELD","BOUCLIER"),2*this.width,this.width/3,this.x,this.y-1.5*this.width,SHIELD,255),this.canAttack=!0,this.missile=new Missile(h,"bullet",this.width/5,this.width/4),h.add.existing(this.missile),this.addScene(h),this.lNode=d;let c=new Condition(!0,!0,!1,.5,0);c.addNode(new Move(!1)),this.addNode(c),this.addNode(new Attack),this.addNode(new Move(!0)),this.setSpeed(n),this.setSpeedReload(o),this.setRange(r),this.setDamage(l),this.setX(this.x),this.setY(this.y)}addScene(t){this.scene=t,"enemy"===this.name?(this.circle=this.scene.add.image(this.x,this.y,"enemy").setOrigin(.5,.5).setInteractive(),this.circle.displayWidth=this.circle.displayHeight=this.width):this.circle=this.scene.add.circle(this.x,this.y,this.width/2,COLOR_MYSELF).setInteractive(),this.circle.on("pointerdown",()=>this.click())}click(){void 0===this.circleRange?this.drawRange():this.eraseRange()}addShield(t){this.shield.increase(t)}setX(t){this.x=t,this.life.setX(this.x),this.shield.setX(this.x),this.circle.setX(this.x),this.drawCircleRange()}setY(t){this.y=t;let e=this.y-this.width,s=this.y-1.5*this.width;e<0?(s=this.y+this.width-this.shield.height,e=this.y+1.5*this.width-this.shield.height):s<0&&(s=e,e=this.y+this.width-this.shield.height),this.life.setY(e),this.shield.setY(s),this.circle.setY(this.y),this.drawCircleRange()}setTarget(t){this.target=t}updateTarget(){this.verifyTarget()&&this.setTargetPos(this.target.x,this.target.y)}setTargetPos(t,e){}setDamage(t=this.damage){this.damage=t+DAMAGE_BASE}setRange(t=this.range){this.range=t+RANGE_BASE,this.drawCircleRange()}setSpeed(t=this.speed){this.speed=t+SPEED_BASE}setSpeedReload(t=this.speedReload){this.speedReload=t+SPEED_RELOAD_BASE}setAttackBonus(t){this.attackBonus=t}increaseSpeedBonus(t){this.speedBonus+=t}decreaseSpeedBonus(t){this.speedBonus-=t,console.log(this.speed)}advanceToTarget(){return this.verifyTarget()&&this.advanceTo(this.target),!1}advanceTo(t){if(t.x!==this.x||t.y!==this.y){let e=!1,s=!1,i=this.getVelocity(t),h=i[0]+this.x,a=i[1]+this.y;return i[0]>=0&&h>=t.x||i[0]<=0&&h<=t.x?(this.setX(t.x),e=!0):this.setX(this.x+i[0]),i[1]>=0&&a>=t.y||i[1]<=0&&a<=t.y?(this.setY(t.y),s=!0):this.setY(this.y+i[1]),!(e&&s)}return!1}fleeFromTarget(){return!!this.verifyTarget()&&this.fleeFrom(this.target)}fleeFrom(t){if(this.target.x!==this.x||this.target.y!==this.y){let e=this.getVelocity(t,!0);return e[0]>=0&&this.x-this.width/2<=0?this.setX(this.width/2):e[0]<=0&&this.x+this.width/2>=WIDTH_MAP?this.setX(WIDTH_MAP-this.width/2):this.setX(this.x-e[0]),e[1]>=0&&this.y-this.width/2<=0?this.setY(this.height/2):e[1]<=0&&this.y+this.width/2>=WIDTH_MAP?this.setY(WIDTH_MAP-this.height/2):this.setY(this.y-e[1]),!0}return!1}getVelocity(t,e=!1){let s=[],i=t.x-this.x,h=t.y-this.y,a=Math.hypot(i,h);return s[0]=i/a*SPEED*this.speed*this.speedBonus*SPEED_GAME,s[1]=h/a*SPEED*this.speed*this.speedBonus*SPEED_GAME,e&&(this.x+this.width/2+s[0]>WIDTH_MAP||this.x-this.width/2-s[0]<0?(s[1]+=s[0]*Math.sign(s[1]),s[0]=0):(this.y+this.width/2-s[1]>WIDTH_MAP||this.y-this.width/2+s[1]<0)&&(s[0]+=s[1]*Math.sign(-s[0]),s[1]=0)),s}attackTarget(t=0){return!!this.verifyTarget()&&(this.canAttack&&this.attack(this.target,t),!0)}verifyTarget(){return!!this.haveTarget()&&(!!this.target.isAlive()||(this.setTarget(null),!1))}attack(t,e){this.canAttack=!1,this.missile.setPosition(this.x,this.y).setVisible(!0),this.missile.setRotation(Math.atan2(this.y-this.target.y,this.x-this.target.x)-1.57),this.scene.sound.play("shot");let s=this.calcDistance(this.target)*WIDTH_MAP/1e3/SPEED_GAME;this.scene.tweens.add({targets:this.missile,x:t.x,y:t.y,ease:"Linear",duration:s,onComplete:()=>this.finishAttack(t,e)}),this.scene.time.addEvent({delay:SPEED_RELOAD/this.speedReload/SPEED_GAME,callback:this.reload,callbackScope:this})}finishAttack(t,e){t.beAttack(this.damage*this.attackBonus*DAMAGE*e)&&this.setTarget(null),this.missile.setVisible(!1),1!==this.attackBonus&&this.setAttackBonus(1)}reload(){this.canAttack=!0}beAttack(t){let e=this.shield.decrease(t),s={font:HEIGHT_DAMAGE.toString()+"px stencil",fill:"#ffff00"},i=this.scene.add.text(this.x,this.y,t.toString(),s).setOrigin(0,1);return this.scene.tweens.add({targets:i,x:this.x+30,y:this.y-50,alpha:0,duration:DURATION_DAMAGE,ease:"Sine.easeOut",onComplete:()=>i.destroy()}),this.scene.sound.play("hit"),console.log("HIT"),e>0&&(console.log("Shield Broken"),this.life.decrease(e)),this.die()}isTargetInRange(t=1){return!!this.haveTarget()&&this.calcDistance(this.target)<=this.range*RANGE*t}calcDistance(t){return Math.hypot(t.x-this.x,t.y-this.y)}isAlive(){return this.life.value>0}die(){return 0===this.life.value&&(void 0!==this.circleRange&&this.circleRange.destroy(),this.circle.destroy(),this.shield.destroy(),this.life.destroy(),!0)}haveTarget(){return null!=this.target}read(){this.verifyTarget();for(let t=0;tt.setFrame(0)),t.on("pointerover",()=>t.setFrame(1)),t.on("pointerdown",()=>this.clickPlay(e))}clickPlay(t){newGame(this.father,t),this.scene.start("Game")}}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1,lSpeedBonus=[],lShieldBonus=[],lAttackBonus=[];const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,COLOR_RED=16711680,COLOR_ORANGE=16744192,COLOR_GREEN=32768,COLOR_RANGE=32768,COLOR_SPEED_RELOAD=8323327,COLOR_MYSELF=6711039,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOWthis.clickBonus(s,i,h,n,o)),this.clickBonus(s,i,h,n,o)}clickBonus(e,...t){e.isTinted?t.forEach(e=>e.setVisible(!0)):t.forEach(e=>e.setVisible(!1))}addNode(){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.lCategory[2].getValue()])),super.cancel())}modifyNode(){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())}}class Attack{constructor(e=1){e>1/3?e>2/3?(e=1,this.percentBonus=1):(e=2/3,this.percentBonus=1.5):(e=1/3,this.percentBonus=2),this.percentRange=e}do(e){return!(!e.haveTarget()||!e.isTargetInRange(this.percentRange))&&e.attackTarget(this.percentBonus)}getFrame(){return 3*this.percentRange-1}getOptionJson(){return this.percentRange}}class Bar extends HealthBar{constructor(e,t="",s,i,a,h,n,o=new CategoryBar,r=1,l){super(e,t,s,i,a,h,void 0!==l?l:o.valueMax,n,n,!1),this.name=t,this.scene=e,this.scene.input.on("pointerdown",this.doDrag,this);let d={font:i.toString()+"px stencil",fill:"#e2e2e2"};this.text=this.scene.add.text(this.bar.x+this.width+10,this.bar.y,this.value.toString(),d).setOrigin(0,0),this.categoryBar=o,this.setValue(0),this.categoryBar.setValueOf(this,r)}doDrag(){let e=this.scene.input;e.x>=this.bar.x-10&&e.x<=this.bar.x+this.width+10&&e.y>=this.bar.y&&e.y<=this.bar.y+this.height&&(this.scene.pauseScene(),this.clickOn())}clickOn(){this.onMove(),this.scene.input.on("pointermove",()=>this.onMove()),this.scene.input.on("pointerup",()=>this.stopClick())}stopClick(){this.scene.input.off("pointermove"),this.scene.input.off("pointerup")}onMove(){this.setValWithX(this.scene.input.x)}setValWithX(e){this.categoryBar.setValueOf(this,Math.round((e-this.bar.x)/this.width*this.valueMax))}draw(){super.draw();let e=this.value/this.valueMax*this.width-5;this.bar.fillStyle(9868950),this.bar.fillRect(e,0,10,this.height),void 0!==this.text&&this.text.setText(this.value+1)}}class BonusAttack extends Bonus{constructor(e,t,s){super(e,t,s,"attack")}useOn(e){e.setAttackBonus(this.value)}}class BonusHealth{constructor(e,t){this.value=e,this.color=t}decrease(e){this.value-=e;let t=0;return this.value<0&&(t=-this.value,this.value=0),t}}class BonusShield extends Bonus{constructor(e,t,s,i,a){super(e,t,s,"shield"),this.time=i,this.color=a}useOn(e,t){let s=new BonusHealth(this.value,this.color);e.shield.addBonus(s),t.time.addEvent({delay:this.time,callback:()=>e.shield.removeBonus(s)})}}class BonusSpeed extends Bonus{constructor(e="",t,s,i){super(e,t,s,"speed"),this.time=i}useOn(e,t){e.increaseSpeedBonus(this.value-1),t.time.addEvent({delay:this.time,callback:()=>e.decreaseSpeedBonus(this.value-1)})}}class BonusView extends Phaser.GameObjects.Image{constructor(e,t,s,i){super(e,t,s,i.texture),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,e.add.existing(this),this.bonus=i}useOn(e){this.bonus.useOn(e,this.scene),this.destroy()}}class Boot extends ManageLang{constructor(e){super("Boot",e)}create(){super.create();this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/3,"WARIA",{font:"200px stencil",fill:"#e2e2e2"}).setOrigin(.5,.5);let e=this.add.sprite(WIDTH_WINDOW/2,HEIGHT_WINDOW/3*2,"playLetter").setInteractive();e.on("pointerout",()=>e.setFrame(0)),e.on("pointerover",()=>e.setFrame(1)),e.on("pointerdown",()=>this.clickPlay(e))}clickPlay(e){console.log("Play"),this.father.scene.add("Type",new Type(this.father)),this.scene.start("Type")}}class Button extends Phaser.GameObjects.Sprite{constructor(e,t,s,i,a,h,n,o=0,r=!0){super(e,t,s,h),this.name=h,this.setInteractive().setVisible(r),this.displayHeight=a,this.displayWidth=i,this.line=o,this.on("pointerout",()=>this.changeFrame(0)),this.on("pointerover",()=>this.changeFrame(1)),this.on("pointerdown",n),this.changeFrame(0),e.add.existing(this)}changeFrame(e=0){this.setFrame(e+2*this.line)}}class Category{constructor(e="undefined",t=!0,s=!0){this.name=e,this.single=t,this.lBtn=[],this.lValue=[],this.obligatory=s}getValue(){return this.single?this.lValue[0]:this.lValue}validate(){return!(0===this.lBtn.length&&this.obligatory)}addEvent(e){this.event=e}add(e,t){0!==this.lBtn.length&&this.single&&(this.lBtn[0].clearTint(),this.lValue=[],this.lBtn=[]),this.lValue.push(t),this.lBtn.push(e),e.tint=15718407,this.oneChange()}remove(e){let t=this.lBtn.indexOf(e);-1!==t&&(this.lBtn.splice(t,1),this.lValue.splice(t,1)),e.clearTint(),this.oneChange()}oneChange(){void 0!==this.event&&this.event()}}class CategoryBar{constructor(e=VALUE_MAX_BAR,t=1){this.startValue=t,this.valueMax=e,this.point=this.valueMax}addPoint(e){if(this.point+=e,this.point<0){let e=this.point;return this.point=0,e}return this.point>this.valueMax&&(this.point=this.valueMax),0}setValueOf(e,t){let s=t-e.value,i=e.value;this.point>=s?e.setValue(t):e.setValue(e.value+this.point),this.addPoint(i-e.value),this.draw()}addText(e,t,s,i,a){this.text=t;let h={font:a.toString()+"px stencil",fill:"#e2e2e2"};this.textScene=e.add.text(s,i,this.text,h).setOrigin(0,0),this.draw()}setTextPos(e,t){this.textScene.setX(e),this.textScene.setY(t)}setText(e){this.text=e,this.draw()}draw(){this.textScene.setText(this.text+this.point)}}class Condition{constructor(e,t=!1,s=!1,i,a){this.shieldFilter=t,this.rangeFilter=s,this.shield=i,this.range=a,this.myself=e,this.lNode=[]}addNode(e){this.lNode.push(e)}do(e){if(this.doCondition(e))for(let t=0;ts.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.on("pointerdown",()=>this.return()),s.displayHeight=HEIGHT_WINDOW/10,s.scaleX=s.scaleY,this.loadBonus()}loadBonus(){this.width=WIDTH_WINDOW/3-20,this.height=HEIGHT_WINDOW/4;let e=0;this.createList(lShieldBonus,e,!0),e=WIDTH_WINDOW/3,this.createList(lSpeedBonus,e,!1),e=WIDTH_WINDOW/1.5,this.createList(lAttackBonus,e,!1)}createList(e,t,s=!0){let i=50;this.createCategoryBonus(t,i,this.width,this.height*e.length),e.forEach(e=>{let a="";void 0!==e.time&&(a=" - "+selectWord("TIME","TEMPS")+" : "+e.time/1e3);let h="";if(void 0!==e.value){let t="x";s&&(t="+"),h="BONUS : "+t+e.value}this.createBonusDescription(t,i,this.width,this.height,e.texture,e.name,h+a),i+=this.height})}createCategoryBonus(e,t,s,i){e+=10,t+=10,this.add.rectangle(e,t,s,i,8816262).setOrigin(0,0)}createBonusDescription(e,t,s,i,a,h,n){e+=20,t+=20,s-=20,i-=20,this.add.rectangle(e,t,s,i,16777215).setOrigin(0,0);let o=this.add.image(e+5,t+5,a).setOrigin(0,0);o.displayHeight=100,o.scaleX=o.scaleY;let r={font:o.displayHeight/2-h.length+"px stencil",fill:"#000000"};this.add.text(e+o.displayWidth+10,t+5+o.displayHeight/2,h.toString(),r).setOrigin(0,.5),r.font=i/6+"px stencil",this.add.text(e+5,t+o.displayHeight+(i-o.displayHeight)/2,n.toString(),r).setOrigin(0,.5)}return(){this.father.scene.start("Game"),this.father.scene.remove("Description")}}function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e,t,s=new Game(e,t)){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",s)}function chooseTarget(e,t){let s=2*WIDTH_MAP,i=[];return t.forEach(function(t){if(t!==e){let a=Math.hypot(t.x-e.x,t.y-e.y);s>=a&&(s>a&&(s=a,i=[]),i.push(t))}}),i.length>1?i[Math.floor(Math.random()*(i.length+1))]:i[0]}function toJson(e,t,s=!1){let i;switch(typeof t){case"string":i='"'+e.toString()+'":"'+t+'"';break;default:i='"'+e.toString()+'":'+t}return s||(i+=","),i}function endLineJson(e){return e.length>0&&","===e[e.length-1]&&(e=e.substr(0,e.length-1)),e}class Game extends ManageLang{constructor(e,t="level1"){super("Game",e),super.addOtherScenes("GamingBoard"),SPEED_GAME=1,this.level=t,this.listPositionRobotInit=[]}preload(){let e,t={font:"100px stencil",fill:"#e2e2e2"};this.load.on("start",()=>{(e=this.add.text(.5*WIDTH_WINDOW,.5*HEIGHT_WINDOW,selectWord("LEVEL LOADING ...","CHARGEMENT DU NIVEAU ..."),t).setOrigin(.5,.5)).alpha=.5}),this.load.on("complete",()=>{e.destroy()}),this.cache.json.exists("level")&&this.cache.json.remove("level"),this.load.json("level","public/json/"+this.level+".json"),this.createGamingBoard()}create(){super.create();let e=this.cache.json.get("level");if(void 0!==e){if(void 0!==this.tree&&void 0!==this.initStat){let t=this.tree.getJson(!0);e.tree=JSON.parse(t);let s=this.initStat.getJson(!0);e.initStat=JSON.parse(s)}this.loadSave(e),this.gm.setEnemyRobotVisible(e.enemyVisible),this.gm.setBonusVisible(e.bonusVisible),this.doLine=!1,this.createButtons(),this.input.keyboard.on("keydown-DELETE",()=>{this.clickBin()}),this.input.keyboard.on("keydown-E",()=>{this.clickPencil()}),this.input.keyboard.on("keydown-ENTER",()=>{this.clickPlus()}),this.scene.setVisible(!0,"GamingBoard")}else console.log("ERROR : LEVEL UNDEFINED")}update(e,t){super.update(e,t),this.doLine&&this.tree.updateLine()}createGamingBoard(){this.gm=new GamingBoard(this),-1!==this.father.scene.getIndex("GamingBoard")&&this.father.scene.remove("GamingBoard"),this.father.scene.add("GamingBoard",this.gm),this.scene.launch("GamingBoard"),this.scene.pause("GamingBoard")}loadSave(e){this.loadBonus(e.lBonus),this.loadTeam(e),this.initStat=this.loadInitSave(e.initStat),this.tree=this.loadTree(e.tree)}loadTree(e,t=CENTERX_TREE,s=OFFY_TREE/2){let i;if(void 0!==e.x&&void 0!==e.y)i=new RectangleNode(e.x,e.y,this,e.type,e.option),void 0!==e.lRect&&e.lRect.length>0&&e.lRect.forEach(e=>i.addRect(this.loadTree(e)));else if(i=new RectangleNode(t,s,this,e.type,e.option),void 0!==e.lRect&&e.lRect.length>0){let a=e.lRect.length,h=t-OFFX_TREE/2*(a-1),n=s+OFFY_TREE;e.lRect.forEach(e=>{i.addRect(this.loadTree(e,h,n)),h+=OFFX_TREE})}return i}loadInitSave(e){let t=new InitStat(this,OFFX_MAP+WIDTH_MAP+5,OFFY_MAP,200,30,10);for(let s=0;s{t+=this.loadT(s.name,s.freeForAll,s.robots,e.robotRandomPosition,t)})}}loadT(e=MY_TEAM,t,s,i,a=0){let h=new Team(e,t);return h.listRobot=this.loadRobot(s,i,a),this.gm.addTeam(h),h.listRobot.length}loadRobot(e=[],t=!1,s=0){let i=s,a=[];return e.forEach(e=>{let s=[];e.lNode.forEach(e=>s.push(this.loadNode(e))),t&&(void 0===this.listPositionRobotInit[i]?(e.x=Math.random()*(1-e.width/2-e.width/2)+e.width/2,e.y=Math.random()*(1-e.height/2-e.height/2)+e.height/2,this.listPositionRobotInit[i]=new Position(e.x,e.y)):(e.x=this.listPositionRobotInit[i].x,e.y=this.listPositionRobotInit[i].y)),a.push(new Robot(WIDTH_MAP*e.height,WIDTH_MAP*e.width,WIDTH_MAP*e.x,WIDTH_MAP*e.y,this.gm,e.name,e.speed,e.speedReload,e.range,e.damage,s)),i+=1}),a}loadNode(e){let t;switch(e.name){case"condition":t=new Condition(e.option[0],e.option[1],e.option[2],e.option[3],e.option[4]);break;case"move":t=new Move(e.option[0],e.option[1]);break;case"attack":t=new Attack(e.option[0]);break;default:return}return void 0!==e.lNode&&e.lNode.forEach(e=>t.addNode(this.loadNode(e))),t}loadBonus(e=[]){e.forEach(e=>{this.gm.addBonus(this.loadB(e))})}loadB(e){let t;switch(e.style){case"speed":t=lSpeedBonus[e.number];break;case"attack":t=lAttackBonus[e.number];break;case"shield":t=lShieldBonus[e.number];break;default:return null}return new BonusView(this.gm,e.x*WIDTH_MAP,e.y*WIDTH_MAP,t)}finish(){let e;console.log("FINISH"),e=this.gm.winner()?new Winner(this.father,this):new Looser(this.father,this),this.father.scene.add("Finish",e),this.scene.pause("Game"),this.scene.launch("Finish")}clickNode(){this.tryClick(),this.selected=this.tree.getSelected(),void 0!==this.selected&&(this.selected!==this.tree&&(this.pencilBtn.setVisible(!0),this.binBtn.setVisible(!0)),this.selected.canAddNode&&this.plusBtn.setVisible(!0))}doDrag(e,t,s,i){t.setX(s),t.setY(i)}dragStart(){console.log("START DRAG"),this.doLine=!0,this.pauseScene()}dragEnd(){console.log("END DRAG"),this.doLine=!1}pauseScene(){this.playBtn.line=0,this.playBtn.changeFrame(0),this.gm.pause()}resume(){this.playBtn.line=1,this.playBtn.changeFrame(0),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()}createButtons(){let e=WIDTH_MAP+OFFX_MAP,t=WIDTH_MAP+OFFY_MAP+5,s=WIDTH_BUTTON,i=1.1*s,a=0;new Button(this,10,10,s,s,"back",()=>this.clickBack()).setOrigin(0,0),new Button(this,WIDTH_WINDOW-i,t,s,s,"bonusBtn",()=>this.clickBonus()).setOrigin(1,0),new Button(this,WIDTH_WINDOW,t,s,s,"save",()=>this.clickSave()).setOrigin(1,0),this.playBtn=new Button(this,e,t,s,s,"play",()=>this.clickPlay()).setOrigin(1,0),a=1===SPEED_GAME?0:1,this.speedBtn=new Button(this,e-i,t,s,s,"speed",()=>this.clickSpeed(),a).setOrigin(1,0),this.pencilBtn=new Button(this,e-2*i,t,s,s,"pencil",()=>this.clickPencil(),0,!1).setOrigin(1,0),this.binBtn=new Button(this,e-3*i,t,s,s,"bin",()=>this.clickBin(),0,!1).setOrigin(1,0),this.plusBtn=new Button(this,e-4*i,t,s,s,"plus",()=>this.clickPlus(),0,!1).setOrigin(1,0),a=this.father.sound.mute?1:0,this.muteBtn=new Button(this,e-5*i,t,s,s,"mute",()=>this.clickMute(),a).setOrigin(1,0),this.input.on("pointerdown",()=>this.clickNode()),this.input.on("drag",this.doDrag),this.input.on("dragstart",()=>this.dragStart()),this.input.on("dragend",()=>this.dragEnd())}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(){this.tree.sort((e,t)=>e.getX()-t.getX());let e='{"tree":'+this.tree.getJson()+',"initStat":'+this.initStat.getJson()+"}";console.log(e)}clickPlay(){this.scene.isPaused("GamingBoard")?this.resume():this.pauseScene(),this.playBtn.changeFrame(1)}clickSpeed(){1===SPEED_GAME?(SPEED_GAME=2,this.speedBtn.line=1):(SPEED_GAME=1,this.speedBtn.line=0),this.speedBtn.changeFrame(1)}clickPencil(){if(void 0!==this.selected){switch(console.log("PENCIL"),this.selected.type){case"attack":this.father.scene.add("AddNode",new AddAttack(this.father,this,this.selected,!1));break;case"move":this.father.scene.add("AddNode",new AddMove(this.father,this,this.selected,!1));break;case"condition":this.father.scene.add("AddNode",new AddCondition(this.father,this,this.selected,!1));break;default:return}this.scene.pause("Game"),this.scene.launch("AddNode")}}clickBin(){void 0!==this.selected&&(console.log("BIN"),this.tree.delete(this.selected),this.binBtn.changeFrame(0),this.tryClick())}clickPlus(){void 0!==this.selected&&this.selected.canAddNode&&(console.log("PLUS"),this.father.scene.add("PlusNode",new PlusNode(this.father,this,this.selected)),this.scene.launch("PlusNode"),this.plusBtn.changeFrame(0),this.scene.pause("Game"))}clickBack(){console.log("BACK"),this.father.scene.stop("GamingBoard"),this.father.scene.remove("GamingBoard"),this.father.scene.stop("Game"),this.father.scene.start("Type")}clickMute(){console.log("MUTE"),this.father.sound.mute?(this.father.sound.mute=!1,this.muteBtn.line=0):(this.father.sound.mute=!0,this.muteBtn.line=1),this.muteBtn.changeFrame(1)}tryClick(){this.pencilBtn.setVisible(!1),this.binBtn.setVisible(!1),this.plusBtn.setVisible(!1),void 0!=this.selected&&(this.selected.deselect(),this.selected=void 0)}}class GamingBoard extends Phaser.Scene{constructor(e){super("GamingBoard"),this.listTeam=[],listBonus=[],this.father=e,this.end=!1}preload(){this.cameras.main.setViewport(OFFX_MAP,OFFY_MAP,WIDTH_MAP,WIDTH_MAP),this.sound.add("shot"),this.sound.add("hit"),this.scene.setVisible(!1,"GamingBoard")}create(){let e=this.add.image(0,0,"background").setOrigin(0,0);e.alpha=.3,e.displayWidth=WIDTH_MAP,e.displayHeight=WIDTH_MAP,this.time.addEvent({delay:2e3,callback:this.upShield,callbackScope:this})}update(e,t){super.update(e,t),this.end||(this.listTeam.forEach(e=>e.readAll()),this.listTeam.forEach(e=>{e.actualise(this.getEnemyRobotTeam(e))||this.listTeam.splice(this.listTeam.indexOf(e,1))}),void 0===this.getMyTeam()&&(this.end=!0,this.finish()))}getEnemyRobotTeam(e){let t=[];return this.listTeam.forEach(s=>{(e.freeForAll||s!==e)&&(t=t.concat(s.getRobots()))}),t}setRobotVisible(e=!0){this.listTeam.forEach(t=>t.setRobotVisible(e))}setEnemyRobotVisible(e=!0){let t=this.getMyTeam();this.listTeam.forEach(s=>{t!==s&&s.setRobotVisible(e)})}setBonusVisible(e=!0){listBonus.forEach(t=>t.setVisible(e))}finish(){this.pause(),this.father.finish()}winner(){return void 0!==this.getMyTeam()}pause(){this.scene.pause("GamingBoard"),this.sound.pauseAll()}resume(){this.scene.resume("GamingBoard"),this.sound.resumeAll(),this.setRobotVisible(!0),this.setBonusVisible(!0)}addTeam(e){this.listTeam.push(e)}addBonus(e){listBonus.push(e)}modifyNodes(e){let t=this.getMyTeam();return void 0!==t&&(t.modifyNodes(e),!0)}modifyValue(e,t,s,i){let a=this.getMyTeam();return void 0!==a&&(a.modifyValue(e,t,s,i),!0)}getMyTeam(){for(let e=0;ee.listRobot.forEach(e=>{e.addShield(SHIELD_PER_SECOND)})),this.time.addEvent({delay:1e3/SPEED_GAME,callback:this.upShield,callbackScope:this})}}class InitStat{constructor(e,t,s,i,a,h){this.scene=e,this.posX=t,this.posY=s,this.width=i,this.height=a,this.category=new CategoryBar(h),this.lBar=[],this.lText=[],this.category.addText(this.scene,selectWord("TOKENS : ","JETONS : "),this.posX,this.posY,this.height)}addBar(e,t,s,i){this.lText.push(i),this.lBar.push(new Bar(this.scene,selectWord(i[0],i[1]),this.width,this.height,this.posX,this.posY,s,this.category,e,t)),this.posY+=1.5*this.height,this.category.setTextPos(this.posX,this.posY)}getJson(){let e="{";return e+='"lBar":[',this.lBar.forEach(t=>e+=t.getJson()+","),e=endLineJson(e)+"],",e+='"lText":[',this.lText.forEach(t=>{e+="[",t.forEach(t=>{e+='"'+t+'",'}),e=endLineJson(e),e+="],"}),e=endLineJson(e),e+="]",e+="}"}}class LoadFile extends Phaser.Scene{constructor(e,t,s){super("LoadFile"),this.father=e,this.son=s,this.nameSon=t,this.father.scene.pause(this.nameSon),this.father.scene.stop(this.nameSon),this.father.scene.remove("LoadFile")}preload(){let e=this.add.graphics(),t=this.add.graphics(),s=WIDTH_WINDOW/2-160,i=HEIGHT_WINDOW/2-25;t.fillStyle(2236962,.8),t.fillRect(s,i,320,50),this.load.on("progress",function(t){e.clear(),e.fillStyle(16777215,1),e.fillRect(s+10,i+10,300*t,30)}),this.load.on("complete",()=>{e.destroy(),t.destroy()}),this.load.audio("shot","assets/sounds/shot.ogg"),this.load.audio("hit","assets/sounds/hit.ogg"),this.loadImage("en","flags/",!0),this.loadImage("fr","flags/",!0),this.loadImage("bonusSpeed0","bonus/",!0),this.loadImage("bonusSpeed1","bonus/",!0),this.loadImage("bonusSpeed2","bonus/",!0),this.loadImage("bonusAttack0","bonus/",!0),this.loadImage("bonusAttack1","bonus/",!0),this.loadImage("bonusAttack2","bonus/",!0),this.loadImage("bonusShield0","bonus/",!0),this.loadImage("bonusShield1","bonus/",!0),this.loadImage("bonusShield2","bonus/",!0),this.loadImage("enemy","robots/"),this.loadSprite("playLetter",550,150,"buttons/"),this.loadSprite("cancel",550,150,"buttons/"),this.loadSprite("add",550,150,"buttons/"),this.loadSprite("modify",550,150,"buttons/"),this.loadSprite("home",550,150,"buttons/"),this.loadSprite("next",550,150,"buttons/"),this.loadSprite("retry",550,150,"buttons/"),this.loadSprite("duel",269,262,"buttons/"),this.loadSprite("last",269,262,"buttons/"),this.loadSprite("team",269,262,"buttons/"),this.loadSprite("flag",269,262,"buttons/"),this.loadSprite("map",269,262,"buttons/"),this.loadSprite("play",100,100,"buttons/",!0),this.loadSprite("bin",100,100,"buttons/",!0),this.loadSprite("plus",100,100,"buttons/",!0),this.loadSprite("pencil",100,100,"buttons/",!0),this.loadSprite("speed",100,100,"buttons/",!0),this.loadSprite("mute",100,100,"buttons/",!0),this.loadSprite("save",100,100,"buttons/",!0),this.loadSprite("bonusBtn",100,100,"buttons/",!0),this.loadSprite("back",200,200,"buttons/",!0),this.loadSprite("shortRange",300,150,"buttons/"),this.loadSprite("mediumRange",300,150,"buttons/"),this.loadSprite("longRange",300,150,"buttons/"),this.loadSprite("shield0",300,150,"buttons/"),this.loadSprite("shield33",300,150,"buttons/"),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/"),this.loadSprite("moveToward",300,150,"buttons/"),this.loadSprite("fleeFrom",300,150,"buttons/"),this.loadSprite("attackNode",180,190,"nodes/",!0),this.loadSprite("moveNode",180,190,"nodes/",!0),this.loadSprite("conditionNode",180,190,"nodes/",!0),this.loadImage("background","others/",!0),this.loadImage("bullet","others/",!0),this.loadImage("logoWaria","others/",!0),this.loadImage("attack","nodes/",!0),this.loadImage("move","nodes/",!0),this.loadImage("condition","nodes/",!0),this.cache.json.exists("listBonus")&&(this.cache.json.remove("listBonus"),lSpeedBonus=[],lShieldBonus=[],lAttackBonus=[]),this.load.json("listBonus","public/json/listBonus.json")}create(){this.loadBonus(),-1===this.father.scene.getIndex(this.nameSon)&&this.father.scene.add(this.nameSon,this.son),this.father.scene.start(this.nameSon)}loadBonus(){let e=this.cache.json.get("listBonus");void 0!==e&&(e.lSpeedBonus.forEach(e=>lSpeedBonus.push(new BonusSpeed(selectWord(e.name.en,e.name.fr),e.texture,e.value,e.time))),e.lShieldBonus.forEach(e=>lShieldBonus.push(new BonusShield(selectWord(e.name.en,e.name.fr),e.texture,e.value,e.time,e.color))),e.lAttackBonus.forEach(e=>lAttackBonus.push(new BonusAttack(selectWord(e.name.en,e.name.fr),e.texture,e.value))))}loadSprite(e,t,s,i="",a=!1){this.textures.exists(e)&&a||(this.deleteLoad(e),a?this.load.spritesheet(e,"assets/"+i+e+".png",{frameWidth:t,frameHeight:s}):this.load.spritesheet(e,"assets/lang/"+LANG+"/"+i+e+".png",{frameWidth:t,frameHeight:s}))}loadImage(e,t="",s=!1){this.textures.exists(e)&&s||(this.deleteLoad(e),s?this.load.image(e,"assets/"+t+e+".png"):this.load.image(e,"assets/lang/"+LANG+"/"+t+e+".png"))}deleteLoad(e){this.textures.exists(e)&&this.textures.remove(e)}}class Looser extends Finish{constructor(e,t){super(e,t)}create(){super.create(),super.addTitle(selectWord("GAME OVER","PARTIE PERDUE")),super.btnRetry(super.createButton(WIDTH_WINDOW/3,"retry")),super.btnHome(super.createButton(WIDTH_WINDOW/1.5,"home"))}}class Missile extends Phaser.GameObjects.Image{constructor(e,t,s,i){super(e,0,0,t),this.visible=!1,this.setOrigin(.5,.5),this.setScale(.02)}}class Move{constructor(e,t=!0,s){this.toward=e,this.enemyBot=t,this.typeBonus=s}do(e){if(this.enemyBot){if(e.verifyTarget())return!0===this.toward?this.moveToward(e):this.fleeFrom(e)}else{let t=chooseTarget(e,this.getListBonus());if(void 0!==t){let s;return(s=!0===this.toward?this.moveToward(e,t):this.fleeFrom(e,t))||(t.useOn(e),listBonus.splice(listBonus.indexOf(t),1),e.target=null),!0}}return!1}getListBonus(){if(void 0!==this.typeBonus){let e=[];return listBonus.forEach(t=>{t.bonus.type===this.typeBonus&&e.push(t)}),e}return listBonus}moveToward(e,t=e.target){return e.advanceTo(t)}fleeFrom(e,t=e.target){return e.fleeFrom(t)}getFrame(){let e;if(e=this.toward?0:5,!this.enemyBot)switch(this.typeBonus){case"speed":e+=2;break;case"attack":e+=3;break;case"shield":e+=4;break;default:e+=1}return e}getOptionJson(){let e=this.toward+","+this.enemyBot;return void 0!==this.typeBonus&&(e+=',"'+this.typeBonus+'"'),e}}class PlusNode extends Phaser.Scene{constructor(e,t,s){super("PlusNode"),this.father=e,this.gameR=t,this.selected=s}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),this.createNode(),this.createButton()}createNode(){let e=WIDTH_WINDOW/2,t=HEIGHT_WINDOW/2,s=WIDTH_WINDOW/3,i=HEIGHT_WINDOW/10,a={font:(i/1.5).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(e-s,t-i,selectWord("ATTACK","ATTAQUE"),a).setOrigin(.5,.5),this.add.text(e,t-i,selectWord("MOVE","DEPLACEMENT"),a).setOrigin(.5,.5),this.add.text(e+s,t-i,selectWord("CONDITION","CONDITION"),a).setOrigin(.5,.5);let h=this.add.sprite(e-s,t+i,"attack").setOrigin(.5,.5).setInteractive().on("pointerdown",()=>this.click("attack"));h.displayHeight=2*i,h.scaleX=h.scaleY,(h=this.add.sprite(e,t+i,"move").setOrigin(.5,.5).setInteractive().on("pointerdown",()=>this.click("move"))).displayHeight=2*i,h.scaleX=h.scaleY,(h=this.add.sprite(e+s,t+i,"condition").setOrigin(.5,.5).setInteractive().on("pointerdown",()=>this.click("condition"))).displayHeight=2*i,h.scaleX=h.scaleY}click(e){switch(e.toString()){case"attack":this.father.scene.add("AddNode",new AddAttack(this.father,this.gameR,this.selected));break;case"move":this.father.scene.add("AddNode",new AddMove(this.father,this.gameR,this.selected));break;case"condition":this.father.scene.add("AddNode",new AddCondition(this.father,this.gameR,this.selected))}this.scene.launch("AddNode"),this.scene.stop("PlusNode"),this.father.scene.remove("PlusNode")}createButton(){let e=WIDTH_WINDOW/2,t=HEIGHT_WINDOW-100,s=this.add.image(e,t,"cancel").setOrigin(.5,.5).setInteractive();s.on("pointerover",()=>s.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.on("pointerdown",()=>this.cancel()),s.displayHeight=HEIGHT_WINDOW/10,s.scaleX=s.scaleY}cancel(){this.scene.resume("Game"),this.scene.stop("PlusNode"),this.father.scene.remove("PlusNode")}}class Position{constructor(e,t){this.x=e,this.y=t}}class RectangleNode{constructor(e,t,s,i,a=[]){switch(i.toString().toLowerCase()){case"attack":this.rect=new Phaser.GameObjects.Image(s,e,t,"attackNode"),this.node=new Attack(a[0]),this.canAddNode=!1,this.line=s.add.graphics();break;case"move":this.rect=new Phaser.GameObjects.Image(s,e,t,"moveNode"),this.node=new Move(a[0],a[1],a[2]),this.canAddNode=!1,this.line=s.add.graphics();break;case"condition":this.rect=new Phaser.GameObjects.Image(s,e,t,"conditionNode"),this.node=new Condition(a[0],a[1],a[2],a[3],a[4]),this.canAddNode=!0,this.lRect=[],this.scene=s,this.line=s.add.graphics();break;case"waria":this.rect=new Phaser.GameObjects.Image(s,e,t,"logoWaria").setInteractive(),this.canAddNode=!0,this.lRect=[],this.scene=s,this.scene.add.existing(this.rect),this.scene.input.setDraggable(this.rect);break;default:return void console.log("Création d'un node echoué")}"waria"!==i.toString().toLowerCase()&&this.rect.setFrame(this.node.getFrame()),this.type=i,this.rect.on("pointerdown",()=>this.click()),this.rect.setOrigin(.5,0),this.rect.displayHeight=HEIGHT_NODE,this.rect.scaleX=this.rect.scaleY}getSelected(){if(this.rect.isTinted)return this;if(this.canAddNode)for(let e=0;ethis.addLine(e))}addLine(e){e.setLine(this.rect.x,this.rect.y+.9*this.rect.displayHeight)}getNode(){if(void 0===this.node){let e=[];return this.lRect.forEach(function(t){e.push(t.getNode())}),e}return this.canAddNode&&(this.node.clearNodes(),this.lRect.forEach(e=>this.node.addNode(e.getNode()))),this.node}sort(e=((e,t)=>e.getX()-t.getX())){this.canAddNode&&(this.lRect.sort(e),this.lRect.forEach(function(t){t.canAddNode&&t.sort(e)}))}destroy(){this.line.destroy(),this.rect.destroy(),void 0!==this.lRect&&this.lRect.forEach(e=>e.destroy())}delete(e){let t=this.lRect.indexOf(e);if(-1!==t)return this.lRect.splice(t,1),e.destroy(),!0;for(let t=0;tt+=s.getJson(e)+","),t=endLineJson(t)+"]"),t=endLineJson(t),t+="}"}}class Robot{constructor(e,t,s,i,a,h="enemy",n=SPEED_BEGIN,o=SPEED_RELOAD_BEGIN,r=RANGE_BEGIN,l=DAMAGE_BEGIN,d=[]){this.speedBonus=1,this.attackBonus=1,this.name=h,this.height=e,this.width=t,this.x=s,this.y=i,this.life=new HealthBar(a,selectWord("LIFE","VIE"),2*this.width,this.width/3,this.x,this.y-this.width,LIFE,32768),this.shield=new HealthBar(a,selectWord("SHIELD","BOUCLIER"),2*this.width,this.width/3,this.x,this.y-1.5*this.width,SHIELD,255),this.canAttack=!0,this.missile=new Missile(a,"bullet",this.width/5,this.width/4),a.add.existing(this.missile),this.addScene(a),this.lNode=d;let c=new Condition(!0,!0,!1,.5,0);c.addNode(new Move(!1)),this.addNode(c),this.addNode(new Attack),this.addNode(new Move(!0)),this.setSpeed(n),this.setSpeedReload(o),this.setRange(r),this.setDamage(l),this.setX(this.x),this.setY(this.y)}addScene(e){this.scene=e,"enemy"===this.name?(this.circle=this.scene.add.image(this.x,this.y,"enemy").setOrigin(.5,.5).setInteractive(),this.circle.displayWidth=this.circle.displayHeight=this.width):this.circle=this.scene.add.circle(this.x,this.y,this.width/2,COLOR_MYSELF).setInteractive(),this.circle.on("pointerdown",()=>this.click())}click(){void 0===this.circleRange?this.drawRange():this.eraseRange()}addShield(e){this.shield.increase(e)}setX(e){this.x=e,this.life.setX(this.x),this.shield.setX(this.x),this.circle.setX(this.x),this.drawCircleRange()}setY(e){this.y=e;let t=this.y-this.width,s=this.y-1.5*this.width;t<0?(s=this.y+this.width-this.shield.height,t=this.y+1.5*this.width-this.shield.height):s<0&&(s=t,t=this.y+this.width-this.shield.height),this.life.setY(t),this.shield.setY(s),this.circle.setY(this.y),this.drawCircleRange()}setTarget(e){this.target=e}updateTarget(){this.verifyTarget()&&this.setTargetPos(this.target.x,this.target.y)}setTargetPos(e,t){}setDamage(e=this.damage){this.damage=e+DAMAGE_BASE}setRange(e=this.range){this.range=e+RANGE_BASE,this.drawCircleRange()}setSpeed(e=this.speed){this.speed=e+SPEED_BASE}setSpeedReload(e=this.speedReload){this.speedReload=e+SPEED_RELOAD_BASE}setAttackBonus(e){this.attackBonus=e}increaseSpeedBonus(e){this.speedBonus+=e}decreaseSpeedBonus(e){this.speedBonus-=e,console.log(this.speed)}advanceToTarget(){return this.verifyTarget()&&this.advanceTo(this.target),!1}advanceTo(e){if(e.x!==this.x||e.y!==this.y){let t=!1,s=!1,i=this.getVelocity(e),a=i[0]+this.x,h=i[1]+this.y;return i[0]>=0&&a>=e.x||i[0]<=0&&a<=e.x?(this.setX(e.x),t=!0):this.setX(this.x+i[0]),i[1]>=0&&h>=e.y||i[1]<=0&&h<=e.y?(this.setY(e.y),s=!0):this.setY(this.y+i[1]),!(t&&s)}return!1}fleeFromTarget(){return!!this.verifyTarget()&&this.fleeFrom(this.target)}fleeFrom(e){if(this.target.x!==this.x||this.target.y!==this.y){let t=this.getVelocity(e,!0);return t[0]>=0&&this.x-this.width/2<=0?this.setX(this.width/2):t[0]<=0&&this.x+this.width/2>=WIDTH_MAP?this.setX(WIDTH_MAP-this.width/2):this.setX(this.x-t[0]),t[1]>=0&&this.y-this.width/2<=0?this.setY(this.height/2):t[1]<=0&&this.y+this.width/2>=WIDTH_MAP?this.setY(WIDTH_MAP-this.height/2):this.setY(this.y-t[1]),!0}return!1}getVelocity(e,t=!1){let s=[],i=e.x-this.x,a=e.y-this.y,h=Math.hypot(i,a);return s[0]=i/h*SPEED*this.speed*this.speedBonus*SPEED_GAME,s[1]=a/h*SPEED*this.speed*this.speedBonus*SPEED_GAME,t&&(this.x+this.width/2+s[0]>WIDTH_MAP||this.x-this.width/2-s[0]<0?(s[1]+=s[0]*Math.sign(s[1]),s[0]=0):(this.y+this.width/2-s[1]>WIDTH_MAP||this.y-this.width/2+s[1]<0)&&(s[0]+=s[1]*Math.sign(-s[0]),s[1]=0)),s}attackTarget(e=0){return!!this.verifyTarget()&&(this.canAttack&&this.attack(this.target,e),!0)}verifyTarget(){return!!this.haveTarget()&&(!!this.target.isAlive()||(this.setTarget(null),!1))}attack(e,t){this.canAttack=!1,this.missile.setPosition(this.x,this.y).setVisible(!0),this.missile.setRotation(Math.atan2(this.y-this.target.y,this.x-this.target.x)-1.57),this.scene.sound.play("shot");let s=this.calcDistance(this.target)*WIDTH_MAP/1e3/SPEED_GAME;this.scene.tweens.add({targets:this.missile,x:e.x,y:e.y,ease:"Linear",duration:s,onComplete:()=>this.finishAttack(e,t)}),this.scene.time.addEvent({delay:SPEED_RELOAD/this.speedReload/SPEED_GAME,callback:this.reload,callbackScope:this})}finishAttack(e,t){e.beAttack(this.damage*this.attackBonus*DAMAGE*t)&&this.setTarget(null),this.missile.setVisible(!1),1!==this.attackBonus&&this.setAttackBonus(1)}reload(){this.canAttack=!0}beAttack(e){let t=this.shield.decrease(e),s={font:HEIGHT_DAMAGE.toString()+"px stencil",fill:"#ffff00"},i=this.scene.add.text(this.x,this.y,e.toString(),s).setOrigin(0,1);return this.scene.tweens.add({targets:i,x:this.x+30,y:this.y-50,alpha:0,duration:DURATION_DAMAGE,ease:"Sine.easeOut",onComplete:()=>i.destroy()}),this.scene.sound.play("hit"),console.log("HIT"),t>0&&(console.log("Shield Broken"),this.life.decrease(t)),this.die()}isTargetInRange(e=1){return!!this.haveTarget()&&this.calcDistance(this.target)<=this.range*RANGE*e}calcDistance(e){return Math.hypot(e.x-this.x,e.y-this.y)}isAlive(){return this.life.value>0}die(){return 0===this.life.value&&(void 0!==this.circleRange&&this.circleRange.destroy(),this.circle.destroy(),this.shield.destroy(),this.life.destroy(),!0)}haveTarget(){return null!=this.target}read(){this.verifyTarget();for(let e=0;ee.read())}getRobots(){return this.listRobot}actualise(e=[]){for(let t=0;t{a.setSpeed(s),a.setRange(i),a.setSpeedReload(t),a.setDamage(e)})}modifyNodes(e){this.listRobot.forEach(t=>{t.cleanNodes(),e.forEach(e=>t.addNode(e))})}setRobotVisible(e){this.listRobot.forEach(t=>t.setVisible(e))}}class Type extends ManageLang{constructor(e){super("Type",e)}preload(){}create(){super.create();this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/4,"WARIA",{font:"200px stencil",fill:"#e2e2e2"}).setOrigin(.5,1);let e=this.add.sprite(WIDTH_WINDOW/8*3,HEIGHT_WINDOW/4*2,"duel").setInteractive();this.createbutton(e,"level1");let t=this.add.sprite(WIDTH_WINDOW/8*5,HEIGHT_WINDOW/4*2,"last").setInteractive();this.createbutton(t,"level2");let s=this.add.sprite(WIDTH_WINDOW/8*2,HEIGHT_WINDOW/4*3,"team").setInteractive();this.createbutton(s,"level3");let i=this.add.sprite(WIDTH_WINDOW/8*4,HEIGHT_WINDOW/4*3,"flag").setInteractive();this.createbutton(i,"level4");let a=this.add.sprite(WIDTH_WINDOW/8*6,HEIGHT_WINDOW/4*3,"map").setInteractive();this.createbutton(a,"level5")}createbutton(e,t){e.displayHeight=HEIGHT_WINDOW/4,e.scaleX=e.scaleY,e.on("pointerout",()=>e.setFrame(0)),e.on("pointerover",()=>e.setFrame(1)),e.on("pointerdown",()=>this.clickPlay(t))}clickPlay(e){newGame(this.father,e),this.scene.start("Game")}}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1,lSpeedBonus=[],lShieldBonus=[],lAttackBonus=[];const MYSELF="myself",MY_TEAM="myTeam",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,COLOR_RED=16711680,COLOR_ORANGE=16744192,COLOR_GREEN=32768,COLOR_RANGE=32768,COLOR_SPEED_RELOAD=8323327,COLOR_MYSELF=6711039,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOW0?this.createButtonModify():this.createButtonAdd()}addButton(t,e,s,i=new Category,h){let a=this.createButton(t,e,s);return a.on("pointerdown",()=>this.click(a,i,h)),i!==this.lastCategory&&this.option.length>0&&(this.option[0]===h||void 0!==this.option[0]&&this.option[0].length>0&&this.option[0][0]===h[0]&&this.option[0][1]===h[1])&&(this.option.splice(0,1),this.lastCategory=i,this.click(a,i,h)),a}createButton(t,e,s,i=this.heightButton,h=null){let a=this.add.image(t,e,s).setOrigin(.5,.5).setInteractive();return a.on("pointerover",()=>a.setFrame(1)),a.on("pointerout",()=>a.setFrame(0)),a.displayHeight=i,null===h?a.scaleX=a.scaleY:a.displayWidth=h,a}click(t,e,s){t.isTinted?e.remove(t):e.add(t,s)}newCategory(t,e,s){let i=new Category(t,e,s);return this.lCategory.push(i),i}addTitle(t,e,s){return this.add.text(t,e,s,this.style).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),"cancel",HEIGHT_WINDOW/9).on("pointerdown",()=>this.cancel())}createButtonAdd(){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"add",HEIGHT_WINDOW/9).on("pointerdown",()=>this.addNode())}createButtonModify(){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"modify",HEIGHT_WINDOW/9).on("pointerdown",()=>this.modifyNode())}verifyCategory(){for(let t=0;ts.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.displayHeight=HEIGHT_WINDOW/9,s.scaleX=s.scaleY,s}btnRetry(t){t.on("pointerdown",()=>this.retry())}retry(){this.close(),console.log("RETRY"),-1===this.father.scene.getIndex("Game")&&newGame(this.father),this.father.scene.start("Game")}btnHome(t){t.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.remove("Game"),this.father.scene.start("Type")}btnNext(t){t.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Finish")}}class HealthBar{constructor(t,e="",s,i,h,a,n,o,r=COLOR_RED,l=!0){this.bar=new Phaser.GameObjects.Graphics(t),this.width=Math.floor(s),this.height=Math.floor(i),this.valueMax=n,this.value=n,this.color=o,this.colorMin=r,this.bonus=[],this.draw(),t.add.existing(this.bar);let c={font:(i-=4).toString()+"px stencil",fill:"#000000"};this.nameText=t.add.text(h,a,e,c).setOrigin(0,0),this.nameText.alpha=.5,this.setX(h,l),this.setY(a)}addBonus(t){t.value>0&&this.bonus.push(t),console.log(this.bonus),this.draw()}removeBonus(t){this.bonus.splice(this.bonus.indexOf(t),1),this.draw()}setValue(t){t<0&&(t=0),t>this.valueMax&&(t=this.valueMax),t!==this.value&&(this.value=t,this.draw())}getValue(){let t=this.value;return this.bonus.forEach(e=>t+=e.value),t}setValueMax(t=this.valueMax){if(t<=0)return;let e=t-this.valueMax;this.valueMax=t,this.setValue(this.value+e)}decrease(t){let e=t;return this.bonus.forEach(s=>{(e=s.decrease(t))>0&&this.bonus.splice(this.bonus.indexOf(s),1)}),this.value-=e,e=0,this.value<0&&(e=-this.value,this.value=0),this.draw(),e}increase(t){this.value+=t,this.value>this.valueMax&&(this.value=this.valueMax),this.draw()}setX(t,e=!0){e&&(t-=this.width/2),this.bar.setX(t),this.nameText.setX(t+5)}setY(t){this.bar.setY(t),this.nameText.setY(t)}draw(){this.bar.clear(),this.bar.fillStyle(0),this.bar.fillRect(0,0,this.width,this.height),this.bar.fillStyle(16777215),this.bar.fillRect(2,2,this.width-4,this.height-4);let t=this.valueMax;this.bonus.forEach(e=>t+=e.value);let e=this.value/this.valueMax;e<1/3?this.bar.fillStyle(this.colorMin):this.bar.fillStyle(this.color);let s=(e=this.value/t)*(this.width-4);this.bar.fillRect(2,2,s,this.height-4);let i=s+2;this.bonus.forEach(e=>{let s=e.value/t;this.bar.fillStyle(e.color);let h=s*(this.width-4);this.bar.fillRect(i,2,h,this.height-4),i+=h})}destroy(){this.bar.destroy(),this.nameText.destroy()}getJson(){let t="{";return t+=toJson("value",this.value)+toJson("valueMax",this.valueMax)+toJson("color",this.color)+toJson("colorMin",this.colorMin),t=endLineJson(t),t+="}"}setVisible(t){this.bar.setVisible(t),this.nameText.setVisible(t)}}class ManageLang extends Phaser.Scene{constructor(t,e){super(t),this.name=t,this.father=e,this.otherScenes=[]}addOtherScenes(t){this.otherScenes.push(t)}create(){this.createFlags()}createFlags(){this.diffXFlag=0,this.createFlag("fr"),this.createFlag("en")}createFlag(t){let e=this.add.image(WIDTH_WINDOW-10-this.diffXFlag,10,t).setOrigin(1,0).setInteractive();e.displayHeight=40,e.scaleX=e.scaleY,this.diffXFlag=this.diffXFlag+e.displayWidth+10,e.on("pointerdown",()=>this.setLang(t))}setLang(t){t!==LANG&&(LANG=t,this.father.scene.add("LoadFile",new LoadFile(this.father,this.name)),this.father.scene.start("LoadFile"),this.otherScenes.forEach(t=>this.father.scene.stop(t)))}} \ No newline at end of file +class AddNode extends Phaser.Scene{constructor(t,e,s,...i){super("AddNode"),this.father=t,this.gameR=e,this.selected=s,this.lCategory=[];let a=HEIGHT_WINDOW/14;this.style={font:a.toString()+"px stencil",fill:"#e2e2e2"},this.heightButton=HEIGHT_WINDOW/8,this.lastCategory=null,void 0===i&&(i=[]),this.option=i}create(){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.option.length>0?this.createButtonModify():this.createButtonAdd()}addButton(t,e,s,i=new Category,a){let h=this.createButton(t,e,s);return h.on("pointerdown",()=>this.click(h,i,a)),i!==this.lastCategory&&this.option.length>0&&(this.option[0]===a||void 0!==this.option[0]&&this.option[0].length>0&&this.option[0][0]===a[0]&&this.option[0][1]===a[1])&&(this.option.splice(0,1),this.lastCategory=i,this.click(h,i,a)),h}createButton(t,e,s,i=this.heightButton,a=null){let h=this.add.image(t,e,s).setOrigin(.5,.5).setInteractive();return h.on("pointerover",()=>h.setFrame(1)),h.on("pointerout",()=>h.setFrame(0)),h.displayHeight=i,null===a?h.scaleX=h.scaleY:h.displayWidth=a,h}click(t,e,s){t.isTinted?e.remove(t):e.add(t,s)}newCategory(t,e,s){let i=new Category(t,e,s);return this.lCategory.push(i),i}addTitle(t,e,s){return this.add.text(t,e,s,this.style).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),"cancel",HEIGHT_WINDOW/9).on("pointerdown",()=>this.cancel())}createButtonAdd(){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"add",HEIGHT_WINDOW/9).on("pointerdown",()=>this.addNode())}createButtonModify(){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"modify",HEIGHT_WINDOW/9).on("pointerdown",()=>this.modifyNode())}verifyCategory(){for(let t=0;ts.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.displayHeight=HEIGHT_WINDOW/9,s.scaleX=s.scaleY,s}btnRetry(t){t.on("pointerdown",()=>this.retry())}retry(){this.close(),console.log("RETRY"),-1===this.father.scene.getIndex("Game")&&newGame(this.father),this.father.scene.start("Game")}btnHome(t){t.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.remove("Game"),this.father.scene.start("Type")}btnNext(t){t.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Finish")}}class HealthBar{constructor(t,e="",s,i,a,h,n,r,o=COLOR_RED,l=!0){this.bar=new Phaser.GameObjects.Graphics(t),this.width=Math.floor(s),this.height=Math.floor(i),this.valueMax=n,this.value=n,this.color=r,this.colorMin=o,this.bonus=[],this.draw(),t.add.existing(this.bar);let c={font:(i-=4).toString()+"px stencil",fill:"#000000"};this.nameText=t.add.text(a,h,e,c).setOrigin(0,0),this.nameText.alpha=.5,this.setX(a,l),this.setY(h)}addBonus(t){t.value>0&&this.bonus.push(t),this.draw()}removeBonus(t){this.bonus.splice(this.bonus.indexOf(t),1),this.draw()}setValue(t){t<0&&(t=0),t>this.valueMax&&(t=this.valueMax),t!==this.value&&(this.value=t,this.draw())}getValue(){let t=this.value;return this.bonus.forEach(e=>t+=e.value),t}setValueMax(t=this.valueMax){if(t<=0)return;let e=t-this.valueMax;this.valueMax=t,this.setValue(this.value+e)}decrease(t){let e=t;return this.bonus.forEach(s=>{(e=s.decrease(t))>0&&this.bonus.splice(this.bonus.indexOf(s),1)}),this.value-=e,e=0,this.value<0&&(e=-this.value,this.value=0),this.draw(),e}increase(t){this.value+=t,this.value>this.valueMax&&(this.value=this.valueMax),this.draw()}setX(t,e=!0){e&&(t-=this.width/2),this.bar.setX(t),this.nameText.setX(t+5)}setY(t){this.bar.setY(t),this.nameText.setY(t)}draw(){this.bar.clear(),this.bar.fillStyle(0),this.bar.fillRect(0,0,this.width,this.height),this.bar.fillStyle(16777215),this.bar.fillRect(2,2,this.width-4,this.height-4);let t=this.valueMax;this.bonus.forEach(e=>t+=e.value);let e=this.value/this.valueMax;e<1/3?this.bar.fillStyle(this.colorMin):this.bar.fillStyle(this.color);let s=(e=this.value/t)*(this.width-4);this.bar.fillRect(2,2,s,this.height-4);let i=s+2;this.bonus.forEach(e=>{let s=e.value/t;this.bar.fillStyle(e.color);let a=s*(this.width-4);this.bar.fillRect(i,2,a,this.height-4),i+=a})}destroy(){this.bar.destroy(),this.nameText.destroy()}getJson(){let t="{";return t+=toJson("value",this.value)+toJson("valueMax",this.valueMax)+toJson("color",this.color)+toJson("colorMin",this.colorMin),t=endLineJson(t),t+="}"}setVisible(t){this.bar.setVisible(t),this.nameText.setVisible(t)}}class ManageLang extends Phaser.Scene{constructor(t,e){super(t),this.name=t,this.father=e,this.otherScenes=[]}addOtherScenes(t){this.otherScenes.push(t)}create(){this.createFlags()}createFlags(){this.diffXFlag=0,this.createFlag("fr"),this.createFlag("en")}createFlag(t){let e=this.add.image(WIDTH_WINDOW-10-this.diffXFlag,10,t).setOrigin(1,0).setInteractive();e.displayHeight=40,e.scaleX=e.scaleY,this.diffXFlag=this.diffXFlag+e.displayWidth+10,e.on("pointerdown",()=>this.setLang(t))}setLang(t){t!==LANG&&(LANG=t,this.father.scene.add("LoadFile",new LoadFile(this.father,this.name)),this.father.scene.start("LoadFile"),this.otherScenes.forEach(t=>this.father.scene.stop(t)))}} \ No newline at end of file diff --git a/Code/public/json/level1.json b/Code/public/json/level1.json index dfbe87e..3f9caa1 100644 --- a/Code/public/json/level1.json +++ b/Code/public/json/level1.json @@ -1 +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"]]},"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":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":"shield","number":0,"x":0.5,"y":0.5}]} \ No newline at end of file +{"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":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]}]}]},{"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.5,"y":0.5}]} \ No newline at end of file diff --git a/Code/public/json/level2.json b/Code/public/json/level2.json index b0d19b1..99498e3 100644 --- a/Code/public/json/level2.json +++ b/Code/public/json/level2.json @@ -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,"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}]} \ No newline at end of file +{"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":[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":[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":[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":[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":[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":[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}]} \ No newline at end of file diff --git a/Code/public/json/level3.json b/Code/public/json/level3.json index 3ac215a..b4252c4 100644 --- a/Code/public/json/level3.json +++ b/Code/public/json/level3.json @@ -1 +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"]]},"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.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}]} \ No newline at end of file +{"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}]} \ No newline at end of file diff --git a/Code/public/json/level4.json b/Code/public/json/level4.json index 1faa6a8..eb9502e 100644 --- a/Code/public/json/level4.json +++ b/Code/public/json/level4.json @@ -1 +1 @@ -{"tree":{"type":"waria","lRect":[{"type":"condition","option":[false,false,true,0.3333333333333333,1],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,false]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":5,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":5,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":0,"valueMax":5,"color":255,"colorMin":255},{"value":0,"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":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.3,"y":0.5,"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":2,"x":0.5,"y":0.5},{"style":"speed","number":1,"x":0.6,"y":0.9}]} \ No newline at end of file +{"tree":{"type":"waria","lRect":[{"type":"condition","option":[false,false,true,0.3333333333333333,1],"lRect":[{"type":"move","option":[false,true]},{"type":"attack","option":[1]}]},{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,false]},{"type":"move","option":[true,true]}]},"initStat":{"lBar":[{"value":5,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":5,"valueMax":5,"color":8323327,"colorMin":8323327},{"value":0,"valueMax":5,"color":255,"colorMin":255},{"value":0,"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":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]}]}]},{"name":"enemyTeam","robots":[{"height":0.1,"width":0.1,"x":0.3,"y":0.5,"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":2,"x":0.5,"y":0.5},{"style":"speed","number":1,"x":0.6,"y":0.9}]} \ No newline at end of file diff --git a/Code/public/json/level5.json b/Code/public/json/level5.json index 28069ae..a34ad89 100644 --- a/Code/public/json/level5.json +++ b/Code/public/json/level5.json @@ -1 +1 @@ -{"tree":{"type":"waria","lRect":[{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,false]},{"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":3,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":2,"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"]]},"robots":[{"height":0.1,"width":0.1,"x":0.6,"y":0.6,"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":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":1,"x":0.5,"y":0.5}]} \ No newline at end of file +{"tree":{"type":"waria","lRect":[{"type":"attack","option":[0.3333333333333333]},{"type":"move","option":[true,false]},{"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":3,"valueMax":5,"color":16711680,"colorMin":16711680},{"value":2,"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.6,"y":0.6,"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":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]}]}]},{"name":"enemyTeam","robots":[{"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":1,"x":0.5,"y":0.5}]} \ No newline at end of file diff --git a/Code/src/js/level2/AddAttack.js b/Code/src/js/level2/AddAttack.js index ebf3aa2..78c0b85 100644 --- a/Code/src/js/level2/AddAttack.js +++ b/Code/src/js/level2/AddAttack.js @@ -1,7 +1,7 @@ class AddAttack extends AddNode { constructor(father, game, selected, add = true) { if (!add) { - super(father, game, selected, [false, selected.node.percentRange]); + super(father, game, selected, false, selected.node.percentRange); } else { super(father, game, selected); } diff --git a/Code/src/js/level2/AddCondition.js b/Code/src/js/level2/AddCondition.js index 80ed8b6..c416774 100644 --- a/Code/src/js/level2/AddCondition.js +++ b/Code/src/js/level2/AddCondition.js @@ -2,9 +2,9 @@ class AddCondition extends AddNode { constructor(father, game, selected, add = true) { if (!add) { if (selected.node.shieldFilter) { - super(father, game, selected, [selected.node.shield, 'shield']); + super(father, game, selected, selected.node.myself, [selected.node.shield, 'shield']); } else { - super(father, game, selected, [selected.node.shield, 'range']); + super(father, game, selected, selected.node.myself, [selected.node.range, 'range']); } } else { super(father, game, selected); diff --git a/Code/src/js/level2/AddMove.js b/Code/src/js/level2/AddMove.js index c2db2db..0b51f5f 100644 --- a/Code/src/js/level2/AddMove.js +++ b/Code/src/js/level2/AddMove.js @@ -1,7 +1,7 @@ class AddMove extends AddNode { constructor(father, game, selected, add = true) { if (!add) { - super(father, game, selected, [selected.node.toward, selected.node.enemyBot, selected.node.typeBonus]); + super(father, game, selected, selected.node.toward, selected.node.enemyBot, selected.node.typeBonus); } else { super(father, game, selected); } diff --git a/Code/src/js/level2/Game.js b/Code/src/js/level2/Game.js index 2ec2aa6..5aa6f07 100644 --- a/Code/src/js/level2/Game.js +++ b/Code/src/js/level2/Game.js @@ -42,7 +42,7 @@ class Game extends ManageLang { let initStat = this.initStat.getJson(true); level.initStat = JSON.parse(initStat); } - this.loadSave(level.tree, level.initStat, level.robots, level.lBonus, level.robotRandomPosition); + this.loadSave(level); this.gm.setEnemyRobotVisible(level.enemyVisible); this.gm.setBonusVisible(level.bonusVisible); @@ -81,12 +81,11 @@ class Game extends ManageLang { this.scene.pause('GamingBoard'); } - - loadSave(tree, initStat, robot, lBonus, robotRandomPosition) { - this.loadBonus(lBonus); - this.loadRobot(robot, robotRandomPosition); - this.initStat = this.loadInitSave(initStat); - this.tree = this.loadTree(tree); + loadSave(level) { + this.loadBonus(level.lBonus); + this.loadTeam(level) + this.initStat = this.loadInitSave(level.initStat); + this.tree = this.loadTree(level.tree); } loadTree(element, posX = CENTERX_TREE, posY = OFFY_TREE / 2) { @@ -123,8 +122,25 @@ class Game extends ManageLang { return initStat; } - loadRobot(element = [], randomPosition = false) { - let i = 0; + loadTeam(level) { + if (level.listTeam !== undefined) { + let init = 0; + level.listTeam.forEach(team => { + init += this.loadT(team.name, team.freeForAll, team.robots, level.robotRandomPosition, init) + }); + } + } + + loadT(name = MY_TEAM, freeForAll, robots, robotRandomPosition, init = 0) { + let t = new Team(name, freeForAll); + t.listRobot = this.loadRobot(robots, robotRandomPosition, init); + this.gm.addTeam(t); + return t.listRobot.length; + } + + loadRobot(element = [], randomPosition = false, init = 0) { + let i = init; + let listRobot = []; element.forEach(robot => { let lNode = []; robot.lNode.forEach(node => lNode.push(this.loadNode(node))); @@ -138,10 +154,11 @@ class Game extends ManageLang { robot.y = this.listPositionRobotInit[i].y; } } - this.gm.addRobot(new Robot(WIDTH_MAP * robot.height, WIDTH_MAP * robot.width, WIDTH_MAP * robot.x, WIDTH_MAP * robot.y, this.gm, robot.name, robot.speed, robot.speedReload, robot.range, robot.damage, lNode)); + listRobot.push(new Robot(WIDTH_MAP * robot.height, WIDTH_MAP * robot.width, WIDTH_MAP * robot.x, WIDTH_MAP * robot.y, this.gm, robot.name, robot.speed, robot.speedReload, robot.range, robot.damage, lNode)); i += 1; } ) + return listRobot; } loadNode(element) { @@ -340,7 +357,7 @@ class Game extends ManageLang { this.father.scene.add('AddNode', new AddMove(this.father, this, this.selected, false)); break; case 'condition': - this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, this.selected.node.myself, false)); + this.father.scene.add('AddNode', new AddCondition(this.father, this, this.selected, false)); break; default: return; diff --git a/Code/src/js/level2/GamingBoard.js b/Code/src/js/level2/GamingBoard.js index 1cd06a7..6effa7f 100644 --- a/Code/src/js/level2/GamingBoard.js +++ b/Code/src/js/level2/GamingBoard.js @@ -1,7 +1,7 @@ class GamingBoard extends Phaser.Scene { constructor(father) { super('GamingBoard'); - this.listRobot = []; + this.listTeam = []; listBonus = []; this.father = father; this.end = false; @@ -26,38 +26,43 @@ class GamingBoard extends Phaser.Scene { update(time, delta) { super.update(time, delta); if (!this.end) { - this.listRobot.forEach(function (robot) { - robot.read(); - }) - - for (let i = 0; i < this.listRobot.length; i++) { - if (!this.listRobot[i].isAlive()) { - this.listRobot.splice(i, 1); - i -= 1; - } else { - if (!this.listRobot[i].haveTarget()) { - this.listRobot[i].setTarget(chooseTarget(this.listRobot[i], this.listRobot)); - } + this.listTeam.forEach(team => team.readAll()); + this.listTeam.forEach(team => { + if (!team.actualise(this.getEnemyRobotTeam(team))) { + this.listTeam.splice(this.listTeam.indexOf(team, 1)); } - } + }); + - if (this.getMyRobot() === undefined || this.listRobot.length <= 1) { + if (this.getMyTeam() === undefined) { this.end = true; this.finish(); } } } + getEnemyRobotTeam(team) { + let list = []; + this.listTeam.forEach(element => { + if (team.freeForAll || element !== team) { + list = list.concat(element.getRobots()); + } + }) + return list; + } + setRobotVisible(boolean = true) { - this.listRobot.forEach(robot => robot.setVisible(boolean)); + this.listTeam.forEach(team => team.setRobotVisible(boolean)); } setEnemyRobotVisible(boolean = true) { - let myself = this.getMyRobot(); - this.listRobot.forEach(robot => { - if (robot !== myself) - robot.setVisible(boolean) + let myTeam = this.getMyTeam(); + this.listTeam.forEach(team => { + if (myTeam !== team) { + team.setRobotVisible(boolean); + } }); + } setBonusVisible(boolean = true) { @@ -70,7 +75,7 @@ class GamingBoard extends Phaser.Scene { } winner() { - return this.getMyRobot() !== undefined; + return this.getMyTeam() !== undefined; } pause() { @@ -85,40 +90,37 @@ class GamingBoard extends Phaser.Scene { this.setBonusVisible(true); } - addRobot(robot) { - this.listRobot.push(robot); + addTeam(team) { + this.listTeam.push(team); } + addBonus(bonus) { listBonus.push(bonus); } modifyNodes(lNodes) { - let myRobot = this.getMyRobot(); - if (myRobot !== undefined) { - myRobot.cleanNodes(); - lNodes.forEach(element => myRobot.addNode(element)); + let myTeam = this.getMyTeam(); + if (myTeam !== undefined) { + myTeam.modifyNodes(lNodes); return true; } return false; } modifyValue(damage, speedReload, speed, range) { - let myRobot = this.getMyRobot(); - if (myRobot !== undefined) { - myRobot.setSpeed(speed); - myRobot.setRange(range); - myRobot.setSpeedReload(speedReload); - myRobot.setDamage(damage); + let myTeam = this.getMyTeam(); + if (myTeam !== undefined) { + myTeam.modifyValue(damage, speedReload, speed, range); return true; } return false; } - getMyRobot() { - for (let i = 0; i < this.listRobot.length; i++) { - if (this.listRobot[i].name === MYSELF) { - return this.listRobot[i]; + getMyTeam() { + for (let i = 0; i < this.listTeam.length; i++) { + if (this.listTeam[i].name === MY_TEAM) { + return this.listTeam[i]; } } return undefined; @@ -126,7 +128,9 @@ class GamingBoard extends Phaser.Scene { upShield() { - this.listRobot.forEach(robot => robot.addShield(SHIELD_PER_SECOND)); + 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}); } diff --git a/Code/src/js/level2/Team.js b/Code/src/js/level2/Team.js new file mode 100644 index 0000000..273c8e6 --- /dev/null +++ b/Code/src/js/level2/Team.js @@ -0,0 +1,54 @@ +class Team { + constructor(name = "enemy", freeForAll = false) { + this.freeForAll = freeForAll; + this.listRobot = []; + this.name = name; + } + + addRobot(robot) { + this.listRobot.push(robot); + } + + readAll() { + this.listRobot.forEach(robot => robot.read()); + } + + getRobots() { + return this.listRobot; + } + + actualise(listEnemyRobot = []) { + for (let i = 0; i < this.listRobot.length; i++) { + if (!this.listRobot[i].isAlive()) { + this.listRobot.splice(i, 1); + i -= 1; + } else { + if (!this.listRobot[i].haveTarget()) { + this.listRobot[i].setTarget(chooseTarget(this.listRobot[i], listEnemyRobot)); + } + } + } + return this.listRobot.length !== 0; + + } + + modifyValue(damage, speedReload, speed, range) { + this.listRobot.forEach(robot => { + robot.setSpeed(speed); + robot.setRange(range); + robot.setSpeedReload(speedReload); + robot.setDamage(damage); + }); + } + + modifyNodes(lNodes) { + this.listRobot.forEach(robot => { + robot.cleanNodes(); + lNodes.forEach(node => robot.addNode(node)); + }); + } + + setRobotVisible(boolean) { + this.listRobot.forEach(robot => robot.setVisible(boolean)); + } +} \ No newline at end of file diff --git a/Code/src/js/level2/Variable.js b/Code/src/js/level2/Variable.js index 4868b24..8f56404 100644 --- a/Code/src/js/level2/Variable.js +++ b/Code/src/js/level2/Variable.js @@ -5,6 +5,7 @@ var lSpeedBonus = []; var lShieldBonus = []; var lAttackBonus = []; const MYSELF = 'myself'; +const MY_TEAM = 'myTeam'; const SHIELD_PER_SECOND = 5; const COLOR_ATTACK = 0xff0000; const COLOR_MOVE = 0x0000ff; diff --git a/Code/src/js/level3/AddNode.js b/Code/src/js/level3/AddNode.js index a3d3736..4fc5e8f 100644 --- a/Code/src/js/level3/AddNode.js +++ b/Code/src/js/level3/AddNode.js @@ -1,5 +1,5 @@ class AddNode extends Phaser.Scene { - constructor(father, game, selected, option = []) { + constructor(father, game, selected, ...option) { super('AddNode'); this.father = father; this.gameR = game; @@ -9,6 +9,9 @@ class AddNode extends Phaser.Scene { this.style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"}; this.heightButton = HEIGHT_WINDOW / 8; this.lastCategory = null; + if (option === undefined) { + option = []; + } this.option = option; } diff --git a/Code/src/js/level3/HealthBar.js b/Code/src/js/level3/HealthBar.js index 61ddbf3..b9cce01 100644 --- a/Code/src/js/level3/HealthBar.js +++ b/Code/src/js/level3/HealthBar.js @@ -27,7 +27,6 @@ class HealthBar { if (bonus.value > 0) { this.bonus.push(bonus); } - console.log(this.bonus); this.draw(); } diff --git a/Code/src/json/level1.json b/Code/src/json/level1.json index 7a8326d..afa3ba0 100644 --- a/Code/src/json/level1.json +++ b/Code/src/json/level1.json @@ -98,100 +98,68 @@ ] ] }, - "robots": [ + "listTeam": [ { - "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": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "height": 0.1, + "width": 0.1, + "x": 0.1, + "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": [ - false + true ] } ] - }, - { - "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": "myTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "height": 0.1, + "width": 0.1, + "x": 0.9, + "y": 0.9, + "name": "myself", + "speed": 3, + "speedReload": 1, + "range": 3, + "damage": 5, "lNode": [ - { - "name": "move", - "option": [ - false - ] - } - ] - }, - { - "name": "attack", - "option": [ - ] - }, - { - "name": "move", - "option": [ - true ] } ] diff --git a/Code/src/json/level2.json b/Code/src/json/level2.json index 32102bd..1548f19 100644 --- a/Code/src/json/level2.json +++ b/Code/src/json/level2.json @@ -86,293 +86,333 @@ ] ] }, - "robots": [ + "listTeam": [ { - "height": 0.1, - "width": 0.1, - "x": 0.9, - "y": 0.9, - "name": "myself", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "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.1, - "y": 0.1, - "name": "enemy", - "speed": 1, - "speedReload": 1, - "range": 5, - "damage": 5, - "lNode": [ - { - "name": "attack", - "option": [ - ] - }, + "name": "enemyTeam", + "robots": [ { - "name": "move", - "option": [ - true + "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "name": "attack", - "option": [ - ] - }, - { - "name": "move", - "option": [ - true - ] } ] } diff --git a/Code/src/json/level3.json b/Code/src/json/level3.json index fa61d6d..acaafd9 100644 --- a/Code/src/json/level3.json +++ b/Code/src/json/level3.json @@ -98,100 +98,123 @@ ] ] }, - "robots": [ + "listTeam": [ { - "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.5, - "y": 0.1, - "name": "enemy", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "myTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "height": 0.1, + "width": 0.1, + "x": 0.9, + "y": 0.9, + "name": "myself", + "speed": 3, + "speedReload": 1, + "range": 3, + "damage": 5, "lNode": [ - { - "name": "move", - "option": [ - false - ] - } ] }, { - "name": "attack", - "option": [ - ] - }, - { - "name": "move", - "option": [ - true + "height": 0.1, + "width": 0.1, + "x": 0.3, + "y": 0.5, + "name": "myself", + "speed": 3, + "speedReload": 1, + "range": 3, + "damage": 5, + "lNode": [ ] } ] }, { - "height": 0.1, - "width": 0.1, - "x": 0.1, - "y": 0.9, - "name": "enemy", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] }, { - "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 + ] + } ] } ] diff --git a/Code/src/json/level4.json b/Code/src/json/level4.json index 05f9c6f..4d09e38 100644 --- a/Code/src/json/level4.json +++ b/Code/src/json/level4.json @@ -95,101 +95,116 @@ ] ] }, - "robots": [ + "listTeam": [ { - "height": 0.1, - "width": 0.1, - "x": 0.9, - "y": 0.9, - "name": "myself", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "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.1, - "y": 0.1, - "name": "enemy", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "height": 0.1, + "width": 0.1, + "x": 0.1, + "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": [ - false + true ] } ] - }, - { - "name": "attack", - "option": [ - ] - }, - { - "name": "move", - "option": [ - true - ] } ] }, { - "height": 0.1, - "width": 0.1, - "x": 0.3, - "y": 0.5, - "name": "enemy", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "height": 0.1, + "width": 0.1, + "x": 0.3, + "y": 0.5, + "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": [ - false + true ] } ] - }, - { - "name": "attack", - "option": [ - ] - }, - { - "name": "move", - "option": [ - true - ] } ] } diff --git a/Code/src/json/level5.json b/Code/src/json/level5.json index be6b653..5b4d4bd 100644 --- a/Code/src/json/level5.json +++ b/Code/src/json/level5.json @@ -95,101 +95,116 @@ ] ] }, - "robots": [ + "listTeam": [ { - "height": 0.1, - "width": 0.1, - "x": 0.6, - "y": 0.6, - "name": "myself", - "speed": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "myTeam", + "robots": [ + { + "height": 0.1, + "width": 0.1, + "x": 0.6, + "y": 0.6, + "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": 3, - "speedReload": 1, - "range": 3, - "damage": 5, - "lNode": [ + "name": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "height": 0.1, + "width": 0.1, + "x": 0.1, + "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": [ - false + true ] } ] - }, - { - "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": "enemyTeam", + "robots": [ { - "name": "condition", - "option": [ - true, - true, - false, - 0.5, - 0 - ], + "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": [ - false + true ] } ] - }, - { - "name": "attack", - "option": [ - ] - }, - { - "name": "move", - "option": [ - true - ] } ] }