Browse Source

Rolle Fertig

Kolja Strohm 4 năm trước cách đây
mục cha
commit
c1a7b048a8

+ 45 - 0
StickmanWorldOnline/Rolle.cpp

@@ -0,0 +1,45 @@
+#include "Rolle.h"
+#include "Spieler.h"
+
+RolleEffect::RolleEffect( Spieler *zSpieler, Richtung r )
+    : Effect( zSpieler, (int)( 2.f + ( 2.f / 100.f ) * zSpieler->getAbklingZeitVerringerung() ) )
+{
+    this->r = r;
+}
+
+RolleEffect::~RolleEffect()
+{}
+
+bool RolleEffect::istSpielerBeweglich( Richtung r )
+{
+    return false;
+}
+
+bool RolleEffect::istSpielerVerwundbar( Richtung r )
+{
+    return r == MITTE;
+}
+
+void RolleEffect::move( double time )
+{
+    switch( r )
+    {
+    case OBEN:
+        zSpieler->setY( zSpieler->getY() - ( 75 + zSpieler->getLaufTempo() ) * time );
+        break;
+    case RECHTS:
+        zSpieler->setX( zSpieler->getX() + ( 75 + zSpieler->getLaufTempo() ) * time );
+        break;
+    case UNTEN:
+        zSpieler->setY( zSpieler->getY() + ( 75 + zSpieler->getLaufTempo() ) * time );
+        break;
+    case LINKS:
+        zSpieler->setX( zSpieler->getX() - ( 75 + zSpieler->getLaufTempo() ) * time );
+        break;
+    }
+}
+
+bool RolleEffect::istGegenstandErlaubt( GegenstandTyp typ )
+{
+    return typ != STURM && typ != ENTERHAKEN;
+}

+ 2 - 0
StickmanWorldOnline/Rolle.h

@@ -5,6 +5,7 @@
 class RolleEffect : public Effect
 {
 private:
+    Richtung r;
 
 public:
     RolleEffect( Spieler *zSpieler, Richtung r );
@@ -12,4 +13,5 @@ public:
     bool istSpielerBeweglich( Richtung r ) override;
     bool istSpielerVerwundbar( Richtung r ) override;
     void move( double time ) override;
+    bool istGegenstandErlaubt( GegenstandTyp typ ) override;
 };

+ 1 - 0
StickmanWorldOnline/StickmanWorldOnline.vcxproj

@@ -92,6 +92,7 @@
     <ClCompile Include="Leben.cpp" />
     <ClCompile Include="LebenRune.cpp" />
     <ClCompile Include="Reader.cpp" />
+    <ClCompile Include="Rolle.cpp" />
     <ClCompile Include="Schalter.cpp" />
     <ClCompile Include="Schiene.cpp" />
     <ClCompile Include="Schild.cpp" />

+ 3 - 0
StickmanWorldOnline/StickmanWorldOnline.vcxproj.filters

@@ -117,6 +117,9 @@
     <ClCompile Include="Sturm.cpp">
       <Filter>Spiel\Effekte</Filter>
     </ClCompile>
+    <ClCompile Include="Rolle.cpp">
+      <Filter>Spiel\Effekte</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="SpielKlasse.h">

+ 5 - 0
StickmanWorldOnline/Sturm.cpp

@@ -52,3 +52,8 @@ bool SturmEffect::tick( double time, Spiel *zSpiel )
     }
     return Effect::tick( time, zSpiel );
 }
+
+bool SturmEffect::istGegenstandErlaubt( GegenstandTyp typ )
+{
+    return typ != ROLLE && typ != ENTERHAKEN;
+}

+ 1 - 0
StickmanWorldOnline/Sturm.h

@@ -14,4 +14,5 @@ public:
     bool istSpielerVerwundbar( Richtung r ) override;
     void move( double time ) override;
     bool tick( double time, Spiel *zSpiel ) override;
+    bool istGegenstandErlaubt( GegenstandTyp typ ) override;
 };