Beispiel #1
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;
 }
Beispiel #2
0
  public void drawScene(Canvas canvas) {
    if (mMap != null) {
      mMap.drawMap(canvas, mMapScreenPos.x, mMapScreenPos.y);
    }

    int playY = 10000;
    boolean hasPlayerBeenDrawn = false;
    if (mPlayer != null) {
      playY = mPlayer.getPosInMap().y;
    }

    NPC[] npcs = getSortedNpcObjs();
    for (int i = npcs.length - 1; i >= 0; --i) {
      if (!hasPlayerBeenDrawn && playY < npcs[i].getPosInMap().y) {
        mPlayer.drawWalkingSprite(canvas, mMapScreenPos);
        hasPlayerBeenDrawn = true;
      }
      npcs[i].drawWalkingSprite(canvas, mMapScreenPos);
    }
    if (mPlayer != null && !hasPlayerBeenDrawn) {
      mPlayer.drawWalkingSprite(canvas, mMapScreenPos);
    }
    Util.drawSideFrame(canvas);
  }
Beispiel #3
0
 @Override
 public boolean canWalk(int x, int y) {
   return mMap.canWalk(x, y)
       && getNpcFromPosInMap(x, y) == null
       && !mPlayer.getPosInMap().equals(x, y);
 }
Beispiel #4
0
 /**
  * 地图的(x,y)处,是否可行走,是否有NPC
  *
  * @param x
  * @param y
  * @return
  */
 public boolean canPlayerWalk(int x, int y) {
   if (mMap == null) return false;
   return mMap.canPlayerWalk(x, y) && getNpcFromPosInMap(x, y) == null;
 }