[Orxonox-commit 5493] r10156 - in code/branches/minigame4DHS14: data/levels src/modules/mini4Dgame

richtero at orxonox.net richtero at orxonox.net
Thu Dec 4 17:16:21 CET 2014


Author: richtero
Date: 2014-12-04 17:16:20 +0100 (Thu, 04 Dec 2014)
New Revision: 10156

Modified:
   code/branches/minigame4DHS14/data/levels/4Dtest.oxw
   code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt
   code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
   code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
   code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.cc
   code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.h
   code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgamePrereqs.h
Log:
getting closer to a playable version

Modified: code/branches/minigame4DHS14/data/levels/4Dtest.oxw
===================================================================
--- code/branches/minigame4DHS14/data/levels/4Dtest.oxw	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/data/levels/4Dtest.oxw	2014-12-04 16:16:20 UTC (rev 10156)
@@ -12,42 +12,7 @@
 ?>
 
 <!-- Templates here -->
-<Template name=mini4Dgameboard>
-  <Mini4DgameBoard>
-    <attached>
-      <?lua
-        	for i = -90, 90, 60
-        	do
-        	?>
-        		<?lua
-        		for j = -90, 90, 60
-        		do
-        		?>
-        			<?lua
-        			for k = -90, 90, 60
-        			do
-        			?>
-        				<Model
-        				position="<?lua print(i) ?>,<?lua print(j) ?>,<?lua print(k) ?>"
-        				mesh="checkPoint.mesh"
-        				scale="5" />
-        			<?lua
-    		  		end
-    				?>
-    			<?lua
-    		  	end
-    			?>
-        	<?lua
-    		end
-    		?>
-    </attached>
-  </Mini4DgameBoard>
-</Template>
 
-<!--
-	<BlinkingBillboard position="0,0,0" frequency=0.6 amplitude=0.4 material="Flares/lensflare" colour="0,1,0">
-	</BlinkingBillboard>
- -->
 
 <Level
  gametype=Mini4Dgame
@@ -74,11 +39,44 @@
     
     <SpawnPoint position="-330,330,165" lookat="0,0,0" />
 
-	<Mini4DgameCenterpoint name=mini4Dgamecenter boardtemplate=mini4Dgameboard width=16 height=16 length=16 position="0,0,0">
+	<Mini4DgameBoard>
+    	<attached>
+      	<?lua
+        	for i = -90, 90, 60
+        	do
+        	?>
+        		<?lua
+        		for j = -90, 90, 60
+        		do
+        		?>
+        			<?lua
+        			for k = -90, 90, 60
+        			do
+        			?>
+        				<Model
+        				position="<?lua print(i) ?>,<?lua print(j) ?>,<?lua print(k) ?>"
+        				mesh="checkPoint.mesh"
+        				scale="5" />
+        			<?lua
+    		  		end
+    				?>
+    			<?lua
+    		  	end
+    			?>
+        	<?lua
+    		end
+    		?>
+    	</attached>
+    	
+  	</Mini4DgameBoard>
 
-    </Mini4DgameCenterpoint>
+<!--
+<attached>
+    <BlinkingBillboard position="0,0,0" frequency=0.6 amplitude=0.4 material="Flares/lensflare" colour="0,1,0" visabilaty=gone>
+	</BlinkingBillboard>
+</attached>
+-->
 
-
   </Scene>
 </Level>
 

Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt	2014-12-04 16:16:20 UTC (rev 10156)
@@ -2,7 +2,6 @@
   Mini4Dgame.cc
   #Mini4DgameAI.cc
   Mini4DgameBoard.cc
