예제 #1
0
  @Override
  public void pulse(int deltaTime) {
    if (timerBuffPulse == null) {
      timerBuffPulse = new TickTimer();
      timerBuffPulse.start(getTime(), BuffManager.INTERVAL_PULSE);
    }
    if (timerStatePulse == null) {
      timerStatePulse = new TickTimer();
      timerStatePulse.start(getTime(), 100);
    }
    super.pulse(deltaTime);

    // 单元移动了
    pulseMove(timeCurr);

    // 周期到了,则更新身上的buff
    if (timerBuffPulse.isPeriod(timeCurr)) {
      BuffManager.inst().pulse(this, timeCurr);
    }

    // 施放可以施放的有前摇的技能
    updateSkill(timeCurr);

    // 更新各种状态
    updateState(timeCurr);
  }
예제 #2
0
  /**
   * 让unitObj进入某种状态,time为持续时间
   *
   * @param stateKey
   * @param time
   */
  public void toState(UnitObjectStateKey stateKey, long time) {
    //		Log.temp.info("toState :{} {}", stateKey.toString(), time);
    long curr = getTime();
    if (state.get(stateKey) != null) {
      TickTimer timer = state.get(stateKey);
      long timeLeft = timer.getTimeLeft(curr);
      timer.start(getTime(), Math.max(time, timeLeft));
    } else {
      TickTimer timer = new TickTimer();
      timer.start(getTime(), time);
      state.put(stateKey, timer);
    }

    updateState(curr, true);
  }
예제 #3
0
  // 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);
    }
  }