ソースを参照

Während Geist aktiv ist, kann der Spieler mit keinem spielobjekt interagieren (auch nicht mit barieren)

Kolja Strohm 4 年 前
コミット
8beacc6037

+ 9 - 4
StickmanWorldOnline/Effect.cpp

@@ -17,17 +17,22 @@ bool Effect::tick( double time, Spiel *zSpiel )
     return timeLeft <= 0;
 }
 
-bool Effect::istSpielerBeweglich( Richtung r )
+bool Effect::istSpielerBeweglich( Richtung r ) const
 {
     return 1;
 }
 
-bool Effect::istSpielerVerwundbar( Richtung r )
+bool Effect::istSpielerVerwundbar( Richtung r ) const
 {
     return 1;
 }
 
-bool Effect::istSpielerSichtbar( Team *zTeam )
+bool Effect::istSpielerSichtbar( Team *zTeam ) const
+{
+    return 1;
+}
+
+bool Effect::istIntersectable() const
 {
     return 1;
 }
@@ -35,7 +40,7 @@ bool Effect::istSpielerSichtbar( Team *zTeam )
 void Effect::move( double time )
 {}
 
-bool Effect::istGegenstandErlaubt( GegenstandTyp typ )
+bool Effect::istGegenstandErlaubt( GegenstandTyp typ ) const
 {
     return 1;
 }

+ 5 - 4
StickmanWorldOnline/Effect.h

@@ -17,11 +17,12 @@ public:
     Effect( Spieler *zSpieler, float maxTime );
     virtual ~Effect();
     virtual bool tick( double time, Spiel *zSpiel );
-    virtual bool istSpielerBeweglich( Richtung r );
-    virtual bool istSpielerVerwundbar( Richtung r );
-    virtual bool istSpielerSichtbar( Team *zTeam );
+    virtual bool istSpielerBeweglich( Richtung r ) const;
+    virtual bool istSpielerVerwundbar( Richtung r ) const;
+    virtual bool istSpielerSichtbar( Team *zTeam ) const;
+    virtual bool istIntersectable() const;
     virtual void move( double time );
-    virtual bool istGegenstandErlaubt( GegenstandTyp typ );
+    virtual bool istGegenstandErlaubt( GegenstandTyp typ ) const;
     Effect *getThis();
     Effect *release();
 };

+ 3 - 3
StickmanWorldOnline/Enterhaken.cpp

@@ -16,7 +16,7 @@ EnterhakenEffect::EnterhakenEffect( Spieler *zSpieler, Richtung r )
 EnterhakenEffect::~EnterhakenEffect()
 {}
 
-bool EnterhakenEffect::istSpielerBeweglich( Richtung r )
+bool EnterhakenEffect::istSpielerBeweglich( Richtung r ) const
 {
     return 0;
 }
@@ -156,12 +156,12 @@ bool EnterhakenEffect::tick( double time, Spiel * zSpiel )
     return state == 5;
 }
 
-bool EnterhakenEffect::istGegenstandErlaubt( GegenstandTyp typ )
+bool EnterhakenEffect::istGegenstandErlaubt( GegenstandTyp typ ) const
 {
     return typ != STURM && typ != ROLLE;
 }
 
-bool EnterhakenEffect::istSpielerVerwundbar( Richtung r )
+bool EnterhakenEffect::istSpielerVerwundbar( Richtung r ) const
 {
     return r != MITTE;
 }

+ 3 - 3
StickmanWorldOnline/Enterhaken.h

@@ -17,9 +17,9 @@ private:
 public:
     EnterhakenEffect( Spieler *zSpieler, Richtung r );
     ~EnterhakenEffect();
-    bool istSpielerBeweglich( Richtung r ) override;
+    bool istSpielerBeweglich( Richtung r ) const override;
     void move( double time ) override;
     bool tick( double time, Spiel *zSpiel ) override;
