Browse Source

Einiege fehlende Funktionen implementiert

Kolja Strohm 5 years ago
parent
commit
6f23f8dd04

+ 1 - 1
StickmanWorldOnline/Aktionen.cpp

@@ -609,7 +609,7 @@ BariereSetEingeschaltet::BariereSetEingeschaltet( RCArray< Aktion > *subActions
 
 void BariereSetEingeschaltet::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
 {
-    ( (Bariere *)zParam( 1 ) )->setEingeschaltet( ( (Boolean *)zParam( 0 ) )->getValue() );
+    ( (Bariere *)zParam( 1 ) )->setStyle( Bariere::Style::Aktiv, ( (Boolean *)zParam( 0 ) )->getValue() );
 }
 
 

+ 0 - 1
StickmanWorldOnline/Bariere.h

@@ -40,7 +40,6 @@ public:
     void setAutoSchaltungMaxTime( int seconds );
     void startAutoSchaltung();
     void setTeam( Team *team );
-    void setEingeschaltet( bool eingeschaltet );
     void tick( double time, Spiel *zSpiel );
     bool hatStyle( int style ) const;
     int getVerschiebungAnzahl() const;

+ 5 - 0
StickmanWorldOnline/Drop.cpp

@@ -45,6 +45,11 @@ void Drop::setMaxTime( int seconds )
     maxTime = seconds;
 }
 
+void Drop::setTime( float time )
+{
+    this->nextDrop = time;
+}
+
 void Drop::doDrop( Spiel *zSpiel )
 {
     nextDrop = (float)maxTime;

+ 7 - 1
StickmanWorldOnline/GameObject.cpp

@@ -1,4 +1,5 @@
 #include "GameObject.h"
+#include "Punkt.h"
 
 
 GameObject::GameObject( VariableTyp typ, int x, int y, int width, int height )
@@ -53,4 +54,9 @@ float GameObject::getWidth() const
 float GameObject::getHeight() const
 {
     return h;
-}
+}
+
+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();
+}

+ 29 - 0
StickmanWorldOnline/Geschoss.cpp

@@ -53,6 +53,35 @@ void Geschoss::addSchalter()
     id++;
 }
 
+void Geschoss::setSpeed( float speed )
+{
+    this->speed = speed;
+}
+
+void Geschoss::setBesitzer( Spieler *besitzer )
+{
+    if( this->besitzer )
+        this->besitzer->release();
+    this->besitzer = besitzer;
+}
+
+void Geschoss::setTyp( GeschossTyp typ )
+{
+    this->typ = typ;
+    if( typ == GESCHOSS_PFEIL )
+    {
+        if( richtung == OBEN || richtung == UNTEN )
+            setHeight( 50 );
+        else
+            setWidth( 50 );
+    }
+    else
+    {
+        setWidth( 20 );
+        setHeight( 20 );
+    }
+}
+
 void Geschoss::setRichtung( Richtung r )
 {
     richtung = r;

+ 1 - 0
StickmanWorldOnline/SSKlient.h

@@ -27,6 +27,7 @@ public:
     void sendeStart( int spielZeit );
     void sendeTastaturStatus( int spielerId, char taste, bool aktiv, int spielZeit );
     void sendeSpielEnde( char gewonnen, int spielZeit );
+    void sendeTick();
     void sendeChatNachricht( char *txt, int spielZeit );
     void sendeStatistikChatNachricht( int vonAccount, char *txt );
     void sendeStatistikSpielerOffline( int account );

+ 149 - 1
StickmanWorldOnline/Spieler.cpp

@@ -52,6 +52,14 @@ void Inventar::setSelected( int slot )
         selected = INVENTORY_SLOTS - 1;
 }
 
+bool Inventar::hatAbklingzeit( GegenstandTyp typ ) const
+{
+    for( int i = 0; i < INVENTORY_SLOTS; i++ )
+        if( slots[ i ] == typ && abklingzeit[ i ] > 0 )
+            return 1;
+    return 0;
+}
+
 GegenstandTyp Inventar::useItem()
 {
     if( slots[ selected ] != KEIN_GEGENSTAND && abklingzeit[ selected ] <= 0 )
@@ -107,6 +115,31 @@ GegenstandTyp Inventar::selectedItem() const
     return slots[ selected ];
 }
 
+int Inventar::getItemAnzahl() const
+{
+    int sum = 0;
+    for( int i = 0; i < INVENTORY_SLOTS; i++ )
+        sum += anzahl[ i ];
+    return sum;
+}
+
+int Inventar::getItemAnzahl( GegenstandTyp typ ) const
+{
+    for( int i = 0; i < INVENTORY_SLOTS; i++ )
+    {
+        if( slots[ i ] == typ )
+            return anzahl[ i ];
+    }
+    return 0;
+}
+
+GegenstandTyp Inventar::getItemTyp( int index ) const
+{
+    if( index < 0 || index >= INVENTORY_SLOTS )
+        return KEIN_GEGENSTAND;
+    return slots[ index ];
+}
+
 
 Spieler::Spieler( int id, Team *team, int spawnX, int spawnY, int farbe )
     : GameObject( SPIELER, spawnX, spawnY, 40, 50 )
