コード例 #1
0
ファイル: UnitObject.java プロジェクト: WilliamGai/java_2017
  /** 技能打断 */
  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);
    }
  }
コード例 #2
0
ファイル: UnitObject.java プロジェクト: WilliamGai/java_2017
  /** 强制单元停止 */
  public void stop() {
    if (!running.isRunning()) return;

    // 强制同步移动
    this.running._pulse(this.getTime(), true);

    // 停止移动
    running._stop();

    // 发送消息
    SCStageMoveStop.Builder msgStop = SCStageMoveStop.newBuilder();
    msgStop.setObjId(id);
    msgStop.setPosEnd(posNow.toMsg());
    StageManager.inst().sendMsgToArea(msgStop, stageObj, posNow);
  }
コード例 #3
0
ファイル: UnitObject.java プロジェクト: WilliamGai/java_2017
  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);
  }
コード例 #4
0
ファイル: UnitObject.java プロジェクト: WilliamGai/java_2017
  // force 是否强制更加状态刷新unit属性
  public void updateState(long curr, boolean force) {
    if (!force && !timerStatePulse.isPeriod(curr)) return;
    // 如果死亡,则把所有限制状态移出
    if (isDie()) {
      state.clear();
    }

    List<UnitObjectStateKey> removeList = new ArrayList<>();
    boolean canMove = true;
    boolean canCastSkill = true;
    boolean canAttack = true;
    boolean castSkilling = false;

    extendCastSkillingTime();

    for (Entry<UnitObjectStateKey, TickTimer> entry : state.entrySet()) {
      UnitObjectStateKey state = entry.getKey();
      TickTimer timer = entry.getValue();
      // 根据不同的状态进行不同的处理,同时如果时间到了则解除状态
      switch (state) {
        case cast_skilling: // 正在释放技能
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            castSkilling = true;
            canCastSkill = false;
          }
          break;
        case skillback: // 技能击退
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canMove = false;
            canCastSkill = false;
            canAttack = false;
          }
          break;
        case stun: // 眩晕
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canMove = false;
            canCastSkill = false;
            canAttack = false;
          }
          break;
        case immobilize: // 冻结
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canMove = false;
          }
          break;
        case silence: // 沉默
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canCastSkill = false;
          }
          break;
        case skill_shake: // 施法前摇
          if (timer.isOnce(curr)) {
            //					Log.temp.info("skill_shake start:{}", Port.getTime());
            removeList.add(state);
          } else {
            //					canMove = false;
            canCastSkill = false;
            canAttack = false;
          }
          break;
        case skill_hypnosis: // 催眠
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canMove = false;
            canCastSkill = false;
            canAttack = false;
          }
          break;
        case skill_sheep: // 变羊
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canMove = false;
            canCastSkill = false;
            canAttack = false;
          }
          break;
        case cast_locked: // 主动
          if (timer.isOnce(curr)) {
            removeList.add(state);
          } else {
            canMove = false;
          }
          break;
        default:
          break;
      }
    }

    // 如果不能移动,直接停下来先
    if (!canMove) {
      stop();
    }

    boolean sendMsg = false;
    // 发送状态变化消息
    if (!isDie()
        && (this.canMove != canMove
            | this.canCastSkill != canCastSkill
            | this.canAttack != canAttack)) {
      if (this.isHumanObj()) {
        HumanInfoChange.listen((HumanObject) this);
      }
      sendMsg = true;
    }

    this.canMove = canMove;
    this.canCastSkill = canCastSkill;
    this.canAttack = canAttack;
    this.castSkilling = castSkilling;
    // 移走记录
    for (UnitObjectStateKey state : removeList) {
      this.state.remove(state);
    }

    if (sendMsg) {
      SCUnitobjStatusChange.Builder StatChange = SCUnitobjStatusChange.newBuilder();
      long type = 0;
      for (UnitObjectStateKey stat : this.state.keySet()) {
        type = type | (1 << stat.getType());
      }
      StatChange.setType(type);
      StatChange.setId(id);
      StatChange.setTeamBundleID(teamBundleID);
      StatChange.setCanMove(this.canMove);
      StatChange.setCanCastSkill(this.canCastSkill);
      StatChange.setCanAttack(this.canAttack);
      StageManager.inst().sendMsgToArea(StatChange, stageObj, posNow);
    }
  }
コード例 #5
0
ファイル: UnitObject.java プロジェクト: WilliamGai/java_2017
  /**
   * 地图单元移动
   *
   * @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());
      }
    }
  }