From 9a537e2839d475e519d440aee1e48b289a8a4439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Wed, 3 Feb 2016 15:57:00 +0100 Subject: [PATCH] feat: ajout de la gestion de l'argent. --- core/src/fr/evolving/UI/IconValue.java | 9 ++++++- core/src/fr/evolving/automata/Grid.java | 21 ++++++++++++---- core/src/fr/evolving/automata/Level.java | 4 +++- core/src/fr/evolving/automata/Worlds.java | 2 ++ core/src/fr/evolving/screens/GameScreen.java | 25 ++++++++++---------- 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/core/src/fr/evolving/UI/IconValue.java b/core/src/fr/evolving/UI/IconValue.java index e8fb53e..ed74944 100644 --- a/core/src/fr/evolving/UI/IconValue.java +++ b/core/src/fr/evolving/UI/IconValue.java @@ -32,8 +32,15 @@ public class IconValue extends ImageTextButton{ this.setVisible(worlds.getInformations().Tech>=1); break; case cout: + worlds.getInformations().Cout=worlds.getInformations().Cout_orig-worlds.getInformations().Cout_copperfiber-worlds.getInformations().Cout_transmuter; this.setText(String.valueOf(worlds.getInformations().Cout)); - this.setVisible(worlds.getInformations().Cout>0); + if (worlds.getInformations().Cout>0.25*worlds.getInformations().Cout_orig) + this.setColor(1f, 1f, 1f, 1f); + else if (worlds.getInformations().Cout>0) + this.setColor(1f, 0.5f, 0.5f, 1f); + else + this.setColor(1f, 0, 0, 1f); + this.setVisible(worlds.getInformations().Cout_orig>0); break; case research: this.setText(String.valueOf(worlds.ReadResearch())); diff --git a/core/src/fr/evolving/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java index b9aa84f..6d19483 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -22,10 +22,15 @@ public class Grid implements Serializable { } } - public void tiling_transmuter() { + public int tiling_transmuter() { + int result=0; for (int x = 0; x < this.sizeX; x++) for (int y = 0; y < this.sizeY; y++) + { GetXY(x, y).Transmuter_calc = 0; + if (GetXY(x, y).Transmuter!=null) + result+=GetXY(x, y).Transmuter.getPrice(); + } for (int x = 0; x < this.sizeX; x++) for (int y = 0; y < this.sizeY; y++) { Transmuter transmuter = getTransmuter(x, y); @@ -48,12 +53,19 @@ public class Grid implements Serializable { Gdx.app.debug("info", x + "," + y + ">" + GetXY(x, y).Transmuter_calc); } + return result; } - public void tiling_copper() { + public int tiling_copper() { + int result=0; for (int x = 0; x < this.sizeX; x++) - for (int y = 0; y < this.sizeY; y++) + for (int y = 0; y < this.sizeY; y++) { + if (getFiber(x,y)) + result+=5; if (getCopper(x, y)) { + result++; + if (getFiber(x,y)) + result+=45; int value = 0; if (getCopper(x, y + 1)) value++; @@ -66,6 +78,7 @@ public class Grid implements Serializable { GetXY(x, y).Copper_calc = value; } else GetXY(x, y).Copper_calc = -1; + } for (int x = 0; x < this.sizeX; x++) for (int y = 0; y < this.sizeY; y++) { int value = 0; @@ -199,7 +212,7 @@ public class Grid implements Serializable { GetXY(x, y).Copper_calc = value; } - return; + return result; } public Cell GetXY(float X, float Y) { diff --git a/core/src/fr/evolving/automata/Level.java b/core/src/fr/evolving/automata/Level.java index 4fecdb4..14a69ea 100644 --- a/core/src/fr/evolving/automata/Level.java +++ b/core/src/fr/evolving/automata/Level.java @@ -30,7 +30,9 @@ public class Level implements Serializable { public int Nrj_orig; public transient int[] Victory; - public transient int Cout; + public transient int Cout_transmuter; + public transient int Cout_copperfiber; + public transient int Cout; public transient Grid Grid; public transient int Cycle; public transient int Temp; diff --git a/core/src/fr/evolving/automata/Worlds.java b/core/src/fr/evolving/automata/Worlds.java index 07d370e..030ac6f 100644 --- a/core/src/fr/evolving/automata/Worlds.java +++ b/core/src/fr/evolving/automata/Worlds.java @@ -309,6 +309,7 @@ public class Worlds extends Actor { public int getMaxUnlockWorlds() { int maxworld=0; + if (levels!=null) for (Level level : levels) if (!level.Locked && level.aWorld>maxworld) maxworld=level.aWorld; @@ -319,6 +320,7 @@ public class Worlds extends Actor { Array tempworld=getLevels(); int maxlevel=0; Level themaxlevel=null; + if (tempworld!=null) for (Level level : tempworld) if (!level.Locked && level.aLevel>maxlevel) { maxlevel=level.aLevel; diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index 86ab07d..699763e 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -447,7 +447,7 @@ public class GameScreen implements Screen { level.Grid.GetXY(x, y).Transmuter = (Transmuter) menu.getTransmuter() .clone(); if (alone) - level.Grid.tiling_transmuter(); + level.Cout_transmuter=level.Grid.tiling_transmuter(); map.redraw(); Gdx.input.vibrate(new long[] { 0, 200, 200, 200 }, -1); } @@ -516,13 +516,13 @@ public class GameScreen implements Screen { for (x = 0; x < level.Grid.sizeX; x++) for (y = 0; y < level.Grid.sizeY; y++) map_transmuter_eraser(0, 0, x, y, false, button, call); - level.Grid.tiling_transmuter(); + level.Cout_transmuter=level.Grid.tiling_transmuter(); for (x = 0; x < level.Grid.sizeX; x++) for (y = 0; y < level.Grid.sizeY; y++) { map_fiber_eraser(0, 0, x, y, false, button, call); map_copper_eraser(0, 0, x, y, false, button, call); } - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } @@ -545,7 +545,7 @@ public class GameScreen implements Screen { + (y + level.Grid.GetXY(x, y).Transmuter_movey)); } if (alone) { - level.Grid.tiling_transmuter(); + level.Cout_transmuter=level.Grid.tiling_transmuter(); map.redraw(); } } @@ -555,7 +555,7 @@ public class GameScreen implements Screen { if (level.Grid.GetXY(x, y).Transmuter_calc == 0) { level.Grid.GetXY(x, y).Fiber = 0; if (alone) { - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } } @@ -567,7 +567,7 @@ public class GameScreen implements Screen { level.Grid.GetXY(x, y).Fiber = -1 * level.Grid.GetXY(x, y).Fiber + 1; if (alone) { - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } } @@ -577,7 +577,7 @@ public class GameScreen implements Screen { if (level.Grid.GetXY(x, y).Transmuter_calc == 0) level.Grid.GetXY(x, y).Fiber = 1; if (alone) { - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } } @@ -587,7 +587,7 @@ public class GameScreen implements Screen { if (level.Grid.GetXY(x, y).Transmuter_calc == 0) { level.Grid.GetXY(x, y).Copper = false; if (alone) { - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } } @@ -598,7 +598,7 @@ public class GameScreen implements Screen { if (level.Grid.GetXY(x, y).Transmuter_calc == 0) level.Grid.GetXY(x, y).Copper = !level.Grid.GetXY(x, y).Copper; if (alone) { - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } } @@ -608,7 +608,7 @@ public class GameScreen implements Screen { if (level.Grid.GetXY(x, y).Transmuter_calc == 0) level.Grid.GetXY(x, y).Copper = true; if (alone) { - level.Grid.tiling_copper(); + level.Cout_copperfiber=level.Grid.tiling_copper(); map.redraw(); } } @@ -699,7 +699,6 @@ public class GameScreen implements Screen { menu.EraseSurtile(); hideInfo(); if (caller == "run") { - worlds.getInformations().Cout-=15; } else if (caller == "stop") { } else if (caller == "speed") { } else if (caller == "move") { @@ -877,8 +876,8 @@ public class GameScreen implements Screen { public void clicked(InputEvent event, float x, float y) { if (this.getTapCount() > 1) worlds.ReadGrid(selSaved.getSelectedIndex()); - level.Grid.tiling_copper(); - level.Grid.tiling_transmuter(); + level.Cout_copperfiber=level.Grid.tiling_copper(); + level.Cout_transmuter=level.Grid.tiling_transmuter(); map.redraw(); map.tempclear(); hideInfo();