Exemplo n.º 1
0
VectorEnumerator& VectorEnumerator::operator++( )
{
  int cur;
  
  if( seqLimit( ) ) {
    curLength--;
    if( curLength>=0 ) {
      stepBack( curVector[curLength] );
      cur = next( curVector[curLength] );
    }
  }
  else
    cur = start( );
  
  while( curLength>=0 ) {
    
    if( !finish( cur ) ) {
      
      if( curLength>=curVector.capacity( ) )
	curVector.resize( curLength+5 );
      
      curVector[curLength] = cur;
      ++curLength;
      
      if( seqOK( ) ) {
	stepTo( );
	if( seqComplete( ) ) {
	  return *this;
	}
	else {
	  if( seqLimit( ) ) {
	    curLength--;
	    stepBack( curVector[curLength] );
	    cur = next( curVector[curLength] );
	  }
	  else {
	    cur = start( );
	  }
	}
      }
      else {
	cur = next( curVector[--curLength] );
      }
    } // if( !finish( cur ) ) {
    else{
      --curLength;
      if( curLength>=0 ) {
	stepBack( curVector[curLength] );
	cur = curVector[curLength];
      }
      cur = next( cur );
    } // if( !finish( cur ) ) { } else {
    
  } // while( curLength>=0 ) {
  
  return *this;
}
Exemplo n.º 2
0
bool Monster::findPath( Pos sour )
{
	this->parent = Pos(sour.x + 1, sour.y);
	Pos** record;
	record = new Pos *[mMapHeight];
	for(int i = 0; i < mMapHeight; ++i)
	{
		record[i] = new Pos[mMapWidth];
	}
	stack<CellNode> st = stack<CellNode>();
	CellNode node;
	node.self = sour;
	st.push(node);

	//判断从起点到终点之间是否有通路
	CellNode temp;
	while(true)
	{
		if(!st.empty())
		{
			temp = st.top();
			st.pop();
		}
		else
		{
			return false;
		}
		if(isFinal(temp.self))
		{
			if(isValid(temp.self))
			{
				markIt(temp.self);
				record[temp.self.y][temp.self.x] = temp.pare;
				parent = temp.pare;
			}
			break;
		}
		else
		{
			if(isValid(temp.self))
			{
				markIt(temp.self);
				record[temp.self.y][temp.self.x] = temp.pare;
				parent = temp.pare;
				pushPos(temp.self, st);
			}
		}
	}

	//// 如果有通路则寻找合适的路径
	Pos parent = finalPos;
	bool success = false;
	while(isValid(parent) && !success)
	{
		stepTo(parent);
		path.push_back(getStep());
		markIt(parent);
		parent = record[parent.y][parent.x];
		if(parent.x==sour.x && parent.y==sour.y)
		{
			success = true;
		}
	}
	path.push_back(fromPos);
	std::reverse(path.begin(),path.end());
	return true;
}
Exemplo n.º 3
0
void Timeline::step( float timestep )
{
	mCurrentTime += timestep;
	stepTo( mCurrentTime, timestep < 0 );
}
Exemplo n.º 4
0
void Timeline::update( float absTime )
{
	absTime = loopTime( absTime );
	stepTo( absTime );
}