MarbleQuarry::MarbleQuarry() : Factory(Good::none, Good::marble, B_MARBLE_QUARRY, Size(2) )
{
  _setProductRate( 9.6f );
  setPicture( Picture::load( ResourceGroup::commerce, 43 ) );

  _getAnimation().load( ResourceGroup::commerce, 44, 10);
  _getAnimation().setFrameDelay( 4 );
  _fgPictures.resize(2);
}
BuildingEngineer::BuildingEngineer() : ServiceBuilding( Service::S_ENGINEER, B_ENGINEER_POST, Size(1) )
{
  setWorkers( 0 );
  setPicture( Picture::load( ResourceGroup::buildingEngineer, 56 ) );

  _getAnimation().load( ResourceGroup::buildingEngineer, 57, 10 );
  _getAnimation().setFrameDelay( 4 );
  _getAnimation().setOffset( Point( 10, 42 ) );
  _fgPictures.resize(1);
}
예제 #3
0
Prefecture::Prefecture() : ServiceBuilding(Service::prefect, constants::building::prefecture, Size(1))
{
  _fireDetect = TilePos( -1, -1 );
  setPicture( ResourceGroup::security, 1 );
  
  _getAnimation().load( ResourceGroup::security, 2, 10);
  _getAnimation().setDelay( 4 );
  _getAnimation().setOffset( Point( 20, 36 ) );
  _getFgPictures().resize(1);
}
Prefecture::Prefecture() : ServiceBuilding(Service::S_PREFECT, B_PREFECTURE, Size(1))
{
  _fireDetect = TilePos( -1, -1 );
  setPicture( Picture::load( ResourceGroup::security, 1 ) );
  
  _getAnimation().load( ResourceGroup::security, 2, 10);
  _getAnimation().setFrameDelay( 4 );
  _getAnimation().setOffset( Point( 20, 36 ) );
  _fgPictures.resize(1);
}
예제 #5
0
IronMine::IronMine() : Factory(G_NONE, G_IRON, B_IRON_MINE, Size(2) )
{
  _setProductRate( 9.6f );
  setWorkers( 0 );

  setPicture( Picture::load(ResourceGroup::commerce, 54) );

  _getAnimation().load( ResourceGroup::commerce, 55, 6 );
  _getAnimation().setFrameDelay( 5 );
  _fgPictures.resize(2);
}
예제 #6
0
void FishPlace::timeStep(const unsigned long time)
{
  _getAnimation().update( time );

  _d->animations[ 0 ] = _getAnimation().getFrame();

  if( _d->walker != 0 )
  {
    TilePos lastPos = _d->walker->getIJ();
    _d->walker->timeStep( time );

    if( lastPos != _d->walker->getIJ() )
    {
      getTile().setOverlay( 0 );
      getTile().setPicture( _d->savePicture );

      TilePos pos =  _d->walker->getIJ();

      _d->savePicture = &_getCity()->getTilemap().at( pos ).getPicture();
      setPicture( *_d->savePicture );

      TileOverlay::build( _getCity(), pos );
    }
    else if( lastPos == _d->walker->getPathway().getDestination().getIJ() )
    {
      deleteLater();
    }
  }
  else
  {
    Pathway pathway;
    bool pathFound = Pathfinder::getInstance().getPath( getTilePos(), _getCity()->getBorderInfo().boatExit,
                                                        pathway, Pathfinder::waterOnly, Size( 1 ) );

    if( !pathFound )
    {
      deleteLater();
    }
    else
    {
      _d->walker = WalkerPtr( new Walker( _getCity() ) );
      _d->walker->drop();
      _d->walker->setSpeed( 0.1f );
      _d->walker->setPathway( pathway );
      _d->walker->setIJ( getTilePos() );
      _d->walker->go();
    }
  }
}
void MarbleQuarry::timeStep( const unsigned long time )
{
  bool mayAnimate = getWorkers() > 0;

  if( mayAnimate && _getAnimation().isStopped() )
  {
    _getAnimation().start();
  }

  if( !mayAnimate && _getAnimation().isRunning() )
  {
    _getAnimation().stop();
  }

  Factory::timeStep( time );
}
void BuildingEngineer::timeStep(const unsigned long time)
{
  bool mayAnimate = getWorkers() > 0;

  if( mayAnimate && _getAnimation().isStopped() )
  {
      _getAnimation().start();
  }

  if( !mayAnimate && _getAnimation().isRunning() )
  {
      _getAnimation().stop();
  }

  ServiceBuilding::timeStep( time );
}
예제 #9
0
void MeshExporter::_dumpAnimation(IGameControl * pGameControl, int boneId)
{
	int start = ExportConfig::Instance()->GetFrameRange().x;
	int end = ExportConfig::Instance()->GetFrameRange().y;
	start *= GetTicksPerFrame();
	end *= GetTicksPerFrame();

	if ((pGameControl->IsAnimated(IGAME_POS)) || pGameControl->IsAnimated(IGAME_ROT) || pGameControl->IsAnimated(IGAME_SCALE))
	{
		IGameKeyTab Key;
		if(pGameControl->GetFullSampledKeys(Key, 1, IGAME_TM, true) )
		{
			SkeletonAnimation * skelAnim = new SkeletonAnimation(boneId);

			int count = Key.Count();
			for(int i=0;i<count;i++)
			{
				if (Key[i].t >= start && Key[i].t <= end)
				{
					float time = (float)Key[i].t / (float)GetTicksPerFrame() / (float)GetFrameRate();
					SkeletonAnimation::KeyFrame * kf = skelAnim->CreateKeyFrame(time);

					kf->position = Utility::ToFloat3(Key[i].sampleKey.gval.Translation());
					kf->rotation = Utility::ToQuat(Key[i].sampleKey.gval.Rotation());
					kf->scale = Utility::ToFloat3(Key[i].sampleKey.gval.Scaling());
				}
			}

			skelAnim->Optimize();
			_getAnimation()->AddSkeletonAnimation(skelAnim);
		}
	}
}
예제 #10
0
FactoryOil::FactoryOil() : Factory(G_OLIVE, G_OIL, B_OIL_WORKSHOP, Size(2) )
{
  setPicture( Picture::load(ResourceGroup::commerce, 99) );

  _getAnimation().load(ResourceGroup::commerce, 100, 8);
  _fgPictures.resize(2);
}
예제 #11
0
Winery::Winery() : Factory(G_GRAPE, G_WINE, B_WINE_WORKSHOP, Size(2) )
{
  setPicture( Picture::load(ResourceGroup::commerce, 86) );

  _getAnimation().load(ResourceGroup::commerce, 87, 12);
  _fgPictures.resize(2);
}
예제 #12
0
FactoryFurniture::FactoryFurniture() : Factory(G_TIMBER, G_FURNITURE, B_FURNITURE, Size(2) )
{
  setPicture( Picture::load(ResourceGroup::commerce, 117) );

  _getAnimation().load(ResourceGroup::commerce, 118, 14);
  _fgPictures.resize(2);
}
예제 #13
0
WeaponsWorkshop::WeaponsWorkshop() : Factory(G_IRON, G_WEAPON, B_WEAPONS_WORKSHOP, Size(2) )
{
  setPicture( Picture::load(ResourceGroup::commerce, 108) );

  _getAnimation().load( ResourceGroup::commerce, 109, 6);
  _fgPictures.resize(2);
}
예제 #14
0
TimberLogger::TimberLogger() : Factory(G_NONE, G_TIMBER, B_TIMBER_YARD, Size(2) )
{
  _setProductRate( 9.6f );
  setPicture( Picture::load(ResourceGroup::commerce, 72) );

  _getAnimation().load( ResourceGroup::commerce, 73, 10);
  _fgPictures.resize(2);
  setWorkers( 0 );
}
예제 #15
0
void ServiceBuilding::timeStep(const unsigned long time)
{
   WorkingBuilding::timeStep(time);   

   if (_d->serviceTimer == 0)
   {
      deliverService();
      _d->serviceTimer = getServiceDelay();
   }
   else if (_d->serviceTimer > 0)
   {
      _d->serviceTimer -= 1;
   }

   _getAnimation().update( time );
   const Picture& pic = _getAnimation().getCurrentPicture();
   if( pic.isValid() )
   {
      int level = _fgPictures.size()-1;
      _fgPictures[level] = _getAnimation().getCurrentPicture();
   }
}
예제 #16
0
FishPlace::FishPlace() : TileOverlay( constants::place::fishPlace ), _d( new Impl )
{
  _getAnimation().setDelay( 3 );
  _d->animations.resize( 1 );
  _d->passQueue.push_back( Renderer::foreground );
  _d->passQueue.push_back( Renderer::animations );

  _d->fishCount = rand() % 100;

  if( _d->fishCount > 1 )
  {
    _getAnimation().load( ResourceGroup::land3a, 19, 24); //big fish place
    _d->basicOffset = Point( -41, 122 );
    _getAnimation().setOffset( _d->basicOffset );
  }
  else
  {
    _getAnimation().load( ResourceGroup::land3a, 1, 18);
    _d->basicOffset =  Point( 0, 55 );
    _getAnimation().setOffset( _d->basicOffset );
  } //small fish place
}
예제 #17
0
void Factory::timeStep(const unsigned long time)
{
   WorkingBuilding::timeStep(time);

   //try get good from storage building for us
   if( time % 22 == 1 && getWorkers() > 0 && getWalkerList().size() == 0 )
   {
     receiveGood(); 
     deliverGood();      
   }

   //start/stop animation when workers found
   bool mayAnimate = mayWork();

   if( mayAnimate && _getAnimation().isStopped() )
   {
     _getAnimation().start();
   }

   if( !mayAnimate && _getAnimation().isRunning() )
   {
     _getAnimation().stop();
   }

   //no workers or no good in stock... stop animate
   if( !mayAnimate )
   {
     return;
   }  
  
   if( _d->progress >= 100.0 )
   {
     _d->produceGood = false;
     
     if( _d->goodStore.getCurrentQty( _d->outGoodType ) < _d->goodStore.getMaxQty( _d->outGoodType )  )
     {
       _d->progress -= 100.f;
       //gcc fix for temporaly ref object
       GoodStock tmpStock( _d->outGoodType, 100, 100 );
       _d->goodStore.store( tmpStock, 100 );
     }
   }
   else
   {
     //ok... factory is work, produce goods
     float workersRatio = float(getWorkers()) / float(getMaxWorkers());  // work drops if not enough workers
     // 1080: number of seconds in a year, 0.67: number of timeSteps per second
     float work = 100.f / 1080.f / 0.67f * _d->productionRate * workersRatio * workersRatio;  // work is proportional to time and factory speed
     if( _d->produceGood )
     {
       _d->progress += work;

       _getAnimation().update( time );
       const Picture& pic = _getAnimation().getCurrentPicture();
       if( pic.isValid() )
       {
         // animation of the working factory
         int level = _fgPictures.size()-1;
         _fgPictures[level] = _getAnimation().getCurrentPicture();
       }
     }
   }  

   if( !_d->produceGood )
   {
     if( _d->inGoodType == G_NONE ) //raw material
     {
       _d->produceGood = true;
     }
     else if( _d->goodStore.getCurrentQty( _d->inGoodType ) >= 100 && _d->goodStore.getCurrentQty( _d->outGoodType ) < 100 )
     {
       _d->produceGood = true;
       //gcc fix temporaly ref object error
       GoodStock tmpStock( _d->inGoodType, 100, 0 );
       _d->goodStore.retrieve( tmpStock, 100  );
     }     
   }
}