Пример #1
0
GameObject* GameObjectManager::CreatePlayer(const Ogre::Vector3& position, void* data){
	CharControllerDef& def = *static_cast<CharControllerDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_PLAYER);
	AnimationComponent* acomp = new AnimationComponent;
	acomp->AddAnimationStates(2);
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	go->AddLateUpdate(contr);
	FollowCameraComponent* fcc = new FollowCameraComponent;
	go->AddComponent(fcc);
	go->AddUpdateable(fcc);
	PlayerInputComponent* pccomp = new PlayerInputComponent;
	go->AddComponent(pccomp);
	go->AddUpdateable(pccomp);
	ChildSceneNodeComponent* csnc = new ChildSceneNodeComponent;
	go->AddComponent(csnc);
	Sound2DComponent* sound2D = new Sound2DComponent;
	go->AddComponent(sound2D);
	Sound3DComponent* sound3D = new Sound3DComponent;
	go->AddComponent(sound3D);
	Music2DComponent* music2D = new Music2DComponent;
	go->AddComponent(music2D);

	acomp->Init("Yomi_2Yomi.mesh", m_scene_manager);
	contr->Init(position, acomp->GetEntity(), def.step_height, def.collider_type, m_physics_engine);
	contr->SetTurnSpeed(def.turn_speed);
	contr->SetVelocity(def.velocity);
	contr->HasFollowCam(true);
	pccomp->Init(m_input_manager);
	sound2D->Init(m_sound_manager);
	sound3D->Init(m_sound_manager);
	music2D->Init(m_sound_manager);
	fcc->Init(m_scene_manager, m_viewport, true);
	fcc->GetCamera()->setNearClipDistance(0.1f);
	fcc->GetCamera()->setFarClipDistance(100);
	csnc->Init(Ogre::Vector3(0.0f, 0.0f, 1.0f), "CreateBubble", acomp->GetSceneNode());
	return go;
}
Пример #2
0
GameObject* GameObjectManager::CreatePlayer(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	PlayerDef& def = *static_cast<PlayerDef*>(data);
	CharacterControllerDef& char_def = *def.character_contr;
	GameObject* go = new GameObject(GAME_OBJECT_PLAYER, "player");
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	AnimationComponent* acomp = new AnimationComponent;
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	MeshRenderComponent* staff_mesh_comp = new MeshRenderComponent;
	go->AddComponent(staff_mesh_comp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	FollowCameraComponent* fcc = new FollowCameraComponent;
	go->AddComponent(fcc);
	go->AddUpdateable(fcc);
	PlayerInputComponent* pccomp = new PlayerInputComponent;
	go->AddComponent(pccomp);
	go->AddUpdateable(pccomp);
	ChildSceneNodeComponent* csnc = new ChildSceneNodeComponent;
	go->AddComponent(csnc);
	Sound2DComponent* sound2D = new Sound2DComponent;
	go->AddComponent(sound2D);
	Sound3DComponent* sound3D = new Sound3DComponent;
	go->AddComponent(sound3D);
	Music2DComponent* music2D = new Music2DComponent;
	go->AddComponent(music2D);
	Music3DComponent* music3D = new Music3DComponent;
	go->AddComponent(music3D);
	CountableResourceGUI* gui = new CountableResourceGUI;
	go->AddComponent(gui);
	go->AddUpdateable(gui);
	TriggerComponent* tc = new TriggerComponent;
	go->AddComponent(tc);
	PlayerRaycastCollisionComponent* prcc = new PlayerRaycastCollisionComponent;
	go->AddComponent(prcc);
	TutorialGraphicsComponent* tutorial = new TutorialGraphicsComponent;
	go->AddComponent(tutorial);
	go->AddUpdateable(tutorial);
	/*
	TriggerComponent* camera_tc = new TriggerComponent;
	go->AddComponent(camera_tc);
	RaycastComponent* camera_rc = new RaycastComponent;
	go->AddComponent(camera_rc);
	CameraRaycastCollisionComponent* camera_rcc = new CameraRaycastCollisionComponent;
	go->AddComponent(camera_rcc);
	//RigidbodyComponent* camera_rb = new RigidbodyComponent;
	*/
	if (def.level_id == "try"){
		tutorial->Init("Level1", def.level_id);
	}
	else{
		tutorial->Init("Level2", def.level_id);
	}

	go->SetId("Player");

	node_comp->Init(position, m_scene_manager);
	node_comp->SetId("player_node");
	
	if(char_def.mesh == "" || char_def.mesh == "Yomi_2Yomi.mesh") char_def.mesh = "Yomi.mesh";
	acomp->Init(char_def.mesh, m_scene_manager, node_comp->GetId(), true);
	acomp->AddAnimationState("Base_Idle");
	acomp->AddAnimationState("Top_Idle");
	//acomp->GetEntity()->setMaterialName("_YomiFBXASC039sFBXASC032staffMaterial__191");

	TriggerDef tdef;
	tdef.body_type = STATIC_BODY;
	tdef.collider_type = COLLIDER_SPHERE;
	tdef.radius = 0.1f;
	tdef.collision_filter.filter = COL_NOTHING;
	tdef.collision_filter.mask = COL_NOTHING;

	tc->Init(position, m_physics_engine, tdef);
	tc->SetId("btrig");
	contr->Init(position, m_physics_engine, char_def);
	contr->HasFollowCam(true);
	contr->SetId("body");
	contr->GetRigidbody()->setContactProcessingThreshold(btScalar(0));
	sound2D->Init(m_sound_manager);
	sound3D->Init(m_sound_manager);
	music2D->Init(m_sound_manager);
	music3D->Init(m_sound_manager);
	gui->Init(def.level_id);
	csnc->Init(Ogre::Vector3(0.0f, char_def.offset.y, 1.0f), "CreateBubble", node_comp->GetSceneNode());
	m_sound_manager->GetYomiNode(node_comp->GetSceneNode()->getName());
	prcc->Init(m_physics_engine);
	prcc->SetCustomVariables(VariableManager::GetSingletonPtr()->GetAsFloat("Bounce_Jump_Mod"));

	fcc->SetNode(node_comp->GetSceneNode());
	fcc->Init(position, m_scene_manager, m_viewport, true);
	fcc->SetMovementSpeed(2.5f);

	fcc->SetPhysEngine(m_physics_engine);
	fcc->SetCustomVariables(
		//VariableManager::GetSingletonPtr()->GetAsInt("Camera_Inverted_Controller_Sticks"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Zoom_Speed"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Stick_Rotation_Acceleration"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Change_Angle_After_Player"),
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Start_Distance"),
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Start_Pitch")
		);
	staff_mesh_comp->Init("Staff.mesh", m_scene_manager, Ogre::StringUtil::BLANK);
	acomp->GetEntity()->attachObjectToBone("CATRigLArmDigit21", staff_mesh_comp->GetEntity(), Ogre::Quaternion(1.0f, 1.0f, 0.7f, 0.0f), Ogre::Vector3(0.01f, -0.02f, 0.0f));
	pccomp->Init(m_input_manager, m_sound_manager, m_physics_engine, m_message_system);
	pccomp->SetCustomVariables(
		VariableManager::GetSingletonPtr()->GetAsFloat("Bubble_Min_Size"),
		VariableManager::GetSingletonPtr()->GetAsFloat("Bubble_Max_Size"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("On_Bubble_Speed_Mod"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("In_Bubble_Speed_Mod"),
		def.level_id
		);
	return go;
}