📄 npcmanager.java
字号:
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class NPCManager
{
NPC[] npc;
Image im;
int[][] pd ;
int[] fs = new int[]{2,3,4,5};
int dn,zn;
public NPCManager(int max)
{
npc = new NPC[max];
try {
im = Image.createImage( "/n10.png");
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
pd = new int[][]{{0,0,35,46 , 18 , 46},
{35,0,35,42 , 18 , 41},
{70,0,48,36 , 24 , 36},
{118,0,55,35 , 26 , 36},
{173,0,43,36 , 21 , 36},
{216,0,57,41 , 28 , 41},
{0, 46,44,49 , 22 , 49},
{44,42,30,53 , 15 , 53},
{74,36,31,29 , 15 , 29},
{105,35,30,50 , 15 , 50},
{135,36,50,50 , 25 , 50},
{185,42,32,39 , 16 , 39},
{217,42,41,47 , 20 , 47},
{258,42,40,44 , 20 , 44},
{0,95,38,38 , 19 , 39},
{38,95,42,28 , 21 , 28},
{90,86,51,21 , 25 , 21},
{141,86,39,32 , 19 , 32},
{180,86,28,45 , 14 , 45},
{208,89,38,39 , 19 , 39},
{246,89,36,58 , 18 , 58},
{0, 133,28,55 , 14 , 55},
{28,133,38,47 , 19 , 47},
{66,122,30,59 , 14 , 55},
{96,110,21,58 , 10 , 54},
{117,122,29,55 ,14 , 55},
{146,122,32,45 , 16 , 45},
{180,134,35,54 , 18 , 53},
{216,147,49,41 , 25 , 41},
{0,0,0,0,0,0}};
}
public void render(int index,Graphics g,int cx,int cy)
{
if (npc[index] != null)
{
npc[index].render( g,cx,cy);
}
}
public void upData(MC mc)
{
this.ZL (mc);
for (int i = 0; i <npc.length ;i++)
{
if (npc[i] != null)
{
npc[i].upData( mc,mc.pl );
if (npc[i].m == 12 &&npc[i].n <= 0)
{
npc[i] = null;
dn --;
break;
}
if (npc[i].n == 2 && npc[i].m == 6 &&mc.pl.y == 0)
{
if (npc[i].f == false)
{
if (npc[i].x > mc.pl .x -20&&npc[i].x < mc.pl .x && Math.abs( npc[i].z - mc.pl.z ) < 10)
{
mc.pl.hp --;
if (mc.pl.hp > 0)
{
mc.pl.m = 8;
mc.pl.n = 5;
mc.pl.setfs( new int []{12});
}
else
{
mc.pl.m = 10;
mc.pl.n = 10;
mc.pl.setfs( new int []{16});
}
}
}
}
else
{
if (npc[i].n == 2 && npc[i].m == 6&&mc.pl.y == 0)
{
if (npc[i].x > mc.pl .x &&npc[i].x < mc.pl .x + 20 && Math.abs( npc[i].z - mc.pl.z ) < 10)
{
mc.pl.hp --;
if (mc.pl.hp > 0)
{
mc.pl.m = 8;
mc.pl.n = 5;
mc.pl.setfs( new int []{12});
}
else
{
mc.pl.m = 10;
mc.pl.n = 10;
mc.pl.setfs( new int []{16});
}
}
}
}
}
}
}
public void create(int m,int x,int z,MC mc)
{
for (int i = 0; i< npc.length ;i++)
{
if (npc[i] == null)
{
switch (m)
{
case 1:
npc[i] = new NPC1(im,pd,fs,mc,x,z);
break;
// case 2:
// npc[i] = new NPC2(im,pd,fs,mc,150,150);
// break;
}
break;
}
}
}
public void ZL( MC mc)
{
switch (mc.cx )
{
case 100:
if (mc.ig == true)
{
mc.ig = false;
dn = 3;
zn = 3;
this.create( 1,mc.cx + 50,180,mc);
this.create( 1,mc.cx + 70,140,mc);
this.create( 1,mc.cx + 80,160,mc);
}
else
{
if (dn < 3 && zn < 5)
{
this.create( 1,mc.cx + 120,140,mc);
dn++;
zn++;
}
if (dn == 0 &&zn == 5)
{
mc.ig =true;
mc.cx += 5;
}
}
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -