Пример #1
0
 public void drawMenu() {
   try {
     if (page == 3) {
       setFont(16);
       g.drawString(nickname, disWidth + 80, disHeight + 15, 0);
     }
     // 判斷在遊戲說明時,防止文字超出螢幕,當超出螢幕時放到下一頁面
     if (page == 1) {
       setFont(0);
       g.setColor(255, 255, 255);
       for (int i = 0; gameUserInfCount < gameUserInf.length; gameUserInfCount++, i += 17) {
         if (gameUserInfCount % 5 != 4) // 遊戲說明
         g.drawString(gameUserInf[gameUserInfCount], disWidth + 10, disHeight + 70 + i, 0);
         else { // 顯示還有下一頁的文字
           g.drawString(gameUserInf[gameUserInfCount], disWidth + 135, disHeight + 70 + i, 0);
           gameUserInfCount++;
           break;
         }
       }
       flushGraphics();
     }
     changeMeun();
     flushGraphics();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #2
0
 public void systemShowInf(String infStr) {
   g.setColor(128, 255, 255);
   g.fillRect(disWidth + 50, disHeight + 166, 80, 15);
   g.setColor(0, 0, 0);
   g.drawString(infStr, disWidth + 55, disHeight + 166, 0);
   flushGraphics();
 }
Пример #3
0
 //	畫出所輸入的字
 public void showBufferString() {
   if (page == 0) {
     drawUser_pass();
   } else if (page == 2) {
     g.setColor(255, 255, 255);
     g.drawString(nickname, disWidth + 60, disHeight + 115, 0);
   }
 }
Пример #4
0
 // 顯示畫面
 public void drawDisplay() {
   g = getGraphics();
   g.setColor(0, 0, 0);
   g.drawRect(disWidth - 1, disHeight - 1, 176 + 1, 208 + 1);
   layMa.paint(g, disWidth, disHeight);
   g.drawString(getWidth() + "|" + getHeight(), 0, 0, 0);
   flushGraphics();
 }
Пример #5
0
 // 判斷是否為密碼
 public void drawUser_pass() {
   g.setColor(255, 255, 255);
   g.drawString(username, disWidth + 60, disHeight + 95, 0);
   if (pass.equals("")) g.drawString("", disWidth + 60, disHeight + 115, 0);
   else g.drawString("*******", disWidth + 60, disHeight + 115, 0);
 }
Пример #6
0
 // 判斷選取的選單選項
 public void changeMeunStart() {
   try {
     if (page == -1) {
       switch (menustate) {
         case 0:
           page = 0;
           spName.setVisible(true);
           changePage();
           break;
         case 1:
           page = 0;
           spName.setVisible(true);
           changePage();
           break;
         case 2:
           // spWelcome.setVisible(false);
           spName.setVisible(false);
           spInterface.setFrame(4);
           drawDisplay();
           GameMain.music.stop();
           exit();
           break;
       }
     } else {
       switch (menustate) {
         case 0:
           try {
             new InputText(nowString[0]);
           } catch (Exception e) {
             e.printStackTrace();
           }
           break;
         case 1:
           new InputText(nowString[1]);
           break;
         case 2: // 登入
           if (page == 0) { // 當在輸入帳號畫面時
             // 未輸入帳號
             if (username.equals("") || pass.equals("")) {
               g.drawString("「請 輸入帳號密碼」", disWidth + 75, disHeight + 140, 0);
               flushGraphics();
             } else if (username.equals("xlinx") && pass.equals("x")) {
               runGame();
               g.drawString("進入遊戲...", disWidth + 15, disHeight + 129, 0);
               flushGraphics();
             } else { // 連到Server
               try {
                 GameMain.conn.setLoginAccess(username, pass); // 送出帳號密碼
               } catch (Exception e) {
                 e.printStackTrace();
               }
               g.setColor(255, 255, 255);
               g.drawString("「登入中」", disWidth + 95, disHeight + 140, 0);
               flushGraphics();
               while (!ConnectionServer.connFin) ; // Server是否回傳完資訊
               page = 0;
               drawDisplay();
               g.setColor(255, 255, 255);
               gameUserInfCount = 0;
               // 成功登入將繼續到下一頁面(第一次進入遊戲)
               if (GameMain.conn.getConnSucess() == 1) {
                 g.drawString("「登入成功」", disWidth + 95, disHeight + 140, 0);
                 flushGraphics();
                 RoleDataValue.userpass = pass;
                 page = 1;
                 changePage();
               } else if (GameMain.conn.getConnSucess() == 0) { // 登入,不是第一次遊戲
                 try {
                   page = -2;
                   g.drawString("「登入成功」", disWidth + 95, disHeight + 140, 0);
                   flushGraphics();
                   RoleDataValue.userpass = pass;
                   g.drawString("讀取使用者資料....", disWidth + 15, disHeight + 69, 0);
                   flushGraphics();
                   GameMain.conn.setGameName("");
                   while (!ConnectionServer.connFin) ; // Server是否回傳完資訊
                   g.drawString("人物狀態初始化.....", disWidth + 15, disHeight + 89, 0);
                   flushGraphics();
                   roleData.getFirstRoleStateForInternet(GameMain.conn.getRequestState());
                   roleData.loginSuccessStart();
                   g.drawString("地圖初始化..........", disWidth + 15, disHeight + 109, 0);
                   flushGraphics();
                 } catch (Exception e) {
                   e.printStackTrace();
                 }
                 runGame();
                 g.drawString("進入遊戲...", disWidth + 15, disHeight + 129, 0);
                 flushGraphics();
               } else {
                 g.drawString("「登入失敗」", disWidth + 95, disHeight + 140, 0);
                 flushGraphics();
               }
             }
           } else if (page == 1) { // 當畫面在遊戲說明時
             if (gameUserInfCount < gameUserInf.length) // 如果遊戲說明未結速時
             changePage();
             else { // 遊戲說明完成,畫面改變為輸入遊戲名稱
               page = 2;
               gameUserInfCount = 20;
               changePage();
             }
           } else if (page == 2) { // 輸入名稱完成,畫面改變為角色建立完成
             if (nickname.equals("")) g.drawString("「請輸入名稱」", disWidth + 90, disHeight + 140, 0);
             else {
               page = 3;
               changePage();
             }
           } else if (page == 3) { // 第一進入遊戲,完成輸入名稱
             page = -2;
             GameMain.conn.setGameName(nickname);
             while (!ConnectionServer.connFin) ; // Server是否回傳完資訊
             try {
               roleData.getFirstRoleStateForInternet(GameMain.conn.getRequestState());
               roleData.loginSuccessStart();
             } catch (Exception e) {
               e.printStackTrace();
             }
             runGame();
           }
           break;
         case 3: // 回主選單,上一頁
           if (page == 0) {
             page = -1;
             menustate = 0;
             menuNum = 3;
           }
           // 判斷當為GameInformation時,要回輸入帳號密碼
           if (page == 1 && gameUserInfCount == 5) page--;
           else if (page == 2 || page == 3) // 判斷當不是GameInformation時
           page--;
           // 切換GameInformaion的頁面
           if (page == 1) {
             gameUserInfCount -= 5 * gameUserInfPage;
             gameUserInfPage++;
             if (gameUserInfPage >= 3) gameUserInfPage = 2;
             changePage();
           } // 回到輸入姓名部份
           else if (page == 2) {
             // rolesprite=true;
             Thread.sleep(300);
             gameUserInfPage = 2;
             changePage();
           } else changePage();
           break;
       }
       showBufferString();
     }
   } catch (Exception e) {
   }
 }
Пример #7
0
  // 選單切換
  private void changeMeun() {
    if (page == -1) {
      setFont(16);
      switch (menustate) {
        case 0:
          // Select----------------------------
          g.setColor(255, 255, 255);
          g.drawString("開始遊戲", disWidth + 60, disHeight + 120, 0);
          // ----------------------------------
          g.setColor(69, 118, 181);
          g.drawString("繼續遊戲", disWidth + 60, disHeight + 140, 0);
          g.drawString("結束遊戲", disWidth + 60, disHeight + 160, 0);
          break;
        case 1:
          g.setColor(69, 118, 181);
          g.drawString("開始遊戲", disWidth + 60, disHeight + 120, 0);
          // Select----------------------------
          g.setColor(255, 255, 255);
          g.drawString("繼續遊戲", disWidth + 60, disHeight + 140, 0);
          // ----------------------------------
          g.setColor(69, 118, 181);
          g.drawString("結束遊戲", disWidth + 60, disHeight + 160, 0);
          break;
        case 2:
          g.setColor(69, 118, 181);
          g.drawString("開始遊戲", disWidth + 60, disHeight + 120, 0);
          g.drawString("繼續遊戲", disWidth + 60, disHeight + 140, 0);
          // Select----------------------------
          g.setColor(255, 255, 255);
          g.drawString("結束遊戲", disWidth + 60, disHeight + 160, 0);
          // ----------------------------------
          break;
      }
    } else {
      setFont(0);
      switch (menustate) {
        case 0:
          // Select------------------------
          g.setColor(255, 255, 255);
          g.drawRoundRect(disWidth + 52, disHeight + 93, 95, 15, 15, 15);
          g.drawString(nowString[0], disWidth + 22, disHeight + 90, 0);
          // ------------------------------
          g.setColor(69, 118, 181);
          g.drawRoundRect(disWidth + 52, disHeight + 113, 95, 15, 15, 15);
          g.drawString(nowString[1], disWidth + 22, disHeight + 110, 0);

          g.drawString(nowString[2], disWidth + 88, disHeight + 165, 0);
          g.drawString(nowString[3], disWidth + 128, disHeight + 165, 0);
          break;
        case 1:
          if (page == 0) { // 當為輸入帳號時顯示
            g.setColor(69, 118, 181);
            g.drawRoundRect(disWidth + 52, disHeight + 93, 95, 15, 15, 15);
            g.drawString(nowString[0], disWidth + 22, disHeight + 90, 0);
          }
          if (page == 0 || page == 2) { // 當為輸入帳號與遊戲名稱時顯示
            // Select------------------------
            g.setColor(255, 255, 255);
            g.drawRoundRect(disWidth + 52, disHeight + 113, 95, 15, 15, 15);
            g.drawString(nowString[1], disWidth + 22, disHeight + 110, 0);
            // ------------------------------
          }
          g.setColor(69, 118, 181);
          g.drawString(nowString[2], disWidth + 88, disHeight + 165, 0);
          g.drawString(nowString[3], disWidth + 128, disHeight + 165, 0);
          // System.out.println(menustate);
          break;
        case 3:
          if (page == 0) { // 當為輸入帳號時顯示
            g.setColor(69, 118, 181);
            g.drawRoundRect(disWidth + 52, disHeight + 93, 95, 15, 15, 15);
            g.drawString(nowString[0], disWidth + 22, disHeight + 90, 0);
          }
          if (page == 0 || page == 2) { // 當為輸入帳號與遊戲名稱時顯示
            g.setColor(69, 118, 181);
            g.drawRoundRect(disWidth + 52, disHeight + 113, 95, 15, 15, 15);
            g.drawString(nowString[1], disWidth + 22, disHeight + 110, 0);
          }
          // Select--------------------------
          g.setColor(255, 255, 255);
          g.drawString(nowString[2], disWidth + 88, disHeight + 165, 0);
          // --------------------------------
          g.setColor(69, 118, 181);
          g.drawString(nowString[3], disWidth + 128, disHeight + 165, 0);
          break;
        case 2:
          if (page == 0) {
            g.setColor(69, 118, 181);
            g.drawRoundRect(disWidth + 52, disHeight + 93, 95, 15, 15, 15);
            g.drawString(nowString[0], disWidth + 22, disHeight + 90, 0);
          }
          if (page == 0 || page == 2) {
            g.setColor(69, 118, 181);
            g.drawRoundRect(disWidth + 52, disHeight + 113, 95, 15, 15, 15);
            g.drawString(nowString[1], disWidth + 22, disHeight + 110, 0);
          }
          g.setColor(69, 118, 181);
          g.drawString(nowString[2], disWidth + 88, disHeight + 165, 0);
          // Select-------------------------
          g.setColor(255, 255, 255);
          g.drawString(nowString[3], disWidth + 128, disHeight + 165, 0);
          // -------------------------------
          break;
      }
    }
    flushGraphics();
  }
Пример #8
0
 public void setFont(int size) {
   Font font = Font.getFont(Font.FACE_SYSTEM, 0, size);
   g.setFont(font);
 }