@@ -538,6 +571,11 @@ void Spieler::setLebensRegeneration( float reg )
     lebensRegeneration = reg;
 }
 
+void Spieler::setName( const char *name )
+{
+    this->name = name;
+}
+
 float Spieler::getLebensRegenneration() const
 {
     return lebensRegeneration;
@@ -578,6 +616,11 @@ Team *Spieler::zTeam() const
     return team;
 }
 
+Team *Spieler::getTeam() const
+{
+    return team ? (Team *)team->getThis() : 0;
+}
+
 int Spieler::getFarbe() const
 {
     return color;
@@ -648,7 +691,7 @@ bool Spieler::istGegenstandErlaubt( GegenstandTyp typ ) const
         if( !erlaubt )
             return 0;
     }
-    return 1;
+    return !inv.hatAbklingzeit( typ );
 }
 
 Richtung Spieler::getAusrichtung() const
@@ -665,3 +708,108 @@ int Spieler::getId() const
 {
     return spielerNummer;
 }
+
+int Spieler::getLevel() const
+{
+    return level;
+}
+
+float Spieler::getLeben() const
+{
+    return leben;
+}
+
+int Spieler::getMaxLeben() const
+{
+    return maxLeben;
+}
+
+float Spieler::getErfahrung() const
+{
+    return erfahrung;
+}
+
+int Spieler::getMaxErfahrung() const
+{
+    return maxErfahrung;
+}
+
+int Spieler::getTode() const
+{
+    return tode;
+}
+
+int Spieler::getKills() const
+{
+    return kills;
+}
+
+int Spieler::getTreffer() const
+{
+    return treffer;
+}
+
+int Spieler::getGetroffen() const
+{
+    return getroffen;
+}
+
+float Spieler::getErlittenerSchaden() const
+{
+    return schadenGenommen;
+}
+
+float Spieler::getGemachterSchaden() const
+{
+    return schadenGemacht;
+}
+
+float Spieler::getGeheiltesLeben() const
+{
+    return lebenGeheilt;
+}
+
+int Spieler::getItemsAufgehoben() const
+{
+    return itemsAufgehoben;
+}
+
+int Spieler::getItemsVerwendet() const
+{
+    return itemsVerwendet;
+}
+
+int Spieler::getItemsInInventory() const
+{
+    return inv.getItemAnzahl();
+}
+
+int Spieler::getItemsInInventory( GegenstandTyp typ ) const
+{
+    return inv.getItemAnzahl( typ );
+}
+
+int Spieler::getTunnelBenutzt() const
+{
+    return tunnelBenutzt;
+}
+
+int Spieler::getSchalterAktiviert() const
+{
+    return schalterAktiviert;
+}
+
+int Spieler::getGeschossen() const
+{
+    return geschosseGeschossen;
+}
+
+GegenstandTyp Spieler::getInventorySlot( int index ) const
+{
+    return inv.getItemTyp( index );
+}
+
+const char *Spieler::getName() const
+{
+    return name;
+}

+ 6 - 1
StickmanWorldOnline/Spieler.h

@@ -21,10 +21,14 @@ public:
     Inventar();
     void addItem( GegenstandTyp typ, int anzahl );
     void setSelected( int slot );
+    bool hatAbklingzeit( GegenstandTyp typ ) const;
     GegenstandTyp useItem();
     void tick( double zeit );
     bool canAddItem( GegenstandTyp typ ) const;
     GegenstandTyp selectedItem() const;
+    int getItemAnzahl() const;
+    int getItemAnzahl( GegenstandTyp typ ) const;
+    GegenstandTyp getItemTyp( int index ) const;
 };
 
 class Spieler : public GameObject
@@ -69,6 +73,7 @@ private:
     int schalterAktiviert;
     int geschosseGeschossen;
     bool tastenStand[ 256 ];
+    Text name;
     Richtung ausrichtung;
     Inventar inv;
 
@@ -101,6 +106,7 @@ public:
     void setGeschossTempo( float tempo );
     void setArmor( float armor );
     void setLebensRegeneration( float reg );
+    void setName( const char *name );
     // setzt alle eigenschafften, die mit dem level gesetzt werden entsprechend
     void setLevel( int level );
     void removeItem( GegenstandTyp typ, int anzahl );
@@ -127,7 +133,6 @@ public:
     bool isVerwundbar( Richtung r ) const;
     bool istBeweglich( Richtung r ) const;
     bool istSichtbar( Team *zTeam ) const;
-    // TODO return false if abklingzeit is active
     bool istGegenstandErlaubt( GegenstandTyp typ ) const;
     Richtung getAusrichtung() const;
     float getAbklingZeitVerringerung() const;

+ 15 - 0
StickmanWorldOnline/Trigger.cpp

@@ -287,6 +287,21 @@ int Trigger::getId() const
     return id;
 }
 
+int Trigger::getRuns() const
+{
+    return runCount;
+}
+
+const char *Trigger::getName() const
+{
+    return name.getText();
+}
+
+bool Trigger::istAktiv() const
+{
+    return aktiv;
+}
+
 
 TriggerRun::TriggerRun( Trigger *trig, Ereignis *e, Spiel *zSpiel )
 {