diff --git a/core/src/fr/evolving/UI/ButtonLevel.java b/core/src/fr/evolving/UI/ButtonLevel.java index 07a42a9..361b588 100644 --- a/core/src/fr/evolving/UI/ButtonLevel.java +++ b/core/src/fr/evolving/UI/ButtonLevel.java @@ -11,7 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.scenes.scene2d.utils.Align; +import com.badlogic.gdx.utils.Align; import fr.evolving.assets.AssetLoader; import fr.evolving.automata.Level; @@ -50,14 +50,14 @@ public class ButtonLevel extends ImageTextButton { this.setBounds(level.X, level.Y*AssetLoader.ratio, 111*scale, 125*scale); Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center); stylelabel=Thelabel.getStyle(); - stylelabel.font.setScale(scale); + //stylelabel.font.setScale(scale); Thelabel.setStyle(stylelabel); style= this.getStyle(); style.pressedOffsetX=style.pressedOffsetX*scale; style.pressedOffsetY=style.pressedOffsetY*scale; style.unpressedOffsetX=style.unpressedOffsetX*scale; style.unpressedOffsetY=style.unpressedOffsetY*scale; - style.font.setScale(scale); + //style.font.setScale(scale); this.setStyle(this.style); } diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index 8e396be..2650209 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -14,6 +14,9 @@ import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.utils.ObjectMap.Entries; +import com.badlogic.gdx.utils.ObjectMap.Entry; +import com.badlogic.gdx.utils.OrderedMap; import fr.evolving.assets.AssetLoader; import fr.evolving.automata.Level; @@ -85,13 +88,12 @@ public void setMenuTransmuterSurtile(int x,int y,Transmuter transmuter) { if (transmuter!=null) { Cell cell=((TiledMapTileLayer)map.getLayers().get(1)).getCell(x,y); - HashMap tiles=transmuter.getTiles(); - Iterator keySetIterator = transmuter.getTiles().keySet().iterator(); - cell.setTile(AssetLoader.tileSet.getTile(83)); - while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); - Cell subcell=((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)(x+key.x),(int)(y+key.y)); - subcell.setTile(AssetLoader.tileSet.getTile(tiles.get(key).ordinal()+80)); + OrderedMap tiles=transmuter.getTilesidrotated(); + Entries iterator=tiles.iterator(); + while(iterator.hasNext()){ + Entry all = iterator.next(); + Cell subcell=((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)(x+all.key.x),(int)(y+all.key.y)); + subcell.setTile(AssetLoader.tileSet.getTile(transmuter.getTilestype(tiles.keys().toArray().indexOf(all.key, false)).ordinal()+80)); } } @@ -121,17 +123,14 @@ public void setMenuTransmuter(int x,int y,String Name,Transmuter.Angular Angle) if (transmuter!=null) { Gdx.app.debug(getClass().getSimpleName(),"Transmuter find:"+transmuter.getName()+" Angle:"+Angle+" coords"+x+","+y); transmuter.setRotation(Angle); - Iterator keySetIterator = transmuter.getTiles().keySet().iterator(); - int MainTile=transmuter.getMainTile(); - cell.setTile(AssetLoader.tileSet.getTile(MainTile++)); - cell.setRotation(Angle.ordinal()); + Iterator> keySetIterator = transmuter.getTilesidrotated().iterator(); while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); - Cell subcell=((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+key.x),(int)(y+key.y)); - subcell.setTile(AssetLoader.tileSet.getTile(MainTile++)); + Entry all = keySetIterator.next(); + Cell subcell=((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+all.key.x),(int)(y+all.key.y)); + subcell.setTile(AssetLoader.tileSet.getTile(all.value)); subcell.setRotation(Angle.ordinal()); - subcell.getTile().getProperties().put("movetox",(int) -key.x); - subcell.getTile().getProperties().put("movetoy",(int) -key.y); + subcell.getTile().getProperties().put("movetox",(int) -all.key.x); + subcell.getTile().getProperties().put("movetoy",(int) -all.key.y); } } diff --git a/core/src/fr/evolving/UI/Objectives.java b/core/src/fr/evolving/UI/Objectives.java index a523df5..3a1ad9e 100644 --- a/core/src/fr/evolving/UI/Objectives.java +++ b/core/src/fr/evolving/UI/Objectives.java @@ -5,7 +5,6 @@ import java.util.Collections; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.scenes.scene2d.Actor; diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 253ec5f..12f883d 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -1,11 +1,15 @@ package fr.evolving.assets; +import java.util.Iterator; +import java.util.Locale; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.loaders.SkinLoader; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.OrthographicCamera; @@ -27,11 +31,23 @@ import com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile; import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.TooltipManager; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.I18NBundle; +import com.badlogic.gdx.utils.ObjectMap.Values; import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.ScalingViewport; import com.badlogic.gdx.utils.viewport.StretchViewport; +import fr.evolving.automata.Inverter_I; +import fr.evolving.automata.Inverter_II; +import fr.evolving.automata.Negativer; +import fr.evolving.automata.Negativer_I; +import fr.evolving.automata.Negativer_II; +import fr.evolving.automata.Negativer_III; +import fr.evolving.automata.Neutraliser_I; +import fr.evolving.automata.Neutraliser_II; +import fr.evolving.automata.Positiver; import fr.evolving.automata.Positiver_I; import fr.evolving.automata.Positiver_II; import fr.evolving.automata.Positiver_III; @@ -60,7 +76,9 @@ public class AssetLoader { public static NinePatch full; public static AssetManager manager; public static TiledMapTileSet tileSet; - public static Transmuter[] allTransmuter; + public static Array allTransmuter; + public static TooltipManager Tooltipmanager; + public static I18NBundle french,usa,language; public static void addstyle(TextureAtlas Atlas_level,String Name) { AtlasRegion AnAtlasRegion = Atlas_level.findRegion(Name); @@ -97,7 +115,7 @@ public class AssetLoader { manager.load("musics/intro.mp3", Music.class); } - public static void finishall() { + public static void finishall() { Gdx.app.debug("AssetLoader","Ajout des textures disabled,over et down"); Atlas_level = manager.get("textures/level.pack"); if (manager.isLoaded("textures/level.pack")) { @@ -162,29 +180,38 @@ public class AssetLoader { } } } - allTransmuter=new Transmuter[3]; - allTransmuter[0]=new Positiver_I(null); - allTransmuter[1]=new Positiver_II(null); - allTransmuter[2]=new Positiver_III(null); - for(int i=0;i(); + allTransmuter.add(new Positiver(null)); + allTransmuter.add(new Positiver_I(null)); + allTransmuter.add(new Positiver_II(null)); + allTransmuter.add(new Positiver_III(null)); + allTransmuter.add(new Negativer(null)); + allTransmuter.add(new Negativer_I(null)); + allTransmuter.add(new Negativer_II(null)); + allTransmuter.add(new Negativer_III(null)); + allTransmuter.add(new Inverter_I(null)); + allTransmuter.add(new Inverter_II(null)); + allTransmuter.add(new Neutraliser_I(null)); + allTransmuter.add(new Neutraliser_II(null)); + for(Transmuter transmuter:allTransmuter) { + Values allTiles=transmuter.getTilesid().iterator(); + while(allTiles.hasNext()) { + Integer atile=allTiles.next(); + Gdx.app.debug("AssetLoader","Ajustement données Tiles N°:"+String.valueOf(atile)+" Nom:"+transmuter.getName()); + AssetLoader.tileSet.getTile(atile).getProperties().put("transmuter", transmuter); + AssetLoader.tileSet.getTile(atile).getProperties().put("name", transmuter.getName()); } } + Gdx.app.debug("AssetLoader","Ajout de la gestion des tooltips"); + Tooltipmanager= new TooltipManager(); + Gdx.app.debug("AssetLoader","Ajout de la gestion des locales"); + FileHandle baseFileHandle = Gdx.files.internal("i18n/messages/messages"); + usa = I18NBundle.createBundle(baseFileHandle, new Locale("en")); + french = I18NBundle.createBundle(baseFileHandle, new Locale("fr")); + language=usa; + I18NBundle.setExceptionOnMissingKey(true); } - public static Transmuter getTransmuter(int Id) { - for(Transmuter transmuter:allTransmuter) { - if (transmuter.isTransmuter(Id)) - return transmuter; - } - return null; - } - public static Transmuter getTransmuter(String Name) { for(Transmuter transmuter:allTransmuter) { if (transmuter.isTransmuter(Name)) @@ -193,14 +220,6 @@ public class AssetLoader { return null; } - public static Vector2 resolveTransmuterMain(int Id) { - Transmuter transmuter=getTransmuter(Id); - if (transmuter!=null) - return transmuter.getPostitionMainTile(Id); - else - 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/Grid.java b/core/src/fr/evolving/automata/Grid.java index c7a2012..8d4a185 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -6,6 +6,7 @@ import java.util.Iterator; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.ObjectMap.Entry; import fr.evolving.automata.Transmuter.CaseType; @@ -33,14 +34,12 @@ public class Grid implements Serializable{ Transmuter transmuter=getTransmuter(x,y); if (transmuter!=null) { - Iterator keySetIterator = transmuter.getTiles().keySet().iterator(); - int MainTile=transmuter.getMainTile(); - GetXY(x,y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+MainTile++; - while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); - GetXY(x+key.x,y+key.y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+MainTile++; - GetXY(x+key.x,y+key.y).Transmuter_movex=(int)-key.x; - GetXY(x+key.x,y+key.y).Transmuter_movey=(int)-key.y; + Iterator> tiles = transmuter.getTilesidrotated().iterator(); + while(tiles.hasNext()){ + Entry all=tiles.next(); + GetXY(x+all.key.x,y+all.key.y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+all.value; + GetXY(x+all.key.x,y+all.key.y).Transmuter_movex=(int)-all.key.x; + GetXY(x+all.key.x,y+all.key.y).Transmuter_movey=(int)-all.key.y; } } } diff --git a/core/src/fr/evolving/automata/Inverter_I.java b/core/src/fr/evolving/automata/Inverter_I.java new file mode 100644 index 0000000..ab84f48 --- /dev/null +++ b/core/src/fr/evolving/automata/Inverter_I.java @@ -0,0 +1,278 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Inverter_I extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Inverter_I(Level level) { + super(level); + this.Name="Inverseur I"; + this.Desc="Inverseur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=new Inverter_II(level); + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 112); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Inverter_II.java b/core/src/fr/evolving/automata/Inverter_II.java new file mode 100644 index 0000000..e304c72 --- /dev/null +++ b/core/src/fr/evolving/automata/Inverter_II.java @@ -0,0 +1,278 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Inverter_II extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Inverter_II(Level level) { + super(level); + this.Name="Inverseur II"; + this.Desc="Inverseur de degré 2 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=null; + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 113); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Negativer.java b/core/src/fr/evolving/automata/Negativer.java new file mode 100644 index 0000000..a576bb8 --- /dev/null +++ b/core/src/fr/evolving/automata/Negativer.java @@ -0,0 +1,278 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Negativer extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Negativer(Level level) { + super(level); + this.Name="Negativeur non activable"; + this.Desc="Negativeur avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=null; + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 101); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Negativer_I.java b/core/src/fr/evolving/automata/Negativer_I.java new file mode 100644 index 0000000..a6e01ce --- /dev/null +++ b/core/src/fr/evolving/automata/Negativer_I.java @@ -0,0 +1,280 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Negativer_I extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Negativer_I(Level level) { + super(level); + this.Name="Negativeur I"; + this.Desc="Negativeur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=new Negativer_II(level); + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); + this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 108); + this.Tilesid.put(new Vector2(1,0), 105); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Negativer_II.java b/core/src/fr/evolving/automata/Negativer_II.java new file mode 100644 index 0000000..6c6c461 --- /dev/null +++ b/core/src/fr/evolving/automata/Negativer_II.java @@ -0,0 +1,280 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Negativer_II extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Negativer_II(Level level) { + super(level); + this.Name="Negativeur II"; + this.Desc="Negativeur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=new Negativer_III(level); + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); + this.Tilestype.put(new Vector2(1,0), CaseType.Fibre); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 109); + this.Tilesid.put(new Vector2(1,0), 107); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Negativer_III.java b/core/src/fr/evolving/automata/Negativer_III.java new file mode 100644 index 0000000..8756ada --- /dev/null +++ b/core/src/fr/evolving/automata/Negativer_III.java @@ -0,0 +1,279 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Negativer_III extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Negativer_III(Level level) { + super(level); + this.Name="Negativeur III"; + this.Desc="Negativeur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=null; + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Tout); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 103); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Neutraliser_I.java b/core/src/fr/evolving/automata/Neutraliser_I.java new file mode 100644 index 0000000..b15bd9d --- /dev/null +++ b/core/src/fr/evolving/automata/Neutraliser_I.java @@ -0,0 +1,278 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Neutraliser_I extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Neutraliser_I(Level level) { + super(level); + this.Name="Neutraliseur I"; + this.Desc="Neutraliseur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=new Neutraliser_II(level); + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 110); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Neutraliser_II.java b/core/src/fr/evolving/automata/Neutraliser_II.java new file mode 100644 index 0000000..e7bf8cb --- /dev/null +++ b/core/src/fr/evolving/automata/Neutraliser_II.java @@ -0,0 +1,278 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Neutraliser_II extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Neutraliser_II(Level level) { + super(level); + this.Name="Neutraliseur II"; + this.Desc="Neutraliseur de degré 2 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=null; + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 111); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Positiver.java b/core/src/fr/evolving/automata/Positiver.java new file mode 100644 index 0000000..ce31e49 --- /dev/null +++ b/core/src/fr/evolving/automata/Positiver.java @@ -0,0 +1,278 @@ +package fr.evolving.automata; + +import java.util.HashMap; +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Positiver extends Transmuter { + private static String Name,Desc; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static boolean Activable; + private int ActivationLevel; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Positiver(Level level) { + super(level); + this.Name="Positiveur non activable"; + this.Desc="Positiveur ...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=0; + this.Upgrade=null; + this.Unlock=null; + this.showed=true; + this.CanUpgradeTemp=true; + this.CanUpgradeCycle=true; + this.CanUpgradeRayon=false; + this.CanUpgradeNrj=false; + this.UpgradedTemp=1f; + this.UpgradedCycle=1f; + this.UpgradedRayon=1f; + this.UpgradedNrj=1f; + this.UsedTemp=0.5f; + this.UsedRayon=0f; + this.UsedNrj=0f; + this.TurnTemp=0f; + this.TurnRayon=0f; + this.TurnNrj=0f; + this.Activable=true; + this.ActivationLevel=0; + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 100); + } + + public String getName() { + return this.Name; + } + + public String getDesc() { + return this.Desc; + } + + public String getaClass() { + return this.theClass.toString(); + } + + public void ProcessCycle() { + this.level.Temp+=TurnTemp*UpgradedTemp; + this.level.Rayon+=TurnRayon*UpgradedRayon; + this.level.Nrj+=TurnNrj*UpgradedNrj; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=this.getMaxActivationLevel(); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public Values getTilesid() { + return Tilesid.values(); + } + + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } + + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + double delta=key.len(); + double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); + } + return newTiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getMaxActivationLevel() { + return ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tilesid.size); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + return TurnNrj*UpgradedNrj; + } + + public Transmuter getUpgrade() { + return this.Upgrade; + } + + public Transmuter getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index 9783f28..e032927 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -5,6 +5,8 @@ import java.util.Iterator; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.ObjectMap.Values; +import com.badlogic.gdx.utils.OrderedMap; import fr.evolving.automata.Transmuter.CaseType; import fr.evolving.automata.Transmuter.Class; @@ -32,11 +34,11 @@ public class Positiver_I extends Transmuter { private static float TurnTemp; private static float TurnRayon; private static float TurnNrj; - private static int Id; private static boolean Activable; private int ActivationLevel; private int Rotation; - private static HashMap Tiles; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; public Positiver_I(Level level) { super(level); @@ -63,11 +65,14 @@ public class Positiver_I extends Transmuter { this.TurnTemp=0f; this.TurnRayon=0f; this.TurnNrj=0f; - this.Id=0; this.Activable=true; this.ActivationLevel=0; - this.Tiles= new HashMap(); - this.Tiles.put(new Vector2(1,0), CaseType.Fibre); + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); + this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 104); + this.Tilesid.put(new Vector2(1,0), 105); } public String getName() { @@ -134,53 +139,22 @@ public class Positiver_I extends Transmuter { UpgradedCycle+=0.2f; } - public int getMainTile() { - return this.getSize()*100+Id*this.getSize(); - } - - public int FindMainTile(int Id) { - int thesize=(Id & 0xFFFF)/100; - int deltaid=(Id & 0xFFFF)-thesize*100; - return thesize*100+((int)(deltaid/thesize))*thesize; - } - - public int[] getallTiles() { - int thesize=Tiles.size()+1; - int[] result; - result=new int[thesize]; - for(int i=0;i getTilesid() { + return Tilesid.values(); } - 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 CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } - public HashMap getTiles() { - HashMap newTiles= new HashMap(); - Iterator keySetIterator = this.Tiles.keySet().iterator(); - while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator tiles = this.Tilesid.keys(); + while(tiles.hasNext()){ + Vector2 key = tiles.next(); double delta=key.len(); double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; - newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tiles.get(key)); + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); } return newTiles; } @@ -212,7 +186,7 @@ public class Positiver_I extends Transmuter { } public int getSize() { - return (Tiles.size()+1); + return (Tilesid.size); } public int getTechnology() { diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index 7b11fd4..f4580c8 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -3,7 +3,10 @@ package fr.evolving.automata; import java.util.HashMap; import java.util.Iterator; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; import fr.evolving.automata.Transmuter.CaseType; import fr.evolving.automata.Transmuter.Class; @@ -31,19 +34,20 @@ public class Positiver_II extends Transmuter { private static float TurnTemp; private static float TurnRayon; private static float TurnNrj; - private static int Id; private static boolean Activable; private int ActivationLevel; - private static HashMap Tiles; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; public Positiver_II(Level level) { super(level); - this.Name="Positiveur II"; - this.Desc="Positiveur de degré 2 avec...blabla"; + this.Name="Positiveur II"; + this.Desc="Positiveur de degré 2222222 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.theClass=Class.Charge; this.Price=50; this.Technology=2; - this.Research=40; + this.Research=0; this.Upgrade=new Positiver_III(level); this.Unlock=null; this.showed=true; @@ -61,11 +65,14 @@ public class Positiver_II extends Transmuter { this.TurnTemp=0f; this.TurnRayon=0f; this.TurnNrj=0f; - this.Id=1; this.Activable=true; this.ActivationLevel=0; - this.Tiles= new HashMap(); - this.Tiles.put(new Vector2(1,0), CaseType.Fibre); + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); + this.Tilestype.put(new Vector2(1,0), CaseType.Fibre); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 106); + this.Tilesid.put(new Vector2(1,0), 107); } public String getName() { @@ -132,53 +139,22 @@ public class Positiver_II extends Transmuter { UpgradedCycle+=0.2f; } - public int getMainTile() { - return this.getSize()*100+Id*this.getSize(); - } + public Values getTilesid() { + return Tilesid.values(); + } - public int FindMainTile(int Id) { - int thesize=(Id & 0xFFFF)/100; - int deltaid=(Id & 0xFFFF)-thesize*100; - return thesize*100+((int)(deltaid/thesize))*thesize; - } + public CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } - public int[] getallTiles() { - int thesize=Tiles.size()+1; - int[] result; - result=new int[thesize]; - 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(); + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); 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(); - while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); - double delta=key.len(); - double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; - newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tiles.get(key)); + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); } return newTiles; } @@ -210,7 +186,7 @@ public class Positiver_II extends Transmuter { } public int getSize() { - return (Tiles.size()+1); + return (Tilesid.size); } public int getTechnology() { @@ -300,4 +276,5 @@ public class Positiver_II extends Transmuter { public Transmuter getUnlock() { return this.Unlock; } + } diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index b150a2b..3dc782b 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -3,7 +3,10 @@ package fr.evolving.automata; import java.util.HashMap; import java.util.Iterator; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.OrderedMap; +import com.badlogic.gdx.utils.ObjectMap.Values; import fr.evolving.automata.Transmuter.CaseType; import fr.evolving.automata.Transmuter.Class; @@ -31,19 +34,20 @@ public class Positiver_III extends Transmuter { private static float TurnTemp; private static float TurnRayon; private static float TurnNrj; - private static int Id; private static boolean Activable; private int ActivationLevel; - private static HashMap Tiles; + private int Rotation; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; public Positiver_III(Level level) { super(level); - this.Name="Positiveur III"; - this.Desc="Positiveur de degré 3 avec...blabla"; + this.Name="Positiveur III"; + this.Desc="Positiveur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.theClass=Class.Charge; this.Price=50; this.Technology=2; - this.Research=120; + this.Research=0; this.Upgrade=null; this.Unlock=null; this.showed=true; @@ -61,11 +65,12 @@ public class Positiver_III extends Transmuter { this.TurnTemp=0f; this.TurnRayon=0f; this.TurnNrj=0f; - this.Id=2; this.Activable=true; this.ActivationLevel=0; - this.Tiles= new HashMap(); - this.Tiles.put(new Vector2(1,0), CaseType.Fibre); + this.Tilestype= new OrderedMap(); + this.Tilestype.put(new Vector2(0,0), CaseType.Tout); + this.Tilesid= new OrderedMap(); + this.Tilesid.put(new Vector2(0,0), 102); } public String getName() { @@ -132,53 +137,22 @@ public class Positiver_III extends Transmuter { UpgradedCycle+=0.2f; } - public int getMainTile() { - return this.getSize()*100+Id*this.getSize(); - } - - public int FindMainTile(int Id) { - int thesize=(Id & 0xFFFF)/100; - int deltaid=(Id & 0xFFFF)-thesize*100; - return thesize*100+((int)(deltaid/thesize))*thesize; - } - - public int[] getallTiles() { - int thesize=Tiles.size()+1; - int[] result; - result=new int[thesize]; - for(int i=0;i getTilesid() { + return Tilesid.values(); } - 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 CaseType getTilestype(int order) { + return Tilestype.values().toArray().get(order); + } - public HashMap getTiles() { - HashMap newTiles= new HashMap(); - Iterator keySetIterator = this.Tiles.keySet().iterator(); + public OrderedMap getTilesidrotated() { + OrderedMap newTiles= new OrderedMap(); + Iterator keySetIterator = this.Tilesid.keys(); while(keySetIterator.hasNext()){ Vector2 key = keySetIterator.next(); double delta=key.len(); double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; - newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tiles.get(key)); + newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); } return newTiles; } @@ -210,7 +184,7 @@ public class Positiver_III extends Transmuter { } public int getSize() { - return (Tiles.size()+1); + return (Tilesid.size); } public int getTechnology() { @@ -300,4 +274,5 @@ public class Positiver_III extends Transmuter { public Transmuter getUnlock() { return this.Unlock; } + } diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index fcd6c70..b637ea8 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -5,10 +5,14 @@ import java.util.Iterator; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.ObjectMap.Entries; +import com.badlogic.gdx.utils.ObjectMap.Entry; +import com.badlogic.gdx.utils.ObjectMap.Values; +import com.badlogic.gdx.utils.OrderedMap; public abstract class Transmuter implements Cloneable { public enum CaseType{Rien,Cuivre_seul,Fibre_seul,Cuivre,Fibre,Tout,Nimporte}; - public enum Class{Structure,Charge,Direction,Filtrage,Synthèse,Détection,Divers,Scénario}; + public enum Class{Structure,Charge,Direction,Filtrage,Synthese,Detection,Divers,Scenario}; public enum Angular{A00,A90,A180,A270}; protected Level level; protected Angular Rotation; @@ -57,45 +61,19 @@ public abstract class Transmuter implements Cloneable { public void UpgradeCycle() { } - public int getMainTile() { - return 0; - } - - public int FindMainTile(int Id) { - return 0; - } - - public boolean isTransmuter(int Id) { - return (FindMainTile(Id)==getMainTile()); - } - public boolean isTransmuter(String Name) { return Name.equals(this.getName()); } - 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 & 0xFFFF)==Idrec) - return new Vector2(); - Transmuter.Angular oldrotation=this.getRotation(); - this.setRotation(Transmuter.Angular.values()[Id>>16]); - while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); - Idrec++; - if ((Id & 0xFFFF)==Idrec) { - this.setRotation(oldrotation); - return new Vector2().sub(key); - } - } - this.setRotation(oldrotation); + public CaseType getTilestype(int order) { return null; } - public HashMap getTiles() { + public OrderedMap getTilesidrotated() { + return null; + } + + public Values getTilesid() { return null; } @@ -209,30 +187,18 @@ public abstract class Transmuter implements Cloneable { public float getTurnNrj() { return 0; } - - public int[] getallTiles() { - return null; - } - - public Vector2[] getallSize() { - return null; - } public String getInformations() { - HashMap tiles=this.getTiles(); - Iterator keySetIterator = tiles.keySet().iterator(); + OrderedMap tiles=this.getTilesidrotated(); + Entries iterator=tiles.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()+"\nTiles:"; - int[] allTiles; - Vector2[] allSize; - allTiles=this.getallTiles(); - for(int i=0;i allTiles=this.getTilesid().iterator(); + while(allTiles.hasNext()) + result+=String.valueOf(allTiles.next())+" "; + while(iterator.hasNext()){ + Entry all = iterator.next(); + result+="\ncoords:" + all.key.x+","+all.key.y + " type: " + this.getTilestype(tiles.keys().toArray().indexOf(all.key, false)) +" id:"+all.value; } result+="\n**********************************"; return result; diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index c5fbf55..7d0f743 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -36,12 +36,15 @@ import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextArea; +import com.badlogic.gdx.scenes.scene2d.ui.Tooltip; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; -import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.ObjectMap.Entries; +import com.badlogic.gdx.utils.ObjectMap.Entry; +import com.badlogic.gdx.utils.OrderedMap; import fr.evolving.UI.Menu; import fr.evolving.worlds.GameRenderer; @@ -65,16 +68,16 @@ public class GameScreen implements Screen { private Array processors; private Timer ScrollTimer; private TimerTask ScrollTask; - private Stage stage,stage_menu,stage_info; - private HorizontalGroup table; - private VerticalGroup table2; + private Stage stage,stage_menu,stage_info,stage_tooltip; + private HorizontalGroup table; + private VerticalGroup table2; private GameWorld world; private GameRenderer Renderer; private float runTime; public Level level; private ImageButton[] Barre; private ImageButton info_up_nrj,info_up_temp,info_up_rayon,info_up_cycle,info_up_nrjval,info_up_tempval,info_up_rayonval,info_up_cycleval; - private ImageTextButton cycle,temp,nrj,rayon,cout,tech,info_cout,info_tech,info_research,info_activation; + private ImageTextButton cycle,temp,nrj,rayon,cout,tech,research,info_cout,info_tech,info_research,info_activation; private ImageTextButton[] Barre2; String[] tocreate={"run","stop","speed","separator","move","zoomp","zoomm","infos","separator","raz","save","levels","tree","exits","separator","screen","sound","tuto","settings","separator","stat"}; public Actor selected; @@ -86,11 +89,11 @@ public class GameScreen implements Screen { private Actor menuactor; private float oldx,oldy; private Label fpsLabel,info_nom; - private TextArea info_desc; + private TextArea info_desc,tooltip; public boolean unroll,mapexit; public enum calling{mouseover,mouseclick,mousedrag,longpress,tap,taptap,zoom,fling,pan,pinch}; GestureDetector gesturedetector; - + // This is the constructor, not the class declaration public GameScreen(Level alevel) { Gdx.app.debug(getClass().getSimpleName(),"Création des Barres verticales & horizontales"); @@ -108,6 +111,7 @@ public class GameScreen implements Screen { stage = new Stage(AssetLoader.viewport); stage_menu = new Stage(AssetLoader.viewport); stage_info = new Stage(AssetLoader.viewport); + stage_tooltip = new Stage(AssetLoader.viewport); this.level=alevel; oldx=0; oldy=0; @@ -127,13 +131,15 @@ public class GameScreen implements Screen { }; ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); Gdx.app.debug(getClass().getSimpleName(),"Création des barres"); + tooltip=new TextArea("tooltip:x\r\n tooltip:y", AssetLoader.Skin_level, "info_tooltip") ; + tooltip.setBounds(541, 27, 100, 50); Barre=new ImageButton[tocreate.length]; int i=0; Gdx.app.debug(getClass().getSimpleName(),"Barre bas:"+Barre.length+" elements"); for (String tocreateitem: tocreate) { Barre[i]= new ImageButton(AssetLoader.Skin_level,tocreateitem); Barre[i].setName(tocreateitem); - Barre[i++].addListener(new ClickListener(){ + Barre[i].addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { Actor caller=event.getListenerActor(); @@ -141,11 +147,12 @@ public class GameScreen implements Screen { preparebarre(caller, this.getTapCount()); } }); + Barre[i++].addListener(new Tooltip(tooltip, AssetLoader.Tooltipmanager)); } Barre2=new ImageTextButton[Transmuter.Class.values().length]; Gdx.app.debug(getClass().getSimpleName(),"Menu:"+Barre2.length+" elements"); for (i=0;i0); + Barre[17].setChecked(AssetLoader.Tooltipmanager.enabled==true); Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du haut"); cycle=new ImageTextButton(String.valueOf(level.Cycle),AssetLoader.Skin_level,"cycle2"); cycle.setPosition(10,AssetLoader.height-74); @@ -173,6 +179,8 @@ public class GameScreen implements Screen { tech.setPosition(1345,AssetLoader.height-74); cout=new ImageTextButton(String.valueOf(level.Cout),AssetLoader.Skin_level,"cout2"); cout.setPosition(1445,AssetLoader.height-74); + research=new ImageTextButton(String.valueOf(0),AssetLoader.Skin_level,"research2"); + research.setPosition(1545,AssetLoader.height-74); objectives=new Objectives(); objectives.setVictory(level.Victory); objectives.setPosition(890,AssetLoader.height-95); @@ -219,29 +227,29 @@ public class GameScreen implements Screen { map=new TouchMaptiles(level,128,128); map.setBounds(0, 0, AssetLoader.width, AssetLoader.height); map.addListener(new ActorGestureListener(){ - @Override - public void zoom(InputEvent event, float initialDistance, float distance) { - String[] exec={"zoomp","zoomm"}; - int zooming=(int)(distance/initialDistance*1000f); - event_coordination(0,0,zooming,calling.zoom,exec); - } @Override - public void pinch(InputEvent event, Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) - { - float deltaX = pointer2.x - pointer1.x; - float deltaY = pointer2.y - pointer1.y; - int angle = (int)((float)Math.atan2((double)deltaY,(double)deltaX) * MathUtils.radiansToDegrees); - angle += 90; - if(angle < 0) - angle = 360 - (-angle); + public void zoom(InputEvent event, float initialDistance, float distance) { + String[] exec={"zoomp","zoomm"}; + int zooming=(int)(distance/initialDistance*1000f); + event_coordination(0,0,zooming,calling.zoom,exec); + } + @Override + public void pinch(InputEvent event, Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) + { + float deltaX = pointer2.x - pointer1.x; + float deltaY = pointer2.y - pointer1.y; + int angle = (int)((float)Math.atan2((double)deltaY,(double)deltaX) * MathUtils.radiansToDegrees); + angle += 90; + if(angle < 0) + angle = 360 - (-angle); String[] exec={"transmuter"}; event_coordination(initialPointer1.x,initialPointer1.y,angle,calling.pinch,exec); - } + } @Override public boolean longPress(Actor actor, float x, float y) { String[] exec={"transmuter"}; return event_coordination(x,y,0,calling.longpress,exec); - } + } @Override public void tap(InputEvent event, float x, float y, int count, int button) { String[] exec={"transmuter"}; @@ -249,28 +257,28 @@ public class GameScreen implements Screen { event_coordination(x,y,button,calling.tap,exec); else if (count>=2) event_coordination(x,y,button,calling.taptap,exec); - } - }); + } + }); map.addListener(new InputListener(){ @Override public boolean mouseMoved(InputEvent event,float x,float y) { String[] exec={"transmuter"}; return event_coordination(x,y,0,calling.mouseover,exec); } - + @Override - public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { oldx=0; oldy=0; String[] exec={"cleaner","infos","zoomp","zoomm","copper_pen","fiber_pen","copper_eraser","fiber_eraser","transmuter_eraser","all_eraser","blank","transmuter","copper_brush","fiber_brush"}; return event_coordination(x,y,button,calling.mouseclick,exec); - } + } @Override public void touchDragged(InputEvent event, float x, float y, int pointer) { String[] exec={"transmuter","move","copper_brush","fiber_brush","copper_eraser","fiber_eraser","transmuter_eraser","all_eraser","blank"}; event_coordination(x,y,0,calling.mousedrag,exec); } - }); + }); menu=new Menu(4,8); map.addListener(new ClickListener(){ @Override @@ -282,31 +290,30 @@ public class GameScreen implements Screen { { menu.EraseMenuTransmuterSurtile(); map.tempclear(); - Gdx.app.debug("menu","Coordonnées:"+x+"x"+y+" Coordonnées deprojettée:"+coords.x+"x"+coords.y+" type:"+tile.get("type")+" name:"+tile.get("name").toString()); if (menuactor==null) menuactor=new Actor(); - Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y); - menuactor.setBounds(coords2.x, coords2.y, 60, 60); - selected=menuactor; map.fillempty(60); + selected=menuactor; if (tile.get("type").toString().startsWith("transmuter")) { - selected.setName("transmuter"); - selected_transmuter=(Transmuter) ((Transmuter) tile.get("transmuter")).clone(); + if (tile.containsKey("movetox")) { + coords.x+=(Integer) tile.get("movetox"); + coords.y+=(Integer) tile.get("movetoy"); + } + MapProperties tilenew=menu.getMenubyTile((int)coords.x,(int)coords.y); + selected_transmuter=(Transmuter) ((Transmuter) tilenew.get("transmuter")).clone(); if (selected_transmuter!=null) { + selected.setName("transmuter"); showInfo(selected_transmuter); - if (tile.containsKey("movetox")) { - coords2=menu.worldtoscreen((int)coords.x+(Integer) tile.get("movetox"),(int)(coords.y+(Integer) tile.get("movetoy"))); - menuactor.setPosition(coords2.x, coords2.y); - Gdx.app.debug("menu","transmuter deplacement vers origine:"+tile.get("movetox").toString()+","+tile.get("movetoy").toString()+" coords:"+coords2.x+"x"+coords2.y); - menu.setMenuTransmuterSurtile((int)coords.x+(Integer) tile.get("movetox"),(int) coords.y+(Integer) tile.get("movetoy"),selected_transmuter); - } - else - menu.setMenuTransmuterSurtile((int)coords.x,(int) coords.y,selected_transmuter); + menu.setMenuTransmuterSurtile((int)coords.x,(int) coords.y,selected_transmuter); + Gdx.app.debug("menu","Choix transmuter:"+selected_transmuter.getName()); } } else selected.setName(tile.get("name").toString()); + Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y); + Gdx.app.debug("menu","Coordonnées:"+x+"x"+y+" Menu:"+coords.x+","+coords.y+" Ecran :"+coords2.x+"x"+coords2.y+" type:"+tile.get("type")); + menuactor.setBounds(coords2.x, coords2.y, 60, 60); } } }); @@ -340,7 +347,7 @@ public class GameScreen implements Screen { } } } - + } return true; } @@ -360,23 +367,19 @@ public class GameScreen implements Screen { } map.tempclear(); boolean positionisgood=true; - HashMap tiles=selected_transmuter.getTiles(); - Iterator keySetIterator = selected_transmuter.getTiles().keySet().iterator(); - int MainTile=selected_transmuter.getMainTile(); - int color=63; - if (level.Grid.getCopper(x,y) && level.Grid.getTransmutercalc(x,y)==0) - color=0; - else - positionisgood=false; - map.tempdraw(x, y, MainTile, selected_transmuter.getRotation().ordinal(),color); - while(keySetIterator.hasNext()){ - Vector2 key = keySetIterator.next(); + int color=0; + OrderedMap tiles=selected_transmuter.getTilesidrotated(); + Entries iterator=tiles.iterator(); + while(iterator.hasNext()){ + Entry all = iterator.next(); color=63; - if (((!level.Grid.getFiber(x+key.x, y+key.y) && !level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Rien) || (level.Grid.getFiber(x+key.x, y+key.y) && level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Tout) || (level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Cuivre) || (level.Grid.getFiber(x+key.x, y+key.y) && tiles.get(key)==CaseType.Fibre) || (level.Grid.getFiber(x+key.x, y+key.y) && !level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Fibre_seul) || (level.Grid.getCopper(x+key.x, y+key.y) && !level.Grid.getFiber(x+key.x, y+key.y) && tiles.get(key)==CaseType.Cuivre_seul)) && (level.Grid.getTransmutercalc(x+key.x, y+key.y)==0)) + int index=tiles.keys().toArray().indexOf(all.key, false); + if (((selected_transmuter.getTilestype(index)==CaseType.Nimporte) || (!level.Grid.getFiber(x+all.key.x, y+all.key.y) && !level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Rien) || (level.Grid.getFiber(x+all.key.x, y+all.key.y) && level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Tout) || (level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Cuivre) || (level.Grid.getFiber(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Fibre) || (level.Grid.getFiber(x+all.key.x, y+all.key.y) && !level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Fibre_seul) || (level.Grid.getCopper(x+all.key.x, y+all.key.y) && !level.Grid.getFiber(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Cuivre_seul)) && (level.Grid.getTransmutercalc(x+all.key.x, y+all.key.y)==0)) color=0; else positionisgood=false; - map.tempdraw(x+key.x, y+key.y, ++MainTile, selected_transmuter.getRotation().ordinal(),color); + map.tempdraw(x+all.key.x, y+all.key.y, all.value, selected_transmuter.getRotation().ordinal(),color); + } if ((call==calling.longpress && button==0) && positionisgood) { level.Grid.GetXY(x,y).Transmuter=(Transmuter) selected_transmuter.clone(); @@ -384,14 +387,13 @@ public class GameScreen implements Screen { map.redraw(60); Gdx.input.vibrate(new long[] { 0, 400, 500, 400}, -1); } - } } - - + + void map_infos(float realx, float realy,int x, int y,boolean alone,int button,calling call) { if (level.Grid.GetXY(x,y)!=null) { - Gdx.app.debug("map","Etat extension:"+unroll); + Gdx.app.debug("map","Etat extension:"+unroll); if (level.Grid.GetXY(x,y).Copper) Gdx.app.debug("map","*** Présence de cuivre"); if (level.Grid.GetXY(x,y).Fiber>0) @@ -402,22 +404,22 @@ public class GameScreen implements Screen { showInfo(level.Grid.getTransmuter(x+level.Grid.GetXY(x,y).Transmuter_movex,y+level.Grid.GetXY(x,y).Transmuter_movey)); map.tempclear(); map.tempdraw(x,y,1069,0,0); - } + } } } - + void map_zoomp(float realx, float realy,int x, int y,boolean alone,int button,calling call) { map.setZoom(0.9f); map.setDec((AssetLoader.width/2-realx)/2,(AssetLoader.height/2-realy)/2); } - + void map_zoomm(float realx, float realy,int x, int y,boolean alone,int button,calling call) { map.setZoom(1.1f); map.setDec((AssetLoader.width/2-realx)/2,(AssetLoader.height/2-realy)/2); } - + void map_move(float realx, float realy,int x, int y,boolean alone,int button,calling call) { if (oldx!=0 && oldy!=0) { map.setDec(realx-oldx,realy-oldy); @@ -426,12 +428,12 @@ public class GameScreen implements Screen { oldx=realx; oldy=realy; } - + void map_blank(float realx, float realy,int x, int y,boolean alone,int button,calling call) { map_fiber_eraser(0,0,x,y,false,button,call); map_copper_eraser(0,0,x,y,alone,button,call); } - + void map_cleaner(float realx, float realy,int x, int y,boolean alone,int button,calling call) { for(x=0;x0) { Gdx.app.debug("Barre","arret son."); AssetLoader.intro.setVolume(0f); - Barre[16].getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("nosound")); } else { Gdx.app.debug("Barre","marche son."); AssetLoader.intro.setVolume(1f); - Barre[16].getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("sound")); } + ((ImageButton)caller).setChecked(AssetLoader.intro.getVolume()>0); } else if (caller.getName()=="tuto") { + if (AssetLoader.Tooltipmanager.enabled) + { + Gdx.app.debug("Barre","arret tuto."); + AssetLoader.Tooltipmanager.enabled=false; + } + else + { + Gdx.app.debug("Barre","marche tuto."); + AssetLoader.Tooltipmanager.enabled=true; + } + ((ImageButton)caller).setChecked(AssetLoader.Tooltipmanager.enabled); } else if (caller.getName()=="settings") { } - else if (caller.getName()=="separator") { + else if (caller.getName()=="flag") { + if (AssetLoader.language.getLocale().getDisplayName().contains("français")) + { + Gdx.app.debug("Barre","Langue USA"); + AssetLoader.language=AssetLoader.usa; + } + else + { + Gdx.app.debug("Barre","Langue FR"); + AssetLoader.language=AssetLoader.french; + } + ((ImageButton)caller).setChecked(AssetLoader.language.getLocale().getDisplayName().contains("français")); } else if (caller.getName()=="stat") { } } - + public void preparemenu(int menuitem) { checkMenu(menuitem,true); menu.clear(); @@ -664,45 +690,53 @@ public class GameScreen implements Screen { menu.EraseMenuTransmuterSurtile(); hideInfo(); if (menuitem==0) { - menu.setMenuTile(0, 7, 71, "copper_pen"); - menu.setMenuTile(1, 7, 72, "copper_brush"); - menu.setMenuTile(2, 7, 73, "copper_eraser"); - menu.setMenuTile(1, 5, 70, "blank"); - menu.setMenuTile(0, 6, 74, "fiber_pen"); - menu.setMenuTile(1, 6, 75, "fiber_brush"); - menu.setMenuTile(2, 6, 76, "fiber_eraser"); - menu.setMenuTile(0, 5, 77, "transmuter_eraser"); - menu.setMenuTile(2, 5, 78, "all_eraser"); - menu.setMenuTile(3, 3, 79, "cleaner"); + menu.setMenuTile(0, 7, 71, "copper_pen"); + menu.setMenuTile(1, 7, 72, "copper_brush"); + menu.setMenuTile(2, 7, 73, "copper_eraser"); + menu.setMenuTile(1, 5, 70, "blank"); + menu.setMenuTile(0, 6, 74, "fiber_pen"); + menu.setMenuTile(1, 6, 75, "fiber_brush"); + menu.setMenuTile(2, 6, 76, "fiber_eraser"); + menu.setMenuTile(0, 5, 77, "transmuter_eraser"); + menu.setMenuTile(2, 5, 78, "all_eraser"); + menu.setMenuTile(3, 3, 79, "cleaner"); } else if (menuitem==1) { - menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00); - menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00); - menu.setMenuTransmuter(2,6,"Positiveur III",Angular.A90); + menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00); + menu.setMenuTransmuter(2,7,"Negativeur I",Angular.A00); + menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00); + menu.setMenuTransmuter(2,6,"Negativeur II",Angular.A00); + menu.setMenuTransmuter(0,5,"Positiveur III",Angular.A00); + menu.setMenuTransmuter(1,5,"Negativeur III",Angular.A00); + menu.setMenuTransmuter(0,4,"Inverseur I",Angular.A00); + menu.setMenuTransmuter(1,4,"Inverseur II",Angular.A00); + menu.setMenuTransmuter(0,3,"Neutraliseur I",Angular.A00); + menu.setMenuTransmuter(1,3,"Neutraliseur II",Angular.A00); } else if (menuitem==2) { - + } else if (menuitem==3) { - + } else if (menuitem==4) { - + } else if (menuitem==5) { - + } else if (menuitem==6) { - + } else if (menuitem==7) { - + menu.setMenuTransmuter(0,7,"Positiveur non activable",Angular.A00); + menu.setMenuTransmuter(1,7,"Negativeur non activable",Angular.A00); } } - + public void showInfo(Transmuter transmuter) { if (transmuter==null) - return; + return; unroll=true; info_nom.setText(transmuter.getName()); info_desc.setText(transmuter.getDesc()); @@ -731,11 +765,11 @@ public class GameScreen implements Screen { info_up_rayonval.getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("jauge"+transmuter.getUpgradeRayon())); info_up_rayonval.setColor(AssetLoader.Levelcolors[2]); } - + public void hideInfo() { unroll=false; } - + public void checkMenu(int menu,boolean check) { for (int i=0;i0) - font.draw(batcher2, "Récompenses", 1215, AssetLoader.height-15); + font.draw(batcher2, "Recompenses", 1215, AssetLoader.height-15); if (LevelScreen.selected!=null && LevelScreen.selected.level.Cout>0) { font.draw(batcher2, "Ressources", 1215, 145); font.draw(batcher2, "Objectifs", 1215, 295);