Exemple #1
0
  /** 技能打断 */
  public void interruptCurrSkill(UnitObject uintObjInterrupt) {
    if (skillTempInfo.skillToExcute == null) {
      return;
    }

    ConfSkill confTemp = ConfSkill.get(skillTempInfo.skillToExcute.sn);
    if (confTemp != null && confTemp.canInterrupted) {
      // 计算前摇百分比
      SkillParamVO vo = new SkillParamVO();

      Event.fire(
          EventKey.SKILL_PASSIVE_CHECK,
          "unitAtk",
          uintObjInterrupt,
          "unitDef",
          this,
          "skillEventKey",
          SkillEventKey.EVENT_ON_SKILL_INTERRUPT,
          "vo",
          vo);

      skillTempInfo.skillToExcute = null;

      SCSkillInterrupt.Builder msg = SCSkillInterrupt.newBuilder();
      msg.setSkillSn(confTemp.sn);
      msg.setUnitObjID(id);
      StageManager.inst().sendMsgToArea(msg, stageObj, posNow);
    }
  }
Exemple #2
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);
  }
Exemple #3
0
  /**
   * 地图单元移动
   *
   * @param posFrom
   * @param posTo
   */
  public void move(Vector3D posFrom, List<Vector3D> posTo, Vector3D dir, boolean fromClient) {
    if (!isInWorld()) return;
    if (!canMove) return;

    // 移动过于频繁,忽略这次消息
    // if (fromClient && !running.isTimeExpired()) {
    // return;
    // }
    //		if(posFrom.z == 0) {
    //			posFrom.z = 0;
    //		}
    // 修正起点
    //		if (isHumanObj()) {
    //			posFrom.set(running.correctPosFrom(posFrom));
    //		}

    // 修正所有点,如果连续两个点相同,则移出后一个
    Vector3D pos = new Vector3D();
    pos.set(posFrom);
    Iterator<Vector3D> it = posTo.iterator();
    while (it.hasNext()) {
      Vector3D posNext = it.next();
      if (pos.distance(posNext) < 0.01) {
        it.remove();
        continue;
      }
      pos.set(posNext);
    }

    // 目标点为空
    if (posTo.isEmpty()) return;

    if (this.isHumanObj()) {
      Event.fire(EventKey.HUMAN_MOVE_START_BEFORE, "humanObj", this);
      Event.fire(EventKey.HUMAN_ACTS_BEFORE, "humanObj", this);
    }

    // 移动
    running._move(posFrom, posTo, 1.0D * getUnit().getSpeed() / 100);

    // 发送消息给前端
    Msg.SCStageMove.Builder move = Msg.SCStageMove.newBuilder();
    move.setObjId(id);
    move.setPosBegin(posFrom.toMsg());
    move.addAllPosEnd(running.getRunPathMsg());
    move.setDir(dir.toMsg());
    StageManager.inst().sendMsgToArea(move, stageObj, posNow);

    // 抛出开始移动的事件
    Event.fire(EventKey.UNIT_MOVE_START, "unitObj", this);
    Event.fire(EventKey.UNIT_ACT, "unitObj", this);
    if (this.isHumanObj()) {
      Event.fire(EventKey.HUMAN_MOVE_START, "humanObj", this);
      Event.fire(EventKey.HUMAN_ACT, "humanObj", this);
    } else {
      Event.fire(EventKey.MONSTER_MOVE_START, "monsterObj", this);
      Event.fire(EventKey.MONSTER_ACT, "monsterObj", this);
    }

    // 记录日志
    if (this.isHumanObj()) {
      if (Log.stageMove.isInfoEnabled()) {
        //				Log.stageMove.info("角色({} {})开始移动,起始位置{},接下来的目标为{}。",
        //						this.name, this.id,posFrom.getPosStr(),
        //						running.getRunPathMsg());
      }
    } else {
      if (Log.stageMove.isInfoEnabled()) {
        //				Log.stageMove.info("地图单元({})开始移动,起始位置{},接下来的目标为{}。", this.name,
        //						posFrom.getPosStr(), running.getRunPathMsg());
      }
    }
  }