admin 管理员组

文章数量: 887021


2024年1月15日发(作者:python从入门到实践在线阅读)

("娓╅Θ鎻愮ず锛氭寜鏁板瓧閿�閫変腑鎵�湁鍐滄皯"); ("娓╅Θ鎻愮ず锛氭寜鏁板瓧閿�閫変腑鎵�湁鏈烘灙鍏�"); }

private void initControl(){

GameGUI gui = (GameGUI) ent(); control = new Control(this, );

PressListener(new KeyPressListener(){ public void press(int keyCode) {

if(keyCode==_1){ (); for(Tile tile:es()){

boolean isScv = (e()==rentType()) &&(tile instanceof Scv); if(isScv){ (); usSprite((Sprite)tile); }

} } else if(keyCode==_2){ (); for(Tile tile:es()){

boolean isMarine = e()==rentType() &&tile instanceof Marine; if(isMarine){ (); usSprite((Sprite)tile); }

} } }

}); gListener(new DragListener(){ public void drag(int x, int y, int dx, int dy) { (x, y, dx, dy); } }); tPressListener(new LeftPressListener(){ public void press(int x, int y) { //(x, y); e(x, y); }

}); htPressListener(new RightPressListener(){ public void press(int x, int y) { (x, y); } });

eListener(new MoveListener(){ public void move(int x, int y) {

int offsetX = X; int screenX = getWidth()-_WIDTH;

public class NewGamePanel extends Abstractpanel { LeftPanel leftPanel; RightPanel rightPanel;

public NewGamePanel(GameGUI gameGUI, String name) { super(gameGUI, name); leftPanel = new LeftPanel(this); rightPanel = new RightPanel(this); (leftPanel); (rightPanel); } public void paintComponent(Graphics g) { age(main, 0, 0, null); } public void update(long elapsedTime) { (elapsedTime); (elapsedTime); } public void reset() { (-50, 50); (800, -180); if(kManager instanceof MockNetWorkManager){ (0).removeAllElements(); (0).addElement("Player"); for(int i=1;i<();++i){ DefaultComboBoxModel cbm = (i); ectedItem("Computer"); } }else{ for(int i=1;i<();++i){ DefaultComboBoxModel cbm = (i); if(ectedItem().equals("Computer")) ectedItem("Open"); } }

}

class TextPanel extends JPanel { private int x, y = 300; Elastic elastic = new Elastic(-50, 50);

Image image = age("");

public TextPanel() { setLayout(null); setSize(400, 270); setLocation(x, y); }

public void paintComponent(Graphics g) { age(image, 0, 0, null); or(fillColor); ct(20, 345, getWidth() - 25, getHeight() - 50); or(borderColor); ct(20, 345, getWidth() - 25, getHeight() - 50);

} public void update(long elapsedTime) { x = (elapsedTime); setLocation(x, y); }

} class LeftPanel extends JPanel { private int x, y = 20; Elastic elastic = new Elastic(-50, 50); Image image = age("");

String labels[] = { "Open", "Closed","Computer"};

LinkedList players = new LinkedList();

String type[] = { "Terran"};

JComboBox[][] jcbs = new JComboBox[4][2];

public LeftPanel(JPanel parenPanel) { setLayout(null); setSize(400, 270); setLocation(x, y); int location=120;

final DefaultComboBoxModel mode1 = new DefaultComboBoxModel(labels); tDataListener(new ListDataListener(){ public void contentsChanged(ListDataEvent e) { DefaultComboBoxModel model = (DefaultComboBoxModel) rce(); Object item = ectedItem(); //n(item+ ".contentsChanged() 1"); if(("Computer") || ("Open") || ("Closed")){ (ng(), 1); //n(item); } } public void intervalAdded(ListDataEvent e) {} public void intervalRemoved(ListDataEvent e) {}

});

final DefaultComboBoxModel mode2 = new DefaultComboBoxModel(labels); tDataListener(new ListDataListener(){ public void contentsChanged(ListDataEvent e) { String value = ectedItem().toString(); if(("Computer") || ("Open") || ("Closed")){ (value,2); } } public void intervalAdded(ListDataEvent e) {} public void intervalRemoved(ListDataEvent e) {}

}); final DefaultComboBoxModel mode3 = new DefaultComboBoxModel(labels); tDataListener(new ListDataListener(){ public void contentsChanged(ListDataEvent e) { String value = ectedItem().toString(); if(("Computer") || ("Open") || ("Closed")){ (value,3); } } public void intervalAdded(ListDataEvent e) {} public void intervalRemoved(ListDataEvent e) {}

});

//如果是SingleGame// if(kManager instanceof MockNetWorkManager){// (new DefaultComboBoxModel(new String[]{"Player"}));// }else{// (new DefaultComboBoxModel());// } //n("kManager:"+kManager); (new DefaultComboBoxModel()); (mode1); (mode2); (mode3);

for(int y=0;y<;++y){

jcbs[y][0] = new JComboBox(); jcbs[y][0].setModel((y)); jcbs[y][0].addItemListener(new GameItemListener(y)); jcbs[y][0].setLocation(50, location); initJComboBox(jcbs[y][0]);

jcbs[y][1] = new JComboBox(type); jcbs[y][1].setLocation(200, location); jcbs[y][1].setVisible(false); initJComboBox(jcbs[y][1]);

location+=30; } }

public void addPlayer(int index,String name){ n("addplayer:"+index+","+name); (index).addElement(name); (index).setSelectedItem(name);

}

public void selectPlayer(int index,String name){

(index).setSelectedItem(name);

}

public void delPlayer(int index,String oldName){

(index).removeElement(oldName);// for(int i=0;i<(index).getSize();++i){// Object item = (index).getElementAt(i);

// if((newName)){// (index).setSelectedItem(newName);// return;// }// }// (index).addElement(newName); }

private class GameItemListener implements ItemListener{ int index;

public GameItemListener(int index) { = index; } public void itemStateChanged(ItemEvent e) {

String value = m().toString(); if(("Closed")||m().toString().equals("Open")){ jcbs[index][1].setVisible(false); }else{ jcbs[index][1].setVisible(true); } }

} private void initJComboBox(JComboBox jcb){ e(120, 20); que(false); usable(false); derer(new StarComboBoxRender()); ((ComboBoxUI) UI(jcb)); der(new RoundBorder()); add(jcb); } public void paintComponent(Graphics g) { age(image, 0, 0, null); or(fillColor); ct(20, 45, getWidth() - 25, getHeight() - 50); or(borderColor); ct(20, 45, getWidth() - 25, getHeight() - 50); or(titleColor); ring("Create Game:", 50, 100); } public void update(long elapsedTime) { x = (elapsedTime); setLocation(x, y); } /** * New Game listener */ ActionListener newbtnLis = new ActionListener() { public void actionPerformed(ActionEvent e) { GameGUI gamePanel = (GameGUI) ent(); (50, -300); (600, 200); try {

(200); } catch (InterruptedException e1) { tackTrace(); } NewGame(); } }; ActionListener loadbtnLis = new ActionListener() { public void actionPerformed(ActionEvent e) { } }; } /** * 右边Panel */ class RightPanel extends JPanel { private int x, y; Elastic elastic = new Elastic(800, -180); Image image = age(""); JButton startbtn = new JButton("Start");

JButton returnbtn = new JButton("Return"); public RightPanel(JPanel parent) { setLayout(null); setSize(180, 180); x = (th() - getWidth()); y = 460; setLocation(x, y);

initButton(startbtn, startListen); ation(0, 45); e(150, 28); add(startbtn);

initButton(returnbtn, returnListen); ation(0, 75); e(150, 28); add(returnbtn); } public void paintComponent(Graphics g) { age(image, getWidth() - th(null), 0, null); } public void update(long elapsedTime) { x = (elapsedTime); setLocation(x, y); } ActionListener startListen = new ActionListener() { public void actionPerformed(ActionEvent e) { PlayerList playerList = ame(); if(playerList!=null){


本文标签: 入门 阅读 实践 作者