📄 kid.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: Kid.java
package falcofinder.Wien;
import java.util.Vector;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
// Referenced classes of package falcofinder.Wien:
// Town, M, AreaA
public class Kid
implements Runnable
{
protected int posx;
protected int posy;
private int xcentro;
private int ycentro;
protected boolean ismoving;
private int section;
protected int keycode;
protected String keyname;
protected int width;
protected int height;
protected int status;
protected String msg;
protected long msgtime;
Town town;
AreaA areaa;
protected int pick;
private boolean turnface;
private int ii;
private long starttime;
public Kid(Town town, AreaA areaa)
{
msg = "";
pick = 0;
turnface = true;
ii = 0;
starttime = 0L;
width = town.width;
height = town.height;
xcentro = Integer.parseInt("" + width / 2);
ycentro = Integer.parseInt("" + height / 2);
this.town = town;
this.areaa = areaa;
posx = 10;
posy = 10;
ismoving = false;
}
protected void start()
{
Thread t = new Thread(this);
t.start();
}
public void run()
{
while(true)
try
{
Thread.sleep(100L);
if(ismoving)
{
if(System.currentTimeMillis() - msgtime > 4000L)
msg = "";
go(keycode);
}
town.m.run();
movetrain();
town.repaint();
}
catch(InterruptedException ie)
{
return;
}
}
private void movetrain()
{
if(areaa.section == areaa.sectiontrain && town.kid.posx >= areaa.posTrainx && town.kid.posx <= areaa.posTrainx + areaa.widthTrain && town.kid.posy >= areaa.posTrainy && town.kid.posy <= areaa.posTrainy + areaa.heightTrain && !town.kid.winGame())
{
town.kid.ismoving = false;
town.kid.status = 1;
}
if(town.areaa.width <= areaa.posTrainx)
{
areaa.sectiontrain++;
ii = 0;
}
if(areaa.sectiontrain == 7 && areaa.posTrainx == 0)
starttime = System.currentTimeMillis();
if(areaa.sectiontrain == 7 && ii == 52)
{
areaa.trainHalts = true;
if(System.currentTimeMillis() - starttime > 10000L)
{
ii = 68;
areaa.trainHalts = false;
}
} else
{
if(town.areaa.width <= areaa.posTrainx)
areaa.posTrainx = -12;
else
areaa.posTrainx = areaa.posTrainx + 2;
ii = ii + 2;
}
if(areaa.sectiontrain == 9)
areaa.sectiontrain = 6;
}
protected void move(int keycode, String keyname)
{
this.keyname = keyname;
this.keycode = keycode;
ismoving = true;
if(areaa.pause)
go(keycode);
}
private void go(int keycode)
{
section = areaa.section;
pick = 0;
if(section > 8 || section < 0)
msg = "Out of map!";
if(keycode == 1 || keyname.compareTo("2") == 0)
if((section == 0 || section == 1 || section == 2) && posy <= 1)
{
msg = "Wall";
} else
{
posy--;
posy--;
}
if(keycode == 6 || keyname.compareTo("8") == 0)
if((section == 6 || section == 7 || section == 8) && posy >= height - 5)
{
msg = "Wall";
} else
{
posy++;
posy++;
}
if(keycode == 2 || keyname.compareTo("4") == 0)
if((section == 0 || section == 3 || section == 6) && posx <= 1)
{
msg = "Wall";
} else
{
posx--;
posx--;
turnface = false;
}
if(keycode == 5 || keyname.compareTo("6") == 0)
if((section == 2 || section == 5 || section == 8) && posx >= width - 5)
{
msg = "Wall";
} else
{
posx++;
posx++;
turnface = true;
}
if(posx >= width)
{
posx = 2;
areaa.section++;
town.m.section = town.m.section + 2;
}
if(posy >= height)
{
posy = 2;
areaa.section = areaa.section + 3;
town.m.section = town.m.section + 2;
}
if(posx <= -2)
{
posx = width - 2;
areaa.section = areaa.section - 1;
town.m.section = town.m.section + 2;
}
if(posy <= -2)
{
areaa.section = areaa.section - 3;
posy = height - 2;
town.m.section = town.m.section + 2;
}
if(keycode == 8 || keyname.compareTo("5") == 0)
{
msgtime = System.currentTimeMillis();
pick = 1;
eventArea();
}
if(keyname.compareTo("1") == 0)
eventArea();
if(keyname.compareTo("3") == 0)
eventArea();
if(keyname.compareTo("9") == 0)
eventArea();
if(keyname.compareTo("7") == 0)
{
msg = "Bag";
eventArea();
}
if(posx >= xcentro && posx <= xcentro + 20 && posy >= ycentro && posy <= ycentro + 20 && areaa.section == areaa.sectionDog && areaa.dogIsAngry)
status = 1;
if(areaa.trainHalts && posx > areaa.posTrainx + 10 && posx < areaa.posTrainx + 40 && posy > areaa.posTrainy && posy < areaa.posTrainy + 30 && areaa.section == areaa.sectiontrain && winGame())
{
posx = -10;
posy = -10;
ismoving = false;
status = 2;
}
}
protected boolean winGame()
{
boolean hasObject1 = false;
boolean hasObject2 = false;
for(int i = 0; i < areaa.objects.size(); i++)
{
String oggetto = "" + areaa.objects.elementAt(i);
if(oggetto.compareTo("Flowers") == 0 || oggetto.compareTo("Ticket") == 0 && !hasObject1)
hasObject1 = true;
else
if(hasObject1 && (oggetto.compareTo("Flowers") == 0 || oggetto.compareTo("Ticket") == 0))
hasObject2 = true;
}
return hasObject1 && hasObject2;
}
public void eventArea()
{
if(msg.equals("Bag"))
{
if(keyname.compareTo("1") == 0)
throwObject(0);
if(keyname.compareTo("3") == 0)
throwObject(1);
if(keyname.compareTo("9") == 0)
throwObject(2);
if(keyname.compareTo("7") == 0)
{
pick = 0;
areaa.pause = false;
}
}
if(keyname.compareTo("") == 0 && keycode != 8)
town.anwr = "" + keyname;
if(keyname.compareTo("1") == 0)
town.anwr = town.anwr + keyname;
if(keyname.compareTo("3") == 0)
town.anwr = town.anwr + keyname;
if(keyname.compareTo("9") == 0)
town.anwr = town.anwr + keyname;
if(pick == 1)
msg = "Nothing to pick up";
if(posx > width - 35 && posy < 22 && areaa.section == 0)
{
msg = "Ticket Office";
if(pick == 1 || areaa.status.equals("office"))
{
areaa.status = "office";
areaa.pause = true;
ismoving = false;
}
}
if(posx >= areaa.posFlowersx && posx <= areaa.posFlowersx + 6 && posy >= areaa.posFlowersy - 6 && posy <= areaa.posFlowersy + 8 && areaa.section == areaa.sectionFlowers)
{
msg = "Flowers";
if(pick == 1)
if(areaa.objects.size() <= 3)
{
msg = "Flowers collected";
areaa.objects.addElement("Flowers");
areaa.posFlowersx = -10;
areaa.posFlowersy = -10;
} else
{
msg = "No room for Flowers";
}
}
if(posx >= width - 40 && posx <= width - 25 && posy >= height - 55 && posy <= height - 40 && areaa.section == 2)
{
msg = "Mother and son";
if(areaa.baloonFollowsKid)
{
msg = "Thanks! take 1 Euro";
areaa.objects.addElement("Money");
areaa.baloonFollowsKid = false;
areaa.posBaloonx = (width - 25) + 6;
areaa.posBaloony = height - 50 - 8;
}
}
if(posx >= areaa.posBonex && posx <= areaa.posBonex + 10 && posy >= areaa.posBoney - 6 && posy <= areaa.posBoney + 10 && areaa.section == areaa.sectionBone)
{
msg = "Bone";
if(pick == 1)
if(areaa.objects.size() <= 3)
{
msg = "Bone collected";
areaa.objects.addElement("Bone");
areaa.posBonex = -10;
areaa.posBoney = -10;
areaa.dogIsAngry = false;
} else
{
msg = "No room for Bone";
}
}
if(posx >= width - 18 && posx <= width - 4 && posy >= height - 45 && posy <= height - 7 && areaa.section == 4)
{
msg = "Where is my dog?";
if(areaa.dogFollowsKid)
{
msg = "Thanks! keep a ballon";
areaa.dogFollowsKid = false;
areaa.baloonFollowsKid = true;
}
}
if(posx >= areaa.posLeadx && posx <= areaa.posLeadx + 13 && posy >= areaa.posLeady - 6 && posy <= areaa.posLeady + 8 && areaa.section == areaa.sectionLead)
{
msg = "Lead";
if(pick == 1)
if(areaa.objects.size() <= 3)
{
msg = "Lead collected";
areaa.objects.addElement("Lead");
areaa.posLeadx = -10;
areaa.posLeady = -10;
} else
{
msg = "No room for a Lead";
}
}
}
public void throwObject(int position)
{
String oggetto = "" + areaa.objects.elementAt(position);
if(oggetto.compareTo("Bone") == 0)
{
areaa.posBonex = posx;
areaa.posBoney = posy;
areaa.bone = true;
areaa.sectionBone = section;
areaa.objects.removeElementAt(position);
if(areaa.posBonex > areaa.posDogx - 20 && areaa.posBonex < areaa.posDogx + 20 && areaa.posBoney > areaa.posDogy - 20 && areaa.posBoney < areaa.posDogy + 20)
{
msg = "Dog thanks u!";
areaa.dogIsEating = true;
areaa.posBonex = -10;
areaa.posBoney = -10;
} else
{
areaa.dogIsAngry = true;
}
}
if(oggetto.compareTo("Flowers") == 0)
{
areaa.posFlowersx = posx;
areaa.posFlowersy = posy;
areaa.sectionFlowers = section;
areaa.flowers = true;
areaa.objects.removeElementAt(position);
}
if(oggetto.compareTo("Lead") == 0)
{
areaa.posLeadx = posx;
areaa.posLeady = posy;
areaa.lead = true;
areaa.sectionLead = section;
areaa.objects.removeElementAt(position);
if(areaa.posLeadx > areaa.posDogx - 20 && areaa.posLeadx < areaa.posDogx + 20 && areaa.posLeady > areaa.posDogy - 20 && areaa.posLeady < areaa.posDogy + 20 && areaa.dogIsEating)
{
areaa.dogFollowsKid = true;
areaa.posLeadx = -10;
areaa.posLeady = -10;
}
}
}
public void drawKid(Graphics g)
{
g.setColor(52, 159, 255);
g.fillRect(posx + 5, posy + 8, 2, 6);
g.drawLine(posx + 5, posy + 13, posx + 2, posy + 16);
g.drawLine(posx + 6, posy + 13, posx + 9, posy + 16);
g.drawLine(posx + 6, posy + 9, posx + 1, posy + 12);
g.drawLine(posx + 6, posy + 9, posx + 9, posy + 12);
g.setColor(0, 0, 0);
if(turnface)
g.fillArc(posx, posy, 9, 9, 0, 360);
else
g.fillArc(posx - 1, posy, 9, 9, 0, 360);
g.setColor(255, 255, 255);
if(turnface)
g.fillArc(posx, posy, 9, 9, 0, 360);
else
g.fillArc(posx - 1, posy, 9, 9, 0, 360);
g.setColor(0, 0, 0);
if(turnface)
g.drawArc(posx + 6, posy + 4, 2, 1, 45, 325);
else
g.drawArc(posx + 1, posy + 4, 2, 1, 45, 325);
if(turnface)
{
g.setColor(247, 255, 2);
g.fillArc(posx, posy, 9, 9, 45, 120);
g.fillRoundRect(posx, posy, 5, 15, 10, 10);
} else
{
g.setColor(247, 255, 2);
g.fillArc(posx, posy, 9, 9, 0, 120);
g.fillRoundRect(posx + 5, posy, 5, 13, 10, 10);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -