//----------------------------------------------------------------------------------------
// GetAllDirectoryNames
//----------------------------------------------------------------------------------------
void
ZMFileUtils::GetAllDirectoryNames(
	const PMString&						parentPath,
	ZMPMStringSList &					oDirectoryNames) const
{
	SDKFileHelper parentFileHelper(parentPath);
	IDFile parIDFile = parentFileHelper.GetIDFile();
	PlatformFileSystemIterator iter;
	if(!iter.IsDirectory(parIDFile))
		return;

	iter.SetStartingPath(parIDFile);
	
	IDFile idFile;
	PMString filter("*.*");
	filter.InsertW(FileUtils::GetDirectorySeperator(), 0);
	bool16 hasNext= iter.FindFirstFile(idFile, filter);

	while(hasNext) {
		if (iter.IsDirectory (idFile))
		{
			SDKFileHelper fileHelper(idFile);
			
			PMString fileNamePath = idFile.GetFileName();
			if(ValidPath(fileNamePath))
			{
				oDirectoryNames.push_back(new PMString(fileNamePath));
			}
		}

		hasNext= iter.FindNextFile(idFile);
	}
}
//----------------------------------------------------------------------------------------
// FetchAdsFileFromPath
//----------------------------------------------------------------------------------------
bool
ZMFileUtils::FetchAdsFileFromPath(
	const PMString&						parentPath,
	ZMPMStringSList &					oAdsList,
	const PMString&						inFilePrefix) const
{
	LogFunctionEnterExit;
	
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "From path : %s", parentPath.GrabCString());
	SDKFileHelper fileHelper(parentPath);
	IDFile fileId = fileHelper.GetIDFile();
	PlatformFileSystemIterator iter;
	if(!iter.IsDirectory(fileId))
		return false;

	iter.SetStartingPath(fileId);

	Utils<IZMAdFileFacade> adFileUtil;
	bool result = false;
	IDFile xmlIdFile;

	PMString filter(inFilePrefix);
	filter.Append("*.xml");
	filter.InsertW(FileUtils::GetDirectorySeperator(), 0);
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "File filter : %s", filter.GrabCString());

	bool16 hasNext = iter.FindFirstFile(xmlIdFile, filter);

	while(hasNext) {
		SDKFileHelper xmlFileHelper(xmlIdFile);
		
		PMString xmlFileName = xmlIdFile.GetFileName();
		if(ValidPath(xmlFileName))
		{
#ifdef MACINTOSH
			PMString extStr(".xml");
			extStr.SetTranslatable(kFalse);
			if (! VerifyPrefixAndSuffix(xmlFileName, inFilePrefix, extStr))
			{
				hasNext= iter.FindNextFile(xmlIdFile);
				continue;
			}
#endif
			
			PMString xmlFullPath (parentPath);
			xmlFullPath.Append(FileUtils::GetDirectorySeperator());
			xmlFullPath.Append(xmlFileName);

			if (adFileUtil->CanBeValidXMLFile(xmlFullPath))
			{
				oAdsList.push_back(new PMString(xmlIdFile.GetFileName()));
				result = true;
			}
		}

		hasNext= iter.FindNextFile(xmlIdFile);
	}

	return result;
}
Esempio n. 3
0
void Piloto::StateMachine(float dt)
{
    switch(charState){
            case MOVENDO:
                if( path.empty() == true){
                    cout << endl << "*" << this->nome << " parou*" << endl;
                    charState = REPOUSO;
                    break;
                }else{
                    cout << "*" << this->nome << " esta andando*\r";
                    Andar();
                }
                break;
            case AGUARDANDO_EMBARCAR:
                Ally* alvo;
                alvo = EncontrarRobo();
                if(alvo != NULL){
                    if(Embarcar(alvo) == true){
                        charState = INATIVO;
                    }else{
                        charState = AGUARDANDO_EMBARCAR;
                    }
                }
                if(InputManager::GetInstance().MousePress(SDL_BUTTON_RIGHT) == true){
                    charState = REPOUSO;
                }
                break;

            case INATIVO:
                break;
            case REPOUSO:
                break;
            case AGUARDANDO_ANDAR:

            //if(InputManager::GetInstance().IsMouseDown(LEFT_MOUSE_BUTTON) == true){
                MakePath();
                if(InputManager::GetInstance().MousePress(LEFT_MOUSE_BUTTON) == true){
                        if(ValidPath() == true){
                                charState = MOVENDO;
                        }else{
                                while(path.empty() == false) path.pop();
                                charState = REPOUSO;
                        }
                        barraCooldown.Esvazia();
                }
                break;
    }
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
// Purpose: Assumes this is ALWAYS enabled
// Input  : origin - position along path to look ahead from
//			dist - distance to look ahead, negative values look backward
//			move - 
// Output : Returns the track that we will be PAST in 'dist' units.
//-----------------------------------------------------------------------------
CPathTrack *CPathTrack::LookAhead( Vector &origin, float dist, int move, CPathTrack **pNextNext )
{
	CPathTrack *pcurrent = this;
	float originalDist = dist;
	Vector currentPos = origin;

	bool bForward = true;
	if ( dist < 0 )
	{
		// Travelling backwards along the path.
		dist = -dist;
		bForward = false;
	}

	// Move along the path, until we've gone 'dist' units or run out of path.
	while ( dist > 0 )
	{
		// If there is no next path track, or it's disabled, we're done.
		if ( !ValidPath( pcurrent->GetNextInDir( bForward ), move ) )
		{
			if ( !move )
			{
				Project( pcurrent->GetNextInDir( !bForward ), pcurrent, origin, dist );
			}

			return NULL;
		}

		// The next path track is valid. How far are we from it?
		Vector dir = pcurrent->GetNextInDir( bForward )->GetLocalOrigin() - currentPos;
		float length = dir.Length();

		// If we are at the next node and there isn't one beyond it, return the next node.
		if ( !length  && !ValidPath( pcurrent->GetNextInDir( bForward )->GetNextInDir( bForward ), move ) )
		{
			if ( pNextNext )
			{
				*pNextNext = NULL;
			}

			if ( dist == originalDist )
			{
				// Didn't move at all, must be in a dead end.
				return NULL;
			}

			return pcurrent->GetNextInDir( bForward );
		}

		// If we don't hit the next path track within the distance remaining, we're done.
		if ( length > dist )
		{
			origin = currentPos + ( dir * ( dist / length ) );
			if ( pNextNext )
			{
				*pNextNext = pcurrent->GetNextInDir( bForward );
			}

			return pcurrent;
		}

		// We hit the next path track, advance to it.
		dist -= length;
		currentPos = pcurrent->GetNextInDir( bForward )->GetLocalOrigin();
		pcurrent = pcurrent->GetNextInDir( bForward );
		origin = currentPos;
	}

	// We consumed all of the distance, and exactly landed on a path track.
	if ( pNextNext )
	{
		*pNextNext = pcurrent->GetNextInDir( bForward );
	}

	return pcurrent;
}
Esempio n. 5
0
// Assumes this is ALWAYS enabled
CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move )
{
	CPathTrack *pcurrent;
	float originalDist = dist;
	
	pcurrent = this;
	Vector currentPos = *origin;

	if ( dist < 0 )		// Travelling backwards through path
	{
		dist = -dist;
		while ( dist > 0 )
		{
			Vector dir = pcurrent->pev->origin - currentPos;
			float length = dir.Length();
			if ( !length )
			{
				if ( !ValidPath(pcurrent->GetPrevious(), move) ) 	// If there is no previous node, or it's disabled, return now.
				{
					if ( !move )
						Project( pcurrent->GetNext(), pcurrent, origin, dist );
					return NULL;
				}
				pcurrent = pcurrent->GetPrevious();
			}
			else if ( length > dist )	// enough left in this path to move
			{
				*origin = currentPos + (dir * (dist / length));
				return pcurrent;
			}
			else
			{
				dist -= length;
				currentPos = pcurrent->pev->origin;
				*origin = currentPos;
				if ( !ValidPath(pcurrent->GetPrevious(), move) )	// If there is no previous node, or it's disabled, return now.
					return NULL;

				pcurrent = pcurrent->GetPrevious();
			}
		}
		*origin = currentPos;
		return pcurrent;
	}
	else 
	{
		while ( dist > 0 )
		{
			if ( !ValidPath(pcurrent->GetNext(), move) )	// If there is no next node, or it's disabled, return now.
			{
				if ( !move )
					Project( pcurrent->GetPrevious(), pcurrent, origin, dist );
				return NULL;
			}
			Vector dir = pcurrent->GetNext()->pev->origin - currentPos;
			float length = dir.Length();
			if ( !length  && !ValidPath( pcurrent->GetNext()->GetNext(), move ) )
			{
				if ( dist == originalDist ) // HACK -- up against a dead end
					return NULL;
				return pcurrent;
			}
			if ( length > dist )	// enough left in this path to move
			{
				*origin = currentPos + (dir * (dist / length));
				return pcurrent;
			}
			else
			{
				dist -= length;
				currentPos = pcurrent->GetNext()->pev->origin;
				pcurrent = pcurrent->GetNext();
				*origin = currentPos;
			}
		}
		*origin = currentPos;
	}

	return pcurrent;
}