Beispiel #1
0
	//Xボタンハンドラ
	void Player::OnPushX() {
		auto XAPtr = App::GetApp()->GetXAudio2Manager();
		XAPtr->Start(L"cursor");

		auto Ptr = GetComponent<Transform>();
		Vec3 Pos = Ptr->GetPosition();
		Pos.y += 0.3f;
		Quat Qt = Ptr->GetQuaternion();
		Vec3 Rot = Qt.toRotVec();
		float RotY = Rot.y;
		Vec3 velo(sin(RotY), 0.05f, cos(RotY));
		velo.normalize();
		velo *= 20.0f;
		auto Group = GetStage()->GetSharedObjectGroup(L"ShellGroup");
		for (size_t i = 0; i < Group->size(); i++) {
			auto shptr = dynamic_pointer_cast<ShellSphere>(Group->at(i));
			if (shptr && !shptr->IsUpdateActive()) {
				//空きが見つかった
				shptr->Reset(Pos, velo);
				return;
			}
		}
		//ここまで来てれば空きがない
		GetStage()->AddGameObject<ShellSphere>(Pos, velo);
	}
Beispiel #2
0
	//砲弾を発射する関数
	//ShellThrowMotion()から呼ばれる
	void RollingTorus::StartShellBall(){
		auto PlayerPtr = GetStage()->GetSharedGameObject<Player>(L"Player");
		auto PlayerPos = PlayerPtr->GetComponent<Transform>()->GetPosition();
		auto Pos = GetComponent<Transform>()->GetPosition();
		auto ShellAngle = PlayerPos - Pos;
		float len = ShellAngle.Length();
		ShellAngle.y = 0;
		ShellAngle.Normalize();
		ShellAngle *= len;
		//打ち上げの上向きの初速度を追加(値は固定)
		ShellAngle += Vector3(0.0f, 5.0f, 0);
		//グループ内に空きがあればそのオブジェクトを再利用
		//そうでなければ新規に作成
		auto Group = GetStage()->GetSharedObjectGroup(L"ShellBallGroup");
		auto ShellVec = Group->GetGroupVector();
		for (auto Ptr : ShellVec){
			//Ptrはweak_ptrなので有効性チェックが必要
			if (!Ptr.expired()){
				auto ShellPtr = dynamic_pointer_cast<ShellBall>(Ptr.lock());
				if (ShellPtr){
					if ((!ShellPtr->IsUpdateActive()) && (!ShellPtr->IsDrawActive())){
						ShellPtr->Refresh(Pos, ShellAngle, true);
						return;
					}
				}
			}
		}
		//ここまで来たら空きがなかったことになる
		//砲弾の追加
		auto Sh = GetStage()->AddGameObject<ShellBall>(Pos, ShellAngle, true);
		//グループに追加
		Group->IntoGroup(Sh);
	}
Beispiel #3
0
	//爆発を演出する関数
	//発射後一定の時間がたったら衝突をアクティブにする
	void ShellBall::HitTestCheckMotion(){
		//衝突判定を呼び出す
		auto PtrCollision = GetComponent<CollisionSphere>();
		if (PtrCollision->IsUpdateActive()){
			//既に衝突は有効
			return;
		}
		float ElapsedTime = App::GetApp()->GetElapsedTime();
		m_InStartTime += ElapsedTime;
		if (m_InStartTime > 0.5f){
			//衝突を有効にする
			PtrCollision->SetUpdateActive(true);
		}
	}
Beispiel #4
0
//--- Call every frame in the client application to control updating for the concrete subclass.
void Updateable::Update (const float deltaTime)
{
	// Only applied if this object is active for updating.
	if (!IsUpdateActive() ) return;
	
	// increment internal measures.
	++mFrameCount;
	mTimeElapsed += deltaTime;
	if (IsTimeToUpdate()) 
	{
		// parameter is the time since OnUpdate was last called, not the time since this function was last called.
		OnUpdate(mTimeElapsed);
		// Reset measure counts.
		mFrameCount = 0;
		mTimeElapsed = 0.0f;
	}
} // end Update function.
Beispiel #5
0
	void GameObject::ComponentUpdate()	{
		auto TMptr = GetComponent<Transform>();
		//マップを検証してUpdate
		list<type_index>::iterator it = pImpl->m_ComponentList.begin();
		while (it != pImpl->m_ComponentList.end()) {
			map<type_index, shared_ptr<Component> >::const_iterator it2;
			it2 = pImpl->m_ComponentData.find(*it);
			if (it2 != pImpl->m_ComponentData.end()) {
				//指定の型のコンポーネントが見つかった
				if (it2->second->IsUpdateActive()) {
					it2->second->OnUpdate();
				}
			}
			it++;
		}
		//TransformMatrixのUpdate
		if (TMptr->IsUpdateActive()) {
			TMptr->OnUpdate();
		}
	}