⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapediter.java

📁 这是自己设计的一款java泡泡游戏。 这是自己设计的一款java泡泡游戏。这是自己设计的一款java泡泡游戏
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		{
			if(e.getKeyCode()==KeyEvent.VK_CONTROL) pressingCtrl=true;
		}
		public void keyReleased(KeyEvent e)
		{
			if(e.getKeyCode()==KeyEvent.VK_CONTROL) pressingCtrl=false;
		}

	}
	private class MouseHandle extends MouseAdapter
	{
		public void mouseClicked(MouseEvent e)
		{
			if(e.getX()<0 || e.getX()> 602||
				e.getY()<0 || e.getY()>522) return;
			if(e.getButton()==MouseEvent.BUTTON2)
			{
				String newtype = "configures\\authorinfo.ini";
				MapEditer.this.setVisible(false);
				newframe = new MapEditer(newtype)
				{
					public void mapInit()
					{
						map = new Map();
						map.playerMax=2;
						map.configureName=resType;
						imageRecord   = group.getImage(2,1);
						fraiseRecord    = 1;
						iconlbl.setIcon((Icon)new ImageIcon(imageRecord));
						tileorfraise  = false;
						imageorstring = true;
						showGrid.setState(false);
						iconlbl.setVisible(true);
						for(int i=0;i<15;i++)
							map.tile[0][i]=i+1;
						for(int i=1;i<13;i++)
							for(int j=0;j<15;j++)
							{
								map.tile[i][j]=16;
							}
					}
				};
				for(int i=1;i<=newframe.group.tileNumbers;i++)
				{
					newframe.flr[i].setVisible(false);
				}
				newframe.coverAll.setVisible(false);
				MapEditer.this.dispose();
				try{
					JOptionPane.showMessageDialog(newframe,"欢迎进入隐藏风格","Welcome!",JOptionPane.INFORMATION_MESSAGE);
				}catch(Exception ex){}
				//手动设置初始地表,照片;
				newframe.sim.repaint();
			}
			else if(e.getButton()==MouseEvent.BUTTON3)
			{
				mouseX=e.getX();
				mouseY=e.getY();
				popmu.show(e.getComponent(),mouseX,mouseY);
			}
			else if(e.getButton()==MouseEvent.BUTTON1)
			{
				if(imageorstring)
				{
					if(tileorfraise)
					{
						map.fraise[(e.getY()-3)/40][(e.getX()-3)/40]=0;
						map.tile  [(e.getY()-3)/40][(e.getX()-3)/40]=tileRecord;
					}
					else 
					{
						if(map.tile[(e.getY()-3)/40][(e.getX()-3)/40]==0) 
						{
							try{
								JOptionPane.showMessageDialog(sim,"现在是经济时代,\n没买地皮,不能建房!","错误",JOptionPane.ERROR_MESSAGE);
							}catch(Exception ex){}
						}
						else 
							map.fraise[(e.getY()-3)/40][(e.getX()-3)/40]=fraiseRecord;
					}
				}
				else
				{
					if(map.tile[(e.getY()-3)/40][(e.getX()-3)/40]==0) 
					{
						try{
							JOptionPane.showMessageDialog(sim,"我晕!!没地让我怎么站!\n要不你上来试试?!","错误",JOptionPane.ERROR_MESSAGE);
						}catch(Exception ex){}
						return;
					}


					if(stringRecord==null){}
					else if(stringRecord.equals("玩家1"))
					{
						map.playersI[0]=(e.getY()-3)/40;
						map.playersJ[0]=(e.getX()-3)/40;
					}
					else if(stringRecord.equals("玩家2"))
					{
						map.playersI[1]=(e.getY()-3)/40;
						map.playersJ[1]=(e.getX()-3)/40;
					}
					
				}

			}
			sim.repaint();
		}
	}
	private class StateHandle implements ItemListener
	{
		public void itemStateChanged(ItemEvent e)
		{
			if(e.getSource()== showGrid)
			{
				if(showGrid.getState())
				{
					tmpg.setColor(Color.BLUE);
				}
				else
				{
					tmpg.setColor(Color.BLACK);
				}
			}
			sim.repaint();
		}
	}
	private class MenuHandle implements ActionListener{
		public void actionPerformed(ActionEvent e)
		{
			if(e.getSource()==save)
			{
				for(int i=0;i<13;i++)
					for(int j=0;j<15;j++)
					{
						if(MapEditer.this.map.tile[i][j]==0)
						{
							try{
								JOptionPane.showMessageDialog(MapEditer.this,"请把地表填充完后再保存,谢谢!",
									"注意",JOptionPane.INFORMATION_MESSAGE);
								return;
							}
							catch(Exception ex){}
						}
					}
				FileDialog saveD = new FileDialog(MapEditer.this,"保存",FileDialog.SAVE);
    			saveD.show(true);
    			String str = saveD.getDirectory();//得到目录
    			if(str==null) return;//没选择就返回null
    			str += saveD.getFile();//得到目录下的文件名
    			try{
    				Map.saveMap(str,map);
    			}
    			catch (Exception ex){}
			}
			else if(e.getSource()==load)
			{
				FileDialog loadD = new FileDialog(MapEditer.this,"载入",FileDialog.LOAD);
				loadD.show(true);
				String str = loadD.getDirectory();
				if(str==null) return;
				str+=loadD.getFile();
				try{
					map=Map.loadMap(str);
				}
				catch (Exception ex){
					JOptionPane.showMessageDialog(MapEditer.this,"载入地图出错","Error",JOptionPane.ERROR_MESSAGE);
					}
				finally{
					MapEditer.this.setVisible(false);
					if(MapEditer.this.map.configureName.equals("configures\\authorinfo.ini"))
					{
						newframe = new MapEditer(MapEditer.this.map.configureName)
						{
							public void mapInit()
							{
								map = new Map();
								map.playerMax=2;
								map.configureName=resType;
								imageRecord   = group.getImage(2,1);
								fraiseRecord    = 1;
								iconlbl.setIcon((Icon)new ImageIcon(imageRecord));
								tileorfraise  = false;
								imageorstring = true;
								showGrid.setState(false);
								iconlbl.setVisible(true);
								for(int i=0;i<15;i++)
									map.tile[0][i]=i+1;
								for(int i=1;i<13;i++)
									for(int j=0;j<15;j++)
									{
										map.tile[i][j]=16;
									}
							}
						};
						for(int i=1;i<=newframe.group.tileNumbers;i++)
						{
							newframe.flr[i].setVisible(false);
						}
						newframe.coverAll.setVisible(false);
					}
					else
					{
						newframe = new MapEditer(MapEditer.this.map.configureName);
					}
					newframe.map = MapEditer.this.map;
					MapEditer.this.dispose();
					newframe.tmpImage = newframe.sim.createImage(606,526);
					newframe.tmpg     = newframe.tmpImage.getGraphics();
					newframe.sim.setSource(newframe.tmpg,newframe.tmpImage,newframe.group,newframe.map);
					newframe.sim.repaint();
				}
			}
			else if(e.getSource()==exit)
			{
				System.exit(0);
			}
			else if(e.getSource()==init)
			{
				MapEditer.this.mapInit();
				tmpImage  = sim.createImage(606,526);
				tmpg      = tmpImage.getGraphics();
				sim.setSource(tmpg,tmpImage,group,map);
			}
			else if(e.getSource()==about)
			{
				JOptionPane.showMessageDialog(MapEditer.this,"开发人员:\n\t厦门大学--软件学院\n\t林铠\n\t李文耀",
					"开发人员信息",JOptionPane.INFORMATION_MESSAGE);
			}
			else if(e.getSource()==fillX)
			{
				fillx();
			}
			else if(e.getSource()==fillY)
			{
				filly();
			}
			sim.repaint();
		}
	}
	private class ButtonHandle implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			if(e.getSource()==b1)
			{
				clo.show( pc,"1");
				floorORfraise=0;
			}
			else if(e.getSource()==b2)
			{
				clo.show(pc,"2");
				floorORfraise=1;
			}
			else if(e.getSource()==coverAll)
			{
				for(int i=0;i<13;i++)
				{
					for(int j=0;j<15;j++)
					{
						map.tile[i][j]=tileRecord;
					}
				}
				sim.repaint();
			}
			else if(e.getSource()==player1)
			{
				imageorstring = false;
				stringRecord  = "玩家1";
				iconlbl.setVisible(false);
			}
			else if(e.getSource()==player2)
			{
				imageorstring = false;
				stringRecord  = "玩家2";
				iconlbl.setVisible(false);
			}
		}
	}
	private class ComboBoxHandle implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			MapEditer.this.newFrame();
		}
	}
	public String getininame()
	{
		//按照外部对应文件设置文件名
		String tmp = new String();
		if(this.setType.getSelectedIndex()==1)       tmp = new String("configures\\xq.ini");
		else if(this.setType.getSelectedIndex()==2)  tmp = new String("configures\\factory.ini");
		else if(this.setType.getSelectedIndex()==3)  tmp = new String("configures\\forest.ini");
		else if(this.setType.getSelectedIndex()==4)  tmp = new String("configures\\tomb.ini");
		else if(this.setType.getSelectedIndex()==5)  tmp = new String("configures\\desert.ini");
		return tmp;
	}
	public void newFrame()
	{
		String newtype;
		if(this.setType.getSelectedIndex()==0) return;
		newtype=this.getininame();
		this.setVisible(false);
		MapEditer newframe = new MapEditer(newtype);
		this.dispose();
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -