예제 #1
0
 @Override
 public void onKeyDown(int key) {
   if (mRunScript && mScriptExecutor != null) {
     mScriptExecutor.keyDown(key);
   } else if (Combat.IsActive()) {
     Combat.KeyDown(key);
     return;
   } else if (mPlayer != null) {
     switch (key) {
       case Global.KEY_LEFT:
         walkLeft();
         break;
       case Global.KEY_RIGHT:
         walkRight();
         break;
       case Global.KEY_UP:
         walkUp();
         break;
       case Global.KEY_DOWN:
         walkDown();
         break;
       case Global.KEY_ENTER:
         triggerSceneObjEvent();
         break;
     }
   }
 }
예제 #2
0
 @Override
 public void onKeyUp(int key) {
   if (mRunScript && mScriptExecutor != null) {
     mScriptExecutor.keyUp(key);
   } else if (Combat.IsActive()) {
     Combat.KeyUp(key);
     return;
   } else if (key == Global.KEY_CANCEL) {
     GameView.getInstance().pushScreen(new ScreenGameMainMenu());
   }
 }
예제 #3
0
 @Override
 public void draw(Canvas canvas) {
   if (mRunScript && mScriptExecutor != null) {
     if (Combat.IsActive()) {
       Combat.Draw(canvas);
     }
     mScriptExecutor.draw(canvas);
   } else if (Combat.IsActive()) {
     Combat.Draw(canvas);
     return;
   } else {
     drawScene(canvas);
   }
 }
예제 #4
0
 @Override
 public void update(long delta) {
   if (mRunScript && mScriptExecutor != null) {
     mScriptExecutor.process();
     mScriptExecutor.update(delta);
   } else if (Combat.IsActive()) { // TODO fix this test
     Combat.Update(delta);
   } else {
     for (int i = 1; i <= 40; i++) {
       if (mNPCObj[i] == null) continue;
       mNPCObj[i].update(delta);
     }
   }
 }
예제 #5
0
 /**
  * 场景切换 如果地图(x,y)有地图事件,就触发该事件
  *
  * @param x
  * @param y
  */
 public boolean triggerMapEvent(int x, int y) {
   if (mMap != null && mScriptExecutor != null) {
     int id = mMap.getEventNum(x, y);
     if (id != 0) {
       mScriptExecutor.triggerEvent(id + 40);
       mRunScript = true;
       return true;
     }
   }
   // 未触发地图事件,随机战斗
   Combat.StartNewRandomCombat();
   return false;
 }
예제 #6
0
  public ScreenMainGame() {
    instance = this;

    mScriptSys = ScriptProcess.getInstance();
    mScriptSys.setScreenMainGame(this);

    if (SaveLoadGame.startNewGame) { // 开始新游戏
      Combat.FightDisable();
      ScriptResources.initGlobalVar();
      ScriptResources.initGlobalEvents();
      SaveLoadGame.NpcObjs = mNPCObj;
      sPlayerList.clear();
      Player.sGoodsList.clear();
      Player.sMoney = 0;
      startChapter(1, 1);
      ScriptExecutor.goonExecute = true;
      mRunScript = true;
    } else { // 再续前缘
      loadMap(
          SaveLoadGame.MapType,
          SaveLoadGame.MapIndex,
          SaveLoadGame.MapScreenX,
          SaveLoadGame.MapScreenY);
      mNPCObj = SaveLoadGame.NpcObjs;
      for (int i = 0; i < mNPCObj.length; i++) {
        if (mNPCObj[i] != null) {
          mNPCObj[i].setICanWalk(mCanWalk);
        }
      }
      if (sPlayerList.size() > 0) {
        mPlayer = sPlayerList.get(0);
      } else {
        createActor(1, 4, 3);
        // Log.e("error", "存档读取出错");
      }
      mScriptSys.loadScript(SaveLoadGame.ScriptType, SaveLoadGame.ScriptIndex);
      mScriptExecutor = mScriptSys.getScriptExecutor();
      ScriptExecutor.goonExecute = true;
      mRunScript = false;
    }
    //		Player.sMoney = 999999;
  }