bool PlayerProfileEntity::mapping(picojson::object &object) {
	if (object["gender"].is<int>()) {
		setGender(object["gender"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "gender");
		return false;
	}
	if (object["age"].is<int>()) {
		setAge(object["age"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "age");
		return false;
	}
	if (object["address"].is<int>()) {
		setAddress(object["address"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "address");
		return false;
	}
	if (object["blood"].is<int>()) {
		setBlood(object["blood"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "blood");
		return false;
	}
	if (object["constellation"].is<int>()) {
		setConstellation(object["constellation"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "constellation");
		return false;
	}
	return true;
}
Esempio n. 2
0
void Monster::go(float timeSinceLastFrame)
{
	
	/// 给动画增加时间
	addTimeToAnimation(timeSinceLastFrame);
	if(!mIsDead)
	{
		if(mDistance < 0.0f || mDistance == 0.0f)
		{
			int size = ogrePath.size();
			mNode->setPosition(ogrePath[mNextPosIndex]);
			if(ogrePath[ogrePath.size()-1] != mNode->getPosition())
			{
				mBeginPosIndex++;
				mNextPosIndex++;
				mDistance = distance(ogrePath[mNextPosIndex], ogrePath[mBeginPosIndex]);
				/// 面向,方向向量
				mFace = (ogrePath[mNextPosIndex] - ogrePath[mBeginPosIndex]);
				mFace.normalise();
			
				/// 旋转面向角度
				Ogre::Vector3 src = mNode->getOrientation() * Vector3::UNIT_X; 
				Ogre::Quaternion quat = src.getRotationTo(mFace);
				mNode->rotate(quat);
			}
			else
			{
				setBlood(0);
				mIsGetUFO = true;
			}
		}
	
		/// 平移所需要走的路
		float moveDistance =  timeSinceLastFrame * mSpeedCurrent;
		mNode->translate(mFace * moveDistance);
		mDistance -= moveDistance;
	}
}
Esempio n. 3
0
Man_3::Man_3() {
	setSpeed(3);
	setBlood(6);
	setPower(2);
	setDis(Director::getInstance()->getVisibleSize().width / 3);
}
Esempio n. 4
0
Man_2::Man_2() {
	setSpeed(6);
	setBlood(3);
	setPower(1);
	setDis(3 * Director::getInstance()->getVisibleSize().width / 5);
}