浏览代码

Geschosse treffen nun auch den eigenen Spieler

Kolja Strohm 4 年之前
父节点
当前提交
9ac0f1b95a

+ 0 - 1
StickmanWorldOnline/Enterhaken.cpp

@@ -6,7 +6,6 @@ EnterhakenEffect::EnterhakenEffect( Spieler *zSpieler, Richtung r )
     : Effect( zSpieler, 1.5f + ( 1.5f / 100.f ) * zSpieler->getAbklingZeitVerringerung() )
 {
     this->r = r;
-    timeLeft = 3;
     maxTime = timeLeft;
     state = 0;
     ehpx = zSpieler->getX() + zSpieler->getWidth() / 2;

+ 1 - 1
StickmanWorldOnline/GameObject.h

@@ -14,7 +14,7 @@ public:
     void setY( float y );
     void setWidth( float width );
     void setHeight( float height );
-    bool intersectsWith( GameObject *zObj );
+    virtual bool intersectsWith( GameObject *zObj );
     float getX() const;
     float getY() const;
     float getWidth() const;

+ 11 - 0
StickmanWorldOnline/Geschoss.cpp

@@ -12,6 +12,7 @@ Geschoss::Geschoss( int id, float speed, GeschossTyp typ, Richtung r, int x, int
     umgelenkt = 0;
     geschosseGetroffen = 0;
     schalter = 0;
+    intersectWithOwner = 1;
     this->id = id;
     setTyp( typ );
 }
@@ -116,6 +117,16 @@ void Geschoss::tick( double zeit )
     }
 }
 
+bool Geschoss::intersectsWith( GameObject *zObj )
+{
+    if( zObj == besitzer && intersectWithOwner )
+    {
+        intersectWithOwner &= GameObject::intersectsWith( zObj );
+        return 0;
+    }
+    return GameObject::intersectsWith( zObj );
+}
+
 GeschossTyp Geschoss::getTyp() const
 {
     return typ;

+ 2 - 0
StickmanWorldOnline/Geschoss.h

@@ -19,6 +19,7 @@ private:
     int umgelenkt;
     int geschosseGetroffen;
     int schalter;
+    bool intersectWithOwner;
     int id;
 
 public:
@@ -34,6 +35,7 @@ public:
     void setTyp( GeschossTyp typ );
     void setRichtung( Richtung r );
     void tick( double zeit );
+    bool intersectsWith( GameObject *zObj ) override;
     GeschossTyp getTyp() const;
     Spieler *zBesitzer() const;
     Spieler *getBesitzer() const;

+ 1 - 1
StickmanWorldOnline/Spiel.cpp

@@ -682,7 +682,7 @@ void Spiel::tick( double zeit )
                     // geschoss - spieler intersection
                     for( auto s = spieler.getIterator(); s; s++ )
                     {
-                        if( s->istAmLeben() && s != g->zBesitzer() && g->intersectsWith( s ) )
+                        if( s->istAmLeben() && g->intersectsWith( s ) )
                         {
                             switch( g->getTyp() )
                             {