-    bool istGegenstandErlaubt( GegenstandTyp typ ) override;
-    bool istSpielerVerwundbar( Richtung r ) override;
+    bool istGegenstandErlaubt( GegenstandTyp typ ) const override;
+    bool istSpielerVerwundbar( Richtung r ) const override;
 };

+ 8 - 0
StickmanWorldOnline/GameObject.cpp

@@ -9,6 +9,7 @@ GameObject::GameObject( VariableTyp typ, int x, int y, int width, int height )
     this->y = (float)y;
     w = (float)width;
     h = (float)height;
+    intersectable = 1;
 }
 
 void GameObject::setX( float x )
@@ -33,6 +34,8 @@ void GameObject::setHeight( float height )
 
 bool GameObject::intersectsWith( GameObject *zObj )
 {
+    if( !intersectable || !zObj->intersectable )
+        return 0;
     return x < zObj->x + zObj->w && x + w > zObj->x && y < zObj->y + zObj->h && y + h > zObj->y;
 }
 
@@ -56,6 +59,11 @@ float GameObject::getHeight() const
     return h;
 }
 
+bool GameObject::isIntersectable() const
+{
+    return intersectable;
+}
+
 float GameObject::abstandZu( GameObject *zObj )
 {
     return ( Vec2<float>( x + w / 2, y + h / 2 ) - Vec2<float>( zObj->x + zObj->w / 2, zObj->y + zObj->h / 2 ) ).getLength();

+ 2 - 0
StickmanWorldOnline/GameObject.h

@@ -6,6 +6,7 @@ class GameObject : public Variable
 {
 protected:
     float x, y, w, h;
+    bool intersectable;
 
 public:
     GameObject( VariableTyp typ, int x, int y, int width, int height );
@@ -18,5 +19,6 @@ public:
     float getY() const;
     float getWidth() const;
     float getHeight() const;
+    bool isIntersectable() const;
     float abstandZu( GameObject *zObj );
 };

+ 6 - 1
StickmanWorldOnline/Geist.cpp

@@ -8,7 +8,12 @@ GeistEffect::GeistEffect( Spieler *zSpieler )
 GeistEffect::~GeistEffect()
 {}
 
-bool GeistEffect::istSpielerSichtbar( Team * zTeam )
+bool GeistEffect::istSpielerSichtbar( Team * zTeam ) const
 {
     return zTeam == zSpieler->zTeam();
 }
+
+bool GeistEffect::istIntersectable() const
+{
+    return 0;
+}

+ 2 - 1
StickmanWorldOnline/Geist.h

@@ -9,5 +9,6 @@ private:
 public:
     GeistEffect( Spieler *zSpieler );
     ~GeistEffect();
-    bool istSpielerSichtbar( Team *zTeam ) override;
+    bool istSpielerSichtbar( Team *zTeam ) const override;
+    bool istIntersectable() const override;
 };

+ 3 - 3
StickmanWorldOnline/Rolle.cpp

@@ -10,12 +10,12 @@ RolleEffect::RolleEffect( Spieler *zSpieler, Richtung r )
 RolleEffect::~RolleEffect()
 {}
 
-bool RolleEffect::istSpielerBeweglich( Richtung r )
+bool RolleEffect::istSpielerBeweglich( Richtung r ) const
 {
     return false;
 }
 
-bool RolleEffect::istSpielerVerwundbar( Richtung r )
+bool RolleEffect::istSpielerVerwundbar( Richtung r ) const
 {
     return r == MITTE;
 }
@@ -41,7 +41,7 @@ void RolleEffect::move( double time )
     }
 }
 
-bool RolleEffect::istGegenstandErlaubt( GegenstandTyp typ )
+bool RolleEffect::istGegenstandErlaubt( GegenstandTyp typ ) const
 {
     return typ != STURM && typ != ENTERHAKEN;
 }

+ 3 - 3
StickmanWorldOnline/Rolle.h

