/*************************************************************//** * * @brief 生成処理を行う * @param 射撃者 * @param インデックス * @param 情報 * @return 銃 * ****************************************************************/ C_BaseGun* C_OptionSmallBeamGunFactory::Create(C_Shooter* pShooter, int32_t index, void* pData) { // プレイヤーの情報を取得 assert(JSON::C_JsonObjectManager::s_GetInstance()->GetJsonObject(ID::JSON::s_pSMALL_BEAM_OPTION)); auto pOptionData = JSON::C_JsonObjectManager::s_GetInstance()->GetJsonObject(ID::JSON::s_pSMALL_BEAM_OPTION).get(); auto pGun = newEx C_NormalGun(pShooter); auto direction = Physics::Vector3(static_cast<float>((*pOptionData)["GunDatas"][index]["Direction"][0].GetValue<JSON::Real>()), static_cast<float>((*pOptionData)["GunDatas"][index]["Direction"][1].GetValue<JSON::Real>()), static_cast<float>((*pOptionData)["GunDatas"][index]["Direction"][2].GetValue<JSON::Real>())); auto offsetFromShooter = Physics::Vector3(static_cast<float>((*pOptionData)["GunDatas"][index]["OffsetFromShooter"][0].GetValue<JSON::Real>()), static_cast<float>((*pOptionData)["GunDatas"][index]["OffsetFromShooter"][1].GetValue<JSON::Real>()), static_cast<float>((*pOptionData)["GunDatas"][index]["OffsetFromShooter"][2].GetValue<JSON::Real>())); pGun->SetShotLogic(newEx C_InputShotLogic((*pOptionData)["GunDatas"][index]["ShotInterval"].GetValue<JSON::Integer>())); pGun->SetBulletId((*pOptionData)["GunDatas"][index]["BulletId"].GetValue<JSON::String>()); pGun->SetBulletPower(newEx C_BasePower((*pOptionData)["GunDatas"][index]["BulletPower"].GetValue<JSON::Integer>())); auto pMoveLogic = newEx C_RigidBodyStraightMoveLogic; pMoveLogic->SetDirection(direction); pMoveLogic->SetMovement(static_cast<float>((*pOptionData)["GunDatas"][index]["BulletMovement"].GetValue<JSON::Real>())); pGun->SetBulletMoveLogic(pMoveLogic); pGun->SetOffsetFromShooter(offsetFromShooter); pGun->SetDirection(direction); return pGun; }
void Monster::setType(const TYPE_OF_CHARACTER_ID &type) throw(unknownIDException) { deleteAllSkills(); MonsterStruct monsterdef; if (! MonsterDescriptions->find(type, monsterdef)) { throw unknownIDException(); } // set attributes setAttribute(Character::luck, Random::uniform(monsterdef.attributes.luck.first, monsterdef.attributes.luck.second)); setAttribute(Character::strength, Random::uniform(monsterdef.attributes.strength.first, monsterdef.attributes.strength.second)); setAttribute(Character::dexterity, Random::uniform(monsterdef.attributes.dexterity.first, monsterdef.attributes.dexterity.second)); setAttribute(Character::constitution, Random::uniform(monsterdef.attributes.constitution.first, monsterdef.attributes.constitution.second)); setAttribute(Character::agility, Random::uniform(monsterdef.attributes.agility.first, monsterdef.attributes.agility.second)); setAttribute(Character::intelligence, Random::uniform(monsterdef.attributes.intelligence.first, monsterdef.attributes.intelligence.second)); setAttribute(Character::perception, Random::uniform(monsterdef.attributes.perception.first, monsterdef.attributes.perception.second)); setAttribute(Character::willpower, Random::uniform(monsterdef.attributes.willpower.first, monsterdef.attributes.willpower.second)); setAttribute(Character::essence, Random::uniform(monsterdef.attributes.essence.first, monsterdef.attributes.essence.second)); setAttribute(Character::hitpoints, monsterdef.hitpoints); setAttribute(Character::height, Random::uniform(monsterdef.minsize, monsterdef.maxsize)); // set skills for (auto it = monsterdef.skills.begin(); it != monsterdef.skills.end(); ++it) { increaseSkill(it->first, Random::uniform(it->second.first, it->second.second)); } // add items for (auto it = monsterdef.items.begin(); it != monsterdef.items.end(); ++it) { auto inventorySlot = it->first; auto possibleItems = it->second; int numberOfPossibleItems = possibleItems.size(); if (numberOfPossibleItems > 0) { int selectedItemIndex; if (numberOfPossibleItems == 1) { selectedItemIndex = 0; } else { selectedItemIndex = Random::uniform(0, numberOfPossibleItems - 1); } auto &selectedItem = possibleItems[selectedItemIndex]; characterItems[inventorySlot].setId(selectedItem.itemid); characterItems[inventorySlot].setNumber(Random::uniform(selectedItem.amount.first, selectedItem.amount.second)); characterItems[inventorySlot].setWear(selectedItem.AgeingSpeed); } } SetMovement(monsterdef.movement); race = monsterdef.race; _canAttack = monsterdef.canattack; name = monsterdef.nameEn; nameDe = monsterdef.nameDe; }
/*************************************************************//** * * @brief ディープコピーを行う * @param なし * @return 自身のコピー * ****************************************************************/ C_RigidBodyMoveLogic* C_RigidBodyForceMoveLogic::DeepCopy() { auto pRigidBodyMoveLogic = newEx C_RigidBodyForceMoveLogic(*upFirstAddForce_, *upAddTorque_); pRigidBodyMoveLogic->SetDirection(*upDirection_); pRigidBodyMoveLogic->SetMovement(movement_); pRigidBodyMoveLogic->SetAddTorque(*upAddTorque_); return pRigidBodyMoveLogic; }
LTBOOL CAIPoodleStrategyFollowPath::UpdateMoveTo(CAIPathWaypoint* pWaypoint) { if ( m_AIMovement.IsSet() ) { if ( !m_AIMovement.Update() ) { return LTFALSE; } if ( m_AIMovement.IsDone() ) { m_pPath->IncrementWaypointIndex(); } } else if ( m_AIMovement.IsUnset() || m_AIMovement.IsDone() ) { if ( !GetAI()->FacePos(pWaypoint->GetArgumentVector1()) ) { // If we're not yet facing the point, don't move, and start to face it. // We need to clear in order to disable the steerings. GetAI()->Stop(); } else { // We're facing the point, so we can start moving. SetMovement(m_eMovement); m_AIMovement.Set(pWaypoint->GetArgumentVector1()); } } else // Stuck { } GetAnimator()->SetMain(m_eMovement); return LTTRUE; }
void run() { uint8_t key[2]; uint8_t key_itr = 0; while(key_itr < 2) key[++key_itr] = 0; key_itr = 0; moveflags = 0; recordIter = 0; speed = 127; le.clear(); re.clear(); recordTime.stop(); recordTime.clear(); uint32_t nextPlay = 0; uint32_t nextPlayBase = 0; state = 0; encoder_play_l.stop(); encoder_play_r.stop(); startTime = 0; /*rs232.send("YuniRC program has started!\r\n" "Controls: W,A,S,D - movement, Space - read sensor values,"); rs232.wait(); rs232.send(" R - reset encoders, Q - On/Off engine correction, 1 2 3 - speed \r\n"); rs232.wait(); rs232.send("Engine correction is disabled.\r\n"); */ char ch; while(true) { if(state & STATE_ERASING) continue; // Move correction if((state & STATE_CORRECTION) && (moveflags == MOVE_FORWARD || moveflags == MOVE_BACKWARD)) MovementCorrection(); if((state & STATE_PLAY) && (lastAdress == 0 || EventHappened(&lastRec, &nextPlayBase, &nextPlay))) { encoder_play_l.stop(); encoder_play_r.stop(); read_mem(&lastRec, lastAdress); lastAdress += REC_SIZE; if((lastRec.key[0] == 0 && lastRec.key[1] == 0 && lastRec.getBigNum() == 0) || lastAdress > 512) { state &= ~(STATE_PLAY); rs232.send("Playback finished\r\n"); setMotorPower(0, 0); le_cor.stop(); re_cor.stop(); moveflags = MOVE_NONE; continue; } SetMovement(lastRec.key); nextPlay = 0; nextPlayBase = 0; if(lastRec.end_event == EVENT_TIME) { nextPlayBase = getTickCount(); nextPlay = (uint32_t(lastRec.getBigNum())*10000) * JUNIOR_WAIT_MUL / JUNIOR_WAIT_DIV; } //Uncomment to set messure delay /*else if(lastRec.end_event == EVENT_RANGE_MIDDLE_HIGHER || lastRec.end_event == EVENT_RANGE_MIDDLE_LOWER) { nextPlayBase = getTickCount(); nextPlay = (50000) * JUNIOR_WAIT_MUL / JUNIOR_WAIT_DIV; }*/ else if(lastRec.end_event == EVENT_DISTANCE || lastRec.end_event == EVENT_DISTANCE_LEFT || lastRec.end_event == EVENT_DISTANCE_RIGHT) { encoder_play_r.clear(); encoder_play_l.clear(); encoder_play_l.start(); encoder_play_r.start(); } ++recordIter; } //Read command if(!rs232.peek(ch)) continue; key[key_itr] = uint8_t(ch); ++key_itr; //key recieved if(key_itr >= 2) { key_itr = 0; // FIXME: ignore two or more keys at once if((state & STATE_RECORD) && char(lastRec.key[1]) == 'd' && char(key[1]) != 'u' && char(key[0]) != 'C') { while(key_itr < 2) key[++key_itr] = '0'; key_itr = 0; continue; } bool down_only = SetMovement(key); if(char(key[0]) == 'O' || char(key[0]) == 'P') continue; else if((state & STATE_RECORD) && char(key[0]) != 'C' && (!down_only || (down_only && char(key[1]) == 'd'))) // do not record down only keys { if(!recordTime.isRunning()) { recordTime.clear(); recordTime.start(); } if(recordIter > 0) { lastRec.end_event = EVENT_TIME; lastRec.setBigNum(recordTime.getTime()/10000); write_mem(&lastRec, lastAdress); lastAdress+=REC_SIZE; } if(recordIter < MEM_SIZE-1) { while(key_itr < 2) { lastRec.key[key_itr] = key[key_itr]; ++key_itr; } key_itr = 0; recordTime.clear(); ++recordIter; } else { key[0] = uint8_t('C'); key[1] = uint8_t('d'); rs232.send("Memory full\r\n"); continue; } } } // EEPROM Flash mode else if(ch == 0x1C) { while(key_itr < 2) key[++key_itr] = '0'; key_itr = 0; erase_eeprom(); rs232.sendCharacter(0x1D); for(lastAdress = 0; true; ) { if(!rs232.peek(ch)) continue; if(ch == 0x1E && lastAdress%5 == 0) break; write_byte(lastAdress, uint8_t(ch)); ++lastAdress; rs232.sendCharacter(0x1F); } lastAdress = 0; } // EEPROM read mode else if(ch == 0x16) { while(key_itr < 2) key[++key_itr] = '0'; key_itr = 0; rs232.sendCharacter(0x17); for(lastAdress = 0; lastAdress < 512; ++lastAdress) { rs232.wait(); rs232.sendCharacter(read_byte(lastAdress)); } rs232.sendCharacter(0x18); lastAdress = 0; } } }
void Monster::setMonsterType(TYPE_OF_CHARACTER_ID type) { deleteAllSkills(); if (!monsterDescriptions->exists(type)) { throw unknownIDException(); } const auto &monsterdef = (*monsterDescriptions)[type]; // set attributes setAttribute(Character::luck, Random::uniform(monsterdef.attributes.luck.first, monsterdef.attributes.luck.second)); setAttribute(Character::strength, Random::uniform(monsterdef.attributes.strength.first, monsterdef.attributes.strength.second)); setAttribute(Character::dexterity, Random::uniform(monsterdef.attributes.dexterity.first, monsterdef.attributes.dexterity.second)); setAttribute(Character::constitution, Random::uniform(monsterdef.attributes.constitution.first, monsterdef.attributes.constitution.second)); setAttribute(Character::agility, Random::uniform(monsterdef.attributes.agility.first, monsterdef.attributes.agility.second)); setAttribute(Character::intelligence, Random::uniform(monsterdef.attributes.intelligence.first, monsterdef.attributes.intelligence.second)); setAttribute(Character::perception, Random::uniform(monsterdef.attributes.perception.first, monsterdef.attributes.perception.second)); setAttribute(Character::willpower, Random::uniform(monsterdef.attributes.willpower.first, monsterdef.attributes.willpower.second)); setAttribute(Character::essence, Random::uniform(monsterdef.attributes.essence.first, monsterdef.attributes.essence.second)); setAttribute(Character::hitpoints, monsterdef.hitpoints); setAttribute(Character::height, Random::uniform(monsterdef.minsize, monsterdef.maxsize)); // set skills for (const auto &skill: monsterdef.skills) { increaseSkill(skill.first, Random::uniform(skill.second.first, skill.second.second)); } // add items for (const auto &item: monsterdef.items) { auto inventorySlot = item.first; auto possibleItems = item.second; int numberOfPossibleItems = possibleItems.size(); if (numberOfPossibleItems > 0) { int selectedItemIndex; if (numberOfPossibleItems == 1) { selectedItemIndex = 0; } else { selectedItemIndex = Random::uniform(0, numberOfPossibleItems - 1); } auto &selectedItem = possibleItems[selectedItemIndex]; items[inventorySlot].setId(selectedItem.itemid); items[inventorySlot].setNumber(Random::uniform(selectedItem.amount.first, selectedItem.amount.second)); items[inventorySlot].setWear(selectedItem.AgeingSpeed); } } SetMovement(monsterdef.movement); setRace(monsterdef.race); _canAttack = monsterdef.canattack; setName(monsterdef.nameEn); nameDe = monsterdef.nameDe; const auto raceConfiguration = raceTypes->getRandomRaceConfiguration(monsterdef.race); setAttribute(sex, raceConfiguration.subType); setHair(raceConfiguration.hair); setBeard(raceConfiguration.beard); setHairColour(raceConfiguration.hairColour); setSkinColour(raceConfiguration.skinColour); setSkinColour(raceConfiguration.skinColour); }