Beispiel #1
0
  /**
   * 角色初始化阵型,将自身放入阵法中
   *
   * @param human
   * @param temp
   * @return
   */
  private BattleForm initBattleForm(Human human, FormTemplate temp) {
    // 初始化时将玩家放入阵型配置的第一个开启位置中
    String[] positions = new String[BattleForm.TotalPositions];
    int initPos = temp.getOpenPositions().get(0);
    positions[initPos - 1] = human.getUUID();

    // 构造阵型对象并保存到数据库中
    BattleForm form = new BattleForm(human);
    form.setFormSn(temp.getId());
    form.setOwner(human);
    form.setPositions(positions);
    FormEntity entity = form.toEntity();
    Globals.getDaoService().getFormDao().save(entity);
    form.setDbId(entity.getId());
    form.setInDb(true);

    // 设置角色阵型
    human.setBattleForm(form);
    return form;
  }