-  Mini4DgameCenterpoint.cc
 )
 
 ORXONOX_ADD_LIBRARY(mini4Dgame

Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc	2014-12-04 16:16:20 UTC (rev 10156)
@@ -49,8 +49,6 @@
 #include "gamestates/GSLevel.h"
 #include "chat/ChatManager.h"
 
-#include "Mini4DgameCenterpoint.h"
-
 namespace orxonox
 {
 
@@ -66,8 +64,8 @@
     {
         RegisterObject(Mini4Dgame);
 
-        this->center_ = 0;
         this->board_ = 0;
+        //ConsoleCommand("Mini4Dgame", "setStone", &Mini4Dgame::setStone).addShortcut().setAsInputCommand();
 
         // Set the type of Bots for this particular Gametype.
         //this->botclass_ = Class(Mini4DgameBot);
@@ -98,17 +96,19 @@
     */
     void Mini4Dgame::start()
     {
-        if (this->center_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place.
+        if (this->board_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place.
         {
+        	/*
         	if (this->board_ == NULL)
         	{
-        		this->board_ = new Mini4DgameBoard(this->center_->getContext());
+        		this->board_ = new Mini4DgameBoard(this->board_->getContext());
         		// Apply the template for the ball specified by the centerpoint.
         		this->board_->addTemplate(this->center_->getBoardtemplate());
         	}
+        	*/
 
         	// Attach the board to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
-        	this->center_->attach(this->board_);
+
         	this->board_->setPosition(0, 0, 0);
 
         }
@@ -176,9 +176,12 @@
         }
     }
 
-    static void Mini4Dgame::setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board)
+    //void Mini4Dgame::setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board)
+    void Mini4Dgame::setStone(int x,int y,int z,int w)//Vector4 move, const int playerColor)
     {
-    	board->makeMove(move,playerColor);
+    	Vector4 move = Vector4(x,y,z,w);
+        ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard>::begin();
+    	it->makeMove(move,1);//playerColor);
     }
 
     void Mini4Dgame::win(Mini4DgameWinner winner)

Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h	2014-12-04 16:16:20 UTC (rev 10156)
@@ -36,7 +36,6 @@
 
 #include "gametypes/Deathmatch.h"
 #include "mini4Dgame/Mini4DgamePrereqs.h"
-#include "Mini4DgameCenterpoint.h"
 #include "Mini4DgameBoard.h"
 
 namespace orxonox
@@ -70,11 +69,15 @@
 
             virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
 
-            void setCenterpoint(Mini4DgameCenterpoint* center)
-            	{ this->center_ = center; }
+            void setGameboard(Mini4DgameBoard* board)
+            	{ this->board_ = board; }
 
-            static void setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board);
+            Mini4DgameBoard* getBoard(void)
+            	{ return this->board_; }
 
+            //static void setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board);
+            static void setStone(int x,int y, int z, int w);//Vector4 move, const int playerColor);
+
             void win(Mini4DgameWinner winner);
 
         protected:
@@ -85,9 +88,7 @@
             void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
 
             //Player players[2];
-
-            WeakPtr<Mini4DgameCenterpoint> center_; //!< The centerpoint to which the objects are attached
-            WeakPtr<Mini4DgameBoard> board_;
+            Mini4DgameBoard* board_;
     };
 }
 

Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.cc
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.cc	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.cc	2014-12-04 16:16:20 UTC (rev 10156)
@@ -37,6 +37,7 @@
 #include "core/GameMode.h"
 
 #include "gametypes/Gametype.h"
+#include "graphics/BlinkingBillboard.h"
 
 #include "core/XMLPort.h"
 
@@ -56,7 +57,7 @@
 
         //this->registerVariables();
 
-        //initialize sound
+        //initialize board
         for(int i=0;i<4;i++){
         	for(int j=0;j<4;j++){
         		for(int k=0;k<4;k++){
@@ -66,6 +67,8 @@
         		}
         	}
         }
+
+        this->checkGametype();
     }
 
     /**
@@ -122,11 +125,23 @@
     	if(this->isValidMove(move))
     	{
     		this->board[(int)move.x][(int)move.y][(int)move.z][(int)move.w] = (mini4DgamePlayerColor::color) playerColor;
-    		//BlinkingBillboard* bb = new BlinkingBillboard(this->getContext());
-    		//bb->setPosition(0,0,0);
+			BlinkingBillboard* bb = new BlinkingBillboard(this->getContext());
+			orxout(user_status) << "Mini4Dgame: move.x " << move.x << endl;
+
+			bb->setPosition(60*(int)move.x-90,60*(int)move.y-90,60*(int)move.z-90);
+			bb->setFrequency(0.6);
+			bb->setAmplitude(0.1);
+			//bb->setMaterial("Flares/lensflare");
+			bb->setMaterial("Numbers/One");
+			bb->setColour(ColourValue(0,1,0));
+
+			this->attach(bb);
+
+
     		Mini4DgameWinner winner = this->getWinner();
     		if(winner.color_ != mini4DgamePlayerColor::none)
     		{
+    			orxout(user_status) << "Mini4Dgame: win!!!!!!!" << endl;
     			//win(winner);
     		}
     	}
@@ -836,4 +851,29 @@
     	}
     	return winner;
     }
+
+    /**
+    @brief
+        Is called when the gametype has changed.
+    */
+    void Mini4DgameBoard::changedGametype()
+    {
+        SUPER(Mini4DgameBoard, changedGametype);
+
+        // Check, whether it's still Mini4Dgame.
+        this->checkGametype();
+    }
+
+    /**
+    @brief
+        Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint.
+    */
+    void Mini4DgameBoard::checkGametype()
+    {
+        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Mini4Dgame)))
+        {
+            Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype().get());
+            Mini4DgameGametype->setGameboard(this);
+        }
+    }
 }

Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.h
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.h	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgameBoard.h	2014-12-04 16:16:20 UTC (rev 10156)
@@ -39,8 +39,6 @@
 
 #include "worldentities/StaticEntity.h"
 
-#include "Mini4DgameCenterpoint.h"
-
 namespace orxonox
 {
 
@@ -72,6 +70,9 @@
             void makeMove(const Vector4 move, const int playerColor);
             Mini4DgameWinner getWinner();
 
+            void changedGametype();
+            void checkGametype();
+
         private:
             //void registerVariables();
             int board[4][4][4][4]; //!< The logical board where the game takes place. board[row][column][height][number]

Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgamePrereqs.h
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgamePrereqs.h	2014-12-03 16:42:49 UTC (rev 10155)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4DgamePrereqs.h	2014-12-04 16:16:20 UTC (rev 10156)
@@ -69,7 +69,6 @@
 {
     class Mini4Dgame;
     class Mini4DgameBoard;
-    class Mini4DgameCenterpoint;
 }
 
 #endif /* _PongPrereqs_H__ */




More information about the Orxonox-commit mailing list