예제 #1
0
파일: Dummy.java 프로젝트: khlieng/InetMaze
 public void update(int time) {
   currentTime += time;
   if (currentTime >= moveTime) {
     currentTime -= moveTime;
     moveTime =
         (short) (Maze.DUMMY_WAIT_MIN + rand.nextInt(Maze.DUMMY_WAIT_MAX - Maze.DUMMY_WAIT_MIN));
     currentPos++;
     if (!first) {
       if (currentPos >= MazeDummy.Path.length) {
         currentPos = 0;
       }
       try {
         int id = (playerID + Short.MAX_VALUE + 1) << 16;
         int x = MazeDummy.Path[currentPos].getXpos() << 8;
         int y = MazeDummy.Path[currentPos].getYpos();
         int position = id | x | y;
         MazeDummy.Players.updatePos(position);
       } catch (RemoteException e) {
         e.printStackTrace();
       }
     } else {
       if (currentPos >= MazeDummy.InitialPathPool[initialPath].length) {
         currentPos = 0;
         first = false;
       }
       try {
         int id = (playerID + Short.MAX_VALUE + 1) << 16;
         int x = MazeDummy.InitialPathPool[initialPath][currentPos].getXpos() << 8;
         int y = MazeDummy.InitialPathPool[initialPath][currentPos].getYpos();
         int position = id | x | y;
         MazeDummy.Players.updatePos(position);
       } catch (RemoteException e) {
         e.printStackTrace();
       }
     }
   }
 }