?? message.java
字號:
/*
* Created on 2005-2-13
*communication
*/
package communication;
import java.io.Serializable;
/**
* @author Emtry Immortal
*
* transmit message with tank's info
*/
public class Message implements Serializable {
String strName = null;
int iID = -1;
int iType = 0;
double dPtX = 0;
double dPtY = 0;
double dSpeed = 0;
double dDirect = 0;
double dBrDirect = 0;
boolean isFire = false;
boolean isMoving = false;
int recivePort = 0;
final public static int MSG_MOVE = 1;
final public static int MSG_BARBETTE_TURN = 2;
final public static int MSG_FIRE = 3;
final public static int MSG_CREATE_TANK = 4;
final public static int MSG_REMOVE_TANK = 5;
final public static int MSG_STOP = 6;
final public static int MSG_LOGIN = -1;
final public static int MSG_LOGOUT = -2;
final public static int MSG_LOGIN_ECHO = -3;
/**
*
*/
protected Message() {
}
public static Message getMsgLoginEcho(int id, double ptX, double ptY) {
Message msg = new Message();
msg.iID = id;
msg.dPtX = ptX;
msg.dPtY = ptY;
msg.iType = Message.MSG_LOGIN_ECHO;
return msg;
}
public static Message getMsgLogin(String name, int recivePort) {
Message msg = new Message();
msg.strName = name;
msg.recivePort = recivePort;
msg.iType = Message.MSG_LOGIN;
return msg;
}
public static Message getMsgLogout(String name, int id) {
Message msg = new Message();
msg.strName = name;
msg.iID = id;
msg.iType = Message.MSG_LOGOUT;
return msg;
}
public static Message getMsgStop(int id) {
Message msg = new Message();
msg.iID = id;
msg.isMoving = false;
msg.iType = Message.MSG_STOP;
return msg;
}
public static Message getMsgMove(int id, double direct, double speed,
double ptX, double ptY) {
Message msg = new Message();
msg.iID = id;
msg.dDirect = direct;
msg.dSpeed = speed;
msg.dPtX = ptX;
msg.dPtY = ptY;
msg.isMoving = true;
msg.iType = Message.MSG_MOVE;
return msg;
}
public static Message getMsgBrTurn(int id, double brDirect) {
Message msg = new Message();
msg.iID = id;
msg.dBrDirect = brDirect;
msg.iType = Message.MSG_BARBETTE_TURN;
return msg;
}
public static Message getMsgFire(int id, double brDirect) {
Message msg = new Message();
msg.iID = id;
msg.dBrDirect = brDirect;
msg.isFire = true;
msg.iType = Message.MSG_FIRE;
return msg;
}
public static Message getMsgCreateTank(int id, String name, double direct,
double ptX, double ptY) {
Message msg = new Message();
msg.iID = id;
msg.strName = name;
msg.dDirect = direct;
msg.dPtX = ptX;
msg.dPtY = ptY;
msg.iType = Message.MSG_CREATE_TANK;
return msg;
}
public static Message getMsgRemoveTank(int id) {
Message msg = new Message();
msg.iID = id;
msg.iType = Message.MSG_REMOVE_TANK;
return msg;
}
/**
* @return Returns the dBrDirect.
*/
public double getDBrDirect() {
return dBrDirect;
}
/**
* @return Returns the dDirect.
*/
public double getDDirect() {
return dDirect;
}
/**
* @return Returns the dPtX.
*/
public double getDPtX() {
return dPtX;
}
/**
* @return Returns the dPtY.
*/
public double getDPtY() {
return dPtY;
}
/**
* @return Returns the iID.
*/
public int getIID() {
return iID;
}
/**
* @return Returns the isFire.
*/
public boolean isFire() {
return isFire;
}
/**
* @return Returns the isMoving.
*/
public boolean isMoving() {
return isMoving;
}
/**
* @return Returns the iType.
*/
public int getIType() {
return iType;
}
/**
* @return Returns the strName.
*/
public String getStrName() {
return strName;
}
/**
* @return Returns the dSpeed.
*/
public double getDSpeed() {
return dSpeed;
}
/**
* @return Returns the recivePort.
*/
public int getRecivePort() {
return recivePort;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -