GameState pre-work for subStates

This commit is contained in:
Dander7BD 2014-02-19 13:15:19 +01:00
parent ed6825a408
commit 8816efafc8
10 changed files with 357 additions and 2 deletions

View File

@ -211,6 +211,8 @@
<ClCompile Include="DLLMain.cpp" />
<ClCompile Include="GameClientState\GameClientState.cpp" />
<ClCompile Include="GameClientState\GameState.cpp" />
<ClCompile Include="GameClientState\GameStateUI.cpp" />
<ClCompile Include="GameClientState\GamingUI.cpp" />
<ClCompile Include="GameClientState\LanMenuState.cpp" />
<ClCompile Include="GameClientState\LevelLoader\LevelLoader.cpp" />
<ClCompile Include="GameClientState\LevelLoader\LevelParser.cpp" />
@ -221,6 +223,7 @@
<ClCompile Include="GameClientState\C_Object.cpp" />
<ClCompile Include="GameClientState\MainState.cpp" />
<ClCompile Include="GameClientState\NetLoadState.cpp" />
<ClCompile Include="GameClientState\RespawnUI.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientState\Camera_Basic.h" />
@ -237,6 +240,8 @@
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
<ClInclude Include="GameClientState\GameClientState.h" />
<ClInclude Include="GameClientState\GameState.h" />
<ClInclude Include="GameClientState\GameStateUI.h" />
<ClInclude Include="GameClientState\GamingUI.h" />
<ClInclude Include="GameClientState\LanMenuState.h" />
<ClInclude Include="GameClientState\LevelLoader\LevelLoader.h" />
<ClInclude Include="GameClientState\LevelLoader\LevelParser.h" />
@ -246,6 +251,7 @@
<ClInclude Include="GameClientState\LobbyAdminState.h" />
<ClInclude Include="GameClientState\MainState.h" />
<ClInclude Include="GameClientState\NetLoadState.h" />
<ClInclude Include="GameClientState\RespawnUI.h" />
<ClInclude Include="GameClientState\SharedStateContent.h" />
<ClInclude Include="Include\GameClient.h" />
<ClInclude Include="GameClientState\LobbyState.h" />

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
<ShowAllFiles>false</ShowAllFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>

View File

@ -35,7 +35,7 @@ namespace DanBias { namespace Client
/******************************************************************
* @param message of the event
* @return message or GameClientState::event_processed.
* @return message or a reference to GameClientState::event_processed.
******************************************************************/
virtual const NetEvent & DataRecieved( const NetEvent &message );
};

View File

@ -0,0 +1,17 @@
#include "GameStateUI.h"
using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
GameStateUI::GameStateUI()
{
this->nextState = GameStateUI::UIState_same;
}
GameStateUI::~GameStateUI() { /* Do nothing */ }
const GameStateUI::NetEvent & GameStateUI::DataRecieved( const GameStateUI::NetEvent &message )
{
/* Do nothing */
return message;
}

View File

@ -0,0 +1,58 @@
#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H
#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
#include "Utilities.h"
#include "NetworkClient.h"
namespace DanBias { namespace Client
{
class GameStateUI
{
public:
enum UIState
{
UIState_same,
UIState_gaming,
UIState_main_menu,
UIState_shut_down
};
typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent;
static const NetEvent event_processed;
GameStateUI();
virtual ~GameStateUI();
virtual UIState Update( float deltaTime ) = 0;
virtual bool HaveGUIRender() const = 0;
virtual bool HaveTextRender() const = 0;
virtual void RenderGUI() const = 0;
virtual void RenderText() const = 0;
virtual bool Release() = 0;
/******************************************************************
* @param message of the event
* @return message or a reference to GameStateUI::event_processed.
******************************************************************/
virtual const NetEvent & DataRecieved( const NetEvent &message );
protected:
UIState nextState;
};
} }
namespace Utility { namespace DynamicMemory
{ // template specializationto allowuse of dynamicmemory tools
template<>
inline void SafeDeleteInstance( ::DanBias::Client::GameStateUI *dynamicInstance )
{
if( dynamicInstance )
{
dynamicInstance->Release();
delete dynamicInstance;
}
}
} }
#endif

View File

