示例#1
0
bool CMapLocation::CheckMapCollision( CMapLocation& box )
{
    // The sides of the SDL_Rects
    int16_t leftA, leftB;
    int16_t rightA, rightB;
    int16_t topA, topB;
    int16_t bottomA, bottomB;

    // Calculate the sides of internal box
    leftA   = mX;
    rightA  = mX + mW;
    topA    = mY;
    bottomA = mY + mH;

    // Calculate the sides of rec box
    leftB   = box.TileX();
    rightB  = box.TileX() + box.TileW();
    topB    = box.TileY();
    bottomB = box.TileY() + box.TileH();

    // If any of the sides from box are outside of box
    if ( bottomA <= topB ) return false;
    if ( topA >= bottomB ) return false;
    if ( rightA <= leftB ) return false;
    if ( leftA >= rightB ) return false;
    // If none of the sides from box are outside box
    return true;    // Collision has occured
}
/*void map_add_object_spot_complex(u16 id, LPCSTR spot_name, LPCSTR hint, 
								 LPCSTR left_icon, LPCSTR right_icon, LPCSTR top_icon, int time_end )
{
	CMapLocation* ml = Level().MapManager().AddMapLocation(spot_name,id);
	R_ASSERT2( ml, spot_name );
	R_ASSERT2( ml->complex_spot(), spot_name );

	ml->complex_spot()->SetTTL( time_end );

	if ( hint && xr_strlen(hint) )
	{
		ml->SetHint(hint);
	}
	if ( left_icon && xr_strlen(left_icon) )
	{
		ml->complex_spot()->SetLeftTexture(left_icon);
	}
	if ( right_icon && xr_strlen(right_icon) )
	{
		ml->complex_spot()->SetRightTexture(right_icon);
	}
	if ( top_icon && xr_strlen(top_icon) )
	{
		ml->complex_spot()->SetTopTexture(top_icon);
	}
}
*/
void map_add_object_spot_ser(u16 id, LPCSTR spot_type, LPCSTR text)
{
	CMapLocation* ml = Level().MapManager().AddMapLocation(spot_type,id);
	if( xr_strlen(text) )
			ml->SetHint(text);

	ml->SetSerializable(true);
}
void map_add_object_spot(u16 id, LPCSTR spot_type, LPCSTR text)
{
	CMapLocation* ml = Level().MapManager().AddMapLocation(spot_type,id);
	if ( xr_strlen(text) )
	{
		ml->SetHint(text);
	}
}
示例#4
0
void CGameTaskManager::UpdateActiveTask				()
{
	GameTasks_it it								= GameTasks().begin();
	GameTasks_it it_e							= GameTasks().end();
	bool bHasSpotPointer						= false;

	for( ;it!=it_e; ++it )
	{
		CGameTask* t							= (*it).game_task;

		if( t->Objective(0).TaskState() != eTaskStateInProgress ) 
			continue;

		for(u32 i=0; i<t->m_Objectives.size() ;++i)
		{
			SGameTaskObjective& obj				= t->Objective(i);

			//1-st enable hidden locations
			if(	(!obj.def_location_enabled)							&& 
				(obj.TaskState()==eTaskStateInProgress)				&& 
				(t->Objective(i-1).TaskState()==eTaskStateCompleted) )
			{
				if(obj.object_id!=u16(-1) && *obj.map_location)
				{
					CMapLocation* ml			= Level().MapManager().AddMapLocation(obj.map_location, obj.object_id);
					if(obj.map_hint.size())		ml->SetHint(obj.map_hint);
					ml->DisablePointer			();
					ml->SetSerializable			(true);
				}
			}
			bHasSpotPointer = bHasSpotPointer || (ActiveObjective()==&t->Objective(i));
		}
	}
	// highlight new spot pointer
	if( !bHasSpotPointer )
	{
		bool bDone								=false;
		GameTasks::iterator it			= GameTasks().begin();
		GameTasks::iterator it_e		= GameTasks().end();

		for( ;(it!=it_e)&&(!bDone); ++it )
		{
			CGameTask* t						= (*it).game_task;
			if(t->Objective(0).TaskState()!=eTaskStateInProgress) continue;
			
			for(u16 i=0; (i<t->m_Objectives.size())&&(!bDone) ;++i)
			{
				if( (i==0) || (t->Objective(i).TaskState() != eTaskStateInProgress) ) continue;
				
				SetActiveTask				(t->m_ID, i);
				bDone						= true;
			}
		}
	}

	m_flags.set					(eChanged, FALSE);
}
示例#5
0
CGameTask*	CGameTaskManager::GiveGameTaskToActor(CGameTask* t, u32 timeToComplete, bool bCheckExisting)
{
	if(bCheckExisting && HasGameTask(t->m_ID)) return NULL;
	m_flags.set					(eChanged, TRUE);

	GameTasks().push_back				(SGameTaskKey(t->m_ID) );
	GameTasks().back().game_task			= t;
	t->m_ReceiveTime				= Level().GetGameTime();
	t->m_TimeToComplete				= t->m_ReceiveTime + timeToComplete;

	
	std::sort						(GameTasks().begin(), GameTasks().end(), task_prio_pred);

	ARTICLE_VECTOR& article_vector = Actor()->encyclopedia_registry->registry().objects();


	SGameTaskObjective	*obj = NULL;
	for (u32 i = 0; i < t->m_Objectives.size(); ++i){
		obj = &t->m_Objectives[i];
		if(obj->article_id.size()){
		FindArticleByIDPred pred(obj->article_id);
		if( std::find_if(article_vector.begin(), article_vector.end(), pred) == article_vector.end() ){
			CEncyclopediaArticle article;
			article.Load(obj->article_id);
			article_vector.push_back(ARTICLE_DATA(obj->article_id, Level().GetGameTime(), article.data()->articleType));
			}
		}

		if(obj->object_id!=u16(-1) && obj->map_location.size() && obj->def_location_enabled){
			CMapLocation* ml =	Level().MapManager().AddMapLocation(obj->map_location, obj->object_id);
			if(obj->map_hint.size())	ml->SetHint(obj->map_hint);
			ml->DisablePointer			();
			ml->SetSerializable			(true);
		}
	}
	CGameTask* _at = ActiveTask();
	if	( (NULL==_at) || (_at->m_priority > t->m_priority) )
	{
		SetActiveTask(t->m_ID, 1);
	}


	//установить флажок необходимости прочтения тасков в PDA
	if(HUD().GetUI()){
		CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
		if(pGameSP) 
			pGameSP->PdaMenu->PdaContentsChanged	(pda_section::quests);
	}
	if(true /*t->m_ID!="user_task"*/)
		t->Objective(0).ChangeStateCallback();

	return t;
}
示例#6
0
bool CUIEventsWnd::ItemHasDescription(CUITaskItem* itm)
{
	if(itm->ObjectiveIdx()==0)// root
	{
		bool bHasLocation	= itm->GameTask()->HasLinkedMapLocations();
		return bHasLocation;
	}else
	{
		SGameTaskObjective	*obj				= itm->Objective();
		CMapLocation* ml						= obj->LinkedMapLocation();
		bool bHasLocation						= (NULL != ml);
		bool bIsMapMode							= GetDescriptionMode(); 
		bool b									= (bIsMapMode&&bHasLocation&&ml->SpotEnabled());
		return b;
	}
}
示例#7
0
void CGameTaskManager::SetActiveTask(const TASK_ID& id, u16 idx)
{
	if(idx==0)
		Msg("! g_active_task_objective_idx==0");

	g_active_task_id			= id;
	g_active_task_objective_id	= idx;

	Level().MapManager().DisableAllPointers();
	SGameTaskObjective* o		= ActiveObjective();

	if(o)
	{
		CMapLocation* ml	= o->LinkedMapLocation();
		if(ml)
			ml->EnablePointer();
	}
}
示例#8
0
void CGameTaskManager::UpdateTasks						()
{
	u32					task_count = GameTasks().size();
	if(0==task_count)	return;

	SGameTaskKey		*tasks = (SGameTaskKey*)_alloca(task_count*sizeof(SGameTaskKey));
	SGameTaskKey		*I = tasks;
	SGameTaskKey		*E = tasks + task_count;
	GameTasks_it		i = GameTasks().begin();
	
	for ( ; I != E; ++I, ++i)
		new	(I)	SGameTaskKey(*i);

	for (I = tasks; I != E; ++I)
	{
		CGameTask		*t = (*I).game_task;
		for(u16 i=0; i<t->m_Objectives.size() ;++i)
		{
			SGameTaskObjective& obj = t->Objective(i);
			if(obj.TaskState()!=eTaskStateInProgress && i==0) break;
			if(obj.TaskState()!=eTaskStateInProgress) continue;

			ETaskState state = obj.UpdateState();

			if( (state==eTaskStateFail || state==eTaskStateCompleted))
				SetTaskState(t, i, state);
		}
	}
	
	for ( ; I != E; ++I, ++i)
		I->~SGameTaskKey	();

	SGameTaskObjective* obj = ActiveObjective();
	if(obj)
	{
		Level().MapManager().DisableAllPointers();
		CMapLocation* ml = obj->LinkedMapLocation();
		if(ml && !ml->PointerEnabled())
			ml->EnablePointer();
	}

	if(	m_flags.test(eChanged) )
		UpdateActiveTask	();
}
示例#9
0
void UISecondTaskItem::update_view()
{
	VERIFY( m_task );
	CMapLocation* ml = m_task->LinkedMapLocation();

	if ( ml && ml->SpotEnabled() )
	{
		m_bt_view->SetCheck( false );
	}
	else
	{
		m_bt_view->SetCheck( true );
	}


	m_name->SetTextST( m_task->m_Title.c_str() );
	m_name->AdjustHeightToText();
	float h1 = m_name->GetWndPos().y + m_name->GetHeight() + 10.0f;
	h1 = _max( h1, GetHeight() );
	SetHeight( h1 );

	CGameTask* activ_task = Level().GameTaskManager().ActiveTask( eTaskTypeAdditional );

	if ( m_task == activ_task )
	{
		m_name->SetTextColor( m_color_states[stt_activ] );
	}
	else if ( m_task->m_read )
	{
		m_name->SetTextColor( m_color_states[stt_read] );
	}
	else
	{
		m_name->SetTextColor( m_color_states[stt_unread] );
	}

}
示例#10
0
void UITaskListWndItem::update_view()
{
	VERIFY( m_task );
	CMapLocation* ml = m_task->LinkedMapLocation();
	if ( ml && ml->SpotEnabled() )
		m_bt_focus->Show(true);
	else
		m_bt_focus->Show(false);

	if(m_task->GetTaskType()==eTaskTypeStoryline)
		m_st_story->InitTexture("ui_inGame2_PDA_icon_Primary_mission");
	else
		m_st_story->InitTexture("ui_inGame2_PDA_icon_Secondary_mission");

	m_name->TextItemControl()->SetTextST( m_task->m_Title.c_str() );
	m_name->AdjustHeightToText();
	float h1 = m_name->GetWndPos().y + m_name->GetHeight() + 10.0f;
	h1 = _max( h1, GetHeight() );
	SetHeight( h1 );

	CGameTask* activ_task = Level().GameTaskManager().ActiveTask();

	if ( m_task == activ_task )
	{
		m_name->SetStateTextColor( m_color_states[stt_activ], S_Enabled );
	}
	else if ( m_task->m_read )
	{
		m_name->SetStateTextColor( m_color_states[stt_read], S_Enabled );
	}
	else
	{
		m_name->SetStateTextColor( m_color_states[stt_unread], S_Enabled );
	}

}
示例#11
0
void CUIEventsWnd::ShowDescription			(CGameTask* t, int idx)
{
	if(GetDescriptionMode()){//map
		SGameTaskObjective& o		= t->Objective(idx);
		CMapLocation* ml			= o.LinkedMapLocation();

		if(ml&&ml->SpotEnabled())
			m_UIMapWnd->SetTargetMap(ml->LevelName(), ml->Position(), true);
	}else
	{//articles
		SGameTaskObjective& o		= t->Objective(0);
		idx							= 0;

		m_UITaskInfoWnd->ClearAll	();

		if(Actor()->encyclopedia_registry->registry().objects_ptr())
		{
			string512	need_group;
			if(0==idx){
				strcpy(need_group,*t->m_ID);
			}else
			if(o.article_key.size())
			{
				sprintf_s(need_group, "%s/%s", *t->m_ID, *o.article_key);
			}else
			{
				sprintf_s(need_group, "%s/%d", *t->m_ID, idx);
			}

			ARTICLE_VECTOR::const_iterator it		= Actor()->encyclopedia_registry->registry().objects_ptr()->begin();

			for(; it != Actor()->encyclopedia_registry->registry().objects_ptr()->end(); ++it)
			{
				if (ARTICLE_DATA::eTaskArticle == it->article_type)
				{
					CEncyclopediaArticle	A;
					A.Load					(it->article_id);

					const shared_str& group = A.data()->group;

					if( strstr(group.c_str(), need_group)== group.c_str() )
					{
						u32 sz			= xr_strlen(need_group);
						if ( group.size()== sz || group.c_str()[sz]=='/' )
							m_UITaskInfoWnd->AddArticle(&A);
					}else
					if(o.article_id.size() && it->article_id ==o.article_id)
					{
						CEncyclopediaArticle			A;
						A.Load							(it->article_id);
						m_UITaskInfoWnd->AddArticle		(&A);
					}
				}
			}
		}
	}

	int sz			= m_ListWnd->GetSize		();

	for(int i=0; i<sz;++i)
	{
		CUITaskItem* itm			= (CUITaskItem*)m_ListWnd->GetItem(i);

		if((itm->GameTask()==t) && (itm->ObjectiveIdx()==idx) )	
			itm->MarkSelected		(true);
		else
			itm->MarkSelected		(false);
	}
}
示例#12
0
bool CRelationMapLocation::Update()
{
	if (false==inherited::Update() ) return false;
	
	bool bAlive = true;

	m_last_relation = ALife::eRelationTypeFriend;

	if(m_owner_se_object)
	{
		CSE_ALifeTraderAbstract*	pEnt = NULL;
		CSE_ALifeTraderAbstract*	pAct = NULL;
		pEnt = smart_cast<CSE_ALifeTraderAbstract*>(m_owner_se_object);
		pAct = smart_cast<CSE_ALifeTraderAbstract*>(ai().alife().objects().object(m_pInvOwnerActorID,true));
		if(!pEnt || !pAct)	
			return false;

		m_last_relation =  RELATION_REGISTRY().GetRelationType(pEnt, pAct);
		CSE_ALifeCreatureAbstract*		pCreature = smart_cast<CSE_ALifeCreatureAbstract*>(m_owner_se_object);
		if(pCreature) //maybe trader ?
			bAlive = pCreature->g_Alive		();
	}else
	{
		CInventoryOwner*			pEnt = NULL;
		CInventoryOwner*			pAct = NULL;

		pEnt = smart_cast<CInventoryOwner*>(Level().Objects.net_Find(m_objectID));
		pAct = smart_cast<CInventoryOwner*>(Level().Objects.net_Find(m_pInvOwnerActorID));
		if(!pEnt || !pAct)	
			return false;

		m_last_relation =  RELATION_REGISTRY().GetRelationType(pEnt, pAct);
		CEntityAlive* pEntAlive = smart_cast<CEntityAlive*>(pEnt);
		if(pEntAlive)
			bAlive = !!pEntAlive->g_Alive		();
	}
	shared_str sname;

	if(bAlive==false)
		sname = "deadbody_location";
	else
		sname = RELATION_REGISTRY().GetSpotName(m_last_relation);

	if(m_curr_spot_name != sname){
		LoadSpot(*sname, true);
		m_curr_spot_name = sname;
	}
// update visibility
	bool vis_res = true;
	if(m_last_relation==ALife::eRelationTypeEnemy || m_last_relation==ALife::eRelationTypeWorstEnemy)
	{
		CObject* _object_ = Level().Objects.net_Find(m_objectID);
		if(_object_)
		{
			CEntityAlive* ea = smart_cast<CEntityAlive*>(_object_);
			if(ea&&!ea->g_Alive()) 
				vis_res =  true;	
			else
			{
				const CGameObject* pObj = smart_cast<const CGameObject*>(_object_);
				CActor* pAct = smart_cast<CActor*>(Level().Objects.net_Find(m_pInvOwnerActorID));
				CHelmet* helm = smart_cast<CHelmet*>(pAct->inventory().ItemFromSlot(HELMET_SLOT));
				if(helm && helm->m_fShowNearestEnemiesDistance)
				{
					if(pAct->Position().distance_to(pObj->Position()) < helm->m_fShowNearestEnemiesDistance)
						vis_res = true;
					else
						vis_res = Actor()->memory().visual().visible_now(pObj);
				}
				else
					vis_res = Actor()->memory().visual().visible_now(pObj);
			}
		}
		else
			vis_res = false;
	}

	if(bAlive==false)
	{
		CObject* _object_ = Level().Objects.net_Find(m_objectID);
		if(_object_)
		{
			const CGameObject* pObj = smart_cast<const CGameObject*>(_object_);
			CActor* pAct = smart_cast<CActor*>(Level().Objects.net_Find(m_pInvOwnerActorID));
			if(/*pAct->Position().distance_to_sqr(pObj->Position()) < 100.0F && */abs(pObj->Position().y-pAct->Position().y)<3.0f)
				vis_res = true;
			else
				vis_res = false;
		}
		else
			vis_res = false;
	}
	
	if(m_b_visible==false && vis_res==true)
		m_minimap_spot->ResetXformAnimation();

	m_b_visible = vis_res;	

	if(m_b_visible)
	{
		m_b_minimap_visible		= true;
		m_b_levelmap_visible	= true;

		if (Level().MapManager().GetMapLocationsForObject(m_objectID, find_locations_res) )
		{
			xr_vector<CMapLocation*>::iterator it = find_locations_res.begin();
			xr_vector<CMapLocation*>::iterator it_e = find_locations_res.end();
			for(;it!=it_e;++it)
			{
				CMapLocation* ml = (*it);
				if(ml==this)
					continue;

				m_b_minimap_visible	= m_b_minimap_visible && (ml->MiniMapSpot()==NULL);
				m_b_levelmap_visible= m_b_levelmap_visible && (ml->LevelMapSpot()==NULL);
			}
			
		}

	}

	return true;
}
示例#13
0
void map_change_spot_hint(u16 id, LPCSTR spot_type, LPCSTR text)
{
	CMapLocation* ml	= Level().MapManager().GetMapLocation(spot_type, id);
	if(!ml)				return;
	ml->SetHint			(text);
}