|
@@ -62,6 +62,8 @@ Spiel::Spiel()
|
|
|
zuletztBenutzterTunnel = 0;
|
|
|
zuletztBenutzteUmlenkung = 0;
|
|
|
resources = 0;
|
|
|
+ nextAutoVerschiebung = 10;
|
|
|
+ nextAutoSchaltung = 10;
|
|
|
ref = 1;
|
|
|
}
|
|
|
|
|
@@ -159,6 +161,60 @@ bool Spiel::istAmLeben() const
|
|
|
void Spiel::tick()
|
|
|
{
|
|
|
rZeit -= TICK;// spieler bewegungen
|
|
|
+ nextAutoVerschiebung -= TICK;
|
|
|
+ nextAutoSchaltung -= TICK;
|
|
|
+ if( nextAutoVerschiebung <= 0 )
|
|
|
+ {
|
|
|
+ nextAutoVerschiebung += 30 + randG.rand() * 30;
|
|
|
+ int anz = 0;
|
|
|
+ for( auto b = barieren.getIterator(); b; b++ )
|
|
|
+ {
|
|
|
+ if( b->hatStyle( Bariere::Style::AutoVerschiebung ) )
|
|
|
+ anz++;
|
|
|
+ }
|
|
|
+ if( anz )
|
|
|
+ {
|
|
|
+ int rand = (int)( randG.rand() * anz );
|
|
|
+ for( auto b = barieren.getIterator(); b; b++ )
|
|
|
+ {
|
|
|
+ if( b->hatStyle( Bariere::Style::AutoVerschiebung ) )
|
|
|
+ {
|
|
|
+ if( rand == 0 )
|
|
|
+ {
|
|
|
+ b->startAutoVerschiebung( this );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ rand--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( nextAutoSchaltung <= 0 )
|
|
|
+ {
|
|
|
+ nextAutoSchaltung += 30 + randG.rand() * 30;
|
|
|
+ int anz = 0;
|
|
|
+ for( auto b = barieren.getIterator(); b; b++ )
|
|
|
+ {
|
|
|
+ if( b->hatStyle( Bariere::Style::AutoSchaltung ) )
|
|
|
+ anz++;
|
|
|
+ }
|
|
|
+ if( anz )
|
|
|
+ {
|
|
|
+ int rand = (int)( randG.rand() * anz );
|
|
|
+ for( auto b = barieren.getIterator(); b; b++ )
|
|
|
+ {
|
|
|
+ if( b->hatStyle( Bariere::Style::AutoSchaltung ) )
|
|
|
+ {
|
|
|
+ if( rand == 0 )
|
|
|
+ {
|
|
|
+ b->startAutoSchaltung( this );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ rand--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for( auto s = spieler.getIterator(); s; s++ )
|
|
|
{
|
|
|
s->move( TICK );
|