Esempio n. 1
0
 @Override
 public void init(SkillCommon skillCommon, ConfSkillEffect conf) {
   // 父类方法初始化了范围前三个参数
   super.init(skillCommon, conf);
   buffSn = Utils.intValue(conf.param1);
   buffProp = Utils.intValue(conf.param2);
   if (buffProp == 0) {
     buffProp = 100;
   }
 }
Esempio n. 2
0
 public static boolean[] parseBoolArray(String value) {
   if (value == null) value = "";
   if (StringUtils.isEmpty(value)) {
     return new boolean[0];
   }
   String[] elems = value.split(",");
   if (elems.length > 0) {
     boolean[] temp = new boolean[elems.length];
     for (int i = 0; i < elems.length; i++) {
       temp[i] = Utils.booleanValue(elems[i]);
     }
     return temp;
   }
   return null;
 }
Esempio n. 3
0
 public static double[] parseDoubleArray(String value) {
   if (value == null) value = "";
   if (StringUtils.isEmpty(value)) {
     return new double[0];
   }
   String[] elems = value.split(",");
   if (elems.length > 0) {
     double[] temp = new double[elems.length];
     for (int i = 0; i < elems.length; i++) {
       temp[i] = Utils.doubleValue(elems[i]);
     }
     return temp;
   }
   return null;
 }
Esempio n. 4
0
    public static float[] parseFloatArray(String value) {
      if (value == null) value = "";

      String[] elems = value.split(",");
      if (StringUtils.isEmpty(value)) {
        return new float[0];
      }
      if (elems.length > 0) {
        float[] temp = new float[elems.length];
        for (int i = 0; i < elems.length; i++) {
          temp[i] = Utils.floatValue(elems[i]);
        }
        return temp;
      }
      return null;
    }
Esempio n. 5
0
  public void die(UnitObject killer, Param params) {
    Unit unit = getUnit();
    unit.setHpCur(0);

    // 设置状态
    inWorld = false;

    // 停止移动
    stop();

    Event.fireEx(
        EventKey.UNIT_BE_KILLED,
        stageObj.sn,
        "killer",
        killer,
        "dead",
        this,
        "skillSn",
        params.get("skillSn"));

    Param param = new Param(params);

    long killerId = 0;
    String killerName = "";
    int skillSn = Utils.getParamValue(param, "skillSn", 0);
    if (killer != null) {
      killerId = killer.id;
      killerName = killer.name;
    }

    // 通知其他玩家 有地图单元离开视野
    SCStageObjectDisappear.Builder msg = createMsgDie();
    msg.setKillerId(killerId);
    msg.setKillerName(killerName);
    msg.setSkillSn(skillSn);

    StageManager.inst().sendMsgToArea(msg, stageObj, posNow);
  }
Esempio n. 6
0
  /**
   * 通过属性获取数据集合 支持排序
   *
   * @param params
   * @return
   */
  public static List<ConfSkillGroup> utilBase(Object... params) {
    List<Object> settings = Utils.ofList(params);

    // 查询参数
    final Map<String, Object> paramsFilter = new LinkedHashMap<>(); // 过滤条件
    final Map<String, OrderBy> paramsOrder = new LinkedHashMap<>(); // 排序规则

    // 参数数量
    int len = settings.size();

    // 参数必须成对出现
    if (len % 2 != 0) {
      throw new SysException("查询参数必须成对出现:query={}", settings);
    }

    // 处理成对参数
    for (int i = 0; i < len; i += 2) {
      String key = (String) settings.get(i);
      Object val = settings.get(i + 1);

      // 参数 排序规则
      if (val instanceof OrderBy) {
        paramsOrder.put(key, (OrderBy) val);
      } else { // 参数 过滤条件
        paramsFilter.put(key, val);
      }
    }

    // 返回结果
    List<ConfSkillGroup> result = new ArrayList<>();

    try {
      // 通过条件获取结果
      for (ConfSkillGroup c : DATA.getList()) {
        // 本行数据是否符合过滤条件
        boolean bingo = true;

        // 判断过滤条件
        for (Entry<String, Object> p : paramsFilter.entrySet()) {
          Field field = c.getClass().getField(p.getKey());

          // 实际结果
          Object valTrue = field.get(c);
          // 期望结果
          Object valWish = p.getValue();

          // 有不符合过滤条件的
          if (!valWish.equals(valTrue)) {
            bingo = false;
            break;
          }
        }

        // 记录符合结果
        if (bingo) {
          result.add(c);
        }
      }
    } catch (Exception e) {
      throw new SysException(e);
    }

    // 对结果进行排序
    Collections.sort(
        result,
        new Comparator<ConfSkillGroup>() {
          @Override
          @SuppressWarnings({"rawtypes", "unchecked"})
          public int compare(ConfSkillGroup a, ConfSkillGroup b) {
            try {
              for (Entry<String, OrderBy> e : paramsOrder.entrySet()) {
                // 两方字段
                Field fa = a.getClass().getField(e.getKey());
                Field fb = b.getClass().getField(e.getKey());
                // 两方字段值
                Comparable va = (Comparable) fa.get(a);
                Comparable vb = (Comparable) fb.get(b);

                // 值排序结果
                int compareResult = va.compareTo(vb);

                // 相等时 根据下一个值进行排序
                if (va.compareTo(vb) == 0) continue;

                // 配置排序规则
                OrderBy order = e.getValue();
                if (order == OrderBy.ASC) return compareResult; // 正序
                else return -1 * compareResult; // 倒序
              }
            } catch (Exception e) {
              throw new SysException(e);
            }

            return 0;
          }
        });

    return result;
  }