WaitPlayer.java
上传用户:haojie1228
上传日期:2022-08-08
资源大小:347k
文件大小:4k
- package poker;
- import com.nokia.mid.ui.*;
- import javax.microedition.lcdui.*;
- import javax.microedition.lcdui.Canvas;
- import java.io.*;
- import java.util.*;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.Displayable;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2004</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- public class WaitPlayer {
- Image backImage,whoImage,manImage,womanImage,exitButtonImage,dotImage;
- int N=0;
- Timer one,listSeatTimer;
- MyTask oneTask;
- ListSeatTask listSeatTask;
- TableList tableList;
- WaitPlayerCanvas waitPlayerCanvas;
- String Account1,Account2,Account3;
- String seatID1,seatID2,seatID3;
- static WaitPlayer _instance;
- static synchronized public WaitPlayer getInstance() {
- if (_instance == null) {
- _instance = new WaitPlayer();
- }
- return _instance;
- }
- public WaitPlayer() {
- try {
- backImage = Image.createImage("/res/back1.gif");
- whoImage=Image.createImage("/res/w1_m1.gif");
- manImage=Image.createImage("/res/w1_m3.gif");
- womanImage=Image.createImage("/res/w1_m2.gif");
- exitButtonImage=Image.createImage("/res/exitbutton.gif");
- dotImage = Image.createImage("/res/dot.gif");
- }
- catch (IOException ex) {
- }
- one=new Timer();
- oneTask=new MyTask();
- waitPlayerCanvas=new WaitPlayerCanvas();
- }
- public void waiting(){
- one.schedule(oneTask,1,100);//draw dot
- /* send "I want a seat message " to server,
- * replay:can(0) can't(-1)
- *
- */
- CanSit canSitThread=new CanSit();
- canSitThread.start();
- }
- class MyTask extends TimerTask{
- public void run() {
- waitPlayerCanvas.repaint();
- }
- }
- class ListSeatTask extends TimerTask{
- public void run(){
- GetServicData.getSeat();
- // GetServicData.imID --->sex
- // GetServicData.imValue --->AccountName
- Account1=GetServicData.imValue[1];
- Account2=GetServicData.imValue[2];
- Account3=GetServicData.imValue[3];
- seatID1=GetServicData.imID[1];
- seatID2=GetServicData.imID[2];
- seatID3=GetServicData.imID[3];
- }
- }
- class CanSit extends Thread {
- String result="";
- public void run(){
- result = GetServicData.getIfCanSit();
- if (result!="-1"){
- listSeatTimer=new Timer();
- listSeatTask=new ListSeatTask();
- listSeatTimer.schedule(listSeatTask,1,1000);
- }else{
- Func.MsgBox.setString("sit Full when your request arrived or something cause your request failed!please choose another seat and try again.");
- Func.MsgBox.setTitle("you can't sit this seat!");
- Func.MsgBox.setTimeout(4000);
- Func.MsgBox.setType(AlertType.ERROR);
- one.cancel();
- listSeatTimer.cancel();
- _instance=null;
- TableList tableList=TableList.getInstance();
- GameInfo.display.setCurrent(Func.MsgBox);
- tableList.downLoad();
- }
- }
- }
- class WaitPlayerCanvas extends FullCanvas implements CommandListener{
- protected void paint(Graphics g) {
- g.drawImage(backImage,0,0,Graphics.TOP|Graphics.LEFT);
- g.drawImage(manImage,0,40,Graphics.TOP|Graphics.LEFT);
- g.drawImage(womanImage,58,22,Graphics.TOP|Graphics.LEFT);
- g.drawImage(whoImage,122,40,Graphics.TOP|Graphics.LEFT);
- g.drawImage(exitButtonImage,134,187,Graphics.TOP|Graphics.LEFT);
- for (int i=0;i<N;++i){
- g.drawImage(dotImage, (10+i*10), 192, Graphics.TOP | Graphics.LEFT);
- }
- N++;
- if(N==10) {N=0;}
- }
- public void keyPressed(int keyCode){
- System.out.println("you press:"+keyCode);
- if (keyCode==-7){
- }
- }
- public void commandAction(Command command, Displayable displayable) {
- }
- }
- }