import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import javax.sound.sampled.*;
import java.util.Random;
import java.text.DecimalFormat;
public class Start extends JFrame implements Runnable
{
Feld[][][] feld;
Texte text;
Items[] item;
int event;
String[] questname, questtext;
int questid;
boolean[] event_finished;
// SPIELFELD GRÖSSE
int s_width = 100;
int s_height = 100;
// FELDGRÖSSE
int feldgröße = 20;
// POSITIONSBESTIMMUNGEN
int pos_x, pos_y;
// ARRAY HILFSVARIABLE
int Rect_x = 0, Rect_y = 0;
// Spielerposition
int spieler_x = 3, spieler_y = 6;
// ACTIONLISTENER ADDEN
Tastatureingabe tasta = new Tastatureingabe();
Mauseingabe maus = new Mauseingabe();
int maus_x, maus_y;
// BILDER HINZUFÜGEN
Image menue, interface_panel, bg;
ImageIcon[] mapimg_tmp, mapimg_v_tmp;
Image[] mapimg, mapimg_v;
ImageIcon[] hero_v_tmp, hero_l_tmp, hero_r_tmp, hero_h_tmp;
Image[] hero_v, hero_l, hero_r, hero_h;
ImageIcon[] npc_tmp;
Image[] npc;
ImageIcon[] itemimg_tmp;
Image[] itemimg;
//MAP EINSTELLUNGEN
int map = 0, oldmap = 1;
//SITUATIONS EINSTELLUNGEN
boolean infight = false, infight_temp = false;
boolean indialog = false, indialog_temp = false;
boolean weiter = false;
int npc_x_tmp = 0, npc_y_tmp = 0, gegner_x_tmp = 0, gegner_y_tmp = 0;
// CREDITS
int credits_count;
String[] credits_text;
boolean credits = false;
// HELD
String blickrichtung = "rechts";
boolean going = false;
int schritt = 2, oldschritt = 2;
int level = 1;
int xp = 0, xptolevel = 500;
int hpticker = 0;
double hp = 100, maxhp = 100;
int manaticker = 0;
double mana = 100, maxmana = 100;
boolean oom = false;
int make_dmg, become_dmg, become_mana;
double gold;
int[] inventar, rucksack, r_anzahl;
boolean inventar_offen, rucksack_offen, questlog_offen;
boolean tod = false, todrepainted = false;
int animation;
//SOUND
Sound s = new Sound();
public static void main(String[] args)
{
// FRAME WIRD INITIALISIERT
Start start = new Start();
start.pack();
start.setSize(1024,768);
start.setVisible(true);
}
Start()
{
// TITEL WIRD GESETZT
super("The Legends of Saria");
// DESIGN WIRD AUF METALL LOOK GESTELLT
try
{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch(Exception ex)
{
System.err.println("Fehler bei LookandFeel\n");
}
Cursor c = getToolkit().createCustomCursor(
new ImageIcon( "cursor.png" ).getImage(),
new Point(1,1), "Cursor" );
setCursor( c );
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Thread th = new Thread (this);
th.start ();
credits_text = new String[7];
credits_text[0] = new String("Schnittchen: Eike");
credits_text[1] = new String("Story: Tobi");
credits_text[2] = new String("Design: Edi");
credits_text[3] = new String("Code: Torben");
credits_text[4] = new String("And special Thankz to:");
credits_text[5] = new String("...");
credits_text[6] = new String("nobody!");
feld = new Feld[10][250][250];
FelderErstellen();
text = new Texte();
questname = new String[900];
questtext = new String[900];
item = new Items[300];
ItemsLaden();
event_finished = new boolean[999];
inventar = new int[55];
InventarLaden();
// 0: füße, 1: beine, 2: brust, 3: hände, 4: kopf, 5: finger, 6: rechte hand, 7: linke hand
rucksack = new int[66];
r_anzahl = new int[66];
RucksackLaden();
// BILDER WERDEN GELADEN
ImageIcon menue_tmp = new ImageIcon("menue.jpg");
menue = menue_tmp.getImage();
ImageIcon bg_tmp = new ImageIcon("bg.jpg");
bg = bg_tmp.getImage();
ImageIcon interface_panel_tmp = new ImageIcon("interface.png");
interface_panel = interface_panel_tmp.getImage();
mapimg = new Image[99];
mapimg_tmp = new ImageIcon[99];
mapimg_v = new Image[99];
mapimg_v_tmp = new ImageIcon[99];
for(int mapcount = 1; mapcount < 15; mapcount++)
{
mapimg_tmp[mapcount] = new ImageIcon("Maps/map_"+mapcount+".png");
mapimg[mapcount] = mapimg_tmp[mapcount].getImage();
mapimg_v_tmp[mapcount] = new ImageIcon("Maps/map_"+mapcount+"_v.png");
mapimg_v[mapcount] = mapimg_v_tmp[mapcount].getImage();
}
hero_v = new Image[4];
hero_v_tmp = new ImageIcon[4];
hero_h = new Image[4];
hero_h_tmp = new ImageIcon[4];
hero_l = new Image[4];
hero_l_tmp = new ImageIcon[4];
hero_r = new Image[4];
hero_r_tmp = new ImageIcon[4];
hero_v_tmp[1] = new ImageIcon("Hero/hero_v_1.png");
hero_v[1] = hero_v_tmp[1].getImage();
hero_v_tmp[2] = new ImageIcon("Hero/hero_v_2.png");
hero_v[2] = hero_v_tmp[2].getImage();
hero_v_tmp[3] = new ImageIcon("Hero/hero_v_3.png");
hero_v[3] = hero_v_tmp[3].getImage();
hero_h_tmp[1] = new ImageIcon("Hero/hero_h_1.png");
hero_h[1] = hero_h_tmp[1].getImage();
hero_h_tmp[2] = new ImageIcon("Hero/hero_h_2.png");
hero_h[2] = hero_h_tmp[2].getImage();
hero_h_tmp[3] = new ImageIcon("Hero/hero_h_3.png");
hero_h[3] = hero_h_tmp[3].getImage();
hero_l_tmp[1] = new ImageIcon("Hero/hero_l_1.png");
hero_l[1] = hero_l_tmp[1].getImage();
hero_l_tmp[2] = new ImageIcon("Hero/hero_l_2.png");
hero_l[2] = hero_l_tmp[2].getImage();
hero_l_tmp[3] = new ImageIcon("Hero/hero_l_3.png");
hero_l[3] = hero_l_tmp[3].getImage();
hero_r_tmp[1] = new ImageIcon("Hero/hero_r_1.png");
hero_r[1] = hero_r_tmp[1].getImage();
hero_r_tmp[2] = new ImageIcon("Hero/hero_r_2.png");
hero_r[2] = hero_r_tmp[2].getImage();
hero_r_tmp[3] = new ImageIcon("Hero/hero_r_3.png");
hero_r[3] = hero_r_tmp[3].getImage();
npc = new Image[99];
npc_tmp = new ImageIcon[99];
for(int npccount = 1; npccount < 10; npccount ++)
{
npc_tmp[npccount] = new ImageIcon("NPCs/npc"+npccount+".png");
npc[npccount] = npc_tmp[npccount].getImage();
}
itemimg = new Image[200];
itemimg_tmp = new ImageIcon[200];
for(int itemimgcount = 1; itemimgcount < 200; itemimgcount ++)
{
itemimg_tmp[itemimgcount] = new ImageIcon("Items/item_"+itemimgcount+".jpg");
itemimg[itemimgcount] = itemimg_tmp[itemimgcount].getImage();
}
setBackground(Color.black);
addKeyListener(tasta);
addMouseListener(maus);
}
public void run ()
{
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while (true)
{
if(credits_count > 565)
credits_count--;
hpticker++;
manaticker++;
if(map > 0)
for(int z = 1; z < 10; z++)
for(int y = 1; y < 50; y++)
for(int x = 1; x < 50; x++)
if((spieler_x == x) && (spieler_y == y));
else
if(feld[z][x][y].Spawntime() > 0)
{
if(feld[z][x][y].Spawntime() == 1)
repaint();
feld[z][x][y].Spawntimer();
}
try
{
Thread.sleep (40);
}
catch (InterruptedException ex)
{
}
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
istTod();
if((credits_count > 565) || (hpticker == 20) || (manaticker == 20))
repaint();
}
}
public void paint(Graphics g)
{
if(map == 0)
{
MenüPaint(g);
}
else
{
istTod();
if(tod)
{
TodPaint(g);
}
else
{
Kämpfen();
LevelUp();
HP_Berechnen();
Mana_Berechnen();
QuestlogÖffnen();
InventarÖffnen();
RucksackÖffnen();
if(!infight && !indialog && !inventar_offen && !rucksack_offen)
{
HeldAusrichtung();
x_Berechnung();
y_Berechnung();
MapCheat();
Mapwechsel();
Pos_Berechnung();
g.fillRect(200, 200, 824, 568);
g.drawImage(mapimg[map], (220 - Rect_x * feldgröße), (220 - Rect_y * feldgröße), mapimg[map].getWidth(this), mapimg[map].getHeight(this), this);
for(int y=0; y<50; y++)
{
for(int x=0; x<50; x++)
{
if((Rect_y>=0) && (Rect_y<=100) && (Rect_x>=0) && (Rect_x<=100))
{
// NPC
if(feld[map][Rect_x][Rect_y].NpcaufFeld() != 0)
{
if((Rect_x == spieler_x) && (spieler_y == Rect_y))
{
if(feld[map][Rect_x][Rect_y].gibGesinnung() == 0)
{
infight = true;
gegner_x_tmp = Rect_x;
gegner_y_tmp = Rect_y;
}
else
{
if(feld[map][Rect_x][Rect_y].gibDialog() != 0)
{
if(!indialog_temp)
indialog = true;
}
npc_x_tmp = Rect_x;
npc_y_tmp = Rect_y;
}
}
int npc_width = npc[feld[map][Rect_x][Rect_y].NpcaufFeld()].getWidth(this);
int npc_height = npc[feld[map][Rect_x][Rect_y].NpcaufFeld()].getHeight(this);
g.drawImage(npc[feld[map][Rect_x][Rect_y].NpcaufFeld()], (197 + x*feldgröße), (200 - (npc_height/3) + y*feldgröße), npc_width, npc_height, this);
}
if((spieler_x == npc_x_tmp) && (spieler_y == npc_y_tmp));
else
{
indialog_temp = false;
event = 0;
}
if((Rect_x == spieler_x) && (spieler_y == Rect_y))
{
// SPIELER
if(blickrichtung == "vorne")
g.drawImage(hero_v[schritt], 600, 473, 20, 27, this);
if(blickrichtung == "hinten")
g.drawImage(hero_h[schritt], 600, 473, 20, 27, this);
if(blickrichtung == "links")
g.drawImage(hero_l[schritt], 600, 473, 20, 27, this);
if(blickrichtung == "rechts")
g.drawImage(hero_r[schritt], 600, 473, 20, 27, this);
}
}
Rect_x++;
}
Rect_x = pos_x;
Rect_y++;
}
Rect_y=pos_y;
}
// VORDERGRUND EBENE ZEICHNEN
g.drawImage(mapimg_v[map], (220 - Rect_x * feldgröße), (220 - Rect_y * feldgröße), mapimg[map].getWidth(this), mapimg[map].getHeight(this), this);
if(questlog_offen)
{
if(tasta.Weiter())
{
questlog_offen = false;
tasta.RemoveMoving();
}
g.setColor(Color.blue);
g.fillRect(200,200,1024,1000);
g.setColor(Color.red);
int text_height2 = 0;
for(int d = 1; d < (questid + 1); d++)
{
g.drawString(questname[d], 370, 200 + 30*d + text_height2);
boolean stringende = false;
int index = 0;
int anfangsindex = 1;
int text_height = 0;
String der_text;
while(!stringende)
{
anfangsindex = index + 1;
index = questtext[d].indexOf("#", anfangsindex);
der_text = questtext[d].substring(anfangsindex, index);
if(der_text.endsWith("+"))
{
stringende = true;
text_height2 = text_height;
break;
}
g.drawString(der_text, 370, 215 + 30*d + text_height);
text_height = text_height + 15;
}
}
}
if(inventar_offen)
{
if(tasta.Weiter())
{
inventar_offen = false;
tasta.RemoveMoving();
}
g.setColor(Color.blue);
g.fillRect(200,200,1024,1000);
g.setColor(Color.red);
for(int c = 0; c < 8; c++)
{
g.drawImage(itemimg[item[inventar[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
g.drawString(item[inventar[c]].Name(), 370, 250 + 70*c);
}
}
if(rucksack_offen)
{
if(tasta.Weiter())
{
rucksack_offen = false;
tasta.RemoveMoving();
}
g.setColor(Color.blue);
g.fillRect(200,200,1024,1000);
g.setColor(Color.red);
for(int c = 0; c < 24; c++)
{
g.drawImage(itemimg[item[rucksack[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
g.drawString(item[rucksack[c]].Name(), 370, 250 + 70*c);
if(rucksack[c] != 0 && r_anzahl[c] > 1)
g.drawString(""+r_anzahl[c], 305, 268 + 70*c);
}
}
if(indialog)
{
if(feld[map][npc_x_tmp][npc_y_tmp].NpcaufFeld() != 1)
blickrichtung = "hinten";
if(tasta.Weiter())
{
indialog_temp = true;
indialog = false;
if(feld[map][npc_x_tmp][npc_y_tmp].Respawnable() == false)
feld[map][npc_x_tmp][npc_y_tmp].NPC_Entfernen();
}
g.setColor(Color.blue);
g.fillRect(+200,+200,1024,1000);
g.setColor(Color.red);
boolean stringende = false;
int index = 0;
int anfangsindex = 1;
int text_height = 300;
int text_width = 0;
int text_rows = 0;
String der_text;
while(!stringende)
{
anfangsindex = index + 1;
index = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
der_text = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).substring(anfangsindex, index);
if(der_text.endsWith("+"))
{
stringende = true;
break;
}
text_rows++;
}
stringende = false;
index = 0;
text_height = 770 - (text_rows *20);
g.setColor(Color.green);
g.fillRect(250, (750 - (text_rows *20)), 724, (text_rows * 20 + 30));
g.setColor(Color.red);
while(!stringende)
{
anfangsindex = index + 1;
index = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
der_text = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).substring(anfangsindex, index);
if(der_text.endsWith("+"))
{
stringende = true;
break;
}
text_width = (g.getFontMetrics().stringWidth(der_text) / 2);
g.drawString(der_text, (610 - text_width), text_height);
text_height = text_height + 20;
}
// EVENTABFRAGE
if(feld[map][npc_x_tmp][npc_y_tmp].gibEvent() != 0 && feld[map][npc_x_tmp][npc_y_tmp].gibGesinnung() == 1)
{
event = feld[map][npc_x_tmp][npc_y_tmp].gibEvent();
Events();
}
}
if((infight) && (!infight_temp))
{
g.setColor(Color.blue);
g.fillRect(+200,+200,1024,1000);
g.setColor(Color.red);
g.drawString("Ungläubiger! Meine geschärfte Klinge wird deinen Leib in tausend Stücke zerteilen!!", 400,400);
g.drawString("Du hast "+make_dmg+" Schaden gemacht und "+become_dmg+" verloren",250, 300);
if(oom == true)
g.drawString("Für den aktuellen Zauber hast du leider nicht genug Mana!",250, 330);
g.drawString("Gegner Level: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibLevel()+" ||| Gegner HP: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibHP()+"/"+feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxHP()+" ||| Gegner Mana: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibMana()+"/"+feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxMana()+"", 300,450);
double tmp_hp2 = feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() / feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxHP() * 200;
double tmp_m2 = feld[map][gegner_x_tmp][gegner_y_tmp].gibMana() / feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxMana() * 200;
g.fillRect(300, 500, ((int)tmp_hp2), 15);
g.fillRect(300, 600, ((int)tmp_m2), 15);
g.setColor(Color.black);
g.drawRect(300, 500, 200, 15);
g.drawRect(300, 600, 200, 15);
g.setColor(Color.red);
}
else
infight_temp = false;
InterfacePaint(g);
tasta.RemoveMoving();
}
}
}
public void MenüPaint(Graphics g)
{
MenuBerechnen();
g.drawImage(menue, 0, 0, 1024, 768, this);
if(credits)
{
g.drawString(credits_text[0], 490, credits_count);
g.drawString(credits_text[1], 490, credits_count + 20);
g.drawString(credits_text[2], 490, credits_count + 40);
g.drawString(credits_text[3], 490, credits_count + 60);
g.drawString(credits_text[4], 490, credits_count + 90);
g.drawString(credits_text[5], 490, credits_count + 110);
g.drawString(credits_text[6], 490, credits_count + 130);
g.drawRect(480, credits_count - 15, 150, 160);
}
}
public void TodPaint(Graphics g)
{
g.setColor(Color.blue);
g.fillRect(0,0,1024,1000);
g.setColor(Color.red);
g.drawString("Du scheinst dem Tod geweiht, Soldat!!", 400,400);
}
public void InterfacePaint(Graphics g)
{
g.drawImage(interface_panel, 0, 0, 1024, 768, this);
g.setColor(Color.red);
double tmp_hp = hp / maxhp * 200;
double tmp_m = mana / maxmana * 200;
g.fillRect(300, 50, ((int)tmp_hp), 15);
g.fillRect(300, 100, ((int)tmp_m), 15);
g.setColor(Color.black);
g.drawRect(300, 50, 200, 15);
g.drawRect(300, 100, 200, 15);
}
// ATTACKEN
public void Kämpfen()
{
if(infight)
{
oom = false;
if(tasta.Attacke() == 1)
{
make_dmg = (5*level + Zufallszahl(1, 10));
feld[map][gegner_x_tmp][gegner_y_tmp].setHP(feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() - make_dmg);
Become_DMG();
}
if(tasta.Attacke() == 2)
{
become_mana = 60;
if(mana - become_mana >= 0)
{
make_dmg = (15*level + Zufallszahl(10, 20));
feld[map][gegner_x_tmp][gegner_y_tmp].setHP(feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() - make_dmg);
mana = mana - become_mana;
Become_DMG();
}
else
oom = true;
}
if(feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() <= 0)
{
make_dmg = 0;
become_dmg = 0;
become_mana = 0;
infight = false;
infight_temp = true;
event = feld[map][gegner_x_tmp][gegner_y_tmp].gibEvent();
Events();
feld[map][spieler_x][spieler_y].NpcLöschen();
XP_Berechnen();
Gold_Berechnen();
}
}
}
public void Become_DMG()
{
become_dmg = Zufallszahl(5, 15);
hp = hp - become_dmg;
}
public void XP_Berechnen()
{
xp = xp + Zufallszahl(90, 110);
}
public void Gold_Berechnen()
{
gold = gold + Zufallszahl(1, 10)*0.1;
}
public void LevelUp()
{
if((xp >= xptolevel) && (!infight))
{
xp = xp - xptolevel;
xptolevel = xptolevel + (xptolevel*30/100);
maxhp = maxhp + level * 10;
maxmana = maxmana + level * 10;
hp = maxhp;
mana = maxmana;
level++;
}
}
public void HP_Berechnen()
{
if((hpticker >= 20) && (!infight))
{
if(hp + 2 * level > maxhp)
hp = maxhp;
else
hp = hp + 2 * level;
hpticker = 0;
}
}
public void Mana_Berechnen()
{
if((manaticker >= 20) && (!infight))
{
if(mana + 2 * level > maxmana)
mana = maxmana;
else
mana = mana + 2 * level;
manaticker = 0;
}
}
public void istTod()
{
if(hp <=0)
{
tod = true;
if(!todrepainted)
repaint();
todrepainted = true;
}
}
public void Pos_Berechnung()
{
// ERSTES FELD WIRD BERECHNET
pos_x = spieler_x - 20;
pos_y = spieler_y - 14;
// DATEN WERDEN FÜR FOR SCHLEIFE KOPIERT
Rect_x = pos_x;
Rect_y = pos_y;
}
public void HeldAusrichtung()
{
// BLICKRICHTUNG
if(tasta.Movex() == -1)
blickrichtung = "links";
else if(tasta.Movex() == 1)
blickrichtung = "rechts";
if(tasta.Movey() == -1)
blickrichtung = "hinten";
else if(tasta.Movey() == 1)
blickrichtung = "vorne";
// IN BEWEGUNG
if(tasta.Movex() != 0 || tasta.Movey() != 0)
going = true;
else
going = false;
// WELCHER FUSS?
if(going == true)
{
if(schritt == 1)
{
schritt = oldschritt;
}
else if(schritt == 2)
{
schritt = 3;
oldschritt = 2;
}
else if(schritt == 3)
{
schritt = 2;
oldschritt = 3;
}
}
else
{
schritt = 1;
}
}
public void x_Berechnung()
{
if(feld[map][spieler_x + tasta.Movex()][spieler_y].begehbar())
{
spieler_x = spieler_x + tasta.Movex();
}
}
public void y_Berechnung()
{
if(feld[map][spieler_x][spieler_y + tasta.Movey()].begehbar())
{
spieler_y = spieler_y + tasta.Movey();
}
}
public void QuestlogÖffnen()
{
if(tasta.QuestlogOffen())
{
if(inventar_offen || rucksack_offen || questlog_offen)
questlog_offen = false;
else
questlog_offen = true;
}
}
public void InventarÖffnen()
{
if(tasta.InventarOffen())
{
if(inventar_offen || rucksack_offen || questlog_offen)
inventar_offen = false;
else
inventar_offen = true;
}
}
public void RucksackÖffnen()
{
if(tasta.RucksackOffen())
{
if(rucksack_offen || inventar_offen || questlog_offen)
rucksack_offen = false;
else
rucksack_offen = true;
}
}
public void Sleep(int milisec)
{
try { Thread.sleep(milisec); }
catch (InterruptedException e) {}
}
public int Zufallszahl(int min, int max)
{
int differenz = (max + 1) - min;
Random zufall = new Random();
return (min + (zufall.nextInt(differenz) - 1));
}
public void Mapwechsel()
{
if(feld[map][spieler_x][spieler_y].istMapsprung() != 0)
{
map = feld[map][spieler_x][spieler_y].istMapsprung();
Einstiegskoordinaten();
}
}
public void MapCheat()
{
if(tasta.MapCheat() != 0)
{
map = map + tasta.MapCheat();
Einstiegskoordinaten();
}
}
public void Einstiegskoordinaten()
{
if(map == 1)
{
if(oldmap == 1)
{
spieler_x = 5;
spieler_y = 6;
}
else if(oldmap == 2)
{
spieler_x = 2;
spieler_y = 9;
}
oldmap = 1;
}
else if(map == 2)
{
if(oldmap == 1)
{
spieler_x = 13;
spieler_y = 3;
}
else if(oldmap == 3)
{
spieler_x = 8;
spieler_y = 9;
}
oldmap = 2;
}
else if(map == 3)
{
if(oldmap == 2)
{
spieler_x = 11;
spieler_y = 5;
}
else if(oldmap == 4)
{
spieler_x = 6;
spieler_y = 1;
}
oldmap = 3;
}
else if(map == 4)
{
if(oldmap == 3)
{
spieler_x = 6;
spieler_y = 10;
}
else if(oldmap == 5)
{
spieler_x = 1;
spieler_y = 8;
}
else if(oldmap == 6)
{
spieler_x = 3;
spieler_y = 6;
}
else if(oldmap == 8)
{
spieler_x = 15;
spieler_y = 9;
}
oldmap = 4;
}
else if(map == 5)
{
if(oldmap == 4)
{
spieler_x = 15;
spieler_y = 8;
}
oldmap = 5;
}
else if(map == 6)
{
if(oldmap == 4)
{
spieler_x = 5;
spieler_y = 14;
}
oldmap = 6;
}
else if(map == 7)
{
if(oldmap == 4)
{
spieler_x = 5;
spieler_y = 14;
}
oldmap = 7;
}
else if(map == 8)
{
if(oldmap == 4)
{
spieler_x = 1;
spieler_y = 21;
}
oldmap = 8;
}
}
public void MenuBerechnen()
{
MausPosition();
if((maus_x > 480 && maus_x < 605) && (maus_y > 375 && maus_y < 405))
{
map = 1;
Maperzeugen();
s.playSound(2);
repaint();
}
else if((maus_x > 495 && maus_x < 590) && (maus_y > 507 && maus_y < 537))
{
credits = true;
credits_count = 780;
repaint();
}
}
public void MausPosition()
{
maus_x = maus.Maus_X();
maus_y = maus.Maus_Y();
maus.RemoveMouse();
}
public void Maperzeugen()
{
for(int mapid = 1; mapid < 10; mapid++)
if(mapid == 1)
{
for(int y=0; y<15; y++)
{
for(int x=0; x<15; x++)
{
if((y<=1) || (y>=11) || (x<=0) || (x>=11))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=2) && (y<=3) && (x>=1) && (x<=7))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=5) && (y<=6) && (x>=1) && (x<=2))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=5) && (y<=6) && (x>=1) && (x<=2))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=6) && (y<=7) && (x>=5) && (x<=7))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=6) && (y<=8) && (x>=10))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][2][10].Feldmarkieren(2);
// NPC FELDER ANLEGEN
feld[mapid][3][6].NpcFreund(1, 1, false, 0);
}
else if(mapid == 2)
{
for(int y=0; y<12; y++)
{
for(int x=0; x<17; x++)
{
if((y<=1) || (y>=11) || (x<=0) || (x>=16))
feld[mapid][x][y].FeldAnlegen(false);
else if((y==2) && (x<=12))
feld[mapid][x][y].FeldAnlegen(false);
else if((y==2) && (x>=14))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=7) && (y<=9) && (x>=1) && (x<=4))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=5) && (y<=7) && (x>=7) && (x<=10))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][13][2].Feldmarkieren(1);
feld[mapid][8][10].Feldmarkieren(3);
// NPC FELDER ANLEGEN
}
else if(mapid == 3)
{
for(int y=0; y<10; y++)
{
for(int x=0; x<17; x++)
{
if((y<=-1) || (y>=9) || (x<=0) || (x>=16))
feld[mapid][x][y].FeldAnlegen(false);
else if((y==0) && (x>=0) && (x<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((y==0) && (x>=7) && (x<=16))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=3) && (y<=4) && (x>=2) && (x<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=3) && (y<=3) && (x>=9) && (x<=13))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=3) && (y<=4) && (x>=9) && (x<=10))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=3) && (y<=4) && (x>=12) && (x<=13))
feld[mapid][x][y].FeldAnlegen(false);
else if((y>=8) && (x>=10))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][11][4].Feldmarkieren(2);
feld[mapid][6][0].Feldmarkieren(4);
// NPC FELDER ANLEGEN
feld[mapid][11][5].NpcFreund(1, 2, false, 0);
feld[mapid][12][5].NpcFreund(3, 3, true, 0);
feld[mapid][3][5].NpcFreund(1, 4, true, 0);
}
else if(mapid == 4)
{
for(int y=0; y<13; y++)
{
for(int x=0; x<17; x++)
{
if((y<=3) || (y>=12) || (x<=-1) || (x>=17))
feld[mapid][x][y].FeldAnlegen(false);
else if((y==11) && (x>=0) && (x<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((y==11) && (x>=7) && (x<=16))
feld[mapid][x][y].FeldAnlegen(false);
else if((x==0) && (y>=0) && (y<=7))
feld[mapid][x][y].FeldAnlegen(false);
else if((x==0) && (y>=9) && (y<=11))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=4) && (y>=1) && (y<=4))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=7) && (x<=8) && (y>=4) && (y<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=10) && (x<=10) && (y>=4) && (y<=4))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=11) && (x<=11) && (y>=4) && (y<=6))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=12) && (x<=15) && (y>=4) && (y<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=12) && (x<=12) && (y>=5) && (y<=6))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=14) && (x<=15) && (y>=5) && (y<=6))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=2) && (y>=5) && (y<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=4) && (x<=4) && (y>=5) && (y<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=16) && (x<=16) && (y>=1) && (y<=8))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=16) && (x<=16) && (y>=10) && (y<=12))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][6][11].Feldmarkieren(3);
feld[mapid][0][8].Feldmarkieren(5);
feld[mapid][3][5].Feldmarkieren(6);
feld[mapid][16][9].Feldmarkieren(8);
// NPC FELDER ANLEGEN
feld[mapid][6][10].NpcFreund(1, 5, false, 0);
feld[mapid][5][10].NpcFreund(5, 6, true, 0);
feld[mapid][9][7].NpcGegner(2, 100, true, 30, 40, 1, 0);
feld[mapid][11][10].NpcGegner(2, 100, true, 200, 600, 3, 0);
feld[mapid][14][10].NpcGegner(4, 100, true, 60, 20, 1, 0);
feld[mapid][15][8].NpcGegner(4, 100, true, 35, 10, 1, 0);
}
else if(mapid == 5)
{
for(int y=0; y<12; y++)
{
for(int x=0; x<18; x++)
{
if((y<=1) || (y>=11) || (x<=0) || (x>=17))
feld[mapid][x][y].FeldAnlegen(false);
else if((x==16) && (y>=0) && (y<=7))
feld[mapid][x][y].FeldAnlegen(false);
else if((x==16) && (y>=9) && (y<=11))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=13) && (y==2))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=8) && (y==3))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=6) && (y==4))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=2) && (y==5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=4) && (x<=7) && (y>=6) && (y<=7))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][16][8].Feldmarkieren(4);
// NPC FELDER ANLEGEN
feld[mapid][2][6].NpcFreund(6, 15, true, 0);
}
else if(mapid == 6)
{
for(int y=0; y<22; y++)
{
for(int x=0; x<12; x++)
{
if((y<=2) || (y>=21) || (x<=0) || (x>=11))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=5) && (y>=3) && (y<=3))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=1) && (y>=4) && (y<=4))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=9) && (x<=10) && (y>=3) && (y<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=6) && (y>=5) && (y<=5))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=3) && (y>=9) && (y<=10))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=6) && (x<=10) && (y>=11) && (y<=12))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=2) && (y>=14) && (y<=15))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=2) && (x<=2) && (y>=13) && (y<=13))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=9) && (x<=10) && (y>=14) && (y<=15))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][5][15].Feldmarkieren(4);
feld[mapid][6][15].Feldmarkieren(4);
// NPC FELDER ANLEGEN
feld[mapid][3][4].NpcFreund(7, 18, true, 0);
feld[mapid][8][10].NpcFreund(8, 17, true, 0);
feld[mapid][10][6].NpcFreund(1, 54, false, 0);
}
else if(mapid == 8)
{
for(int y=0; y<30; y++)
{
for(int x=0; x<30; x++)
{
if((y<=11) || (y>=26) || (x<=-1) || (x>=27))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=0) && (x<=0) && (y>=11) && (y<=19))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=0) && (x<=0) && (y>=22) && (y<=26))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=26) && (x<=26) && (y>=11) && (y<=23))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=26) && (x<=26) && (y>=26) && (y<=26))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=1) && (x<=5) && (y>=11) && (y<=17))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=4) && (x<=7) && (y>=22) && (y<=24))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=6) && (x<=13) && (y>=11) && (y<=15))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=14) && (x<=14) && (y>=11) && (y<=14))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=15) && (x<=15) && (y>=11) && (y<=13))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=16) && (x<=17) && (y>=11) && (y<=12))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=19) && (x<=26) && (y>=11) && (y<=22))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=14) && (x<=18) && (y>=18) && (y<=22))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=9) && (x<=9) && (y>=17) && (y<=18))
feld[mapid][x][y].FeldAnlegen(false);
else if((x>=18) && (x<=18) && (y>=17) && (y<=17))
feld[mapid][x][y].FeldAnlegen(false);
else
feld[mapid][x][y].FeldAnlegen(true);
}
}
// SPRUNG FELDER ANLEGEN
feld[mapid][0][20].Feldmarkieren(4);
feld[mapid][0][21].Feldmarkieren(4);
feld[mapid][26][24].Feldmarkieren(9);
feld[mapid][26][25].Feldmarkieren(9);
// NPC FELDER ANLEGEN
feld[mapid][18][12].NpcFreund(9, 7, true, 1);
}
}
public void FelderErstellen()
{
for(int z=1; z<10; z++)
{
for(int y=0; y<150; y++)
{
for(int x=0; x<150; x++)
{
feld[z][x][y] = new Feld(z, x, y);
}
}
}
}
public void ItemsLaden()
{
/* int typ, int symbol, String name, int schadenmin, int schadenmax, int rüstung, int sellvalue, String qualität, int str, int agi, int sta, int intl)
* typ Deklarierung:
* 1: Schwert
* 2: Zweihandschwert
* 3: Axt
* 4: Zweihandaxt
* 5: Schild
* 6: Brust
* 7: Hose
* 8: Schuhe
* 9: Handschuhe
* 10: Helm
* 11: Ring
* 12: Trank
* 13: Questgegenstand
* 14: Crap
* 15: Dolch
*/
item[0] = new Items(0, 0, "", 0, 0, 0, 0, "", 0, 0, 0, 0);
item[1] = new Items(6, 1, "Bauernhemd", 0, 0, 2, 1, "Weiß", 0, 0, 0, 0);
item[2] = new Items(7, 4, "Leinenhose", 0, 0, 3, 1, "Weiß", 0, 0, 0, 0);
item[3] = new Items(8, 6, "Bauernstiefel", 0, 0, 3, 2, "Weiß", 0, 0, 0, 0);