Exemplo n.º 1
0
void ShowTileInfo::_exec(Game& game, unsigned int time)
{
  switch( _mode )
  {
  case current:
  break;

  case next:
  case prew:
  {
    city::Helper helper( game.city() );
    ConstructionPtr c =  ptr_cast<Construction>( game.city()->getOverlay( _pos ) );
    c = (_mode == next ? helper.next( c ) : helper.prew( c ));

    if( c.isValid() )
    {
      _pos = c->pos();

      GameEventPtr e = MoveCamera::create( _pos );
      e->dispatch();
    }
  }
  break;

  default:
  break;
  }

  gui::infobox::Manager::getInstance().showHelp( game.city(), game.gui(), _pos );
}
Pathway ChastenerElephant::_findPathway2NearestConstruction( unsigned int range )
{
  Pathway ret;

  for( unsigned int tmpRange=1; tmpRange <= range; tmpRange++ )
  {
    ConstructionList constructions = _findContructionsInRange( tmpRange );

    foreach( it, constructions )
    {
      ConstructionPtr c = ptr_cast<Construction>( *it );
      ret = PathwayHelper::create( pos(), c->pos(), makeDelegate( _d.data(), &Impl::mayMove ) );
      if( ret.isValid() )
      {
        return ret;
      }
    }
  }
Exemplo n.º 3
0
void RomeArcher::timeStep(const unsigned long time)
{
  Soldier::timeStep( time );

  switch( _subAction() )
  {
  case Soldier::fightEnemy:
  {
    WalkerList enemies = _findEnemiesInRange( attackDistance() );

    if( !enemies.empty() )
    {
      WalkerPtr p = enemies.front();
      turn( p->pos() );

      if( _animationRef().index() == (int)(_animationRef().frameCount()-1) )
      {
        _fire( p->pos() );
        _updateAnimation( time+1 );
      }
    }
    else
    {
      //_check4attack();
      send2patrol();
    }
  }
  break;

  case Soldier::destroyBuilding:
  {
    ConstructionList constructions = _findContructionsInRange( attackDistance() );

    if( !constructions.empty() )
    {
      ConstructionPtr b = constructions.front();
      turn( b->pos() );

      if( _animationRef().index() == (int)(_animationRef().frameCount()-1) )
      {
        _fire( b->pos() );
        _updateAnimation( time+1 );
      }
    }
    else
    {
      //_check4attack();
      send2patrol();
    }
  }

  case Soldier::patrol:
    if( game::Date::current().day() % 2 == 0 )
    {
      _tryAttack();
    }
  break;

  default: break;
  } // end switch( _d->action )
}