feat: ajout d'un composant worlds qui contient les mondes d'une campagne evite le rechargement des niveaux et garde le dernier niveau selectionné changement des méthodes qui concerne le déblocage et les upgrades des transmuteurs

This commit is contained in:
Nicolas Hordé 2016-01-28 00:54:35 +01:00
parent 0087776ff7
commit e33cf80443
31 changed files with 416 additions and 558 deletions

View File

@ -14,16 +14,18 @@ import fr.evolving.automata.Level;
public class ButtonLevel extends ImageTextButton {
public Level level;
public boolean Activated;
TextureRegion Finalled, Locked;
Label Thelabel;
float scale;
float ratio;
ImageTextButtonStyle style;
LabelStyle stylelabel;
private TextureRegion Finalled, Locked;
private Label Thelabel;
private float scale;
private float ratio;
private ImageTextButtonStyle style;
private LabelStyle stylelabel;
private boolean modifyxy;
public ButtonLevel(Level level, boolean Activated, float ratio) {
public ButtonLevel(Level level, boolean Activated, float ratio, boolean modifyxy) {
super(level.Name, AssetLoader.Skin_level, "world"
+ String.valueOf(level.aWorld));
this.modifyxy=modifyxy;
this.level = level;
this.ratio = ratio;
this.Activated = Activated;
@ -70,11 +72,12 @@ public class ButtonLevel extends ImageTextButton {
@Override
public void setPosition(float x, float y) {
super.setPosition(x, y);
if (modifyxy) {
level.X = x;
level.Y = y;
level.Y = y/ratio;
}
Thelabel.setColor(level.X / 1024f, level.X / 1024f, level.X / 1024f, 1f);
Thelabel.setPosition(level.X + 54 * scale,
level.Y * ratio + 20 * scale, Align.bottom | Align.center);
Thelabel.setPosition(x + 54 * scale,y + 20 * scale, Align.bottom | Align.center);
this.setColor(1f, 0.47f + (float) level.X / 1024f * 0.529f,
0.607f + (float) level.X / 768f * 0.392f, 1f);
}
@ -83,15 +86,15 @@ public class ButtonLevel extends ImageTextButton {
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
if (level.Special) {
batch.draw(Finalled, level.X, level.Y * ratio,
batch.draw(Finalled, getX(), getY() ,
Finalled.getRegionWidth() * scale,
Finalled.getRegionHeight() * scale);
}
if (!Activated) {
batch.draw(
Locked,
level.X + this.getWidth() - Locked.getRegionWidth(),
level.Y * ratio + this.getHeight()
getX() + this.getWidth() - Locked.getRegionWidth(),
getY() + this.getHeight()
- Locked.getRegionHeight(), Locked.getRegionWidth()
* scale, Locked.getRegionHeight() * scale);
}

View File

@ -16,7 +16,7 @@ public class Worldlist extends List {
public void Refresh() {
Array<String> worlds = null;
if (AssetLoader.Datahandler.game() != null)
worlds = AssetLoader.Datahandler.game().getworlds();
worlds = AssetLoader.Datahandler.game().getCampaigns();
if (worlds == null)
worlds = new Array<String>();
this.setItems(worlds);

View File

@ -225,7 +225,6 @@ public class AssetLoader {
Datahandler.RegisterBackend(LocalBase.class);
Datahandler.RegisterBackend(SqlBase.class);
Databasemanagerfrompref();
Gdx.app.log("init", "Ok");
}
public static void Databasemanagerfrompref() {

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Insufler100 extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -119,19 +120,6 @@ public class Insufler100 extends Transmuter {
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();
@ -219,14 +207,6 @@ public class Insufler100 extends Transmuter {
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;
}
@ -295,7 +275,7 @@ public class Insufler100 extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Insufler33 extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -49,7 +50,8 @@ public class Insufler33 extends Transmuter {
this.Technology = 3;
this.Research = 0;
this.Upgrade = null;
this.Unlock = new Insufler50(null);
this.Unlock = new Array<Transmuter>();
this.Unlock.add(new Insufler50(null));
this.showed = false;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = false;
@ -119,19 +121,6 @@ public class Insufler33 extends Transmuter {
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();
@ -219,14 +208,6 @@ public class Insufler33 extends Transmuter {
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;
}
@ -295,7 +276,7 @@ public class Insufler33 extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Insufler50 extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -49,7 +50,8 @@ public class Insufler50 extends Transmuter {
this.Technology = 3;
this.Research = 120;
this.Upgrade = null;
this.Unlock = new Insufler100(null);
this.Unlock = new Array<Transmuter>();
this.Unlock.add(new Insufler100(null));
this.showed = false;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = false;
@ -119,19 +121,6 @@ public class Insufler50 extends Transmuter {
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();
@ -219,14 +208,6 @@ public class Insufler50 extends Transmuter {
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;
}
@ -295,7 +276,7 @@ public class Insufler50 extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Inverter_I extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Inverter_I extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Inverter_I extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Inverter_I extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Inverter_II extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Inverter_II extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Inverter_II extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Inverter_II extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -25,6 +25,7 @@ public class Level implements Serializable {
public int Maxtemp;
public int Maxrayon;
public int Maxnrj;
public int Research;
public boolean Special;
public String Tuto;
public int[][] Link;

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Negativer extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Negativer extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Negativer extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Negativer extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Negativer_I extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -105,19 +106,6 @@ public class Negativer_I extends Transmuter {
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();
@ -205,14 +193,6 @@ public class Negativer_I extends Transmuter {
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;
}
@ -281,7 +261,7 @@ public class Negativer_I extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Negativer_II extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -105,19 +106,6 @@ public class Negativer_II extends Transmuter {
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();
@ -205,14 +193,6 @@ public class Negativer_II extends Transmuter {
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;
}
@ -281,7 +261,7 @@ public class Negativer_II extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Negativer_III extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Negativer_III extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Negativer_III extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Negativer_III extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Neutraliser_I extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Neutraliser_I extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Neutraliser_I extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Neutraliser_I extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Neutraliser_II extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Neutraliser_II extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Neutraliser_II extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Neutraliser_II extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Oneway extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -49,7 +50,8 @@ public class Oneway extends Transmuter {
this.Technology = 5;
this.Research = 0;
this.Upgrade = null;
this.Unlock = new distributor(level);
this.Unlock = new Array<Transmuter>();
this.Unlock.add(new distributor(level));
this.showed = false;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = false;
@ -103,19 +105,6 @@ public class Oneway extends Transmuter {
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();
@ -203,14 +192,6 @@ public class Oneway extends Transmuter {
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;
}
@ -279,7 +260,7 @@ public class Oneway extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Positiver extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -103,19 +104,6 @@ public class Positiver extends Transmuter {
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();
@ -203,14 +191,6 @@ public class Positiver extends Transmuter {
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;
}
@ -279,7 +259,7 @@ public class Positiver extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Positiver_I extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -105,19 +106,6 @@ public class Positiver_I extends Transmuter {
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();
@ -205,14 +193,6 @@ public class Positiver_I extends Transmuter {
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;
}
@ -281,7 +261,7 @@ public class Positiver_I extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class Positiver_II extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -105,19 +106,6 @@ public class Positiver_II extends Transmuter {
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.Upgrade.SetShowed(true);
this.SetShowed(false);
}
public void Activate() {
if (this.Activable)
ActivationLevel = this.getMaxActivationLevel();
@ -205,14 +193,6 @@ public class Positiver_II extends Transmuter {
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;
}
@ -281,7 +261,7 @@ public class Positiver_II extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -15,7 +16,7 @@ public class Positiver_III extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -102,19 +103,6 @@ public class Positiver_III extends Transmuter {
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();
@ -202,14 +190,6 @@ public class Positiver_III extends Transmuter {
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;
}
@ -278,7 +258,7 @@ public class Positiver_III extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.io.Serializable;
import com.badlogic.gdx.math.Vector2;
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.ObjectMap.Values;
@ -39,8 +40,8 @@ public abstract class Transmuter implements Cloneable, Serializable {
A00, A90, A180, A270
};
protected Level level;
protected Angular Rotation;
protected transient Level level;
protected transient Angular Rotation;
public Transmuter(Level level) {
this.level = level;
@ -69,12 +70,6 @@ public abstract class Transmuter implements Cloneable, Serializable {
public void Run() {
}
public void Unlock() {
}
public void Upgrade() {
}
public void Activate() {
}
@ -134,11 +129,41 @@ public abstract class Transmuter implements Cloneable, Serializable {
return 0;
}
public boolean isUpgradable() {
return false;
public void Unlock(Transmuter transmuter) {
Array<Transmuter> transmuters=this.getUnlock();
if (transmuters != null) {
for(Transmuter transmuter2:transmuters) {
if (transmuter2==transmuter)
transmuter.SetShowed(true);
}
}
}
public boolean isUnlockable() {
public void Unlock() {
this.SetShowed(true);
}
public void Upgrade() {
Transmuter transmuter=this.getUpgrade();
if (transmuter == null)
return;
transmuter.SetShowed(true);
this.SetShowed(false);
}
public boolean isUpgradable(int value) {
Transmuter transmuter=this.getUpgrade();
return transmuter!= null && !transmuter.isShowed() && transmuter.getResearch()>=value;
}
public boolean isUnlockable(int value) {
Array<Transmuter> transmuters=this.getUnlock();
if (transmuters != null) {
for(Transmuter transmuter:transmuters) {
if (!transmuter.isShowed() && transmuter.getResearch()>=value)
return true;
}
}
return false;
}
@ -173,7 +198,7 @@ public abstract class Transmuter implements Cloneable, Serializable {
return null;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return null;
}
@ -242,11 +267,11 @@ public abstract class Transmuter implements Cloneable, Serializable {
+ " Visible:"
+ this.isShowed()
+ "\nUpgradable:"
+ ((this.isUpgradable()) ? this.getUpgrade().getName() : this
.isUpgradable())
+ ((this.isUpgradable(0)) ? this.getUpgrade().getName() : this
.isUpgradable(0))
+ " Unlockable:"
+ ((this.isUnlockable()) ? this.getUnlock().getName() : this
.isUnlockable()) + "\nUpgrade Cycle:"
+ ((this.isUnlockable(0)) ? this.getUnlock().size : this
.isUnlockable(0)) + "\nUpgrade Cycle:"
+ this.getUpgradeCycle() + " upgrade:"
+ this.isUpgradableCycle() + "\nUpgrade Temperature:"
+ this.getUpgradeTemp() + " upgrade:" + this.isUpgradableTemp()

View File

@ -0,0 +1,192 @@
package fr.evolving.automata;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent;
import com.badlogic.gdx.utils.Array;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.InitWorlds;
import fr.evolving.assets.Preference;
public class Worlds extends Actor {
private ChangeEvent event;
private Array<Level> levels;
private String name;
private int usedworld;
private Level usedlevel;
private Array<Transmuter> Transmuters;
private State state;
public enum State {pause,simulating,notloaded,databasefailed};
public Worlds(String campaign) {
name=campaign;
init();
}
public void init() {
levels=null;
usedworld=-1;
usedlevel=null;
if (!AssetLoader.Datahandler.verifyall()) {
Gdx.app.debug(getClass().getSimpleName(),"Pilotes de bases de donnée défaillant.");
state=State.databasefailed;
}
else
state=State.notloaded;
this.load(name);
if (state==State.notloaded)
this.init(name);
onchanged();
}
public void SaveGrid() {
if (usedlevel!=null)
AssetLoader.Datahandler.user().setGrid(0, usedlevel.id, usedlevel.Grid);
}
public void SaveLastGrid() {
if (usedlevel!=null)
AssetLoader.Datahandler.user().setGrid(0, usedlevel.id, "LAST", usedlevel.Grid);
}
public void Forcereload() {
onchanged();
}
public void onchanged() {
ChangeEvent event=new ChangeEvent();
event.setTarget(this);
event.setListenerActor(this);
event.setStage(this.getStage());
if (event.getStage()!=null)
this.fire(event);
}
public Array<Level> getLevels() {
Array<Level> tempworld=new Array<Level>();
if (state!=State.notloaded && this.levels!=null)
{
for(Level level:levels)
if (level!=null && level.aWorld==usedworld)
tempworld.add(level);
return tempworld;
}
else
return null;
}
public State getState() {
return state;
}
public void setLevel(int alevel) {
if (state!=State.notloaded)
if (usedworld>=0) {
Array<Level> tempworld=getLevels();
for(Level level:tempworld)
if (level.aLevel==alevel)
{
usedlevel=level;
return;
}
}
}
public Level getInformations() {
return usedlevel;
}
public int getLevel() {
return usedlevel.aLevel;
}
public void delLevel() {
usedlevel=null;
}
public void setWorld(int world) {
if (state!=State.notloaded)
if (world<getMaxWorlds()) {
usedworld=world;
onchanged();
}
}
public void NextWorld() {
if (state!=State.notloaded)
if (usedworld<getMaxWorlds()-1) {
usedworld++;
onchanged();
}
}
public void PreviousWorld() {
if (state!=State.notloaded)
if (usedworld>0) {
usedworld--;
onchanged();
}
}
public int getWorld() {
if (state!=State.notloaded)
return usedworld;
else
return -1;
}
public void set(String campaign) {
Gdx.app.log("*****", "Définition de la compagne "+campaign);
Preference.prefs.putString("world", campaign);
Preference.prefs.flush();
load(campaign);
}
public void load(String campaign) {
Gdx.app.log("*****", "Chargement de la compagne "+campaign);
levels=AssetLoader.Datahandler.game().getCampaign(campaign);
name=campaign;
if (levels==null)
{
state=State.notloaded;
}
else
state=State.pause;
}
public void init(String campaign) {
Gdx.app.log("*****", "initialisation de la compagne "+campaign);
try {
levels=InitWorlds.go();
Preference.prefs.putString("world",campaign);
Preference.prefs.flush();
name=campaign;
AssetLoader.Datahandler.game().setCampaign(levels,name);
state=State.pause;
}
catch (Exception e) {
state=State.notloaded;
}
}
public void save(String campaign) {
Gdx.app.log("*****", "enregistrement de la compagne "+campaign);
AssetLoader.Datahandler.game().setCampaign(levels,campaign);
}
public int getMaxWorlds() {
int max = 0;
for (Level level : levels)
if (level != null && level.aWorld > max)
max = level.aWorld;
return max;
}
public String getName() {
return this.name;
}
}

View File

@ -3,6 +3,7 @@ package fr.evolving.automata;
import java.util.Iterator;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
@ -16,7 +17,7 @@ public class distributor extends Transmuter {
private static int Technology;
private static int Research;
private static Transmuter Upgrade;
private static Transmuter Unlock;
private static Array<Transmuter> Unlock;
private static boolean showed;
private static boolean CanUpgradeTemp;
private static boolean CanUpgradeCycle;
@ -111,18 +112,6 @@ public class distributor extends Transmuter {
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)
@ -211,14 +200,6 @@ public class distributor extends Transmuter {
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;
}
@ -287,7 +268,7 @@ public class distributor extends Transmuter {
return this.Upgrade;
}
public Transmuter getUnlock() {
public Array<Transmuter> getUnlock() {
return this.Unlock;
}

View File

@ -23,28 +23,28 @@ public abstract class Base {
// Gestion type Gamebase
public Array<String> getworlds() {
public Array<String> getCampaigns() {
return null;
}
public Array<Level> getworld(String description) {
public Array<Level> getCampaign(String description) {
return null;
}
public boolean setworld(Array<Level> world, String description) {
public boolean setCampaign(Array<Level> campaign, String description) {
return false;
}
public boolean deleteworld(String description) {
public boolean deleteCampaign(String description) {
return false;
}
// Gestion type Userbase
public boolean getlevellock(int user, int level) {
public boolean getLevellock(int user, int level) {
return false;
}
public boolean setlevelunlock(int user, int level) {
public boolean setLevelunlock(int user, int level) {
return false;
}
@ -99,7 +99,7 @@ public abstract class Base {
public void Close() {
}
public String getprefix() {
public String getPrefix() {
return "";
}

View File

@ -71,7 +71,7 @@ public class DatabaseManager {
Base back;
try {
back = (Base) classe.newInstance();
if (back.getprefix().equals(Type)) {
if (back.getPrefix().equals(Type)) {
back = (Base) classe.getDeclaredConstructor(cArg)
.newInstance(model, Url);
return back;
@ -92,7 +92,7 @@ public class DatabaseManager {
Base back;
try {
back = (Base) classe.newInstance();
if (back.getprefix().equals(Type))
if (back.getPrefix().equals(Type))
return true;
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | SecurityException e) {

View File

@ -101,7 +101,7 @@ public class LocalBase extends Base {
// Gestion model type gamedata
public Array<String> getworlds() {
public Array<String> getCampaigns() {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select desc,date from worlds;");
@ -114,7 +114,7 @@ public class LocalBase extends Base {
return returnvalue;
}
public Array<Level> getworld(String description) {
public Array<Level> getCampaign(String description) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler
@ -138,7 +138,7 @@ public class LocalBase extends Base {
return null;
}
public boolean deleteworld(String description) {
public boolean deleteCampaign(String description) {
try {
dbHandler.rawQuery("delete from worlds where desc='" + description
+ "';");
@ -148,7 +148,7 @@ public class LocalBase extends Base {
return true;
}
public boolean setworld(Array<Level> world, String description) {
public boolean setCampaign(Array<Level> world, String description) {
String encoded = "";
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -169,7 +169,7 @@ public class LocalBase extends Base {
// Gestion de données type userdata
public boolean getlevellock(int user, int level) {
public boolean getLevellock(int user, int level) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select user from locks where user="
@ -183,7 +183,7 @@ public class LocalBase extends Base {
return false;
}
public boolean setlevelunlock(int user, int level) {
public boolean setLevelunlock(int user, int level) {
try {
dbHandler.rawQuery("insert into locks (user,level) values (" + user
+ "," + level + ");");
@ -317,29 +317,19 @@ public class LocalBase extends Base {
public boolean setGrid(int user, int level, Grid data) {
String encoded = "";
try {
Gdx.app.log("Base", "Infos:"+user+","+level);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Gdx.app.log("Base", "CK1");
ObjectOutputStream oos = new ObjectOutputStream(bos);
Gdx.app.log("Base", "CK2");
oos.writeObject(data);
Gdx.app.log("Base", "CK3");
oos.flush();
Gdx.app.log("Base", "CK4");
oos.close();
bos.close();
byte[] bytes = bos.toByteArray();
Gdx.app.log("Base", "size"+bytes.length);
encoded = Base64Coder.encodeLines(bytes);
Gdx.app.log("Base", "size2"+encoded.length());
dbHandler.rawQuery("insert into grids (user,level,object) values ("
+ user + "," + level + ",'" + encoded + "');");
Gdx.app.log("Base", "CK5");
} catch (Exception e) {
Gdx.app.log("Base", "cancel");
return false;
}
Gdx.app.log("Base", "Ok");
return true;
}
@ -419,7 +409,7 @@ public class LocalBase extends Base {
}
}
public String getprefix() {
public String getPrefix() {
return "local";
}

View File

@ -9,7 +9,7 @@ public class SqlBase extends Base {
public SqlBase() {
}
public String getprefix() {
public String getPrefix() {
return "mysql";
}

View File

@ -27,10 +27,6 @@ public class LevelRenderer {
BitmapFont font;
String reward,goal,ressource,handicap;
public LevelRenderer(LevelScreen LevelScreen) {
this.reward=AssetLoader.language.get("[reward-levelscreen]");
this.goal=AssetLoader.language.get("[goal-levelscreen]");
@ -71,8 +67,8 @@ public class LevelRenderer {
public void render(float delta, float runTime) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
if (LevelScreen.world >= 0)
font.setColor(AssetLoader.Levelcolors[LevelScreen.world]);
if (LevelScreen.worlds.getWorld() >= 0)
font.setColor(AssetLoader.Levelcolors[LevelScreen.worlds.getWorld()]);
batcher.begin();
batcher.setProjectionMatrix(AssetLoader.Camera.combined);
batcher.setColor(0.25f, 0.25f, 0.25f, 1f);

View File

@ -67,6 +67,7 @@ import fr.evolving.automata.Neutraliser_II;
import fr.evolving.automata.Transmuter;
import fr.evolving.automata.Transmuter.Angular;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Worlds;
import fr.evolving.renderers.GameRenderer;
public class GameScreen implements Screen {
@ -105,6 +106,7 @@ public class GameScreen implements Screen {
private Label fpsLabel, info_nom;
private TextArea info_desc, tooltip;
public boolean unroll;
private Worlds worlds;
public enum calling {
mouseover, mouseclick, mousedrag, longpress, tap, taptap, zoom, fling, pan, pinch
@ -198,13 +200,12 @@ public class GameScreen implements Screen {
GestureDetector gesturedetector;
// This is the constructor, not the class declaration
public GameScreen(Level alevel) {
public GameScreen(Worlds aworlds) {
Gdx.app.log("game", "Ok");
this.level = alevel;
Gdx.app.debug(getClass().getSimpleName(),
"Récupération des derniers niveaux.");
this.level.Grid = AssetLoader.Datahandler.user().getGrid(0,
this.level.id, "LAST");
this.worlds = aworlds;
this.level=worlds.getInformations();
Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux.");
this.level.Grid = AssetLoader.Datahandler.user().getGrid(0, this.level.id, "LAST");
if (this.level.Grid == null) {
Gdx.app.debug(getClass().getSimpleName(), "Copie monde original.");
this.level.Grid = this.level.Grid_orig;
@ -223,7 +224,6 @@ public class GameScreen implements Screen {
Gdx.app.debug("Barre", "Element changé");
hideInfo();
map.tempclear();
//map.fillempty(60);
menu.unSelect();
map.setSelected(getselected());
}
@ -244,8 +244,7 @@ public class GameScreen implements Screen {
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);
Gdx.app.debug(getClass().getSimpleName(),
"Création de la barre de gestion du haut");
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.setVisible(level.aWorld>=1);
cycle.setPosition(10, AssetLoader.height - 74);
@ -271,7 +270,7 @@ public class GameScreen implements Screen {
objectives.setVictory(level.Victory);
objectives.setPosition(890, AssetLoader.height - 95);
objectives.setVisible(level.Cout>0);
buttonlevel = new ButtonLevel(level, true, 1.0f);
buttonlevel = new ButtonLevel(level, true, 1.0f, false);
buttonlevel.setPosition(1760, AssetLoader.height - 125);
buttonlevel.addListener(new ClickListener() {
@Override
@ -328,7 +327,7 @@ public class GameScreen implements Screen {
info_up.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (menu.getTransmuter()!=null && menu.getTransmuter().isUpgradable())
if (menu.getTransmuter()!=null && menu.getTransmuter().isUpgradable(0))
menu.getTransmuter().Upgrade();
}
});
@ -352,7 +351,6 @@ public class GameScreen implements Screen {
menu.NextPage();
Gdx.app.debug("menu", "Page suivante:"+menu.getPage());
map.tempclear();
//map.fillempty(53);
hideInfo();
nextpage.setDisabled(menu.isNextEmpty());
previouspage.setDisabled(menu.isPreviousEmpty());
@ -368,7 +366,6 @@ public class GameScreen implements Screen {
menu.PreviousPage();
Gdx.app.debug("menu", "Page précédente:"+menu.getPage());
map.tempclear();
//map.fillempty(53);
hideInfo();
nextpage.setDisabled(menu.isNextEmpty());
previouspage.setDisabled(menu.isPreviousEmpty());
@ -383,7 +380,6 @@ public class GameScreen implements Screen {
Gdx.app.debug("Menu", "Element changé");
hideInfo();
map.tempclear();
//map.fillempty(60);
if (menu.getTransmuter() != null)
showInfo(menu.getTransmuter());
else
@ -700,7 +696,6 @@ public class GameScreen implements Screen {
}
public void preparebarre(String caller, int count) {
//map.fillempty(53);
map.tempclear();
menu.EraseSurtile();
hideInfo();
@ -725,21 +720,17 @@ public class GameScreen implements Screen {
if (winSave.isVisible())
readsaved();
} else if (caller == "save") {
Gdx.app.log("save", "Ok");
Gdx.app.debug("Barre", "Sauvegarde de la grille.");
Gdx.app.debug("Barre", AssetLoader.Datahandler.user().toString());
AssetLoader.Datahandler.user().setGrid(0, level.id, level.Grid);
worlds.SaveGrid();
readsaved();
} else if (caller == "levels") {
Gdx.app.debug("Barre", "Affichage des niveaux.");
AssetLoader.Datahandler.user().setGrid(0, level.id, "LAST",
this.level.Grid);
((Game) Gdx.app.getApplicationListener())
.setScreen(new LevelScreen(level.aWorld));
worlds.SaveLastGrid();
((Game) Gdx.app.getApplicationListener()).setScreen(new LevelScreen(worlds));
} else if (caller == "tree") {
} else if (caller == "exits") {
AssetLoader.Datahandler.user().setGrid(0, level.id, "LAST",
this.level.Grid);
worlds.SaveLastGrid();
Gdx.app.exit();
} else if (caller == "screen") {
DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode();
@ -799,7 +790,6 @@ public class GameScreen implements Screen {
public void preparemenu(int menuitem) {
map.tempclear();
//map.fillempty(53);
horizbar.unSelect();
menu.setPageType(0,menuitem);
nextpage.setDisabled(menu.isNextEmpty());
@ -820,8 +810,7 @@ public class GameScreen implements Screen {
info_research.setVisible(transmuter.getResearch() > 0);
info_research.setText(String.valueOf(transmuter.getResearch()));
info_activation.setVisible(transmuter.isActivable());
info_activation.setText(String.valueOf(transmuter
.getMaxActivationLevel()));
info_activation.setText(String.valueOf(transmuter.getMaxActivationLevel()));
info_up_cycle.setVisible(transmuter.isUpgradableCycle());
info_up_nrj.setVisible(transmuter.isUpgradableNrj());
info_up_temp.setVisible(transmuter.isUpgradableTemp());
@ -846,6 +835,8 @@ public class GameScreen implements Screen {
AssetLoader.Atlas_level.findRegion("jauge"
+ transmuter.getUpgradeRayon()));
info_up_rayonval.setColor(AssetLoader.Levelcolors[2]);
info_up.setVisible(transmuter.isUnlockable(0)||transmuter.isUpgradable(0));
}
public void hideInfo() {

View File

@ -18,7 +18,9 @@ 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.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent;
import com.badlogic.gdx.utils.Array;
import fr.evolving.UI.ButtonLevel;
@ -30,6 +32,8 @@ import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.InitWorlds;
import fr.evolving.assets.Preference;
import fr.evolving.automata.Level;
import fr.evolving.automata.Worlds;
import fr.evolving.automata.Worlds.State;
import fr.evolving.database.Base;
import fr.evolving.renderers.LevelRenderer;
@ -51,48 +55,18 @@ public class LevelScreen implements Screen {
private ServerList Statdata, Userdata, Gamedata;
private Worldlist Worlddata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel;
private Array<Level> thelevels;
private TextArea TextDescriptive;
public int world;
public Worlds worlds;
private Objectives Victory;
public ButtonLevel selected;
public int getMaxWorld() {
int max = 0;
for (Level level : thelevels)
if (level != null && level.aWorld > max)
max = level.aWorld;
return max;
}
public void play() {
if (!AssetLoader.Datahandler.verifyall())
Gdx.app.debug(getClass().getSimpleName(),
"Pilotes de bases de donnée défaillant.");
else {
Gdx.app.debug(getClass().getSimpleName(),
"Chargement des mondes depuis la base.");
try {
if (world < 0)
world = 0;
thelevels = AssetLoader.Datahandler.game().getworld(
Preference.prefs.getString("world"));
/*
thelevels= InitWorlds.go();
AssetLoader.Datahandler.game().setworld
(thelevels,Preference.prefs.getString("world"));
*/
loadWorld(world);
Previous.setVisible(true);
Next.setVisible(true);
buttonPlay.setVisible(true);
TextDescriptive.setVisible(true);
} catch (Exception e) {
Previous.setVisible(false);
Next.setVisible(false);
buttonPlay.setVisible(false);
TextDescriptive.setVisible(false);
}
if (worlds.getState()!=State.notloaded && worlds.getState()!=State.databasefailed) {
Gdx.app.debug(getClass().getSimpleName(),"Afficher le monde 0");
if (worlds.getWorld() < 0)
worlds.setWorld(0);
worlds.Forcereload();
}
}
@ -180,7 +154,6 @@ public class LevelScreen implements Screen {
buttonConnect.setVisible(true);
buttonStat.setVisible(true);
SetButtonStat();
if (Preference.prefs.contains("world"))
play();
}
@ -217,7 +190,7 @@ public class LevelScreen implements Screen {
buttonPlaythis.setVisible(false);
}
public void loadWorld(int aworld) {
public void loadWorld() {
int i = 0;
if (buttonLevels != null)
for (int j = 0; j < 10; j++) {
@ -228,14 +201,13 @@ public class LevelScreen implements Screen {
}
buttonLevels = null;
buttonLevels = new ButtonLevel[10];
for (Level level : thelevels) {
if (level != null && level.aWorld == aworld) {
for (Level level : worlds.getLevels()) {
if (level != null) {
if (level.Name.isEmpty())
level.Name=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-name]");
if (level.Description.isEmpty())
level.Description=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-desc]");
buttonLevels[i] = new ButtonLevel(level, true,
AssetLoader.ratio);
buttonLevels[i] = new ButtonLevel(level, true, AssetLoader.ratio, true);
Gdx.app.debug(getClass().getSimpleName(), "Ajout du niveau :"
+ level.Name + "" + String.valueOf(level.aLevel));
buttonLevels[i++].addListener(new ClickListener() {
@ -278,14 +250,43 @@ public class LevelScreen implements Screen {
}
}
Gdx.app.debug(getClass().getSimpleName(), "Mise en place du level 0.");
world = world;
buttonLevels[0].setChecked(true);
showlevel(buttonLevels[0]);
}
public LevelScreen(int aworld) {
Gdx.app.log("level", "Ok");
this.world = aworld;
public LevelScreen(Worlds aworlds) {
this.worlds = aworlds;
worlds.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (worlds.getState()!=Worlds.State.notloaded && worlds.getWorld()>=0)
{
LevelScreen.this.loadWorld();
if (buttonLevels!=null)
for (int j = 0; j < 10; j++)
{
if (buttonLevels[j]!=null) {
buttonLevels[j].setChecked(false);
if (worlds.getInformations()!=null && buttonLevels[j].level.id == worlds.getInformations().id) {
selected=buttonLevels[j];
selected.setChecked(true);
break;
}
}
}
Previous.setVisible(true);
Next.setVisible(true);
buttonPlay.setVisible(true);
TextDescriptive.setVisible(true);
}
else {
Previous.setVisible(false);
Next.setVisible(false);
buttonPlay.setVisible(false);
TextDescriptive.setVisible(false);
}
}
});
Gdx.app.debug(getClass().getSimpleName(),
"Création des elements primordiaux du screen (stage, renderer, table)");
stage = new Stage(AssetLoader.viewport);
@ -371,8 +372,7 @@ public class LevelScreen implements Screen {
AssetLoader.Datahandler.Attach(Gamedata.getModel(),
Gamedata.getUrl());
if (!AssetLoader.Datahandler.verifyall()) {
dialog.Show(
AssetLoader.language.get("[dialog-levelscreen-errorloading]"),stage);
dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errorloading]"),stage);
initlevel();
} else
menu();
@ -389,6 +389,7 @@ public class LevelScreen implements Screen {
else
Userdata.setColor(1f, 1f, 1f, 1f);
Worlddata.Refresh();
worlds.init();
}
});
buttonSave = new TextButton(AssetLoader.language.get("[buttonSave-levelscreen]"), AssetLoader.Skin_ui);
@ -399,6 +400,7 @@ public class LevelScreen implements Screen {
Preference.prefs.putString("userdata", Userdata.getUrl());
Preference.prefs.putString("gamedata", Gamedata.getUrl());
Preference.prefs.putString("statdata", Statdata.getUrl());
Preference.prefs.flush();
dialog.Show(
AssetLoader.language.get("[dialog-levelscreen-savedatabase]"),stage);
}
@ -416,8 +418,8 @@ public class LevelScreen implements Screen {
buttonPlay.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
((Game) Gdx.app.getApplicationListener())
.setScreen(new GameScreen(selected.level));
worlds.setLevel(selected.level.aLevel);
((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen(worlds));
}
});
buttonStat = new TextButton(AssetLoader.language.get("[buttonStat-levelscreen]"), AssetLoader.Skin_ui);
@ -429,7 +431,7 @@ public class LevelScreen implements Screen {
}
});
buttonPlaythis = new TextButton(AssetLoader.language.get("[buttonPlaythis-levelscreen]"), AssetLoader.Skin_ui);
buttonPlaythis.setBounds(1480, 50, 190, 40);
buttonPlaythis.setBounds(1480, 50, 230, 40);
buttonPlaythis.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (!AssetLoader.Datahandler.verifyall())
@ -438,8 +440,7 @@ public class LevelScreen implements Screen {
if (Worlddata.getSelected() == null)
dialog.Show(AssetLoader.language.get("[dialog-levelscreen-errornoworld]"), stage);
else {
Preference.prefs.putString("world",
(String) Worlddata.getSelected());
worlds.set((String) Worlddata.getSelected());
Preference.prefs.flush();
play();
}
@ -462,13 +463,10 @@ public class LevelScreen implements Screen {
Next.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (world < getMaxWorld()) {
world++;
loadWorld(world);
}
worlds.NextWorld();
Gdx.app.debug(event.getListenerActor().toString(),
"World:" + String.valueOf(world) + " Maxworld:"
+ String.valueOf(getMaxWorld()));
"World:" + String.valueOf(worlds.getWorld()) + " Maxworld:"
+ String.valueOf(worlds.getMaxWorlds()));
}
});
Previous = new ImageButton(AssetLoader.Skin_level, "Previous");
@ -476,13 +474,10 @@ public class LevelScreen implements Screen {
Previous.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (world > 0) {
world--;
loadWorld(world);
}
worlds.PreviousWorld();
Gdx.app.debug(event.getListenerActor().toString(),
"World:" + String.valueOf(world) + " Maxworld:"
+ String.valueOf(getMaxWorld()));
"World:" + String.valueOf(worlds.getWorld()) + " Maxworld:"
+ String.valueOf(worlds.getMaxWorlds()));
}
});
cout = new ImageTextButton("5", AssetLoader.Skin_level, "cout");
@ -530,7 +525,7 @@ public class LevelScreen implements Screen {
Userdata.Refresh();
Gamedata.Refresh();
Gdx.app.debug(getClass().getSimpleName(), "Affichage du menu.");
if (aworld != -1)
if (worlds.getWorld() != -1)
level();
else
menu();
@ -553,6 +548,7 @@ public class LevelScreen implements Screen {
public void show() {
Gdx.app.log("*****", "Affichage du choix des mondes & niveaux.");
table.setFillParent(true);
stage.addActor(worlds);
stage.addActor(MenuSolo);
stage.addActor(MenuMulti);
stage.addActor(MenuScenario);

View File

@ -10,6 +10,8 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.Preference;
import fr.evolving.automata.Worlds;
import fr.evolving.game.main;
public class SplashScreen implements Screen {
@ -48,8 +50,7 @@ public class SplashScreen implements Screen {
}), Actions.run(new Runnable() {
@Override
public void run() {
((Game) Gdx.app.getApplicationListener())
.setScreen(new LevelScreen(-1));
((Game) Gdx.app.getApplicationListener()).setScreen(new LevelScreen(new Worlds(Preference.prefs.getString("world"))));
}
})));
}