@Override
  public Message execute(ActionContext context, C0200_WalkSynchMoveReqMessage req) {
    try {
      RoleInstance currentRole = this.getCurrentRole(context);
      if (null == currentRole) {
        return null;
      }
      // 中断剧情模式
      currentRole.setDramaState(false);

      if (currentRole.getJumpMap().get()) {
        return null;
      }
      if (!currentRole.getBehavior().canMove()) {
        return null;
      }
      MapInstance mapInstance = currentRole.getMapInstance();
      if (null == mapInstance) {
        // 切换地图的时候有可能会为空
        return null;
      }

      if (currentRole.isDeath()) {
        // 死亡以后行走不处理
        return null;
      }

      mapInstance.move(
          currentRole,
          new Point(currentRole.getMapId(), req.getMapx(), req.getMapy()),
          req.getDir());

      C0200_WalkSynchMoveRespMessage respMsg = new C0200_WalkSynchMoveRespMessage();
      respMsg.setRoleId(currentRole.getIntRoleId());
      respMsg.setMapx(req.getMapx());
      respMsg.setMapy(req.getMapy());
      respMsg.setDir(req.getDir());
      respMsg.setSpeed(req.getSpeed());
      currentRole.getBehavior().notifyPosition(respMsg);
      return null;
    } catch (Exception e) {
      logger.error("", e);
      return null;
    }
  }
Beispiel #2
0
  @Override
  public void listEntry(String entryId, RoleInstance caller) {
    if (null == caller || Util.isEmpty(entryId)) {
      return;
    }
    MapInstance mapInstance = caller.getMapInstance();
    if (null == mapInstance) {
      return;
    }

    // 采集点情况
    PointType pointType = GameContext.getFallApp().getPointType(entryId);
    if (pointType.isCollectPoint()) {
      CollectablePoint<RoleInstance> cp = mapInstance.getCollectPointMap().get(entryId);
      if (null == cp) {
        return;
      }
      // 采集点条件
      String info = cp.isSatisfyCond(caller);
      if (!Util.isEmpty(info)) {
        caller
            .getBehavior()
            .sendMessage(new C0602_FallListRespMessage(FallRespType.error.getType(), info));
        return;
      }
      // 触发采集点
      try {
        cp.trigger(caller);
      } catch (ServiceException e) {
        logger.error("", e);
      }
      return;
    }
    // box情况
    if (pointType.isBox()) {
      C0602_FallListRespMessage respMsg = new C0602_FallListRespMessage();
      respMsg.setType(FallRespType.fall.getType());
      respMsg.setFallItemList(this.getBoxFallItemList(entryId, caller));
      respMsg.setInstanceId(entryId);
      caller.getBehavior().sendMessage(respMsg);
    }
  }
Beispiel #3
0
 @Override
 public void pickupEntry(String entryId, RoleInstance role, int itemId) {
   MapInstance mapInstance = role.getMapInstance();
   if (null == mapInstance) {
     return;
   }
   PointType pointType = this.getPointType(entryId);
   if (pointType.isCollectPoint()) {
     // 采集点
     CollectablePoint<RoleInstance> cp = mapInstance.getCollectPointMap().get(entryId);
     if (null == cp) {
       C0603_FallPickupRespMessage respMsg = new C0603_FallPickupRespMessage();
       respMsg.setStatus(RespTypeStatus.SUCCESS);
       respMsg.setInfo(GameContext.getI18n().getText(TextId.FALL_HAS_PICK));
       respMsg.setInstanceId(entryId);
       role.getBehavior().sendMessage(respMsg);
       return;
     }
     cp.pickup(role, itemId);
     return;
   }
   if (pointType.isBox()) {
     // 宝箱
     Cache<String, BoxEntry> boxes = GameContext.getMapApp().getBoxesCache();
     BoxEntry boxEntry = boxes.getQuiet(entryId);
     if (null == boxEntry || !boxEntry.isOwner(role)) {
       C0603_FallPickupRespMessage respMsg = new C0603_FallPickupRespMessage();
       respMsg.setInstanceId(entryId);
       respMsg.setStatus(RespTypeStatus.FAILURE);
       respMsg.setInfo(GameContext.getI18n().getText(TextId.FALL_INVALID_TARGET));
       role.getBehavior().sendMessage(respMsg);
       return;
     }
     boxEntry.pickup(role, itemId);
   }
 }
  @Override
  protected void updateSub() throws ServiceException {
    super.updateSub();
    // 1秒循环一次
    if (this.mapStateLoop.isReachCycle()) {
      // 判断是否超时,若超时则将地图切换到超时状态
      this.timeOver();

      switch (this.mapState) {
        case init:
          this.do_mapState_init();
          break;
        case refresh:
          this.do_mapState_refresh();
          break;
        case refresh_end:
          this.do_mapState_refreshEnd();
          break;
        case time_over:
          this.do_mapState_timeOver();
          break;
      }

      // 根据地图上通关标记,处理通关的逻辑
      switch (this.mapSign) {
        case init:
          // 如果通关,标记为已通关
          if (this.passed) {
            this.mapSign = MapSign.pass;
          }
          break;
        case pass:
          this.do_mapSign_Pass_Logic();
          break;
        case end:
          break;
      }
    }
  }
