Explorar el Código

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

Kolja Strohm hace 4 años
padre
commit
069bbd71b9

+ 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;
     virtual void renderSpieler( Bild &rObj );
     virtual Resource *getCurrentResource();
     Effect *getThis();

+ 3 - 3
StickmanWorldOnline/Enterhaken.cpp

@@ -23,7 +23,7 @@ EnterhakenEffect::~EnterhakenEffect()
     spieler->release();
 }
 
-bool EnterhakenEffect::istSpielerBeweglich( Richtung r )
+bool EnterhakenEffect::istSpielerBeweglich( Richtung r ) const
 {
     return 0;
 }
@@ -163,12 +163,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

@@ -20,11 +20,11 @@ private:
 public:
     EnterhakenEffect( ResourceRegistry *zResources, 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;
     void renderSpieler( Bild &rObj ) override;
     Resource *getCurrentResource() override;
 };

+ 2 - 0
StickmanWorldOnline/GameObject.h

@@ -13,6 +13,7 @@ protected:
     float x, y, w, h;
     Bild *textur;
     bool texturScale;
+    bool intersectable;
 
 public:
     GameObject( VariableTyp typ, int x, int y, int width, int height );
@@ -27,5 +28,6 @@ public:
     float getY() const;
     float getWidth() const;
     float getHeight() const;
+    bool isIntersectable() const;
     float abstandZu( GameObject *zObj );
 };

+ 8 - 0
StickmanWorldOnline/GameObjekt.cpp

@@ -11,6 +11,7 @@ GameObject::GameObject( VariableTyp typ, int x, int y, int width, int height )
     h = (float)height;
     textur = 0;
     texturScale = 0;
+    intersectable = 1;
 }
 
 GameObject::~GameObject()
@@ -41,6 +42,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;
 }
 
@@ -85,6 +88,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();

+ 6 - 1
StickmanWorldOnline/Geist.cpp

@@ -12,11 +12,16 @@ GeistEffect::~GeistEffect()
     bild->release();
 }
 
-bool GeistEffect::istSpielerSichtbar( Team *zTeam )
+bool GeistEffect::istSpielerSichtbar( Team *zTeam ) const
 {
     return zTeam == zSpieler->zTeam();
 }
 
+bool GeistEffect::istIntersectable() const
+{
+    return 0;
+}
+
 void GeistEffect::renderSpieler( Bild &rObj )
 {
     if( rObj.setDrawOptions( (int)zSpieler->getX(), (int)zSpieler->getY(), (int)zSpieler->getWidth(), (int)zSpieler->getHeight() ) )

+ 2 - 1
StickmanWorldOnline/Geist.h

@@ -10,6 +10,7 @@ private:
 public:
     GeistEffect( ResourceRegistry *zResources, Spieler *zSpieler );
     ~GeistEffect();
-    bool istSpielerSichtbar( Team *zTeam ) override;
+    bool istSpielerSichtbar( Team *zTeam ) const override;
+    bool istIntersectable() const override;
     void renderSpieler( Bild &rObj ) override;
 };

+ 3 - 3
StickmanWorldOnline/Rolle.cpp

@@ -22,12 +22,12 @@ RolleEffect::~RolleEffect()
         annimation->release();
 }
 
-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;
 }
@@ -53,7 +53,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

@@ -11,9 +11,9 @@ private:
 public:
     RolleEffect( ResourceRegistry *zResources, 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;
     Resource *getCurrentResource() override;
 };

+ 1 - 1
StickmanWorldOnline/Schild.cpp

@@ -13,7 +13,7 @@ SchildEffect::~SchildEffect()
     bild->release();
 }
 
-bool SchildEffect::istSpielerVerwundbar( Richtung r )
+bool SchildEffect::istSpielerVerwundbar( Richtung r ) const
 {
     return 0;
 }

+ 1 - 1
StickmanWorldOnline/Schild.h

@@ -10,6 +10,6 @@ private:
 public:
     SchildEffect( ResourceRegistry *zResources, Spieler *zSpieler );
     ~SchildEffect();
-    bool istSpielerVerwundbar( Richtung r ) override;
+    bool istSpielerVerwundbar( Richtung r ) const override;
     void renderSpieler( Bild &rObj ) override;
 };

+ 3 - 0
StickmanWorldOnline/Spieler.cpp

@@ -489,8 +489,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 );
@@ -556,6 +558,7 @@ void Spieler::tick( double zeit, Spiel *zSpiel )
     }
     else
     {
+        intersectable = 0;
         effekte.leeren();
         wiederbelebungsZeit -= (float)zeit;
         if( wiederbelebungsZeit <= 0 )

+ 3 - 3
StickmanWorldOnline/Sturm.cpp

@@ -23,12 +23,12 @@ SturmEffect::~SturmEffect()
         annimation->release();
 }
 
-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;
 }
@@ -67,7 +67,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

@@ -11,10 +11,10 @@ private:
 public:
     SturmEffect( ResourceRegistry *zResources, 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;
     Resource *getCurrentResource() override;
 };