1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2025-07-07 17:01:10 +00:00

finish to add time

This commit is contained in:
2022-06-16 14:24:20 +02:00
parent e748f763a8
commit 20a4356f69
9 changed files with 30 additions and 38 deletions

View File

@ -1,12 +1,11 @@
package Main;
import java.util.Vector;
import com.badlogic.gdx.Input;
import Control.Controller;
import Entity.Character.Direction;
import Entity.Enemy;
import Entity.Entity;
import Entity.Character.Direction;
import Game.Battle;
import Screen.ScreenBattle;
import Screen.ScreenMap;
@ -20,6 +19,8 @@ public class PokeMudry extends PortableApplication {
private Controller controller;
private static Vector<Enemy> enemies = new Vector<>();
private static Vector<Entity> entities = new Vector<>();
private long beginTime;
private long lastMesure;
public static boolean front_montant = false;
@ -42,7 +43,7 @@ public class PokeMudry extends PortableApplication {
public void onInit() {
sp.init();
controller.init();
// add player, create and add all enemies in entities
entities.add((Entity) sp.p);
enemies.add(new Enemy("Mudry", 5, 11, "lumberjack_sheet32", "21N304", 25, "informatique", Direction.DOWN));
@ -51,11 +52,13 @@ public class PokeMudry extends PortableApplication {
enemies.add(new Enemy("Bianchi", 1, 3, "lumberjack_sheet32", "23N308", 0, "electricite", Direction.RIGHT));
enemies.add(new Enemy("Nicollier", 4, 2, "lumberjack_sheet32", "21N308", 0, "mathematique", Direction.LEFT));
enemies.add(new Enemy("Ellert", 1, 4, "lumberjack_sheet32", "23N215", 0, "physique", Direction.RIGHT));
for (Enemy enemy : enemies) { entities.add(enemy); }
//Init all entities
for (Entity entity : entities) { entity.init(); }
beginTime = System.currentTimeMillis();
lastMesure = beginTime;
}
@Override
@ -63,6 +66,14 @@ public class PokeMudry extends PortableApplication {
g.clear();
boolean onMapScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class);
boolean onBattleScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenBattle.class);
long timeNow = System.currentTimeMillis();
if((timeNow-lastMesure) >= 1000){
lastMesure = timeNow;
for (Enemy enemy : enemies) { enemy.recoveredTime++; }
}
if((timeNow-beginTime)/1000 >= 60 * Settings.TIME) System.out.println("Game finished");
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
@ -71,14 +82,16 @@ public class PokeMudry extends PortableApplication {
sp.e = sp.p.lastEnemy;
int pv = sp.e.getPv();
boolean recovered = sp.e.recoveredTime>=Settings.RECOVERED;
if (pv>0) {
if (pv>0 && recovered) {
sp.sb = sp.screenManager.getScreenBattle();
sp.b = new Battle(sp.e);
//set pv and xp to display
sp.b.setXpPlayer(sp.p.getXp());
g.zoom(1);
g.resetCamera();
} else {
sp.p.onEnemy = false;
@ -114,17 +127,6 @@ public class PokeMudry extends PortableApplication {
public void onKeyDown(int keycode) {
super.onKeyDown(keycode);
front_montant = true;
switch (keycode) {
case Input.Keys.Z:
if (sp.sm.zoom == 1.0) {
sp.sm.zoom = 0.5f;
} else {
sp.sm.zoom = 1;
}
return;
default:
break;
}
controller.keyStatus.put(keycode, true);
sp.screenManager.getActiveScreen().onKeyUp(keycode);
}

View File

@ -5,6 +5,8 @@ public class Settings {
public static final boolean ANDROID = false;
public static final int PLAYERS = 1;
public static final int TIME = 10; // number of minutes for kill all enemy
public static final int RECOVERED = 30; // number of seconds an enemy need for recovered
public static final int SWITCHMAPTIME = 250; // Number of milliseconds the player wait for switch map
public static final int SIDE = 800;