From e2f28ba535b85ffe1d9549eb9838fb6266f68c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sat, 8 Aug 2015 08:16:11 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20de=20transmuter=20dans=20le=20m?= =?UTF-8?q?enu=20permet=20l'ajout=20de=20transmuter=20sur=20le=20plateau?= =?UTF-8?q?=20(sans=20v=C3=A9rification=20conditions)=20ajout=20de=20fonct?= =?UTF-8?q?ions=20permettant=20la=20gestion=20des=20transmuteurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/Menu.java | 1 + core/src/fr/evolving/assets/AssetLoader.java | 8 ++++ .../src/fr/evolving/automata/Positiver_I.java | 20 ++++++++++ .../fr/evolving/automata/Positiver_II.java | 22 ++++++++++- .../fr/evolving/automata/Positiver_III.java | 20 ++++++++++ core/src/fr/evolving/automata/Transmuter.java | 36 ++++++++++++++++- core/src/fr/evolving/screens/GameScreen.java | 39 +++++++++++++++++-- 7 files changed, 140 insertions(+), 6 deletions(-) diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index 3c99ab7..6d74e0c 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -25,6 +25,7 @@ public class Menu extends Actor{ private float decy; private int size=32; + public Menu(int tilesizex,int tilesizey) { this.tilesizex=tilesizex; this.tilesizey=tilesizey; diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 9af1b05..a32efb5 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -150,6 +150,14 @@ public class AssetLoader { } } + public static Transmuter getTransmuter(int Id) { + for(Transmuter transmuter:allTransmuter) { + if (transmuter.isTransmuter(Id)) + return transmuter; + } + return null; + } + public static int setpref() { prefs = Gdx.app.getPreferences("WireWorld - Evolving Games"); if (prefs.contains("log")) diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index d3844a0..d0bd9aa 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -148,6 +148,26 @@ public class Positiver_I extends Transmuter { return result; } + public Vector2[] getallSize() { + HashMap newTiles= new HashMap(); + Iterator keySetIterator = this.Tiles.keySet().iterator(); + Vector2[] vector=new Vector2[2]; + vector[0]=new Vector2(); + vector[1]=new Vector2(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + float x=(float)Math.round(delta*Math.cos(alpha)); + float y=(float)Math.round(delta*Math.sin(alpha)); + vector[0].x=Math.min(vector[0].x, x); + vector[0].y=Math.min(vector[0].y, y); + vector[1].x=Math.max(vector[1].x, x); + vector[1].y=Math.max(vector[1].y, y); + } + return vector; + } + public HashMap getTiles() { HashMap newTiles= new HashMap(); Iterator keySetIterator = this.Tiles.keySet().iterator(); diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index b67373a..8eae5c1 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -144,7 +144,27 @@ public class Positiver_II extends Transmuter { for(int i=0;i newTiles= new HashMap(); + Iterator keySetIterator = this.Tiles.keySet().iterator(); + Vector2[] vector=new Vector2[2]; + vector[0]=new Vector2(); + vector[1]=new Vector2(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + float x=(float)Math.round(delta*Math.cos(alpha)); + float y=(float)Math.round(delta*Math.sin(alpha)); + vector[0].x=Math.min(vector[0].x, x); + vector[0].y=Math.min(vector[0].y, y); + vector[1].x=Math.max(vector[1].x, x); + vector[1].y=Math.max(vector[1].y, y); + } + return vector; + } public HashMap getTiles() { HashMap newTiles= new HashMap(); diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index 87ba68c..f5ac055 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -146,6 +146,26 @@ public class Positiver_III extends Transmuter { return result; } + public Vector2[] getallSize() { + HashMap newTiles= new HashMap(); + Iterator keySetIterator = this.Tiles.keySet().iterator(); + Vector2[] vector=new Vector2[2]; + vector[0]=new Vector2(); + vector[1]=new Vector2(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + float x=(float)Math.round(delta*Math.cos(alpha)); + float y=(float)Math.round(delta*Math.sin(alpha)); + vector[0].x=Math.min(vector[0].x, x); + vector[0].y=Math.min(vector[0].y, y); + vector[1].x=Math.max(vector[1].x, x); + vector[1].y=Math.max(vector[1].y, y); + } + return vector; + } + public HashMap getTiles() { HashMap newTiles= new HashMap(); Iterator keySetIterator = this.Tiles.keySet().iterator(); diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index a77787f..cca8e41 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -61,6 +61,27 @@ public abstract class Transmuter { return 0; } + public boolean isTransmuter(int Id) { + return (FindMainTile(Id)==getMainTile()); + } + + public Vector2 getPostitionMainTile(int Id) { + if (!isTransmuter(Id)) + return null; + HashMap tiles=this.getTiles(); + Iterator keySetIterator = tiles.keySet().iterator(); + int Idrec=this.getMainTile(); + if (Id==Idrec) + return new Vector2(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + Idrec++; + if (Id==Idrec) + return new Vector2().sub(key); + } + return null; + } + public HashMap getTiles() { return null; } @@ -174,13 +195,24 @@ public abstract class Transmuter { public int[] getallTiles() { return null; - } + } + + public Vector2[] getallSize() { + return null; + } public String getInformations() { HashMap tiles=this.getTiles(); Iterator keySetIterator = tiles.keySet().iterator(); String result; - result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Id:"+this.getMainTile()+" Rotation:"+this.getRotation()+"\nPrice:"+this.getPrice()+" Tech:"+this.getTechnology()+"\nResearch:"+this.getResearch()+" Size:"+this.getSize()+"\nActivable:"+this.isActivable()+" Activation:"+this.getActivationLevel()+" Visible:"+this.isShowed()+"\nUpgradable:"+((this.isUpgradable())?this.getUpgrade().getName():this.isUpgradable())+" Unlockable:"+((this.isUnlockable())?this.getUnlock().getName():this.isUnlockable())+"\nUpgrade Cycle:"+this.getUpgradeCycle()+" upgrade:"+this.isUpgradableCycle()+"\nUpgrade Temperature:"+this.getUpgradeTemp()+" upgrade:"+this.isUpgradableTemp()+"\nUpgrade Nrj:"+this.getUpgradeNrj()+" upgrade:"+this.isUpgradableNrj()+"\nUpgrade Rayon:"+this.getUpgradeRayon()+" upgrade:"+this.isUpgradableRayon()+"\nTemperature /turn:"+this.getTurnTemp()+" Rayon /turn:"+this.getTurnRayon()+" Nrj /turn:"+this.getTurnNrj()+"\nTemperature /use:"+this.getUsedTemp()+" Rayon /use:"+this.getUsedRayon()+" Nrj /use:"+this.getUsedNrj()+"\n"; + result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Id:"+this.getMainTile()+" Rotation:"+this.getRotation()+"\nPrice:"+this.getPrice()+" Tech:"+this.getTechnology()+"\nResearch:"+this.getResearch()+" Size:"+this.getSize()+"\nActivable:"+this.isActivable()+" Activation:"+this.getActivationLevel()+" Visible:"+this.isShowed()+"\nUpgradable:"+((this.isUpgradable())?this.getUpgrade().getName():this.isUpgradable())+" Unlockable:"+((this.isUnlockable())?this.getUnlock().getName():this.isUnlockable())+"\nUpgrade Cycle:"+this.getUpgradeCycle()+" upgrade:"+this.isUpgradableCycle()+"\nUpgrade Temperature:"+this.getUpgradeTemp()+" upgrade:"+this.isUpgradableTemp()+"\nUpgrade Nrj:"+this.getUpgradeNrj()+" upgrade:"+this.isUpgradableNrj()+"\nUpgrade Rayon:"+this.getUpgradeRayon()+" upgrade:"+this.isUpgradableRayon()+"\nTemperature /turn:"+this.getTurnTemp()+" Rayon /turn:"+this.getTurnRayon()+" Nrj /turn:"+this.getTurnNrj()+"\nTemperature /use:"+this.getUsedTemp()+" Rayon /use:"+this.getUsedRayon()+" Nrj /use:"+this.getUsedNrj()+"\nTiles:"; + int[] allTiles; + Vector2[] allSize; + allTiles=this.getallTiles(); + for(int i=0;i99) { + Transmuter transmuter=AssetLoader.getTransmuter(tile); + if (transmuter!=null) { + Vector2 gotomain=transmuter.getPostitionMainTile(tile); + if (gotomain!=null) { + coords2=menu.worldtoscreen((int)(coords.x+gotomain.x),(int)(coords.y+gotomain.y)); + menuactor.setPosition(coords2.x, coords2.y); + selected.setName("transmuter"); + selected_transmuter=transmuter; + Gdx.app.debug(event.getListenerActor().toString(),"transmuter deplacement vers origine:"+String.valueOf(gotomain.x)+","+String.valueOf(gotomain.y)+" coords:"+coords2.x+"x"+coords2.y); + } + } + } } return false; }