Ejemplo n.º 1
0
//==============================================================================
// プレイヤー判定スキップ
//==============================================================================
void CGame::PushBackBattleArea(void)
{
	// 判定
	CPlayer*	pPlayerCurrent = nullptr;		// 対象オブジェクト
	for (int cntPlayer = 0; cntPlayer < PLAYER_MAX; ++cntPlayer)
	{
		// 対象オブジェクトを取得
		pPlayerCurrent = Player[cntPlayer];

		// 対象のステートを確認
		if (NeedsSkipPlayer(pPlayerCurrent))
		{
			continue;
		}

		// 押し戻し
		VECTOR3	vectorPlayerToCenter = Ground->Pos() - pPlayerCurrent->Pos();
		vectorPlayerToCenter.y = 0.0f;
		float	distanceFromCenter = vectorPlayerToCenter.x * vectorPlayerToCenter.x + vectorPlayerToCenter.y * vectorPlayerToCenter.y + vectorPlayerToCenter.z * vectorPlayerToCenter.z;
		if (distanceFromCenter > (RADIUS_AREA_BATTLE - RADIUS_PUSH_CHARACTER) * (RADIUS_AREA_BATTLE - RADIUS_PUSH_CHARACTER))
		{
			float	distancePushBack = sqrtf(distanceFromCenter) - (RADIUS_AREA_BATTLE - RADIUS_PUSH_CHARACTER);
			vectorPlayerToCenter.Normalize();
   pPlayerCurrent->AddPos(vectorPlayerToCenter * distancePushBack);
   pPlayerCurrent->AddDestPos(vectorPlayerToCenter * distancePushBack);
		}
	}
}
Ejemplo n.º 2
0
//==============================================================================
// キャラクターと岩の押し戻し
//==============================================================================
void CGame::PushBackRock(void)
{
	// 攻撃側の決定
	CPlayer*	pPlayer = nullptr;		// 攻撃側プレイヤー
	for (int cntPlayer = 0; cntPlayer < PLAYER_MAX; ++cntPlayer)
	{
		// プレイヤーを取得
		pPlayer = Player[cntPlayer];

		// プレイヤーが判定可能か確認
		if (NeedsSkipPlayer(pPlayer))
		{
			continue;
		}

		// 防御側の決定
		for (int cntRock = 0; cntRock < MAX_ROCK; ++cntRock)
		{
			// 岩を取得
			CObject*	pRock = ppRock_[cntRock];		// 岩オブジェクト

			// 当たり判定
			VECTOR3	positionPlayer = pPlayer->Pos();	// 攻撃判定中心座標
			VECTOR3	positionRock = pRock->Pos();		// 防御判定中心座標
			VECTOR3	vectorOffenseToDefense;				// 攻撃判定から防御判定へのベクトル
			float	distanceOffenseAndDefense;			// 判定の中心同士の距離
			float	scalingRock;						// 岩の大きさ
			scalingRock = (pRock->Scl().x < pRock->Scl().z ? pRock->Scl().x : pRock->Scl().z);
			positionPlayer.y += HEIGHT_PUSH_CHARACTER;
			positionRock.y += HEIGHT_PUSH_ROCK;
			vectorOffenseToDefense = positionRock - positionPlayer;
			distanceOffenseAndDefense = sqrtf(vectorOffenseToDefense.x * vectorOffenseToDefense.x + vectorOffenseToDefense.y * vectorOffenseToDefense.y + vectorOffenseToDefense.z * vectorOffenseToDefense.z);

			if (distanceOffenseAndDefense < RADIUS_PUSH_CHARACTER + RADIUS_PUSH_ROCK * scalingRock)
			{
				// 押し戻し
				if (distanceOffenseAndDefense < -FLT_EPSILON || distanceOffenseAndDefense > FLT_EPSILON)
				{
					VECTOR3	vectorPushBack = vectorOffenseToDefense * -(RADIUS_PUSH_CHARACTER + RADIUS_PUSH_ROCK * scalingRock - distanceOffenseAndDefense) / distanceOffenseAndDefense;
					vectorPushBack.y = 0.0f;
     pPlayer->AddPos(vectorPushBack);
     pPlayer->AddDestPos(vectorPushBack);
				}
				else
				{
     pPlayer->AddPosX(RADIUS_PUSH_CHARACTER + RADIUS_PUSH_ROCK * scalingRock);
     pPlayer->AddDestPosX(RADIUS_PUSH_CHARACTER + RADIUS_PUSH_ROCK * scalingRock);
				}

				// エフェクト:火花 プレイヤーと岩のぶつかり
			}
		}
	}
}
Ejemplo n.º 3
0
//==============================================================================
// キャラクター同士の押し戻し
//==============================================================================
void CGame::PushBackCharacter(void)
{
	// 攻撃側の決定
	CPlayer*	pPlayerOffense = nullptr;		// 攻撃側プレイヤー
	for (int cntBullet = 0; cntBullet < PLAYER_MAX; ++cntBullet)
	{
		// プレイヤーを取得
		pPlayerOffense = Player[cntBullet];

		// プレイヤーが判定可能か確認
		if (NeedsSkipPlayer(pPlayerOffense))
		{
			continue;
		}

		// 防御側の決定
		for (int cntPlayer = 0; cntPlayer < PLAYER_MAX; ++cntPlayer)
		{
			// プレイヤーを取得
			CPlayer*	pPlayerDefense = Player[cntPlayer];		// 防御側プレイヤー

			// プレイヤーが判定可能か確認
			if (NeedsSkipPlayer(pPlayerDefense))
			{
				continue;
			}
			if (cntBullet == cntPlayer)
			{
				continue;
			}

			// 当たり判定
			VECTOR3	positionOffense = pPlayerOffense->Pos();		// 攻撃判定中心座標
			VECTOR3	positionDefense = pPlayerDefense->Pos();		// 防御判定中心座標
			VECTOR3	vectorOffenseToDefense;							// 攻撃判定から防御判定へのベクトル
			float	distanceOffenseAndDefense;						// 判定の中心同士の距離
			positionOffense.y += HEIGHT_PUSH_CHARACTER;
			positionDefense.y += HEIGHT_PUSH_CHARACTER;
			vectorOffenseToDefense = positionDefense - positionOffense;
			distanceOffenseAndDefense = sqrtf(vectorOffenseToDefense.x * vectorOffenseToDefense.x + vectorOffenseToDefense.y * vectorOffenseToDefense.y + vectorOffenseToDefense.z * vectorOffenseToDefense.z);
			if (distanceOffenseAndDefense < 2.0f * RADIUS_PUSH_CHARACTER)
			{
				// 押し戻し
				if (distanceOffenseAndDefense < -FLT_EPSILON || distanceOffenseAndDefense > FLT_EPSILON)
				{
					VECTOR3	vectorPushBack = vectorOffenseToDefense * 0.51f * (2.0f * RADIUS_PUSH_CHARACTER - distanceOffenseAndDefense) / distanceOffenseAndDefense;
     pPlayerDefense->AddPos(vectorPushBack);
     pPlayerDefense->AddDestPos(vectorPushBack);
					vectorPushBack *= -1.0f;
     pPlayerOffense->AddPos(vectorPushBack);
     pPlayerOffense->AddDestPos(vectorPushBack);
				}
				else
				{
     pPlayerOffense->AddPosX(RADIUS_PUSH_CHARACTER);
     pPlayerOffense->AddDestPosX(RADIUS_PUSH_CHARACTER);
     pPlayerDefense->AddPosX(-RADIUS_PUSH_CHARACTER);
     pPlayerDefense->AddDestPosX(-RADIUS_PUSH_CHARACTER);
				}

				// エフェクト:火花 プレイヤー同士のぶつかり
			}
		}
	}
}