Commit ae574bf2 authored by 魔大农's avatar 魔大农

Added game phases

parent c47cd355
No preview for this file type
No preview for this file type
......@@ -6,7 +6,8 @@
URHO3D_DEFINE_APPLICATION_MAIN(MasterControl);
MasterControl::MasterControl(Context *context):
Application(context)
Application(context),
gamePhase_{GamePhase::PLAYER1PICKS}
{
}
......@@ -42,7 +43,6 @@ void MasterControl::Exit()
engine_->Exit();
}
void MasterControl::CreateScene()
{
world.scene = new Scene(context_);
......@@ -58,6 +58,7 @@ void MasterControl::CreateScene()
tableModel->SetModel(cache_->GetResource<Model>("Models/Plane.mdl"));
tableModel->SetMaterial(cache_->GetResource<Material>("Resources/Materials/Basic.xml"));
//Create board and pieces
new Board(context_, this);
for (int p = 0; p < 16; ++p){
Piece* newPiece = new Piece(context_, this, std::bitset<4>(p));
......@@ -66,6 +67,7 @@ void MasterControl::CreateScene()
}
}
void MasterControl::CreateLights()
{
//Add a directional light to the world. Enable cascaded shadows on it
......@@ -90,3 +92,17 @@ void MasterControl::CreateLights()
pointLight->SetRange(42.0f);
pointLight->SetColor(Color(0.75f, 1.0f, 0.75f));
}
void MasterControl::NextPhase()
{
switch (gamePhase_) {
case GamePhase::PLAYER1PICKS: gamePhase_ = GamePhase::PLAYER2PUTS;
break;
case GamePhase::PLAYER2PUTS: gamePhase_ = GamePhase::PLAYER2PICKS;
break;
case GamePhase::PLAYER2PICKS: gamePhase_ = GamePhase::PLAYER1PUTS;
break;
case GamePhase::PLAYER1PUTS: gamePhase_ = GamePhase::PLAYER1PICKS;
break;
}
}
......@@ -16,6 +16,8 @@ using namespace Urho3D;
class QuartoCam;
class InputMaster;
enum class GamePhase{PLAYER1PICKS, PLAYER2PUTS, PLAYER2PICKS, PLAYER1PUTS};
typedef struct GameWorld
{
SharedPtr<QuartoCam> camera;
......@@ -46,10 +48,13 @@ public:
void Exit();
void CreateLights();
inline GamePhase GetGamePhase() const noexcept { return gamePhase_; }
private:
GamePhase gamePhase_;
Node* movingLightNode_;
void CreateScene();
void NextPhase();
void HandleUpdate(StringHash eventType, VariantMap& eventData);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment