[Orxonox-commit 7767] r12359 - in code/branches/OrxoBlox_FS19: data/levels data/overlays src/modules/OrxoBlox

ahuwyler at orxonox.net ahuwyler at orxonox.net
Thu May 9 15:29:29 CEST 2019


Author: ahuwyler
Date: 2019-05-09 15:29:29 +0200 (Thu, 09 May 2019)
New Revision: 12359

Modified:
   code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
   code/branches/OrxoBlox_FS19/data/overlays/OrxoBloxHUD.oxo
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.h
Log:
fuer de jerome

Modified: code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
===================================================================
--- code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw	2019-05-09 13:29:29 UTC (rev 12359)
@@ -90,8 +90,6 @@
   </templates>
   <?lua include("includes/notifications.oxi") ?>
 
-  <WorldAmbientSound source="Ganymede.ogg" looping="true" playOnLoad="true"/>
-  
 
   <Scene
    ambientlight = "0.5, 0.5, 0.5"
@@ -104,19 +102,16 @@
     <!--<Model mesh="axes.mesh" scale=10 position="0,0,0" /> -->
 
 
-    <MovableEntity rotationrate=0 rotationaxis="0,0,1">
+    <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="90,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25 StoneTemplate=OrxoBloxstone WallTemplate=OrxoBloxwall position="-55,-75,0">
+        
       <attached>
-        <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="90,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25 StoneTemplate=OrxoBloxstone WallTemplate=OrxoBloxwall>
-        
-          <attached>
             <!-- Balken die das Spielfeld begrenzen. -->
-            <Model position="0,0,-49" mesh="cube.mesh" scale3D="45,1,1" />
-            <Model position="46,0,0" mesh="cube.mesh" scale3D="1,1,50"/>
-            <Model position="-46,0,0" mesh="cube.mesh" scale3D="1,1,50"/>
-          </attached>
-        </OrxoBloxCenterpoint>
+          <Model position="0,0,-49" mesh="cube.mesh" scale3D="45,1,1" />
+          <Model position="46,0,0" mesh="cube.mesh" scale3D="1,1,50"/>
+          <Model position="-46,0,0" mesh="cube.mesh" scale3D="1,1,50"/>
       </attached>
-    </MovableEntity>   
+    </OrxoBloxCenterpoint>
+      
   </Scene>
 </Level>
 

Modified: code/branches/OrxoBlox_FS19/data/overlays/OrxoBloxHUD.oxo
===================================================================
--- code/branches/OrxoBlox_FS19/data/overlays/OrxoBloxHUD.oxo	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/data/overlays/OrxoBloxHUD.oxo	2019-05-09 13:29:29 UTC (rev 12359)
@@ -1,70 +1,24 @@
 <Template name="OrxoBloxHUD">
   <OverlayGroup name="OrxoBloxHUD" scale = "1, 1">
     <OrxoBloxScore
-     position  = "0.05, 0.05"
+     position  = "0.9, 0.2"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
-     textsize  = 0.06
+     textsize  = 0.05
      colour    = "1.0, 1.0, 1.0, 1.0"
      align     = "left"
-
-     showleftplayer  = true
-     showrightplayer = false
-     showname        = true
-     showscore       = false
     />
 
-    <OrxoBloxScore
-     position  = "0.49, 0.05"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.06
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "right"
-
-     showleftplayer  = true
-     showrightplayer = false
-     showname        = false
-     showscore       = true
-    />
-
     <OverlayText
-     position  = "0.505, 0.05"
+     position  = "0.7, 0.20"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
-     textsize  = 0.06
+     textsize  = 0.05
      colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "center"
-
-     caption   = ":"
-    />
-
-    <OrxoBloxScore
-     position  = "0.51, 0.05"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.06
-     colour    = "1.0, 1.0, 1.0, 1.0"
      align     = "left"
 
-     showleftplayer  = false
-     showrightplayer = true
-     showname        = false
-     showscore       = true
+     caption   = "Points: "
     />
 
-    <OrxoBloxScore
-     position  = "0.95, 0.05"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.06
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "right"
-
-     showleftplayer  = false
-     showrightplayer = true
-     showname        = true
-     showscore       = false
-    />
   </OverlayGroup>
 </Template>

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-05-09 13:29:29 UTC (rev 12359)
@@ -169,11 +169,16 @@
         this->starttimer_.startTimer();
 
         // Set variable to temporarily force the player to spawn.
+        // Set variable to temporarily force the player to spawn.
+        bool temp = this->bForceSpawn_;
         this->bForceSpawn_ = true;
 
         // Call start for the parent class.
         Deathmatch::start();
 
+        // Reset the variable.
+        this->bForceSpawn_ = temp;
+
     }
 
     /**
@@ -183,6 +188,13 @@
     void OrxoBlox::end()
     {
         ChatManager::message("You suck!!");
+
+        if (Highscore::exists())
+        {
+            int score = this->getScore(this->getPlayer());
+            Highscore::getInstance().storeScore("Tetris", score, this->getPlayer());
+        }
+
         this->cleanup();
 
         // Call end for the parent class.
@@ -190,16 +202,9 @@
         GSLevel::startMainMenu();
     }
 
-    OrxoBloxShip* OrxoBlox::getPlayer()
+    PlayerInfo* OrxoBlox::getPlayer()
     {
-        if (playership == nullptr)
-        {
-            for (OrxoBloxShip* ship_ : ObjectList<OrxoBloxShip>())
-            {
-                playership = ship_;
-            }
-        }
-        return playership;
+        return this->player_;
     }
    
     void OrxoBlox::spawnPlayer(PlayerInfo* player)
@@ -216,7 +221,7 @@
 
     void OrxoBlox::LevelUp(){
         level_++;
-
+        this->playerScored(this->player_);// add points
         for(OrxoBloxStones* stone : this->stones_){
             int x_=(stone->getPosition()).x;
             int y_=(stone->getPosition()).y;

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h	2019-05-09 13:29:29 UTC (rev 12359)
@@ -72,7 +72,7 @@
             virtual void start() override; //!< Starts the OrxoBlox minigame.
             virtual void end() override; ///!< Ends the OrxoBlox minigame.
 
-            OrxoBloxShip* getPlayer();
+            PlayerInfo* getPlayer();
             void spawnPlayer(PlayerInfo* Player) override;
 
             void LevelUp();

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h	2019-05-09 13:29:29 UTC (rev 12359)
@@ -73,6 +73,7 @@
     class OrxoBloxWall;
     class OrxoBloxStones;
     class OrxoBloxShip;
+    class OrxoBloxScore;
 }
 
 #endif /* _OrxoBloxPrereqs_H__ */

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc	2019-05-09 13:29:29 UTC (rev 12359)
@@ -34,13 +34,11 @@
 #include "OrxoBloxScore.h"
 
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
 #include "util/Convert.h"
 
 #include "infos/PlayerInfo.h"
 
 #include "OrxoBlox.h"
