Пример #1
0
 private boolean hasBoss(Collection<NpcInstance> npcList, String npcId) {
   if (Util.isEmpty(npcList)) {
     return false;
   }
   for (NpcInstance npc : npcList) {
     if (npc.getNpcid().equals(npcId)) {
       return true;
     }
   }
   return false;
 }
Пример #2
0
 private boolean hasEnemy(Collection<NpcInstance> npcList) {
   if (Util.isEmpty(npcList)) {
     return false;
   }
   for (NpcInstance npc : npcList) {
     if (npc.getNpc().getNpctype() == NpcType.monster.getType()) {
       return true;
     }
   }
   return false;
 }
Пример #3
0
  @Override
  public boolean summonFallBox(
      NpcInstance dieNpc, Summon summon, RoleInstance ownerInstance, RoleInstance summonInstance) {
    if (null == dieNpc || null == ownerInstance || null == ownerInstance.getMapInstance()) {
      return false;
    }
    String templateId = dieNpc.getNpc().getNpcid();
    OutputConsumeType ocType = OutputConsumeType.summon_monster_fall;
    List<GoodsOperateBean> npcLootList = this.getLootGoodsBeanMap(templateId);
    Collection<RoleInstance> sameMapMembers = ownerInstance.getMapInstance().getRoleList();

    if (null != summonInstance && !Util.isEmpty(npcLootList)) {
      this.npcDieFallBox(summonInstance, npcLootList, dieNpc, ocType);
      // 通知玩家个人获得的奖励
      sendSummonFall(sameMapMembers, npcLootList, summonInstance.getRoleName());
    }

    // 全员奖励
    List<GoodsOperateBean> allLootList = summon.getAllGainGoods();
    if (Util.isEmpty(allLootList)) {
      return true;
    }
    // 获得本地图内的玩家
    for (AbstractRole itemRole : ownerInstance.getMapInstance().getRoleList()) {
      // 给地图内玩家发放奖励
      this.npcDieFallBox((RoleInstance) itemRole, allLootList, dieNpc, ocType);
    }
    return true;
  }
Пример #4
0
 private boolean npcDieFallBox(
     RoleInstance role,
     List<GoodsOperateBean> itemList,
     NpcInstance dieNpc,
     OutputConsumeType ocType) {
   if (Util.isEmpty(itemList)) {
     return false;
   }
   boolean result = this.fallBox(role, itemList, ocType, dieNpc.getMapX(), dieNpc.getMapY(), true);
   // 广播
   broadcast(role.getRoleName(), dieNpc.getNpcid(), itemList);
   if (dieNpc.getNpc().npcIsBoss()) {
     // 如果是boss,打印日志
     GameContext.getStatLogApp().goodsFallLog(role, dieNpc.getNpc(), itemList);
   }
   return result;
 }
Пример #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;
  }