|
@@ -8,99 +8,246 @@
|
|
|
SpielObjekt::SpielObjekt( ObjektStr *zStr, Schrift *zSchrift )
|
|
|
: Model2DObject()
|
|
|
{
|
|
|
- id = zStr->id;
|
|
|
- style = zStr->style;
|
|
|
- stabilität = zStr->maxStabilität;
|
|
|
- energie = zStr->maxEnergie;
|
|
|
- maxStabilität = zStr->maxStabilität;
|
|
|
- maxEnergie = zStr->maxEnergie;
|
|
|
- energieRadius = zStr->energieRadius;
|
|
|
- reparatur = zStr->reparatur;
|
|
|
- akkuLeistung = zStr->akkuLeistung;
|
|
|
- team = 0;
|
|
|
- nText = initTextFeld( 0, 0, 152, 30, zSchrift, TextFeld::Style::Text | TextFeld::Style::Rahmen | TextFeld::Style::Center |
|
|
|
- TextFeld::Style::Hintergrund | TextFeld::Style::HAlpha, "" );
|
|
|
+ id = zStr->id;
|
|
|
+ style = zStr->style;
|
|
|
+ stabilität = zStr->maxStabilität;
|
|
|
+ energie = zStr->maxEnergie;
|
|
|
+ maxStabilität = zStr->maxStabilität;
|
|
|
+ maxEnergie = zStr->maxEnergie;
|
|
|
+ energieRadius = zStr->energieRadius;
|
|
|
+ reparatur = zStr->reparatur;
|
|
|
+ akkuLeistung = zStr->akkuLeistung;
|
|
|
+ zteam = 0;
|
|
|
+ amLeben = 1;
|
|
|
+ level = 1;
|
|
|
+ ep = 0;
|
|
|
+ nextSkillEp = 80;
|
|
|
+ setCollision( ( style | 0x4 ) == style );
|
|
|
+ deadPlayer = 0;
|
|
|
+ nText = initTextFeld( 0, 0, 152, 30, zSchrift, TextFeld::Style::Text | TextFeld::Style::Rahmen | TextFeld::Style::Center |
|
|
|
+ TextFeld::Style::Hintergrund | TextFeld::Style::HAlpha, "" );
|
|
|
+ save();
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
|
SpielObjekt::~SpielObjekt()
|
|
|
{
|
|
|
- if( team )
|
|
|
- team->release();
|
|
|
- nText->release();
|
|
|
+ nText->release();
|
|
|
+ if( deadPlayer )
|
|
|
+ deadPlayer->release();
|
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
|
-void SpielObjekt::setTextur( Bild *textur )
|
|
|
+void SpielObjekt::save()
|
|
|
+{
|
|
|
+ last.rSpeed = rSpeed;
|
|
|
+ last.pos = position;
|
|
|
+ last.speed = speed;
|
|
|
+ last.rotation = rotation;
|
|
|
+ last.amLeben = amLeben;
|
|
|
+ last.akkuAbk = akkuAbk;
|
|
|
+ last.repAbk = repAbk;
|
|
|
+ last.energie = energie;
|
|
|
+ last.stabilität = stabilität;
|
|
|
+ last.reparatur = reparatur;
|
|
|
+ last.akkuLeistung = akkuLeistung;
|
|
|
+ last.maxEnergie = maxEnergie;
|
|
|
+ last.maxStabilität = maxStabilität;
|
|
|
+ last.level = level;
|
|
|
+}
|
|
|
+
|
|
|
+void SpielObjekt::load()
|
|
|
+{
|
|
|
+ rSpeed = last.rSpeed;
|
|
|
+ position = last.pos;
|
|
|
+ speed = last.speed;
|
|
|
+ rotation = last.rotation;
|
|
|
+ amLeben = last.amLeben;
|
|
|
+ akkuAbk = last.akkuAbk;
|
|
|
+ repAbk = last.repAbk;
|
|
|
+ energie = last.energie;
|
|
|
+ stabilität = last.stabilität;
|
|
|
+ reparatur = last.reparatur;
|
|
|
+ akkuLeistung = last.akkuLeistung;
|
|
|
+ maxEnergie = last.maxEnergie;
|
|
|
+ maxStabilität = last.maxStabilität;
|
|
|
+ level = last.level;
|
|
|
+}
|
|
|
+
|
|
|
+void SpielObjekt::setTextur( Bild * textur )
|
|
|
{
|
|
|
Textur2D *t = new Textur2D();
|
|
|
t->setTexturZ( textur );
|
|
|
__super::setTextur( t );
|
|
|
}
|
|
|
|
|
|
-void SpielObjekt::setTeam( Team *team )
|
|
|
+void SpielObjekt::setTeam( Team * team )
|
|
|
{
|
|
|
- if( this->team )
|
|
|
- this->team->release();
|
|
|
- this->team = team;
|
|
|
+ this->zteam = team;
|
|
|
+ nText->setHintergrundFarbe( 0xA0000000 | ( zteam->farbe & 0x00FFFFFF ) );
|
|
|
+ nText->setRahmenFarbe( zteam->farbe );
|
|
|
}
|
|
|
|
|
|
-bool SpielObjekt::tick( const WeltInfo &info, double zeit )
|
|
|
-{
|
|
|
- repAbk -= zeit;
|
|
|
- if( repAbk < 0 )
|
|
|
- repAbk = 0;
|
|
|
- akkuAbk -= zeit;
|
|
|
- if( akkuAbk < 0 )
|
|
|
- akkuAbk = 0;
|
|
|
- if( !repAbk )
|
|
|
- {
|
|
|
- stabilität += reparatur * zeit;
|
|
|
- if( stabilität > maxStabilität )
|
|
|
- stabilität = maxStabilität;
|
|
|
- }
|
|
|
- if( !akkuAbk )
|
|
|
- {
|
|
|
- if( !team )
|
|
|
- {
|
|
|
- energie -= akkuLeistung * zeit;
|
|
|
- if( energie < 0 )
|
|
|
- energie = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- energie += akkuLeistung * zeit;
|
|
|
- if( energie > maxEnergie )
|
|
|
- energie = maxEnergie;
|
|
|
- }
|
|
|
- }
|
|
|
- __super::tick( info, zeit );
|
|
|
- return 1;
|
|
|
+bool SpielObjekt::tick( const WeltInfo & info, double zeit )
|
|
|
+{
|
|
|
+ if( !amLeben )
|
|
|
+ return 0;
|
|
|
+ repAbk -= zeit;
|
|
|
+ if( repAbk < 0 )
|
|
|
+ repAbk = 0;
|
|
|
+ akkuAbk -= zeit;
|
|
|
+ if( akkuAbk < 0 )
|
|
|
+ akkuAbk = 0;
|
|
|
+ if( !repAbk )
|
|
|
+ {
|
|
|
+ stabilität += reparatur * zeit;
|
|
|
+ if( stabilität > maxStabilität )
|
|
|
+ stabilität = maxStabilität;
|
|
|
+ }
|
|
|
+ if( !akkuAbk )
|
|
|
+ {
|
|
|
+ if( !zteam )
|
|
|
+ {
|
|
|
+ energie -= akkuLeistung * zeit;
|
|
|
+ if( energie < 0 )
|
|
|
+ energie = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ energie += akkuLeistung * zeit;
|
|
|
+ if( energie > maxEnergie )
|
|
|
+ energie = maxEnergie;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( ( style | 0x2 ) != style )
|
|
|
+ {
|
|
|
+ speed.x = 0;
|
|
|
+ speed.y = 0;
|
|
|
+ rSpeed = 0;
|
|
|
+ }
|
|
|
+ return Model2DObject::tick( info, zeit );
|
|
|
}
|
|
|
|
|
|
-void SpielObjekt::render( Mat3<float> &kamMat, Bild &zRObj, const char *kamName )
|
|
|
+void SpielObjekt::render( Mat3<float> & kamMat, Bild & zRObj, const char *kamName )
|
|
|
{
|
|
|
+ if( !amLeben )
|
|
|
+ return;
|
|
|
+ Model2DObject::render( kamMat, zRObj, kamName );
|
|
|
if( Text( "minimap" ).istGleich( kamName ) )
|
|
|
return;
|
|
|
- nText->setPosition( (Punkt)( kamMat * (getPosition() - Punkt( 76, (int)( zModel()->maxP.y * getSize() ) + 30 ) ) ) );
|
|
|
- nText->render( zRObj );
|
|
|
- int teamF = team ? team->farbe : 0;
|
|
|
- double teamStab = team ? team->maxStabilität : 0;
|
|
|
- double teamEner = team ? team->maxEnergie : 0;
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 4, 150, teamF );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 25, 150, teamF );
|
|
|
- int l = (int)( stabilität * 100 / ( maxStabilität + teamStab ) * 1.5 + 0.5 );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 1, l, 0xFF00FF00 );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 2, l, 0xFF00FF00 );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 3, l, 0xFF00FF00 );
|
|
|
- int e = (int)( energie * 100 / ( maxEnergie + teamEner ) * 1.5 + 0.5 );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 26, e, 0xFFFFFF00 );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 27, e, 0xFFFFFF00 );
|
|
|
- zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 28, e, 0xFFFFFF00 );
|
|
|
+ nText->setPosition( (Punkt)( kamMat * ( getPosition() - Punkt( 76, (int)( zModel()->maxP.y * getSize() ) + 30 ) ) ) );
|
|
|
+ nText->setText( Text( " (" ) + level + ")" );
|
|
|
+ nText->render( zRObj );
|
|
|
+ int teamF = zteam ? zteam->farbe : 0;
|
|
|
+ double teamStab = zteam ? zteam->maxStabilität : 0;
|
|
|
+ double teamEner = zteam ? zteam->maxEnergie : 0;
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 4, 150, teamF );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 25, 150, teamF );
|
|
|
+ int l = (int)( stabilität * 100 / ( maxStabilität + teamStab ) * 1.5 + 0.5 );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 1, l, 0xFF00FF00 );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 2, l, 0xFF00FF00 );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 3, l, 0xFF00FF00 );
|
|
|
+ int e = (int)( energie * 100 / ( maxEnergie + teamEner ) * 1.5 + 0.5 );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 26, e, 0xFFFFFF00 );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 27, e, 0xFFFFFF00 );
|
|
|
+ zRObj.drawLinieH( nText->getX() + 1, nText->getY() + 28, e, 0xFFFFFF00 );
|
|
|
+}
|
|
|
+
|
|
|
+void SpielObjekt::nimmSchaden( double &intensity, int sLevel )
|
|
|
+{
|
|
|
+ if( ( style | 0x1 ) != style )
|
|
|
+ {
|
|
|
+ intensity = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double originalIntens = intensity;
|
|
|
+ /*double schieldVal = intensity - intensity / calculateEnergieSchild();
|
|
|
+ double schieldEVal = schieldVal / ( calculateEnergieSchildEffizienz() / 100 );
|
|
|
+ if( schieldEVal > energie )
|
|
|
+ {
|
|
|
+ schieldEVal = energie;
|
|
|
+ schieldVal = schieldEVal * ( calculateEnergieSchildEffizienz() / 100 );
|
|
|
+ }
|
|
|
+ intensity -= schieldVal;
|
|
|
+ energie -= schieldEVal;*/
|
|
|
+ stabilität -= intensity;
|
|
|
+ akkuAbk = 1.5;
|
|
|
+ repAbk = 2;
|
|
|
+ if( stabilität > 0 && doesShotAddEp() )
|
|
|
+ {
|
|
|
+ float levelFactor = (float)sLevel / (float)level;
|
|
|
+ addEp( ( (float)originalIntens / 20 ) * levelFactor );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void SpielObjekt::addEp( float ep )
|
|
|
+{
|
|
|
+ this->ep += ep;
|
|
|
+ while( this->ep >= nextSkillEp )
|
|
|
+ {
|
|
|
+ level++;
|
|
|
+ this->ep -= nextSkillEp;
|
|
|
+ nextSkillEp *= 1.025f;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void SpielObjekt::calcDeadPlayerObject( Laser * zSchuss )
|
|
|
+{
|
|
|
+ Vertex hp;
|
|
|
+ Polygon2D a;
|
|
|
+ Polygon2D b;
|
|
|
+ Punkt pa;
|
|
|
+ Punkt pb;
|
|
|
+ if( calcHitPoint( zSchuss->getPosition() - zSchuss->getSpeed(), zSchuss->getSpeed(), hp ) )
|
|
|
+ {
|
|
|
+ zModel()->split( getObjectPos( hp ), getObjectDir( zSchuss->getSpeed() ) * 0.1f, "ship", a, b, pa, pb, []()
|
|
|
+ {
|
|
|
+ return rand() / (double)RAND_MAX;
|
|
|
+ } );
|
|
|
+ hp = ( hp * getSize() ).rotation( getDrehung() ) + getPosition();
|
|
|
+ pa = pa.rotation( getDrehung() ) + getPosition();
|
|
|
+ pb = pb.rotation( getDrehung() ) + getPosition();
|
|
|
+ Array< Polygon2D > *npaA = new Array< Polygon2D >();
|
|
|
+ npaA->add( a );
|
|
|
+ Model2DData *npdA = new Model2DData();
|
|
|
+ npdA->erstelleModell( npaA );
|
|
|
+ Array< Polygon2D > *npaB = new Array< Polygon2D >();
|
|
|
+ npaB->add( b );
|
|
|
+ Model2DData *npdB = new Model2DData();
|
|
|
+ npdB->erstelleModell( npaB );
|
|
|
+ if( deadPlayer )
|
|
|
+ deadPlayer->release();
|
|
|
+ deadPlayer = new DeadPlayer( npdA, npdB, pa, pb, getSpeed() * ( rand() / (float)RAND_MAX ), getSpeed() * ( rand() / (float)RAND_MAX ), getDrehung(), getDrehung(), getDrehungSpeed() * ( rand() / (float)RAND_MAX ), getDrehungSpeed() * ( rand() / (float)RAND_MAX ), zTextur( "ship" ) );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+DeadPlayer * SpielObjekt::sterben()
|
|
|
+{
|
|
|
+ amLeben = 0;
|
|
|
+ setCollision( 0 );
|
|
|
+ stabilität = 0;
|
|
|
+ return deadPlayer ? (DeadPlayer *)deadPlayer->getThis() : 0;
|
|
|
}
|
|
|
|
|
|
// constant
|
|
|
Team *SpielObjekt::zTeam() const
|
|
|
{
|
|
|
- return team;
|
|
|
+ if( ( style | 0x10 ) == style )
|
|
|
+ return 0;
|
|
|
+ return zteam;
|
|
|
+}
|
|
|
+
|
|
|
+bool SpielObjekt::doesShotAddEp() const
|
|
|
+{
|
|
|
+ return ( style | 0x20 ) == style;;
|
|
|
+}
|
|
|
+
|
|
|
+int SpielObjekt::getLevel() const
|
|
|
+{
|
|
|
+ return level;
|
|
|
+}
|
|
|
+
|
|
|
+int SpielObjekt::getObjektId() const
|
|
|
+{
|
|
|
+ return id;
|
|
|
}
|