From 79f4246e8fbb77c71628fed70a7907e711316bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sun, 9 Oct 2016 14:02:39 +0200 Subject: [PATCH] feat: with the new sources --- core/src/fr/evolving/automata/Canon_I.java | 295 ++++++++++++++++++ core/src/fr/evolving/automata/Canon_II.java | 298 +++++++++++++++++++ core/src/fr/evolving/automata/Canon_III.java | 297 ++++++++++++++++++ core/src/fr/evolving/automata/Canon_IV.java | 295 ++++++++++++++++++ 4 files changed, 1185 insertions(+) create mode 100644 core/src/fr/evolving/automata/Canon_I.java create mode 100644 core/src/fr/evolving/automata/Canon_II.java create mode 100644 core/src/fr/evolving/automata/Canon_III.java create mode 100644 core/src/fr/evolving/automata/Canon_IV.java diff --git a/core/src/fr/evolving/automata/Canon_I.java b/core/src/fr/evolving/automata/Canon_I.java new file mode 100644 index 0000000..f86e1c5 --- /dev/null +++ b/core/src/fr/evolving/automata/Canon_I.java @@ -0,0 +1,295 @@ +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; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Particle.Charge; +import fr.evolving.automata.Particle.Orientation; +import fr.evolving.automata.Particle.Size; +import fr.evolving.automata.Particle.Type; +import fr.evolving.automata.Transmuter.Class; + +public class Canon_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 Array 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 transient int ActivationLevel; + private static String id; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Canon_I() { + super(); + this.id="->1"; + this.Name = AssetLoader.language.get("[canoni-name]"); + this.Desc = AssetLoader.language.get("[canoni-desc]"); + this.theClass = Class.Synthese; + this.Price = 50; + this.Technology = 1; + this.Research = 50; + this.Upgrade = new Canon_II(); + this.Unlock = null; + this.showed = true; + this.CanUpgradeTemp = true; + this.CanUpgradeCycle = false; + this.CanUpgradeRayon = false; + this.CanUpgradeNrj = true; + this.UpgradedTemp = 1f; + this.UpgradedCycle = 1f; + this.UpgradedRayon = 1f; + this.UpgradedNrj = 1f; + this.UsedTemp = 2f; + this.UsedRayon = 0f; + this.UsedNrj = 1f; + this.TurnTemp = 0f; + this.TurnRayon = 0f; + this.TurnNrj = 0f; + this.Activable = false; + 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), 176); + } + + public String getName() { + return this.Name; + } + + public String getID() { + return this.id; + } + + public String getDesc() { + return this.Desc; + } + + public Class getaClass() { + return this.theClass; + } + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + + public Particle ProcessCycle() { + this.level.Temp += TurnTemp * UpgradedTemp; + this.level.Rayon += TurnRayon * UpgradedRayon; + this.level.Nrj += TurnNrj * UpgradedNrj; + if (this.Activable) + if (this.ActivationLevel>0) this.ActivationLevel -= 1; + if (this.level.Cycle%10==0) { + Particle electron = new Particle(null); + electron.setType(Type.Electron); + electron.setSize(Size.Petit); + electron.setCharge(Charge.Neutre); + this.level.Temp += UsedTemp * UpgradedTemp; + this.level.Rayon += UsedRayon * UpgradedRayon; + this.level.Nrj += UsedNrj * UpgradedNrj; + return electron; + } + else + return null; + } + + public void Run(Particle particle) { + } + + public void Unactivate() { + if (this.Activable) + ActivationLevel = 0; + } + + 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 (int) (Transmuter.ACTIVATION_LIFE * 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 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 Array getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Canon_II.java b/core/src/fr/evolving/automata/Canon_II.java new file mode 100644 index 0000000..4646c6b --- /dev/null +++ b/core/src/fr/evolving/automata/Canon_II.java @@ -0,0 +1,298 @@ +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; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Particle.Charge; +import fr.evolving.automata.Particle.Size; +import fr.evolving.automata.Particle.Type; +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Canon_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 Array 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 transient int ActivationLevel; + private static String id; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Canon_II() { + super(); + this.id="->2"; + this.Name = AssetLoader.language.get("[canonii-name]"); + this.Desc = AssetLoader.language.get("[canonii-desc]"); + this.theClass = Class.Synthese; + this.Price = 100; + this.Technology = 1; + this.Research = 200; + this.Upgrade = new Canon_III(); + this.Unlock = null; + this.showed = false; + this.CanUpgradeTemp = true; + this.CanUpgradeCycle = false; + this.CanUpgradeRayon = false; + this.CanUpgradeNrj = true; + this.UpgradedTemp = 1f; + this.UpgradedCycle = 1f; + this.UpgradedRayon = 1f; + this.UpgradedNrj = 1f; + this.UsedTemp = 2f; + this.UsedRayon = 0f; + this.UsedNrj = 1f; + this.TurnTemp = 0f; + this.TurnRayon = 0f; + this.TurnNrj = 0f; + this.Activable = false; + this.ActivationLevel = 0; + this.Tilestype = new OrderedMap(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre); + this.Tilestype.put(new Vector2(1, 0), CaseType.Cuivre); + this.Tilesid = new OrderedMap(); + this.Tilesid.put(new Vector2(0, 0), 177); + this.Tilesid.put(new Vector2(1, 0), 105); + } + + public String getName() { + return this.Name; + } + + public String getID() { + return this.id; + } + + public String getDesc() { + return this.Desc; + } + + public Class getaClass() { + return this.theClass; + } + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + + public Particle ProcessCycle() { + this.level.Temp += TurnTemp * UpgradedTemp; + this.level.Rayon += TurnRayon * UpgradedRayon; + this.level.Nrj += TurnNrj * UpgradedNrj; + if (this.Activable) + if (this.ActivationLevel>0) this.ActivationLevel -= 1; + if (this.level.Cycle%10==0) { + Particle electron = new Particle(null); + electron.setType(Type.Electron); + electron.setSize(Size.Petit); + electron.setCharge(Charge.Neutre); + this.level.Temp += UsedTemp * UpgradedTemp; + this.level.Rayon += UsedRayon * UpgradedRayon; + this.level.Nrj += UsedNrj * UpgradedNrj; + return electron; + } + else + return null; + } + + public void Run(Particle particle) { + particle.ChargeInvert(); + } + + public void Unactivate() { + if (this.Activable) + ActivationLevel = 0; + } + + 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 (int) (Transmuter.ACTIVATION_LIFE * 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 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 Array getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Canon_III.java b/core/src/fr/evolving/automata/Canon_III.java new file mode 100644 index 0000000..65f7ac5 --- /dev/null +++ b/core/src/fr/evolving/automata/Canon_III.java @@ -0,0 +1,297 @@ +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; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Particle.Charge; +import fr.evolving.automata.Particle.Size; +import fr.evolving.automata.Particle.Type; +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Canon_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 Array 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 transient int ActivationLevel; + private static String id; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Canon_III() { + super(); + this.id="->3"; + this.Name = AssetLoader.language.get("[canoniii-name]"); + this.Desc = AssetLoader.language.get("[canoniii-desc]"); + this.theClass = Class.Synthese; + this.Price = 150; + this.Technology = 1; + this.Research = 400; + this.Upgrade = new Canon_IV(); + this.Unlock = null; + this.showed = false; + this.CanUpgradeTemp = true; + this.CanUpgradeCycle = false; + this.CanUpgradeRayon = false; + this.CanUpgradeNrj = true; + this.UpgradedTemp = 1f; + this.UpgradedCycle = 1f; + this.UpgradedRayon = 1f; + this.UpgradedNrj = 1f; + this.UsedTemp = 2f; + this.UsedRayon = 0f; + this.UsedNrj = 1f; + this.TurnTemp = 0f; + this.TurnRayon = 0f; + this.TurnNrj = 0f; + this.Activable = false; + this.ActivationLevel = 0; + this.Tilestype = new OrderedMap(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre); + this.Tilestype.put(new Vector2(1, 0), CaseType.Cuivre); + this.Tilesid = new OrderedMap(); + this.Tilesid.put(new Vector2(0, 0), 178); + this.Tilesid.put(new Vector2(1, 0), 107); + } + + public String getName() { + return this.Name; + } + + public String getID() { + return this.id; + } + + public String getDesc() { + return this.Desc; + } + + public Class getaClass() { + return this.theClass; + } + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + + public Particle ProcessCycle() { + this.level.Temp += TurnTemp * UpgradedTemp; + this.level.Rayon += TurnRayon * UpgradedRayon; + this.level.Nrj += TurnNrj * UpgradedNrj; + if (this.Activable) + if (this.ActivationLevel>0) this.ActivationLevel -= 1; + if (this.level.Cycle%10==0) { + Particle electron = new Particle(null); + electron.setType(Type.Electron); + electron.setSize(Size.Petit); + electron.setCharge(Charge.Neutre); + this.level.Temp += UsedTemp * UpgradedTemp; + this.level.Rayon += UsedRayon * UpgradedRayon; + this.level.Nrj += UsedNrj * UpgradedNrj; + return electron; + } + else + return null; + } + + public void Run(Particle particle) { + } + + public void Unactivate() { + if (this.Activable) + ActivationLevel = 0; + } + + 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 (int) (Transmuter.ACTIVATION_LIFE * 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 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 Array getUnlock() { + return this.Unlock; + } + +} diff --git a/core/src/fr/evolving/automata/Canon_IV.java b/core/src/fr/evolving/automata/Canon_IV.java new file mode 100644 index 0000000..6b76623 --- /dev/null +++ b/core/src/fr/evolving/automata/Canon_IV.java @@ -0,0 +1,295 @@ +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; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Particle.Charge; +import fr.evolving.automata.Particle.Size; +import fr.evolving.automata.Particle.Type; +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Canon_IV 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 Array 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 transient int ActivationLevel; + private static String id; + private static OrderedMap Tilestype; + private static OrderedMap Tilesid; + + public Canon_IV() { + super(); + this.id="->4"; + this.Name = AssetLoader.language.get("[canoniv-name]"); + this.Desc = AssetLoader.language.get("[canoniv-desc]"); + this.theClass = Class.Synthese; + this.Price = 200; + this.Technology = 1; + this.Research = 0; + this.Upgrade = null; + this.Unlock = null; + this.showed = false; + this.CanUpgradeTemp = true; + this.CanUpgradeCycle = false; + this.CanUpgradeRayon = false; + this.CanUpgradeNrj = true; + this.UpgradedTemp = 1f; + this.UpgradedCycle = 1f; + this.UpgradedRayon = 1f; + this.UpgradedNrj = 1f; + this.UsedTemp = 2f; + this.UsedRayon = 0f; + this.UsedNrj = 1f; + this.TurnTemp = 0f; + this.TurnRayon = 0f; + this.TurnNrj = 0f; + this.Activable = false; + this.ActivationLevel = 0; + this.Tilestype = new OrderedMap(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Tout); + this.Tilesid = new OrderedMap(); + this.Tilesid.put(new Vector2(0, 0), 179); + } + + public String getName() { + return this.Name; + } + + public String getID() { + return this.id; + } + + public String getDesc() { + return this.Desc; + } + + public Class getaClass() { + return this.theClass; + } + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + + public Particle ProcessCycle() { + this.level.Temp += TurnTemp * UpgradedTemp; + this.level.Rayon += TurnRayon * UpgradedRayon; + this.level.Nrj += TurnNrj * UpgradedNrj; + if (this.Activable) + if (this.ActivationLevel>0) this.ActivationLevel -= 1; + if (this.level.Cycle%10==0) { + Particle electron = new Particle(null); + electron.setType(Type.Electron); + electron.setSize(Size.Petit); + electron.setCharge(Charge.Neutre); + this.level.Temp += UsedTemp * UpgradedTemp; + this.level.Rayon += UsedRayon * UpgradedRayon; + this.level.Nrj += UsedNrj * UpgradedNrj; + return electron; + } + else + return null; + } + + public void Run(Particle particle) { + } + + public void Unactivate() { + if (this.Activable) + ActivationLevel = 0; + } + + 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 (int) (Transmuter.ACTIVATION_LIFE * 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 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 Array getUnlock() { + return this.Unlock; + } + +}