📄 metalmaxcanvas.java
字号:
}else if(cursorheight > listH && shopPage == 0){
cursorheight = listH;
cursorwidth = 0;
}
}
/*输入右键,指针坐标更新,只用于出售物品*/
if ((KeyState & RIGHT_PRESSED) != 0) {
if(isShop_Sell){
if (cursorwidth != listW) {
cursorwidth += listW;
}
}
}
/*输入左键,指针坐标更新,只用于出售物品*/
if ((KeyState & LEFT_PRESSED) != 0) {
if(isShop_Sell){
if (cursorwidth != 0) {
cursorwidth -= listW;
}
}
}
/*输入"1"键,取消操作,状态恢复为正常状态*/
if ((KeyState & GAME_A_PRESSED) != 0) {
gameState = GAME_NORMAL;
menuState = MENU_NORMAL;
shopState = SHOP_NORMAL;
isShop_ItemList = false;
isShop_EquList = false;
isShop_Sell = false;
listH = 20;
shopPage = 0;
cursorwidth = 0;
cursorheight = 0;
this.eventID = 0;
}
/*输入确定键,根据当前显示的内容作出不同的处理*/
if ((KeyState & FIRE_PRESSED) != 0) {
/*根据指针的坐标位置,判断指针指向的内容*/
switch(cursorwidth / listW){
case 0:
switch (cursorheight / 10) {
case 0:
/*如果显示的是选择商店菜单界面*/
if(!isShop_ItemList && !isShop_EquList && !isShop_Sell){
cursorheight = 0;
cursorwidth = 0;
shopState = SHOP_CHO1;
}
/*如果显示的是购买人类工具界面*/
if(isShop_ItemList){
if(shopPage == 0){
buyItem(g, 0);
}else if(shopPage == 1){
buyItem(g, 4);
}
}
/*如果显示的是购买人类装备界面*/
if(isShop_EquList){
if(shopPage == 0){
buyEquItem(g, 0);
}else if(shopPage == 1){
buyEquItem(g, 4);
}
}
/*如果显示的是显示出售物品界面*/
if(isShop_Sell){
/*根据不同的商店类型,出售不同的商店物品*/
if(shopType == 4){
sellItem(g, 0);
}else if(shopType == 3){
sellEquItem(g, 0);
}
}
break;
case 1:
if(!isShop_ItemList && !isShop_EquList && !isShop_Sell){
cursorheight = 0;
cursorwidth = 0;
shopState = SHOP_CHO2;
}
if(isShop_ItemList){
if(shopPage == 0){
buyItem(g, 1);
}else if(shopPage == 1){
buyItem(g, 5);
}
}
if(isShop_EquList){
if(shopPage == 0){
buyEquItem(g, 1);
}else if(shopPage == 1){
buyEquItem(g, 5);
}
}
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 2);
}else if(shopType == 3){
sellEquItem(g, 2);
}
}
break;
case 2:
if(!isShop_ItemList && !isShop_EquList && !isShop_Sell){
shopState = SHOP_CHO3;
}
if(isShop_ItemList){
if(shopPage == 0){
buyItem(g, 2);
}else if(shopPage == 1){
buyItem(g, 6);
}
}
if(isShop_EquList){
if(shopPage == 0){
buyEquItem(g, 2);
}else if(shopPage == 1){
buyEquItem(g, 6);
}
}
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 4);
}else if(shopType == 3){
sellEquItem(g, 4);
}
}
break;
case 3:
if(!isShop_ItemList && !isShop_EquList && !isShop_Sell){
shopState = SHOP_CHO4;
}
if(isShop_ItemList){
if(shopPage == 0){
buyItem(g, 3);
}else if(shopPage == 1){
buyItem(g, 7);
}
}
if(isShop_EquList){
if(shopPage == 0){
buyEquItem(g, 3);
}else if(shopPage == 1){
buyEquItem(g, 7);
}
}
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 6);
}else if(shopType == 3){
sellEquItem(g, 6);
}
}
break;
}
break;
case 1:
switch(cursorheight / 10){
case 0:
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 1);
}else if(shopType == 3){
sellEquItem(g, 1);
}
}
break;
case 1:
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 3);
}else if(shopType == 3){
sellEquItem(g, 3);
}
}
break;
case 2:
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 5);
}else if(shopType == 3){
sellEquItem(g, 5);
}
}
break;
case 3:
if(isShop_Sell){
if(shopType == 4){
sellItem(g, 7);
}else if(shopType == 3){
sellEquItem(g, 7);
}
}
break;
default:
break;
}
break;
default:
break;
}
}
/*判断商店状态,作出相应的处理*/
switch(shopState){
/*如果选择的是商店的第一个菜单,显示的是"买什么"*/
case SHOP_CHO1:
/*根据商店管理器获取商店库存物品信息*/
shopItemList = sm.getShopItem();
/*图片刷新*/
g.drawImage(shopImg, 0, 0, Graphics.TOP | Graphics.LEFT);
g.drawImage(cursorImg, cursorwidth + 62, 5 + cursorheight, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getShopName(), 5, 10, Graphics.TOP | Graphics.LEFT);
g.drawString(String.valueOf(mHero.getHeroMoney()), 12, 32, Graphics.TOP | Graphics.LEFT);
/*如果是物品寄存*/
if(shopType == 1){
g.drawString(sm.getCho1(), 80, 2, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho2(), 80, 12, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho3(), 80, 22, Graphics.TOP | Graphics.LEFT);
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP| Graphics.LEFT);
g.drawString("该功能还未实现!", 70, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
gameState = GAME_NORMAL;
menuState = MENU_NORMAL;
shopState = SHOP_NORMAL;
isShop_ItemList = false;
isShop_EquList = false;
isShop_Sell = false;
listH = 20;
shopPage = 0;
cursorwidth = 0;
cursorheight = 0;
}
/*如果是战车补给*/
if(shopType == 2){
g.drawString(sm.getCho1(), 80, 2, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho2(), 80, 12, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho3(), 80, 22, Graphics.TOP | Graphics.LEFT);
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
g.drawString("该功能还未实现!", 70, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
gameState = GAME_NORMAL;
menuState = MENU_NORMAL;
shopState = SHOP_NORMAL;
isShop_ItemList = false;
isShop_EquList = false;
isShop_Sell = false;
listH = 20;
shopPage = 0;
cursorwidth = 0;
cursorheight = 0;
}
/*如果是人类武器店*/
if(shopType == 3){
/*设置为显示人类武器界面*/
isShop_EquList = true;
/*商店库存物品初始化,并根据显示的页数显示相应的物品信息*/
shopEquItem = new EquItemManager[shopItemList.length];
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
g.drawString("买点什么?", 80, getHeight() -40, Graphics.TOP | Graphics.LEFT);
if(shopPage == 0){
for(int i= 0; i < (shopItemList.length >= 4 ? 4 : shopItemList.length); i++){
shopEquItem[i] = new EquItemManager(shopItemList[i]);
g.drawString(shopEquItem[i].getEquItemName(), 80, 2+10*i, Graphics.TOP|Graphics.LEFT);
g.drawString(String.valueOf(shopEquItem[i].getBuyPrice()) + "G", getHeight() -40, 2+10*i, Graphics.TOP|Graphics.LEFT);
}
}else if(shopPage == 1){
for(int i= 4; i < shopItemList.length; i++){
shopEquItem[i] = new EquItemManager(shopItemList[i]);
g.drawString(shopEquItem[i].getEquItemName(), 80, 2+10*(i - 4), Graphics.TOP|Graphics.LEFT);
g.drawString(String.valueOf(shopEquItem[i].getBuyPrice()) + "G", getHeight() -40, 2+10*(i - 4), Graphics.TOP|Graphics.LEFT);
}
}
}
/*如果是人类工具店*/
if(shopType == 4){
isShop_ItemList = true;
shopHeroItem = new ItemManager[shopItemList.length];
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
g.drawString("买点什么?", 80, getHeight() -40, Graphics.TOP | Graphics.LEFT);
if(shopPage == 0){
for(int i= 0; i < (shopItemList.length >= 4 ? 4 : shopItemList.length); i++){
shopHeroItem[i] = new ItemManager(shopItemList[i]);
g.drawString(shopHeroItem[i].getItemName(), 80, 2+10*i, Graphics.TOP|Graphics.LEFT);
g.drawString(String.valueOf(shopHeroItem[i].getBuyPrice()) + "G", getHeight() -40, 2+10*i, Graphics.TOP|Graphics.LEFT);
}
}else if(shopPage == 1){
for(int i= 4; i < shopItemList.length; i++){
shopHeroItem[i] = new ItemManager(shopItemList[i]);
g.drawString(shopHeroItem[i].getItemName(), 80, 2+10*(i - 4), Graphics.TOP|Graphics.LEFT);
g.drawString(String.valueOf(shopHeroItem[i].getBuyPrice()) + "G", getHeight() -40, 2+10*(i - 4), Graphics.TOP|Graphics.LEFT);
}
}
}
/*如果是勇士办事处*/
if(shopType == 5){
g.drawString(sm.getCho1(), 80, 2, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho2(), 80, 12, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho3(), 80, 22, Graphics.TOP | Graphics.LEFT);
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP| Graphics.LEFT);
g.drawString("布告上的水怪", 70, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
g.drawString("躲在山洞里", 70, getHeight() - menuImg.getHeight() + 10, Graphics.TOP | Graphics.LEFT);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
gameState = GAME_NORMAL;
menuState = MENU_NORMAL;
shopState = SHOP_NORMAL;
isShop_ItemList = false;
isShop_EquList = false;
isShop_Sell = false;
listH = 20;
shopPage = 0;
cursorwidth = 0;
cursorheight = 0;
}
break;
/*如果选择的是商店的第二个菜单,显示的是"卖什么"*/
case SHOP_CHO2:
shopItemList = sm.getShopItem();
isShop_ItemList = false;
isShop_EquList = false;
g.drawImage(shopImg, 0, 0, Graphics.TOP | Graphics.LEFT);
g.drawImage(cursorImg, cursorwidth + 62, 5 + cursorheight, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getShopName(), 5, 10, Graphics.TOP | Graphics.LEFT);
g.drawString(String.valueOf(mHero.getHeroMoney()), 12, 32, Graphics.TOP | Graphics.LEFT);
/*物品寄存*/
if(shopType == 1){
g.drawString(sm.getCho1(), 80, 2, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho2(), 80, 12, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho3(), 80, 22, Graphics.TOP | Graphics.LEFT);
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP| Graphics.LEFT);
g.drawString("该功能还未实现!", 70, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
gameState = GAME_NORMAL;
menuState = MENU_NORMAL;
shopState = SHOP_NORMAL;
isShop_ItemList = false;
isShop_EquList = false;
isShop_Sell = false;
listH = 20;
shopPage = 0;
cursorwidth = 0;
cursorheight = 0;
}
/*战车补给*/
if(shopType == 2){
g.drawString(sm.getCho1(), 80, 2, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho2(), 80, 12, Graphics.TOP | Graphics.LEFT);
g.drawString(sm.getCho3(), 80, 22, Graphics.TOP | Graphics.LEFT);
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP| Graphics.LEFT);
g.drawString("该功能还未实现!", 70, getHeight() - menuImg.getHeight(), Graphics.TOP | Graphics.LEFT);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
gameState = GAME_NORMAL;
menuState = MENU_NORMAL;
shopState = SHOP_NORMAL;
isShop_ItemList = false;
isShop_EquList = false;
isShop_Sell = false;
listH = 20;
shopPage = 0;
cursorwidth = 0;
cursorheight = 0;
}
if(shopType == 3){/*出售人类武器*/
isShop_Sell = true;
g.drawImage(menuImg, 0, getHeight() - menuImg.getHeight(), Graphics.TOP| Graphics.LEFT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -