import android.util.DisplayMetrics;
import android.view.WindowManager;
public class Data{
public static int minWidth = 150;
public static int maxWidth = 250;
//游戏舞台1 列与行
public static int stage_1_arrow = 11;
public static int stage_1_column = 11;
//游戏舞台格子大小
public static int stage_size;
//public static int game_one_size = 400;
public static int game_one_width;
public static int game_two_width;
public static int game_two_height;
public static int currentStage=0;
public static int maxStage = 20;
public static int addLifeScore = 3000;
public static int getScreenWidth(WindowManager win){
int width;
DisplayMetrics metric = new DisplayMetrics();
win.getDefaultDisplay().getMetrics(metric);
width = metric.widthPixels; // 屏幕宽度(像素)
return width;
}
public static int getScreenHeight(WindowManager win){
DisplayMetrics metric = new DisplayMetrics();
win.getDefaultDisplay().getMetrics(metric);
int height = metric.heightPixels; // 屏幕高度(像素)
return height;
}
public static int boat_bomb_image[]={
R.drawable.boat_bomb1,R.drawable.boat_bomb2,
R.drawable.boat_bomb3,R.drawable.boat_bomb4,
R.drawable.boat_bomb5,R.drawable.boat_bomb6,
R.drawable.boat_bomb7,R.drawable.boat_bomb8,
R.drawable.boat_bomb9,R.drawable.boat_bomb10,
R.drawable.boat_bomb11,R.drawable.boat_bomb12,
R.drawable.boat_bomb13,R.drawable.boat_bomb15
};
//格子数
public static String myRand(int spaceSize){
Random rd=new Random(System.currentTimeMillis());
int b=rd.nextInt(spaceSize);
int c=rd.nextInt(spaceSize);
if(b==0){
b=1;
}
if(c==0){
c=1;
}
return b+" "+c;
}
public static List<RandData> getRandData(int spaceSize,int enemyAmount,int barrierAmount,ArrayList<RandData> exist){
int i=0;
List<RandData> list = exist;
List<RandData> listOne =new ArrayList<RandData>();
while(i<enemyAmount+barrierAmount){
String str = myRand(spaceSize);
for(int j=0;j<list.size();j++){
if(list.get(j).getToatal().equals(str)){
break;
}
if(j==list.size()-1){
String []strOne = str.split(" ");
list.add(new RandData(Integer.parseInt(strOne[0]),Integer.parseInt(strOne[1])));
listOne.add(new RandData(Integer.parseInt(strOne[0]),Integer.parseInt(strOne[1])));
i++;
}
}
}
return listOne;
}
}
package com.data;
public class RandData{
//行
private int arrow;
//列
private int column;
public RandData(int arrow,int column){
this.arrow = arrow;
this.column = column;
}
//得到行
public int getArrow(){
return this.arrow;
}
//得到列
public int getColumn(){
return this.column;
}
public String getToatal(){
return this.arrow+" "+this.column;
}
}
package com.data;