Prechádzať zdrojové kódy

Aktionen zum steuern von Basen implementiert

Kolja Strohm 5 rokov pred
rodič
commit
f351f07a71
1 zmenil súbory, kde vykonal 146 pridanie a 1 odobranie
  1. 146 1
      StickmanWorldOnline/Aktionen.cpp

+ 146 - 1
StickmanWorldOnline/Aktionen.cpp

@@ -1504,6 +1504,34 @@ bool DropDoDrop::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemo
 }
 
 
+BariereBewegung::BariereBewegung( Aktion *bariere )
+    : Aktion( BARIERE_BEWEGUNG )
+{
+    this->bariere = bariere;
+}
+
+BariereBewegung::~BariereBewegung()
+{
+    bariere->release();
+}
+
+bool BariereBewegung::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
+{
+    if( bariere->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+    {
+        Variable *t = zMemory->zVariable( "__return__" );
+        if( !t || t->getVariableTyp() != BARIERE )
+        {
+            zPC->stepOut();
+            return 1;
+        }
+        ( (Bariere *)t )->startAutoVerschiebung( zSpiel );
+        return 1;
+    }
+    return 0;
+}
+
+
 BariereSetEingeschaltet::BariereSetEingeschaltet( Aktion *eingeschaltet, Aktion *bariere )
     : Aktion( BARIERE_SET_EINGESCHALTET )
 {
@@ -2135,7 +2163,7 @@ bool UmlenkungSetMaxAbk::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemor
     zPC->stepIn();
     if( zPC->currentPosition() == 0 )
     {
-        if( richtung->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        if( abk->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
         {
             Variable *t = zMemory->zVariable( "__return__" );
             if( !t || t->getVariableTyp() != INTEGER )
@@ -2215,3 +2243,120 @@ bool UmlenkungSetEnabled::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemo
     zPC->stepOut();
     return 0;
 }
+
+
+BaseSetPosition::BaseSetPosition( Aktion *x, Aktion *y, Aktion *base )
+    : Aktion( BASE_SET_POSITION )
+{
+    this->x = x;
+    this->y = y;
+    this->base = base;
+}
+
+BaseSetPosition::~BaseSetPosition()
+{
+    x->release();
+    y->release();
+    base->release();
+}
+
+bool BaseSetPosition::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
+{
+    zPC->stepIn();
+    if( zPC->currentPosition() == 0 )
+    {
+        if( x->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != FLOAT )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 1 && waitCount <= 0 )
+    {
+        if( y->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != FLOAT )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 2 && waitCount <= 0 )
+    {
+        if( base->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != BASE )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            ( (Base *)t )->setX( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
+            ( (Base *)t )->setY( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
+            zPC->stepOut();
+            return 1;
+        }
+    }
+    zPC->stepOut();
+    return 0;
+}
+
+
+BaseSetTeam::BaseSetTeam( Aktion *team, Aktion *base )
+    : Aktion( BASE_SET_TEAM )
+{
+    this->team = team;
+    this->base = base;
+}
+
+BaseSetTeam::~BaseSetTeam()
+{
+    team->release();
+    base->release();
+}
+
+bool BaseSetTeam::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
+{
+    zPC->stepIn();
+    if( zPC->currentPosition() == 0 )
+    {
+        if( team->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != TEAM )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 1 && waitCount <= 0 )
+    {
+        if( base->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != BASE )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            ( (Base *)t )->setTeam( ( (Team *)zMemory->getVariable( zPC->getUniqueString() + "R0__" ) ) );
+            zPC->stepOut();
+            return 1;
+        }
+    }
+    zPC->stepOut();
+    return 0;
+}