📄 createrole.java
字号:
package assistant;
import role.Box;
import role.Dragon;
import role.Fire;
import role.Flower;
import role.FlyMonkey;
import role.Hag;
import role.ON_OFF;
import role.Skull;
import role.WaterFall;
import frame.GameStartFrame;
/**
* 本类为创建角色类
* @author Administrator
*
*/
public class CreateRole {
/**箱子计数器*/
private static int boxCount;
/**飞龙计数器*/
private static int dragonCount;
/**女巫计数器*/
private static int hagCount;
/**瀑布计数器*/
private static int waterFallCount;
/**骷髅计数器*/
private static int skullCount;
/**火计数器*/
private static int fireCount;
/**飞猴计数器*/
private static int flyMonkeyCount;
/**花计数器*/
private static int flowerCount;
/**
* 创建角色方法
*
*/
public static void createRole(){
createBox();
createDragon();
createHag();
createWaterFall();
createSkull();
createFire();
createFlyMonkey();
createFlower();
}
/**
* Method: createCamp
* Description: 创建箱子对象
*
* */
private static void createBox(){
if(boxCount == 0 && GameStartFrame.mapX == 0){
createFourBox(2,2,200,380,true,false);
boxCount = 1;
}
else if(boxCount == 1 && GameStartFrame.mapX <=-200){
createFourBox(2,2,800,380,true,true);
boxCount = 2;
}
else if(boxCount == 2 && GameStartFrame.mapX <=-600){
createFourBox(3,3,800,350,false,false);
boxCount = 3;
}
else if(boxCount == 3 && GameStartFrame.mapX <=-1600){
createFourBox(2,2,650,380,false,false);
boxCount = 4;
}
else if(boxCount == 4 && GameStartFrame.mapX <=-3100){
createFourBox(2,2,720,10,true,false);
boxCount = 5;
}
else if(boxCount == 5 && GameStartFrame.mapY >=-1950){
createFourBox(1,2,330,-65,false,false);
boxCount = 6;
}
else if(boxCount == 6 && GameStartFrame.mapY >= -1650){
createFourBox(1,2,520,-170,true,false);
boxCount = 7;
}
else if(boxCount == 7 && GameStartFrame.mapX >= -3200){
createFourBox(3,3,-140,130,true,true);
boxCount = 8;
}
else if(boxCount == 8 && GameStartFrame.mapX >= -2600){
createFourBox(2,1,-140,260,true,true);
createFourBox(2,2,-700,232,false,false);
boxCount = 9;
}
else if(boxCount == 9 && GameStartFrame.mapX >= -1600){
createFourBox(2,2,-190,380,false,false);
boxCount = 10;
}
else if(boxCount == 10 && GameStartFrame.mapX >= -1000){
createFourBox(2,2,-158,306,true,true);
boxCount = 11;
}
else if(boxCount == 11 && GameStartFrame.mapX >= -500){
createFourBox(2,2,-256,306,false,true);
boxCount = 12;
}
else if(boxCount == 12 && GameStartFrame.mapY >= -300){
createFourBox(1,2,0,-140,false,true);
boxCount = 13;
}
else if(boxCount == 13 && GameStartFrame.mapX <=-200){
createFourBox(3,3,750,350,true,true);
boxCount = 14;
}
else if(boxCount == 14 && GameStartFrame.mapX <=-600){
createFourBox(2,2,750,380,false,false);
boxCount = 15;
}
else if(boxCount == 15 && GameStartFrame.mapX <=-1300){
createFourBox(2,2,710,85,false,true);
boxCount = 16;
}
else if(boxCount == 16 && GameStartFrame.mapX <=-1800){
createFourBox(2,2,855,235,true,false);
boxCount = 17;
}
else if(boxCount == 17 && GameStartFrame.mapX <=-2620){
createFourBox(2,2,655,385,false,true);
boxCount = 18;
}
}
/**
* 创建多个箱子
* @param row 箱子行数
* @param col 箱子列数
* @param x 箱子起始X坐标
* @param y 箱子起始Y坐标
* @param flowerProp 箱子是否产生花道具
* @param hartProp 箱子是否产生心道具
*/
private static void createFourBox(int row,int col,int x,int y,boolean flowerProp,boolean hartProp){
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
boolean isFlower = false;
boolean isHart = false;
if(flowerProp && ((i == 0 && j == 0)) || (i == 1 && j == 0)){
isFlower = true;
}
else if(hartProp && (i == 1 && j == 1)){
isHart = true;
}
Box box=new Box(x+i*40,y+j*30,Box.ISWOOD,isFlower,isHart);
PublicVar.roleList.add(box);
}
}
}
/**
* 创建飞龙对象
*
*/
private static void createDragon(){
Dragon dragon = null;
if(dragonCount == 0 && GameStartFrame.mapX <= -200){
dragon=new Dragon(700,378,PublicVar.LEFT);
PublicVar.roleList.add(dragon);
dragonCount = 1;
}
else if(dragonCount == 1 && GameStartFrame.mapY >= -1400){
dragon=new Dragon(520,-150,PublicVar.LEFT);
PublicVar.roleList.add(dragon);
dragonCount = 2;
}
else if(dragonCount == 2 && GameStartFrame.mapX >= -500){
dragon=new Dragon(-120,300,PublicVar.RIGHT);
PublicVar.roleList.add(dragon);
dragonCount = 3;
}
else if(dragonCount == 3 && GameStartFrame.mapX <= -500){
dragon=new Dragon(720,380,PublicVar.LEFT);
PublicVar.roleList.add(dragon);
dragonCount = 4;
}
}
/**
* 创建女巫对象
*
*/
private static void createHag(){
Hag hag = null;
if(hagCount == 0 && GameStartFrame.mapX <= -800){
hag = new Hag(650,75,PublicVar.LEFT);
PublicVar.roleList.add(hag);
hagCount = 1;
}
if(hagCount == 1 && GameStartFrame.mapX <= -2100){
hag = new Hag(650,370,PublicVar.LEFT);
PublicVar.roleList.add(hag);
hagCount = 2;
}
if(hagCount == 2 && GameStartFrame.mapX >= -2600 && GameStartFrame.mapY == -1100){
hag = new Hag(-300,370,PublicVar.RIGHT);
PublicVar.roleList.add(hag);
hagCount = 3;
}
if(hagCount == 3 && GameStartFrame.mapX >= -1250 && GameStartFrame.mapY == -1100){
hag = new Hag(-170,300,PublicVar.RIGHT);
PublicVar.roleList.add(hag);
hagCount = 4;
}
if(hagCount == 4 && GameStartFrame.mapX <= -1800){
hag = new Hag(760,370,PublicVar.LEFT);
PublicVar.roleList.add(hag);
hagCount = 5;
}
}
/**
* 创建瀑布对象
*
*/
private static void createWaterFall(){
WaterFall water = null;
if(waterFallCount == 0 && GameStartFrame.mapX == -3250
&& GameStartFrame.mapY >-1330){
water = new WaterFall(10,-200,PublicVar.RIGHT);
PublicVar.roleList.add(water);
PublicVar.roleList.add(new ON_OFF(330,-180,water,false));
waterFallCount = 1;
}
if(waterFallCount == 1 && GameStartFrame.mapX == 0
&& GameStartFrame.mapY >-230){
water = new WaterFall(520,-200,PublicVar.LEFT);
PublicVar.roleList.add(water);
PublicVar.roleList.add(new ON_OFF(270,-185,water,false));
waterFallCount = 2;
}
if(waterFallCount == 2 && GameStartFrame.mapX <= -2800
&& GameStartFrame.mapY ==0){
water = new WaterFall(905,240,PublicVar.LEFT);
PublicVar.roleList.add(water);
PublicVar.roleList.add(new ON_OFF(780,190,water,true));
waterFallCount = 3;
}
}
/**
* 创建骷髅对象
*
*/
private static void createSkull(){
Skull skull = null;
if(skullCount == 0 && GameStartFrame.mapX == 0){
skull = new Skull(610,100,PublicVar.LEFT);
PublicVar.roleList.add(skull);
skullCount = 1;
}
else if(skullCount == 1 && GameStartFrame.mapX <= -1500){
skull=new Skull(700,390,PublicVar.LEFT);
PublicVar.roleList.add(skull);
skullCount = 2;
}
else if(skullCount == 2 && GameStartFrame.mapX >= -1400){
skull=new Skull(-220,100,PublicVar.RIGHT);
PublicVar.roleList.add(skull);
skullCount = 3;
}
else if(skullCount == 3 && GameStartFrame.mapX <= -500){
skull=new Skull(820,175,PublicVar.LEFT);
PublicVar.roleList.add(skull);
skullCount = 4;
}
else if(skullCount == 4 && GameStartFrame.mapX <= -1050 && GameStartFrame.mapY == 0){
skull=new Skull(820,390,PublicVar.LEFT);
PublicVar.roleList.add(skull);
System.out.println("ku");
skullCount = 5;
}
else if(skullCount == 5 && GameStartFrame.mapX <= -2200){
skull=new Skull(1010,250,PublicVar.LEFT);
PublicVar.roleList.add(skull);
skullCount = 6;
}
}
/**
* 创建火对象
*
*/
private static void createFire(){
Fire fire = null;
if(fireCount == 0 && GameStartFrame.mapX >= -2600 && GameStartFrame.mapY == -1100){
fire = new Fire(-360,55,PublicVar.RIGHT,60);
PublicVar.roleList.add(fire);
fire = new Fire(-780,55,PublicVar.RIGHT,62);
PublicVar.roleList.add(fire);
fireCount = 1;
}
if(fireCount == 1 && GameStartFrame.mapX <= 0 && GameStartFrame.mapY == 0){
fire = new Fire(820,135,PublicVar.LEFT,45);
PublicVar.roleList.add(fire);
fireCount = 2;
}
if(fireCount == 2 && GameStartFrame.mapX <= -1050){
fire = new Fire(850,210,PublicVar.LEFT,60);
PublicVar.roleList.add(fire);
fireCount = 3;
}
if(fireCount == 3 && GameStartFrame.mapX <= -1800){
fire = new Fire(760,65,PublicVar.LEFT,40);
PublicVar.roleList.add(fire);
fireCount = 4;
}
}
/**
* 创建飞猴对象
*
*/
private static void createFlyMonkey(){
FlyMonkey flyMonkey = null;
if(flyMonkeyCount == 0 && GameStartFrame.mapY >= -1900){
flyMonkey = new FlyMonkey(50,-100,PublicVar.RIGHT);
PublicVar.roleList.add(flyMonkey);
flyMonkeyCount = 1;
}
else if(flyMonkeyCount == 1 && GameStartFrame.mapX <= -1900 && GameStartFrame.mapY == 0){
flyMonkey = new FlyMonkey(750,-100,PublicVar.RIGHT);
System.out.println("monkey");
PublicVar.roleList.add(flyMonkey);
flyMonkeyCount = 2;
}
}
/**
* 创建花对象
*
*/
private static void createFlower(){
if(flowerCount == 0 && GameStartFrame.mapX == 0){
createTwoFlower(150,50,PublicVar.LEFT);
createTwoFlower(50,250,PublicVar.UP);
flowerCount = 1;
}
else if(flowerCount == 1 && GameStartFrame.mapX <= -165){
createTwoFlower(650,50,PublicVar.LEFT);
flowerCount = 2;
}
else if(flowerCount == 2 && GameStartFrame.mapX <= -650){
createTwoFlower(650,30,PublicVar.UP);
flowerCount = 3;
}
else if(flowerCount == 3 && GameStartFrame.mapX <= -1300){
createTwoFlower(670,20,PublicVar.UP);
flowerCount = 4;
}
else if(flowerCount == 4 && GameStartFrame.mapX <= -1800){
createTwoFlower(670,100,PublicVar.UP);
createTwoFlower(800,320,PublicVar.LEFT);
flowerCount = 5;
}
else if(flowerCount == 5 && GameStartFrame.mapX <= -2600){
createTwoFlower(670,180,PublicVar.UP);
createTwoFlower(700,180,PublicVar.UP);
PublicVar.roleList.add(new Flower(820,150));
flowerCount = 6;
}
else if(flowerCount == 6 && GameStartFrame.mapY >= -1400){
createTwoFlower(220,-50,PublicVar.UP);
flowerCount = 7;
}
else if(flowerCount == 7 && GameStartFrame.mapX >= -2600){
createTwoFlower(-140,320,PublicVar.UP);
createTwoFlower(-110,320,PublicVar.UP);
createTwoFlower(-200,30,PublicVar.LEFT);
createTwoFlower(-650,30,PublicVar.LEFT);
flowerCount = 8;
}
else if(flowerCount == 8 && GameStartFrame.mapX >= -1100){
createTwoFlower(-100,30,PublicVar.LEFT);
flowerCount = 9;
}
else if(flowerCount == 9 && GameStartFrame.mapY >= -750){
createTwoFlower(260,-70,PublicVar.UP);
createTwoFlower(260,-300,PublicVar.UP);
flowerCount = 10;
}
else if(flowerCount == 10 && GameStartFrame.mapX <= -100){
createTwoFlower(700,250,PublicVar.UP);
flowerCount = 11;
}
else if(flowerCount == 11 && GameStartFrame.mapX <= -500){
createTwoFlower(650,50,PublicVar.UP);
createTwoFlower(680,50,PublicVar.UP);
flowerCount = 12;
}
else if(flowerCount == 12 && GameStartFrame.mapX <= -1050){
createTwoFlower(700,100,PublicVar.UP);
createTwoFlower(730,100,PublicVar.UP);
createTwoFlower(800,310,PublicVar.UP);
createTwoFlower(830,310,PublicVar.UP);
flowerCount = 13;
}
else if(flowerCount == 13 && GameStartFrame.mapX <= -1800){
createTwoFlower(730,30,PublicVar.LEFT);
createTwoFlower(650,310,PublicVar.UP);
flowerCount = 14;
}
}
/**
* 创建两朵花对象
* @param x X坐标
* @param y Y坐标
* @param state 排列方式
*/
private static void createTwoFlower(int x,int y,int state){
Flower flower= null;
if(state == PublicVar.UP){
flower = new Flower(x,y);
PublicVar.roleList.add(flower);
flower = new Flower(x,y+30);
PublicVar.roleList.add(flower);
}
else{
flower = new Flower(x,y);
PublicVar.roleList.add(flower);
flower = new Flower(x+30,y);
PublicVar.roleList.add(flower);
}
}
public static void rest(){
boxCount = 0;
dragonCount = 0;
hagCount = 0;
waterFallCount = 0;
skullCount = 0;
fireCount = 0;
flyMonkeyCount = 0;
flowerCount = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -