Player::Player() {
    health = 0;
    damage = 0;
    score = 0;
    total_cost = 0;
    position = toPosition(-1,-1);
}
示例#2
0
//-----------------------------------------------------------------------------
//! ダメージ計算と当たり判定処理
//-----------------------------------------------------------------------------
s32 AllyHealer::calcDamageAndCollision()
{
	// ダメージ保存用
	s32 damage = 0;
	//---- 当たり判定
	for( s32 i=0; i<_myCollision.getHitCount(); ++i )
	{
		Collision* obj = _myCollision.getHitObj(i);
		if( isAllyHealer(obj) ){

			// 補正位置を取得する
			Vector3	dir = _myCollision.getOffsetPos(obj);
			// 補正位置に設定
			_hitPosition = dir;
			// あたり判定用の球情報更新
			setSphereParam(_hitPosition, _hitRadius);

		}else if( isEnemyLeaderAttack(obj) || isEnemyAttakerAttack(obj) || isEnemyDeffenderAttack(obj) ){
			// ダメージ判定
			_hitAttack = true;
			damage += (s32)IObjDataManager()->_enemyStatus->getParam()->_atkPow;
		}
		// 座標の設定
		toPosition(_hitPosition, _position);
	}

	return damage;
}
示例#3
0
//-----------------------------------------------------------------------------
//! 更新(この中で更新すべきUpdateを呼び出す)
//-----------------------------------------------------------------------------
void EnemyBase::Update()
{
	// 死亡フラグが立っていたら処理しない
	if( _isDead ) return;
	// 所属している分隊からリーダーの位置を取得
	if( _keyType != KEY_LEADER ) { 
		_goalPos = _pSquad->getLeader()->getPosition();
	}

	s32	currentAnimation = _pTaskModel->getAnimation();

	// リーダーの命令によって処理変更
	UpdateByCommand();
	
	//---- 移動
	// キャラの移動(左スティックの情報取得)
	_mov._x = sinf( _rotation._y )  * _speed;
	_mov._z = cosf( _rotation._y )  * _speed;

	if( _speed > 0.0f ) 
	{
		// デグリーに直す
		_rotation._y = TO_DEGREE(_rotation._y );
	}

	// 更新
	_oldPosition = _position;

	// フリーズしなかったら
	if( !checkFreeze(currentAnimation) ){
		// 移動してなければ
		if( _mov._x == 0.0f && _mov._z == 0.0f )
		{
			// 立ちモーション
			//_aniState = STATE_WAIT;
			if( currentAnimation != _aniWait ) {
				_pTaskModel->setAnimation(_aniWait, ANIMATION_PLAY_REPEAT);
			}
		}else{
			// 歩きモーション
			//_aniState = STATE_MOVE;
			if( currentAnimation != _aniMove ) {
				_pTaskModel->setAnimation(_aniMove, ANIMATION_PLAY_REPEAT);
			}
		}
	}

	// 攻撃してたら
	if( currentAnimation == _aniAttack ) {
		// 移動速度を少なくする
		_mov._x *= 0.5f;
		_mov._z *= 0.5f;
	}else if( currentAnimation == _aniDamage ){
		// 移動速度をなくす
		_mov._x *= 0.0f;
		_mov._z *= 0.0f;
	}

	_position += _mov * Global::deltaTime;

	//---- パーティクル
	// パーティクルの生成待ち時間カウント
	_genCount += 1 * Global::deltaTime;

	Vector3 sub = _oldPosition - _position;

	// 移動している且つ、生成待ち時間が切れた時
	if( (abs(sub._x) > 0.0f || abs(sub._z) > 0.0f) && _genCount >= _waitGenTime ) {

		// カウントリセット
		_genCount = 0;

		Vector3 pos = _position + Vector3( (f32)(rand() % 40 - 20) );

		Vector3 mov = -_mov;

		mov._x *= (rand() %  50) / 100.0f;
		mov._y  = (rand() % 100) / 100.0f;
		mov._z *= (rand() %  50) / 100.0f;

		f32		rot = ( rand() % 20 ) / 20.0f;
		Radian	angVel = Radian( ( rand() % 10 ) / 100.0f );

		// パーティクル生成
		IParticleMan()->generateParticle(pos,
										 mov,
										 Vector3(0.5f, 0.5f, 0.0f),
										 Radian(rot),
										 100, 0,
										 angVel,
										 ParticleManager::PARTICLE_SMOKE); 
	}


	// あたり判定の球の更新
	Man::Update();
	
	//---- マップとの当たり判定
	GmSystemCollision()->checkCollisionModel(_hitPosition, _radius, _hitGround);

	// 外にいけなくする
	ICastleCol()->hitOutRange(_hitPosition);

	// あたり判定用の球情報更新
	setSphereParam(_hitPosition, _hitRadius);
	// 座標の設定
	toPosition(_hitPosition, _position);

	// 重力処理
	if( !_hitGround ){
		_mov._y -= 0.6f * Global::deltaTime;
	}
	else{
		_mov._y = 0.0f;
	}

	// 最大重力設定
	if( _mov._y <= -9.8f )
	{
		_mov._y = -9.8f; 
	}

	if( _aniAttack != -1 ) {

		// 攻撃ボタンが押されているかどうか
		if( _key->getPushState("Attack") )
		{
			// 攻撃アニメーション再生
			_pTaskModel->setAnimation(_aniAttack);
			// 攻撃
			Attack();

		}else if ( currentAnimation == _aniAttack ) {

			// 攻撃再生中なら
			// 再生比率取得
			f32	aniRate = _pTaskModel->getAnimationRate();
			// 再生が半分いったら
			if( aniRate >= 0.5f && !_isAttack ) {
				// 攻撃
				Attack();
			}else if( _isAttack ){
				// 攻撃範囲、座標を戻す
				_attackPosition = Vector3( 0.0f, 0.0f, 0.0f );
				_attackRadius	= 0.0f;
			}

		}else{
			// この時点で半径が初期化されてなければ
			if( _attackRadius != 0.0f ){
				// 攻撃範囲、座標を戻す
				_attackPosition = Vector3( 0.0f, 0.0f, 0.0f );
				_attackRadius	= 0.0f;
			}
			// 攻撃フラグを元に戻す
			_isAttack = false;
		}

	}

	// 体力が0以下なら
	if( _myStatus->getParam()->_HP <= 0 )
	{
		// 死亡フラグを立てる
		_isDead = true;
	}
}
示例#4
0
/**
 * Constructs a tile. Use this over setTile if a tile has not been generated
 * for the position yet.
 *
 * @param pType Type of the tile to create.
 */
Tile::Tile(const Vector2i& tilePosition, Type type) :
		Rectangle(toPosition(tilePosition),
				CATEGORY_WORLD,	(isSolid(type)) ? 0xffff : 0,
				Yaml(getConfig(type))),	mType(type) {
}
Position Monster::calculateToPosition (const Game& game, const Position& player_position) const {
	// Examine the four possible locations for the monster to move,
	// one to each of north, south, east, and west, to see which
	// is closest to the target
	Position new_position = position;
	double new_distance = calculateDistance(position, player_position);

	Position temp_position;
	double temp_distance;

	if (position.row > 0)
	{
		temp_position = 
			toPosition(position.row - 1, position.column);
		temp_distance = calculateDistance(temp_position, player_position);
		if (!game.isBlockedForMonster(temp_position)) { //Check for wall
			if (temp_distance < new_distance)
			{
				new_position = temp_position;
				new_distance = temp_distance;
			}
		}
	}
	if (position.row  < (ROWS - 1))
	{
		temp_position = 
			toPosition(position.row + 1, position.column);
		temp_distance = calculateDistance(temp_position, player_position);
		if (!game.isBlockedForMonster(temp_position)) {
			if (temp_distance < new_distance)
			{
				new_position = temp_position;
				new_distance = temp_distance;
			}
		}
	}
	if (position.column > 0)
	{
		temp_position = 
			toPosition(position.row, position.column - 1);
		temp_distance = calculateDistance(temp_position, player_position);
		if (!game.isBlockedForMonster(temp_position)) {
			if (temp_distance < new_distance)
			{
				new_position = temp_position;
				new_distance = temp_distance;
			}
		}
	}
	if (position.column < (COLUMNS - 1))
	{
		temp_position = 
			toPosition(position.row, position.column + 1);
		temp_distance = calculateDistance(temp_position, player_position);
		if (!game.isBlockedForMonster(temp_position)) {
			if (temp_distance < new_distance)
			{
				new_position = temp_position;
				new_distance = temp_distance;
			}
		}
	}
	return new_position;
}
Monster::Monster() {
	health = 0;
	damage = 0;
	points = 0;
	position = toPosition(-1, -1);
}