mirror of
https://github.com/Klagarge/PokeHES.git
synced 2024-11-23 01:43:28 +00:00
commit
edd8e028d4
@ -1,4 +1,4 @@
|
||||
Un mudry sauvage se balade dans les salles de classe. Il va te tester pour savoir si tu a traviallé cette année
|
||||
Un mudry sauvage se balade dans les salles de classe. Il va te tester pour savoir si tu a travaillé cette année
|
||||
Une question pour commencer :
|
||||
Encore une autre :
|
||||
Est ce que tu est vraiment chaud pour
|
||||
|
BIN
resources/font/Ubuntu-Medium.ttf
Normal file
BIN
resources/font/Ubuntu-Medium.ttf
Normal file
Binary file not shown.
BIN
resources/font/Ubuntu-Regular.ttf
Normal file
BIN
resources/font/Ubuntu-Regular.ttf
Normal file
Binary file not shown.
@ -8,7 +8,9 @@ public class Enemy extends Character{
|
||||
|
||||
|
||||
|
||||
|
||||
public Enemy(String name, int x, int y, String img, String map, int pv, String branch, Character.Direction dir) {
|
||||
|
||||
super(name, x, y, img, map);
|
||||
//generate his text
|
||||
|
||||
@ -19,8 +21,6 @@ public class Enemy extends Character{
|
||||
this.branch = branch;
|
||||
|
||||
this.pv = pv;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y, String map){
|
||||
@ -42,4 +42,10 @@ public class Enemy extends Character{
|
||||
return branch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPv(){
|
||||
//the pv can go under 0, but his real pv is 0 (for the player)
|
||||
return (pv<0) ? 0 : pv;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ public class Player extends Character{
|
||||
this.xp += xp;
|
||||
}
|
||||
|
||||
public int getXp(){
|
||||
return xp;
|
||||
}
|
||||
|
||||
public void manageEntity(ScreenMap sm, Controller c) {
|
||||
|
||||
boolean onDoor = sm.isDoor(getPosition());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package Game;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import Entity.Enemy;
|
||||
import Text.TextEnemy;
|
||||
|
||||
@ -10,9 +8,11 @@ public class Battle {
|
||||
private Enemy e;
|
||||
public TextEnemy textEnemy;
|
||||
private int lineSpeech;
|
||||
public int answer;
|
||||
|
||||
private int newXp;
|
||||
|
||||
public int newXp;
|
||||
public int pvEnemy;
|
||||
public int xpPlayer;
|
||||
|
||||
public boolean screenBattleOn = true;
|
||||
|
||||
@ -21,20 +21,38 @@ public class Battle {
|
||||
textEnemy = new TextEnemy(e);
|
||||
textEnemy.generateText();
|
||||
}
|
||||
|
||||
pvEnemy = e.getPv();
|
||||
lineSpeech = 0;
|
||||
newXp = 0;
|
||||
|
||||
System.out.println("lll : "+ getLine());
|
||||
|
||||
}
|
||||
|
||||
public void readNextLine(){
|
||||
//change line
|
||||
System.out.println(textEnemy.lines.size());
|
||||
if(lineSpeech < textEnemy.lines.size()-1){
|
||||
if(lineSpeech < 5){
|
||||
lineSpeech++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void action(int answer){
|
||||
System.out.println("pv enemy : " +pvEnemy);
|
||||
System.out.println("xp player : " + xpPlayer);
|
||||
System.out.println("xp win " + newXp);
|
||||
|
||||
if(getLineSpeech() == 4){
|
||||
FinishSpeech();
|
||||
}
|
||||
else if( getLineSpeech() == 5 || getLineSpeech() == 6){
|
||||
finish();
|
||||
}
|
||||
else if(0 < getLineSpeech() && getLineSpeech() < 4){
|
||||
checkAnswer(answer);
|
||||
}
|
||||
else{
|
||||
readNextLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//check the choice answer
|
||||
@ -42,36 +60,52 @@ public class Battle {
|
||||
int attack = lineSpeech-1;
|
||||
//get number current attack random
|
||||
int currentAttack = textEnemy.getCurrentData().get(attack)[0];
|
||||
System.out.println(Arrays.toString(textEnemy.getCurrentData().get(attack)));
|
||||
|
||||
//get number current answer random
|
||||
int currentAnswer = textEnemy.getCurrentData().get(attack)[answer];
|
||||
|
||||
//get the answer of the player
|
||||
String answerPlayer = textEnemy.fightData.getAttack(currentAttack).getAnswer(currentAnswer);
|
||||
System.out.println("answer player : " + answerPlayer);
|
||||
|
||||
//get true answer
|
||||
String trueAsnwer = textEnemy.fightData.getAttack(currentAttack).getTrueAnswer();
|
||||
System.out.println("true answer : " + trueAsnwer);
|
||||
|
||||
//check the choice of the player
|
||||
if(answerPlayer == trueAsnwer){
|
||||
newXp += textEnemy.fightData.getAttack(currentAttack).getXp();
|
||||
updatePlayerEnemy(textEnemy.fightData.getAttack(currentAttack).getXp());
|
||||
System.out.println("it's true !!!!");
|
||||
|
||||
}
|
||||
else{
|
||||
System.out.println("it's false !!!!");
|
||||
}
|
||||
|
||||
readNextLine();
|
||||
}
|
||||
|
||||
public void updatePlayerEnemy(int xp){
|
||||
//add xp for the player
|
||||
xpPlayer += xp;
|
||||
//remove pv enemy
|
||||
pvEnemy -= xp;
|
||||
|
||||
}
|
||||
|
||||
public void FinishSpeech(){
|
||||
if(pvEnemy>0){
|
||||
//alive (speechline = 6)
|
||||
lineSpeech += 2;
|
||||
System.out.println("enemy alive");
|
||||
}
|
||||
else{
|
||||
//dead (speechline = 5)
|
||||
lineSpeech += 1;
|
||||
System.out.println("enemy dead");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean finish(){
|
||||
return false;
|
||||
public void finish(){
|
||||
screenBattleOn = false;
|
||||
}
|
||||
|
||||
public boolean getAttackOn(){
|
||||
@ -80,24 +114,29 @@ public class Battle {
|
||||
|
||||
public String getLine(){
|
||||
if(e==null) return null;
|
||||
|
||||
return textEnemy.lines.get(lineSpeech).line;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//get the line for the dialog
|
||||
public int getLineSpeech() {
|
||||
return lineSpeech;
|
||||
}
|
||||
|
||||
//return true if the screen is active
|
||||
public boolean getScreenBattleOn(){
|
||||
return screenBattleOn;
|
||||
}
|
||||
|
||||
//get the total xp win in the battle
|
||||
public int getNewXp(){
|
||||
return newXp;
|
||||
}
|
||||
|
||||
public void setXpPlayer(int xp){
|
||||
xpPlayer = xp;
|
||||
}
|
||||
|
||||
//set enemy
|
||||
public void setEnemy(Enemy e){
|
||||
this.e = e;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package Main;
|
||||
|
||||
|
||||
import java.util.Vector;
|
||||
import com.badlogic.gdx.Input;
|
||||
|
||||
@ -70,6 +69,17 @@ public class PokeMudry extends PortableApplication {
|
||||
// Switch screen
|
||||
if (sp.p.onEnemy && onMapScreen){
|
||||
sp.e = sp.p.lastEnemy;
|
||||
|
||||
sp.sb = sp.screenManager.getScreenBattle();
|
||||
if(sp.e == null) System.out.println("sdfsdfsdfsdf");
|
||||
|
||||
sp.b = new Battle(sp.e);
|
||||
|
||||
//set pv and xp to display
|
||||
sp.b.setXpPlayer(sp.p.getXp());
|
||||
|
||||
g.resetCamera();
|
||||
|
||||
int pv = sp.e.getPv();
|
||||
|
||||
if (pv>0) {
|
||||
@ -79,16 +89,20 @@ public class PokeMudry extends PortableApplication {
|
||||
} else {
|
||||
sp.p.onEnemy = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(onBattleScreen) sp.sb.manage(controller, sp.b);
|
||||
|
||||
|
||||
if(!sp.b.getScreenBattleOn() && onBattleScreen){
|
||||
//addXp for the player
|
||||
sp.p.addXp(sp.b.getNewXp());
|
||||
//remove pv of the enemy
|
||||
sp.e.removedPv(sp.b.getNewXp());
|
||||
|
||||
sp.p.onEnemy = false;
|
||||
sp.sm = sp.screenManager.getScreenMap();
|
||||
sp.p.addXp(sp.b.getNewXp());
|
||||
sp.e.removedPv(sp.b.getNewXp());
|
||||
}
|
||||
|
||||
// Graphics render
|
||||
|
@ -27,24 +27,17 @@ public class ScreenBattle extends RenderingScreen{
|
||||
|
||||
private Battle b = null;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
//display the question
|
||||
generateFont("resources/font/OptimusPrinceps.ttf", 40, Color.BLACK);
|
||||
|
||||
generateFont("resources/font/Ubuntu-Regular.ttf", 30, Color.BLACK);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onGraphicRender(GdxGraphics g) {
|
||||
g.clear(Color.BLACK);
|
||||
|
||||
displayDialog(g);
|
||||
|
||||
//System.out.println("render: " + battle.getLineSpeech());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,14 +70,10 @@ public class ScreenBattle extends RenderingScreen{
|
||||
//dialog
|
||||
if(b == null) return;
|
||||
if(b.getLine() == null) return;
|
||||
g.drawString(15, 245 ,b.getLine() , optimus40);
|
||||
|
||||
|
||||
g.drawString(15, 260 ,b.getLine() , optimus40);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void displayEnemy(Enemy e){
|
||||
// TODO affficher l'enemi
|
||||
}
|
||||
@ -97,34 +86,28 @@ public class ScreenBattle extends RenderingScreen{
|
||||
|
||||
public void manage(Controller c, Battle battle){
|
||||
if(PokeMudry.front_montant){
|
||||
System.out.println("manage: " + battle.getLineSpeech());
|
||||
|
||||
if( battle.getAttackOn() == false){
|
||||
if (c.keyStatus.get(Input.Keys.SPACE)){
|
||||
System.out.println("in");
|
||||
battle.readNextLine();
|
||||
battle.action(-1);
|
||||
}
|
||||
if (c.keyStatus.get(Input.Keys.ENTER)){
|
||||
battle.screenBattleOn = battle.finish();
|
||||
battle.screenBattleOn = battle.screenBattleOn;
|
||||
}
|
||||
}
|
||||
|
||||
if(battle.getAttackOn() == true){
|
||||
if (c.keyStatus.get(Input.Keys.NUM_1)){
|
||||
|
||||
battle.checkAnswer(1);
|
||||
battle.action(1);
|
||||
}
|
||||
else if (c.keyStatus.get(Input.Keys.NUM_2)){
|
||||
|
||||
battle.checkAnswer(2);
|
||||
battle.action(2);
|
||||
}
|
||||
else if (c.keyStatus.get(Input.Keys.NUM_3)){
|
||||
|
||||
battle.checkAnswer(3);
|
||||
battle.action(3);
|
||||
}
|
||||
else if (c.keyStatus.get(Input.Keys.NUM_4)){
|
||||
|
||||
battle.checkAnswer(4);
|
||||
battle.action(4);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader;
|
||||
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import Entity.Character.Direction;
|
||||
import Entity.Character;
|
||||
import Entity.Player;
|
||||
import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
|
||||
@ -179,7 +180,9 @@ public class ScreenMap extends RenderingScreen{
|
||||
try { Door.nextMap = mapProperties.get("nextMap").toString(); } catch (Exception e) { }
|
||||
try { Door.nextX = Integer.parseInt(mapProperties.get("nextX").toString()); } catch (Exception e) { }
|
||||
try { Door.nextY = Integer.parseInt(mapProperties.get("nextY").toString()); } catch (Exception e) { }
|
||||
|
||||
try { Door.nextDirection = Character.Direction.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
public class TextEnemy {
|
||||
private static final int CUT = 60;
|
||||
public FightData fightData;
|
||||
public SpeechData speechData;
|
||||
|
||||
@ -83,28 +84,31 @@ public class TextEnemy {
|
||||
|
||||
|
||||
//introduction line
|
||||
lines.add(new Line(speechData.getSpeechs(0), false));
|
||||
String introduction = formatLine(speechData.getSpeechs(0), CUT);
|
||||
lines.add(new Line(introduction, false));
|
||||
|
||||
orderAttack = randomGenerate(0, fightData.nbre_line-1, 4);
|
||||
|
||||
for(int j=0; j<4;j++){
|
||||
int[] currentRandom = new int[5];
|
||||
currentRandom[0] = orderAttack[j];
|
||||
|
||||
//generate the order of the answer
|
||||
orderAnswer = randomGenerate(0, 3, 4);
|
||||
System.out.println("\n attaque " + j + " : " + Arrays.toString(orderAnswer) + "\n");
|
||||
|
||||
//save the order of answer and attack
|
||||
for(int k=1;k<5;k++){
|
||||
currentRandom[k] = orderAnswer[k-1];
|
||||
}
|
||||
|
||||
String attack = formatLine( speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ? ("+fightData.getAttack(orderAttack[j]).getXp()+ ") ", CUT);
|
||||
String answer1 = formatLine("1. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]), CUT);
|
||||
String answer2 = formatLine("2. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]), CUT);
|
||||
String answer3 = formatLine("3. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]), CUT);
|
||||
String answer4 = formatLine("4. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[3]), CUT);
|
||||
|
||||
//attack and answer (number on vector : 1-4)
|
||||
lines.add(new Line(
|
||||
speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + " ? ("+fightData.getAttack(orderAttack[j]).getXp()+ ") " + "\n" +
|
||||
"1. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) + "\n" +
|
||||
"2. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[1]) + "\n" +
|
||||
"3. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[2]) + "\n" +
|
||||
"4. " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[3]), true));
|
||||
lines.add(new Line(attack + "\n" +answer1 + "\n" + answer2 + "\n" + answer3 + "\n" + answer4, true));
|
||||
|
||||
|
||||
currentData.add(currentRandom);
|
||||
@ -115,8 +119,11 @@ public class TextEnemy {
|
||||
}
|
||||
|
||||
//finish (win and death)
|
||||
lines.add(new Line(speechData.getSpeechs(5), false));
|
||||
lines.add(new Line(speechData.getSpeechs(6), false));
|
||||
String alive = formatLine(speechData.getSpeechs(5), CUT);
|
||||
String death = formatLine(speechData.getSpeechs(6), CUT);
|
||||
|
||||
lines.add(new Line(alive, false));
|
||||
lines.add(new Line(death, false));
|
||||
}
|
||||
|
||||
public Vector<int[]> getCurrentData() {
|
||||
@ -124,5 +131,67 @@ public class TextEnemy {
|
||||
}
|
||||
|
||||
|
||||
public String formatLine(String line, int cut){
|
||||
|
||||
String cutLine = "";
|
||||
String newLine = "";
|
||||
|
||||
int startC = 0;
|
||||
int stoppC = cut;
|
||||
|
||||
|
||||
if(cut>line.length()-1){
|
||||
newLine =line;
|
||||
}
|
||||
else{
|
||||
|
||||
char[] c = new char[line.length()];
|
||||
|
||||
for(int i=0; i<c.length;i++){
|
||||
c[i] = line.charAt(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
while(true){
|
||||
System.out.println(line.length());
|
||||
for(int i =stoppC; i>=startC; i--){
|
||||
if(c[i] == ' '){
|
||||
stoppC = i;
|
||||
break;
|
||||
}
|
||||
else if(stoppC == c.length-1){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//découper le mot
|
||||
for(int i=startC;i<=stoppC;i++){
|
||||
cutLine += c[i];
|
||||
}
|
||||
|
||||
newLine += cutLine + "\n";
|
||||
cutLine = "";
|
||||
|
||||
startC = stoppC + 1;
|
||||
|
||||
|
||||
if(c.length-1-stoppC <=0){
|
||||
break;
|
||||
}
|
||||
else if(c.length-1-stoppC <= cut){
|
||||
stoppC = c.length-1;
|
||||
}
|
||||
else{
|
||||
stoppC += cut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return newLine;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,87 @@ import java.util.RandomAccess;
|
||||
class testYann{
|
||||
public static void main(String[] args) {
|
||||
|
||||
FightData t = new FightData("enemi");
|
||||
t.readFile();
|
||||
|
||||
System.out.println(t.getAttack(1).getAnswer(0).toString());
|
||||
|
||||
String text = "aaaaaa aaaaaa\naaaaaa aaaaaa";
|
||||
String newText ="";
|
||||
String cutLine = "";
|
||||
String newLine = "";
|
||||
|
||||
int cut = 6;
|
||||
|
||||
int startC = 0;
|
||||
int stoppC = cut;
|
||||
|
||||
String[] s = text.split("\n");
|
||||
|
||||
for(String line : s){
|
||||
System.out.println(line);
|
||||
|
||||
if(cut>line.length()-1){
|
||||
newLine =line;
|
||||
}
|
||||
else{
|
||||
|
||||
char[] c = new char[line.length()];
|
||||
|
||||
for(int i=0; i<c.length;i++){
|
||||
c[i] = line.charAt(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
while(true){
|
||||
for(int i =stoppC; i>=startC; i--){
|
||||
if(c[i] == ' '){
|
||||
stoppC = i;
|
||||
break;
|
||||
}
|
||||
else if(stoppC == c.length-1){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//découper le mot
|
||||
for(int i=startC;i<=stoppC;i++){
|
||||
cutLine += c[i];
|
||||
}
|
||||
|
||||
newLine += cutLine+"\n";
|
||||
cutLine = "";
|
||||
|
||||
startC = stoppC + 1;
|
||||
|
||||
|
||||
if(c.length-1-stoppC <=0){
|
||||
break;
|
||||
}
|
||||
else if(c.length-1-stoppC <= cut){
|
||||
stoppC = c.length-1;
|
||||
}
|
||||
else{
|
||||
stoppC += cut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newText += newLine + "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println(newText);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user