Ejemplo n.º 1
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);
	}
Ejemplo n.º 2
0
	void GameObject::ComponentDraw() {
		//Transformがなければ例外
		auto Tptr = GetComponent<Transform>();
		//マップを検証してDraw
		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->IsDrawActive()) {
					//そのコンポーネントの描画
					it2->second->OnDraw();
				}
			}
			it++;
		}
		//TransformのDraw
		//Transformの派生クラス対策
		if (Tptr->IsDrawActive()) {
			Tptr->OnDraw();
		}
	}