@@ -10,8 +10,8 @@ private:
 public:
     RolleEffect( Spieler *zSpieler, Richtung r );
     ~RolleEffect();
-    bool istSpielerBeweglich( Richtung r ) override;
-    bool istSpielerVerwundbar( Richtung r ) override;
+    bool istSpielerBeweglich( Richtung r ) const override;
+    bool istSpielerVerwundbar( Richtung r ) const override;
     void move( double time ) override;
-    bool istGegenstandErlaubt( GegenstandTyp typ ) override;
+    bool istGegenstandErlaubt( GegenstandTyp typ ) const override;
 };

+ 1 - 1
StickmanWorldOnline/Schild.cpp

@@ -9,7 +9,7 @@ SchildEffect::SchildEffect( Spieler *zSpieler )
 SchildEffect::~SchildEffect()
 {}
 
-bool SchildEffect::istSpielerVerwundbar( Richtung r )
+bool SchildEffect::istSpielerVerwundbar( Richtung r ) const
 {
     return 0;
 }

+ 1 - 1
StickmanWorldOnline/Schild.h

@@ -9,5 +9,5 @@ private:
 public:
     SchildEffect( Spieler *zSpieler );
     ~SchildEffect();
-    bool istSpielerVerwundbar( Richtung r ) override;
+    bool istSpielerVerwundbar( Richtung r ) const override;
 };

+ 3 - 0
StickmanWorldOnline/Spieler.cpp

@@ -414,8 +414,10 @@ void Spieler::tick( double zeit, Spiel *zSpiel )
 {
     if( istAmLeben() )
     {
+        intersectable = 1;
         for( int i = 0; i < effekte.getEintragAnzahl(); i++ )
         {
+            intersectable &= effekte.z( i )->istIntersectable();
             if( effekte.z( i )->tick( zeit, zSpiel ) && istAmLeben() )
             {
                 effekte.remove( i );
@@ -432,6 +434,7 @@ void Spieler::tick( double zeit, Spiel *zSpiel )
     }
     else
     {
+        intersectable = 0;
         effekte.leeren();
         wiederbelebungsZeit -= (float)zeit;
         if( wiederbelebungsZeit <= 0 )

+ 3 - 3
StickmanWorldOnline/Sturm.cpp

@@ -11,12 +11,12 @@ SturmEffect::SturmEffect( Spieler *zSpieler, Richtung r )
 SturmEffect::~SturmEffect()
 {}
 
-bool SturmEffect::istSpielerBeweglich( Richtung r )
+bool SturmEffect::istSpielerBeweglich( Richtung r ) const
 {
     return false;
 }
 
-bool SturmEffect::istSpielerVerwundbar( Richtung r )
+bool SturmEffect::istSpielerVerwundbar( Richtung r ) const
 {
     return r != this->r;
 }
@@ -55,7 +55,7 @@ bool SturmEffect::tick( double time, Spiel *zSpiel )
     return Effect::tick( time, zSpiel );
 }
 
-bool SturmEffect::istGegenstandErlaubt( GegenstandTyp typ )
+bool SturmEffect::istGegenstandErlaubt( GegenstandTyp typ ) const
 {
     return typ != ROLLE && typ != ENTERHAKEN;
 }

+ 3 - 3
StickmanWorldOnline/Sturm.h

@@ -10,9 +10,9 @@ private:
 public:
     SturmEffect( Spieler *zSpieler, Richtung r );
     ~SturmEffect();
-    bool istSpielerBeweglich( Richtung r ) override;
-    bool istSpielerVerwundbar( Richtung r ) override;
+    bool istSpielerBeweglich( Richtung r ) const override;
+    bool istSpielerVerwundbar( Richtung r ) const override;
     void move( double time ) override;
     bool tick( double time, Spiel *zSpiel ) override;
-    bool istGegenstandErlaubt( GegenstandTyp typ ) override;
+    bool istGegenstandErlaubt( GegenstandTyp typ ) const override;
 };