-#include "sound/WorldSound.h" /////////////////////////////
 
 namespace orxonox
 {
@@ -55,12 +53,8 @@
         RegisterObject(OrxoBloxScore);
 
         this->owner_ = nullptr;
+        this->player_ = nullptr;
 
-        this->bShowName_ = true;
-        this->bShowScore_ = true;
-        this->bShowPlayer_ = true;
-    }
-
     /**
     @brief
         Destructor.
@@ -69,21 +63,9 @@
     {
     }
 
+    
     /**
     @brief
-        Method to create a OrxoBloxScore through XML.
-    */
-    void OrxoBloxScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(OrxoBloxScore, XMLPort, xmlelement, mode);
-
-        XMLPortParam(OrxoBloxScore, "showname",        setShowName,        getShowName,        xmlelement, mode).defaultValues(false);
-        XMLPortParam(OrxoBloxScore, "showscore",       setShowScore,       getShowScore,       xmlelement, mode).defaultValues(false);
-        XMLPortParam(OrxoBloxScore, "showplayer",  setShowPlayer,  getShowPlayer,  xmlelement, mode).defaultValues(false);
-    }
-
-    /**
-    @brief
         Is called each tick.
         Creates and sets the caption to be displayed by the OrxoBloxScore.
     @param dt
@@ -96,48 +78,20 @@
         // If the owner is set. The owner being a OrxoBlox game.
         if (this->owner_ != nullptr)
         {
-            if (!this->owner_->hasEnded())
+            std::string score("0");
+            if(!this->owner_->hasEnded())
             {
-                // Get the player.
-                //Fehlermeldung
-                //player1_ = this->owner_->getPlayer();
+                //get the player
+                player_ = this->owner_->getPlayer();
             }
 
-            std::string name1;
-
-            std::string score1("0");
-
-            // Save the name and score of each player as a string.
-            if (player1_ != nullptr)
+            if(this->owner_->hasStarted())
             {
-                name1 = player1_->getName();
-                score1 = multi_cast<std::string>(this->owner_->getScore(player1_));
+                // Save the name and score of each player as a string.
+                if (player_ != nullptr)
+                    score = multi_cast<std::string>(this->owner_->getScore(player_));
             }
-
-            // Assemble the strings, depending on what should all be displayed.
-            std::string output1;
-            if (this->bShowPlayer_)
-            {
-                if (this->bShowName_ && this->bShowScore_ && player1_ != nullptr)
-                    output1 = name1 + " - " + score1;
-                else if (this->bShowScore_)
-                    output1 = score1;
-                else if (this->bShowName_)
-                    output1 = name1;
-            }
-
-            std::string output("OrxoBlox");
-            /* Keine Ahnung wofuer das gut ist.
-
-            if (this->bShowName_ || this->bShowScore_)
-            {
-                if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
-                    output = output1 + ':' + output2;
-                else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
-                    output = output1 + output2;
-            }*/
-
-            this->setCaption(output);
+            this->setCaption(score);
         }
     }
 

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.h	2019-05-09 13:08:21 UTC (rev 12358)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.h	2019-05-09 13:29:29 UTC (rev 12359)
@@ -60,72 +60,12 @@
             virtual ~OrxoBloxScore();
 
             virtual void tick(float dt) override; //!< Creates and sets the caption to be displayed by the OrxoBloxScore.
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
             virtual void changedOwner() override; //!< Is called when the owner changes.
 
-            /**
-            @brief Set whether the OrxoBloxScore displays the players' names.
-            @param value If true the players' names are displayed.
-            */
-            inline void setShowName(bool value)
-                { this->bShowName_ = value; }
-            /**
-            @brief Get whether the OrxoBloxScore displays the players' names.
-            @return Returns true if the players' names are displayed, false otherwise.
-            */
-            inline bool getShowName() const
-                { return this->bShowName_; }
 
-            /**
-            @brief Set whether the OrxoBloxScore displays the players' scores.
-            @param value If true the players' scores are displayed.
-            */
-            inline void setShowScore(bool value)
-                { this->bShowScore_ = value; }
-            /**
-            @brief Get whether the OrxoBloxScore displays the players' scores.
-            @return Returns true if the players' scores are displayed, false otherwise.
-            */
-            inline bool getShowScore() const
-                { return this->bShowScore_; }
-
-            /**
-            @brief Set whether the OrxoBloxScore displays the left player.
-            @param value If true the left player is displayed.
-            */
-            inline void setShowPlayer(bool value)
-                { this->bShowPlayer_ = value; }
-            /**
-            @brief Get whether the OrxoBloxScore displays the left player.
-            @return Returns true if the left player is displayed, false otherwise.
-            */
-            inline bool getShowPlayer() const
-                { return this->bShowPlayer_; }
-
-/*
-            /**
-            @brief Set whether the OrxoBloxScore displays the right player.
-            @param value If true the right player is displayed.
-            
-            inline void setShowRightPlayer(bool value)
-                { this->bShowRightPlayer_ = value; }
-            /**
-            @brief Get whether the OrxoBloxScore displays the right player.
-            @return Returns true if the right player is displayed, false otherwise.
-            
-            inline bool getShowRightPlayer() const
-                { return this->bShowRightPlayer_; }
-*/
         private:
             OrxoBlox* owner_; //!< The OrxoBlox game that owns this OrxoBloxScore.
-            bool bShowName_; //!< Whether the names of the players are shown.
-            bool bShowScore_; //!< Whether the score of the players is shown.
-            bool bShowPlayer_; //!< Whether the left player is shown.
-            //bool bShowRightPlayer_; //!< Whether the right player is shown.
-            WeakPtr<PlayerInfo> player1_; //!< Store information about left player permanently.
-            WeakPtr<PlayerInfo> player2_; //!< Same for the right player. To end the game properly.
-            WorldSound* scoreSound_;
-
+            PlayerInfo* player_; //!< Store information about the player permanently.
     };
 }
 #endif /* _OrxoBloxScore_H__ */



More information about the Orxonox-commit mailing list