feat: ajout de la gestion de l'argent.

This commit is contained in:
Nicolas Hordé 2016-02-03 15:57:00 +01:00
parent 487bf7d021
commit 9a537e2839
5 changed files with 42 additions and 19 deletions

View File

@ -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()));

View File

@ -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) {

View File

@ -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;

View File

@ -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<Level> tempworld=getLevels();
int maxlevel=0;
Level themaxlevel=null;
if (tempworld!=null)
for (Level level : tempworld)
if (!level.Locked && level.aLevel>maxlevel) {
maxlevel=level.aLevel;

View File

@ -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();