Beispiel #5
0
  @Override
  public boolean fallBox(NpcInstance dieNpc, RoleInstance role, OutputConsumeType ocType) {
    // 1.获得npc掉落
    // 2.获得世界掉落
    // 3.获得任务掉落
    // 4.生成宝箱
    if (null == dieNpc || null == role || null == role.getMapInstance()) {
      return false;
    }
    String templateId = dieNpc.getNpc().getNpcid();
    Team team = role.getTeam();

    if (null == team || team.getOnlinePlayerNum() <= 1) {
      // 获得掉落物品
      List<GoodsOperateBean> npcLootList = this.getLootGoodsBeanMap(templateId);
      // 任务掉落
      List<GoodsOperateBean> questGoodsList = this.getQuestLootList(templateId, role);
      if (!Util.isEmpty(questGoodsList)) {
        if (null == npcLootList) {
          npcLootList = new ArrayList<GoodsOperateBean>();
        }
        npcLootList.addAll(questGoodsList);
      }
      return this.npcDieFallBox(role, npcLootList, dieNpc, ocType);
    }

    // 获得本地图内同队伍的玩家
    MapInstance mapInstance = role.getMapInstance();
    List<AbstractRole> sameMapMembers = new ArrayList<AbstractRole>();
    for (AbstractRole member : team.getMembers()) {
      MapInstance mi = member.getMapInstance();
      if (null == mi || !mi.getInstanceId().equals(mapInstance.getInstanceId())) {
        continue;
      }
      sameMapMembers.add(member);
    }

    NpcTemplate npcTemplate = GameContext.getNpcApp().getNpcTemplate(templateId);
    LootList lootList = npcLootListMap.get(npcTemplate.getLootNpc() + "");
    LootList worldLootList = worldLootListMap.get(npcTemplate.getLootWorld() + "");

    List<GoodsOperateBean> needRollList = null;
    List<GoodsOperateBean> allMapGoodsList = null;
    if (null != lootList && lootList.getLootType() == NpcLootType.NORMAL.getType()) {
      needRollList =
          this.mergerGoodsBeanMap(this.getGoodsBean(lootList), this.getGoodsBean(worldLootList));
    } else {
      needRollList = this.getGoodsBean(worldLootList);
      allMapGoodsList = this.getGoodsBean(lootList);
    }
    // roll点分配
    Map<String, List<GoodsOperateBean>> rollList = this.roll(needRollList, sameMapMembers);
    for (AbstractRole itemRole : sameMapMembers) {
      List<GoodsOperateBean> roleRollList = rollList.get(itemRole.getRoleId());
      List<GoodsOperateBean> questGoodsList =
          this.getQuestLootList(templateId, (RoleInstance) itemRole);

      List<GoodsOperateBean> roleList = new ArrayList<GoodsOperateBean>();
      if (!Util.isEmpty(roleRollList)) {
        roleList.addAll(roleRollList);
      }
      if (!Util.isEmpty(questGoodsList)) {
        roleList.addAll(questGoodsList);
      }
      if (!Util.isEmpty(allMapGoodsList)) {
        roleList.addAll(allMapGoodsList);
      }
      if (Util.isEmpty(roleList)) {
        continue;
      }
      this.npcDieFallBox((RoleInstance) itemRole, roleList, dieNpc, ocType);
    }
    return true;
  }
 @Override
 protected void enter(AbstractRole role) {
   super.enter(role);
 }