@ -0,0 +1,153 @@
#include "GamingUI.h"
#include <Protocols.h>
using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
using namespace ::GameLogic;
GamingUI::GamingUI() :
GameStateUI()
{
/* Should never be called! */
this->input = nullptr;
this->netClient = nullptr;
this->camera = nullptr;
}
GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *camera ) :
GameStateUI()
{
this->input = input;
this->netClient = connection;
this->camera = camera;
}
GamingUI::~GamingUI() { /* Do nothing */ }
GameStateUI::UIState GamingUI::Update( float deltaTime )
{
return this->nextState;
}
bool GamingUI::HaveGUIRender() const
{
return false; // TODO: change to true when we want UI elements like a crosshair
}
bool GamingUI::HaveTextRender() const
{
return false; // TODO: change to true when we want UI elements like a chat window
}
void GamingUI::RenderGUI() const
{
// TODO: Render crosshairs and such here. Don't forget to adjust GamingUI::HaveGUIRender
}
void GamingUI::RenderText() const
{
// TODO: Render chattext and such here. Don't forget to adjust GamingUI::HaveGUIRender
}
bool GamingUI::Release()
{
// TODO: Release UI components here.
return true;
}
void GamingUI::ReadKeyInput()
{
if( this->input->IsKeyPressed(DIK_W) )
{
this->netClient->Send( Protocol_PlayerMovementForward() );
}
if( this->input->IsKeyPressed(DIK_S) )
{
this->netClient->Send( Protocol_PlayerMovementBackward() );
}
if( this->input->IsKeyPressed(DIK_A) )
{
this->netClient->Send( Protocol_PlayerMovementLeft() );
}
if( this->input->IsKeyPressed(DIK_D) )
{
this->netClient->Send( Protocol_PlayerMovementRight() );
}
// if( this->input->IsKeyPressed(DIK_R) )
// {
// if( !this->key_Reload_Shaders )
// {
//#ifdef _DEBUG
// Graphics::API::ReloadShaders();
//#endif
// this->key_Reload_Shaders = true;
// }
// }
// else
// this->key_Reload_Shaders = false;
//send delta mouse movement
{
this->camera->YawRight( this->input->GetYaw() * 0.017f );
this->camera->PitchDown( this->input->GetPitch() * 0.017f );
this->camera->UpdateOrientation();
this->netClient->Send( Protocol_PlayerLook(this->camera->GetLook(), this->camera->GetRight()) );
}
// shoot
//if( this->input->IsKeyPressed(DIK_Z) )
//{
// if( !this->key_Shoot )
// {
// Protocol_PlayerShot playerShot;
// playerShot.primaryPressed = true;
// playerShot.secondaryPressed = false;
// playerShot.utilityPressed = false;
// this->netClient->Send( playerShot );
// this->key_Shoot = true;
// }
//}
//else
// this->key_Shoot = false;
//if( this->input->IsKeyPressed(DIK_X) )
//{
// if( !this->key_Shoot )
// {
// Protocol_PlayerShot playerShot;
// playerShot.primaryPressed = false;
// playerShot.secondaryPressed = true;
// playerShot.utilityPressed = false;
// this->netClient->Send( playerShot );
// this->key_Shoot = true;
// }
//}
//else
// this->key_Shoot = false;
//if( this->input->IsKeyPressed(DIK_C) )
//{
// if( !this->key_Shoot )
// {
// Protocol_PlayerShot playerShot;
// playerShot.primaryPressed = false;
// playerShot.secondaryPressed = false;
// playerShot.utilityPressed = true;
// this->netClient->Send( playerShot );
// this->key_Shoot = true;
// }
//}
//else
// this->key_Shoot = false;
// jump
if( this->input->IsKeyPressed(DIK_SPACE) )
{
this->netClient->Send( Protocol_PlayerJump() );
}
}

View File

@ -0,0 +1,33 @@
#ifndef DANBIAS_CLIENT_GAMING_UI_H
#define DANBIAS_CLIENT_GAMING_UI_H
#include "GameStateUI.h"
#include "L_inputClass.h"
#include "Camera_FPSV2.h"
namespace DanBias { namespace Client
{
class GamingUI : public GameStateUI
{
public:
GamingUI( InputClass *input, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
virtual ~GamingUI();
UIState Update( float deltaTime );
bool HaveGUIRender() const;
bool HaveTextRender() const;
void RenderGUI() const;
void RenderText() const;
bool Release();
private:
InputClass *input;
::Oyster::Network::NetworkClient *netClient;
Camera_FPSV2 *camera;
GamingUI();
void ReadKeyInput();
};
} }
#endif

View File

@ -0,0 +1,58 @@
#include "RespawnUI.h"
using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
using namespace ::Utility::Value;
RespawnUI::RespawnUI() :
GameStateUI()
{
/* Should never be called! */
this->netClient = nullptr;
this->countDown = 0.0f;
}
RespawnUI::RespawnUI( NetworkClient *connection, float delay ) :
GameStateUI()
{
this->netClient = connection;
this->countDown = delay;
}
RespawnUI::~RespawnUI() { /* Do nothing */ }
GameStateUI::UIState RespawnUI::Update( float deltaTime )
{
this->countDown = Max( this->countDown - deltaTime, 0.0f );
return this->nextState;
}
bool RespawnUI::HaveGUIRender() const
{
return false; // TODO: change to true when we want UI elements like a crosshair
}
bool RespawnUI::HaveTextRender() const
{
return false; // TODO: change to true when we want UI elements like a chat window
}
void RespawnUI::RenderGUI() const
{
// TODO: We need?
}
void RespawnUI::RenderText() const
{
// TODO: Text countdown somewhere on screen would be nice
}
bool RespawnUI::Release()
{
// TODO: Release UI components here.
return true;
}

View File

@ -0,0 +1,29 @@
#ifndef DANBIAS_CLIENT_RESPAWN_UI_H
#define DANBIAS_CLIENT_RESPAWN_UI_H
#include "GameStateUI.h"
namespace DanBias { namespace Client
{
class RespawnUI : public GameStateUI
{
public:
RespawnUI( ::Oyster::Network::NetworkClient *connection, float delay );
virtual ~RespawnUI();
UIState Update( float deltaTime );
bool HaveGUIRender() const;
bool HaveTextRender() const;
void RenderGUI() const;
void RenderText() const;
bool Release();
private:
::Oyster::Network::NetworkClient *netClient;
float countDown;
RespawnUI();
};
} }
#endif

View File

@ -7,6 +7,7 @@
#ifndef _INPUTCLASS_H_
#define _INPUTCLASS_H_
#define NOMINMAX
#define DIRECTINPUT_VERSION 0x0800
#pragma comment(lib, "dinput8.lib")