Ejemplo n.º 1
0
void MusicManager::preloadAllTracks(CharacterManager* manager, Level* level) {
  CCArray* characters = manager->getCharacters();
  CCObject* obj0 = NULL;
  CCARRAY_FOREACH(characters, obj0) {
    Character* chara = (Character*)obj0;
    CCArray* skills = level->getAllSkills(chara);
    CCObject* obj1 = NULL;
    CCARRAY_FOREACH(skills, obj1) {
      Skill* skill = (Skill*)obj1;
      int repeat = skill->getMaxRepeat();
      for (int i = 0; i < repeat; ++i) {
        string file = buildTrackName(skill->getIdentifier().c_str(), skill, i, chara);
        BufferCache::sharedCache()->addBuffer(this->getTrackFileName(file.c_str()).c_str());
      }
    }
Ejemplo n.º 2
0
string MusicManager::checkSkillTrackName(Skill* skill, SkillPerformType& performeType) {
  performeType = SkillPerformTypeNone;
  if (skill) {
    _characterManager->setWaitTurn(_characterManager->getWaitTurn() + 1);
    if (_characterManager->getWaitTurn() == skill->getTurn()) {
      if (_characterManager->getLastSkill() &&
          string(_characterManager->getLastSkill()->getIdentifier()) != string(skill->getIdentifier())) {
        _characterManager->setRepeatCount(0);
        _characterManager->setRepeatCountRaw(0);
      }
      if (_characterManager->getLastSkill() == NULL || _characterManager->getLastSkill()->getIdentifier() != skill->getIdentifier()) {
        // 前のターンがwaitだった場合、カウンターをリセット
        _characterManager->setRepeatCount(0);
        _characterManager->setRepeatCountRaw(0);
      } else {
        // そうじゃなかったら+1
        _characterManager->setRepeatCount(_characterManager->getRepeatCount() + 1);
        _characterManager->setRepeatCountRaw(_characterManager->getRepeatCountRaw() + 1);
      }
      if (skill->isLoop()) {
        _characterManager->setRepeatCount((_characterManager->getRepeatCount()) % skill->getMaxRepeat());
      } else {
        _characterManager->setRepeatCount(min(_characterManager->getRepeatCount(), skill->getMaxRepeat() - 1));
      }
      Skill* lastSkill = _characterManager->getLastSkill();
      _characterManager->setLastSkill(skill);
      _characterManager->setCurrentSkill(NULL);
      _characterManager->setWaitTurn(0);
      
      performeType = SkillPerformTypeSuccess;
      // 攻撃ミスってたら失敗扱いに
      CCArray* targets = _enemyManager->getTargets(skill);
      bool isMiss = targets->count() > 0;
      if (targets->count() > 0) {
        int power = skill->getPower(_characterManager);
        for (int i = 0; i < targets->count(); ++i) {
          Enemy* enemy = (Enemy*)targets->objectAtIndex(i);
          DamageType damageType = DamageTypeNone;
          enemy->damage(power, skill, _characterManager, damageType, true); // ダメージは与えずに結果だけ取り出す
          if (damageType != DamageTypePhysicalInvalid && damageType != DamageTypeMagicalInvalid && damageType != DamageTypeDisable) {
            isMiss = false;
          }
        }
      }
      if (skill->getMP() > _characterManager->getMP()) { // MP足りてないとき、失敗に
        performeType = SkillPerformTypeFailure;
        isMiss = true;
      } else if (lastSkill && !skill->canRepeat() && lastSkill->getIdentifier() == skill->getIdentifier()) {
        performeType = SkillPerformTypeFailure;
        isMiss = true;
      }
      if (performeType == SkillPerformTypeFailure || isMiss) { // 失敗したとき、もしくはピロったとき、miss音を返す
        return this->buildTrackName("miss", NULL, -1);
      } else {
        return this->buildTrackName(skill->getIdentifier().c_str(), skill, _characterManager->getRepeatCount());
      }
    } else {
      _characterManager->setCurrentSkill(skill);
      performeType = SkillPerformTypeCharge;
      std::stringstream ss;
      ss << _characterManager->getCurrentCharacter()->getIdentifier() << skill->getIdentifier() << "_charge" << (_characterManager->getWaitTurn() - 1); // チャージ中の時、チャージ音返す
      return ss.str().c_str();
    }
  } else {
    if (_characterManager->getLastSkill() == NULL) {
      int newWaitCount = ((_characterManager->getRepeatCount() + 1) % _musicSet->getWaitCount());
      if (_isAfterIntro) {
        newWaitCount = 0;
      }
      _characterManager->setRepeatCount(newWaitCount);
      return this->buildTrackName("wait", NULL, newWaitCount);
    } else {
      _characterManager->setRepeatCount(0);
      _characterManager->setRepeatCountRaw(0);
    }
    _characterManager->setLastSkill(skill);
  }
  return this->buildTrackName("wait", NULL, _characterManager->getRepeatCount());
}