Merge with GameServer

This commit is contained in:
Robin Engman 2014-02-19 09:00:00 +01:00
commit 2fac21584f
79 changed files with 2151 additions and 813 deletions

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ Bin/DLL/
Bin/Executable/
Obj/
External/
Code/Game/GameClient/GameClient.vcxproj.user

View File

@ -64,7 +64,12 @@ namespace DanBias
{
WindowShell::CreateConsoleWindow();
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
WindowShell::WINDOW_INIT_DESC winDesc;
winDesc.windowSize.x = 1280;
winDesc.windowSize.y = 720;
if(! data.window->CreateWin(winDesc) )
return DanBiasClientReturn_Error;
if( FAILED( InitDirect3D() ) )
@ -136,9 +141,11 @@ namespace DanBias
Oyster::Graphics::API::Option p;
p.modelPath = L"..\\Content\\Models\\";
p.texturePath = L"..\\Content\\Textures\\";
Oyster::Graphics::API::SetOptions(p);
p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f );
//! @todo fix proper amb value
p.AmbientValue = 1.0f;
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess)
return E_FAIL;
return S_OK;
}

View File

@ -201,7 +201,9 @@
<ClCompile Include="DanBiasGame_Impl.cpp" />
<ClCompile Include="GameClientState\Camera_Basic.cpp" />
<ClCompile Include="GameClientState\Camera.cpp" />
<ClCompile Include="GameClientState\Camera_BasicV2.cpp" />
<ClCompile Include="GameClientState\Camera_FPS.cpp" />
<ClCompile Include="GameClientState\Camera_FPSV2.cpp" />
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
@ -226,7 +228,9 @@
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />
<ClInclude Include="GameClientState\Buttons\ButtonRectangle.h" />
<ClInclude Include="GameClientState\Camera.h" />
<ClInclude Include="GameClientState\Camera_BasicV2.h" />
<ClInclude Include="GameClientState\Camera_FPS.h" />
<ClInclude Include="GameClientState\Camera_FPSV2.h" />
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />

View File

@ -21,21 +21,37 @@ namespace DanBias
ButtonRectangle()
: EventButtonGUI(), width(0), height(0)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButtonGUI(textureName, buttonText,
textColor, backColor, hoverColor, pressedColor,
owner, pos, size, resize)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButtonGUI(textureName, buttonText,
textColor, backColor, hoverColor, pressedColor,
func, pos, size, resize)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButtonGUI(textureName, buttonText,
textColor, backColor, hoverColor, pressedColor,
func, owner, pos, size, resize)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButtonGUI(textureName, buttonText,
textColor, backColor, hoverColor, pressedColor,
func, owner, userData, pos, size, resize)
{}
virtual ~ButtonRectangle()
{}

View File

@ -30,32 +30,40 @@ namespace DanBias
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
{
public:
EventButtonGUI()
: EventButton(), pos(0, 0), size(0, 0), texture(NULL), buttonText(""), textColor(1, 1, 1, 1)
{}
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText),
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{
CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
}
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText),
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{
CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
}
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText),
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{
CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
}
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText),
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{
CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
@ -77,23 +85,23 @@ namespace DanBias
if(EventButton<Owner>::Enabled())
{
// let the using dev decide what is rendered
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float4(1.0f, 1.0f, 1.0f, 1.0f));
//Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float4(1.0f, 1.0f, 1.0f, 1.0f));
//Render att xPos and yPos
//With width and height
//if(EventButton<Owner>::GetState() == ButtonState_None)
//{
// Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
//}
//else if(EventButton<Owner>::GetState() == ButtonState_Hover)
//{
// Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f));
//}
//else
//{
// Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
//}
if(EventButton<Owner>::GetState() == ButtonState_None)
{
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, backColor);
}
else if(EventButton<Owner>::GetState() == ButtonState_Hover)
{
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, hoverColor);
}
else
{
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, pressedColor);
}
}
}
@ -102,7 +110,7 @@ namespace DanBias
{
if(buttonText.size() > 0)
{
Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, 0.0f), size*2.0f, size.y * 0.5f, textColor);
Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, -0.001f), size, size.y * 0.5f, textColor);
}
}
@ -126,6 +134,10 @@ namespace DanBias
std::wstring buttonText;
Oyster::Math::Float4 textColor;
Oyster::Math::Float4 backColor;
Oyster::Math::Float4 hoverColor;
Oyster::Math::Float4 pressedColor;
};
}
}

View File

@ -20,7 +20,7 @@ namespace DanBias { namespace Client
{
public:
TextField();
TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height );
TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, ::Oyster::Math::Float4 backColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height );
virtual ~TextField();
virtual void RenderText();
@ -62,8 +62,8 @@ namespace DanBias { namespace Client
}
template<typename Owner>
TextField<Owner>::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize )
: ButtonRectangle( backgroundTexture, L"", textColor, owner, pos, size, resize )
TextField<Owner>::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, ::Oyster::Math::Float4 backColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize )
: ButtonRectangle( backgroundTexture, L"", textColor, backColor, backColor, backColor, owner, pos, size, resize )
{
this->fontHeight = 0.025f;
this->lineSpacing = 0.001f;

View File

@ -0,0 +1,117 @@
#include "Camera_BasicV2.h"
using namespace ::Oyster::Math3D;
Camera_BasicV2::Camera_BasicV2()
{
this->translation = Float3::null;
this->rotation = Quaternion::identity;
this->projection = Float4x4::identity;
}
Camera_BasicV2::Camera_BasicV2( const Float3 &position, const Quaternion &rotation, const Float4x4 &projection )
{
this->translation = position;
this->rotation = rotation;
this->projection = projection;
}
Camera_BasicV2::~Camera_BasicV2() {}
Camera_BasicV2 & Camera_BasicV2::operator = ( const Camera_BasicV2 &camera )
{
this->translation = camera.translation;
this->rotation = camera.rotation;
this->projection = camera.projection;
return *this;
}
void Camera_BasicV2::SetPosition( const Float3 &translation )
{
this->translation = translation;
}
void Camera_BasicV2::SetRotation( const Quaternion &rotation )
{
this->rotation = rotation;
}
void Camera_BasicV2::SetAngular( const Float3 &axis )
{
this->rotation = Rotation( axis );
}
void Camera_BasicV2::SetProjection( const Float4x4 &matrix )
{
this->projection = matrix;
}
void Camera_BasicV2::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
{
ProjectionMatrix_Orthographic( width, height, nearClip, farClip, this->projection );
}
void Camera_BasicV2::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
{
ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, this->projection );
}
void Camera_BasicV2::Move( const Float3 &deltaPosition )
{
this->translation += deltaPosition;
}
void Camera_BasicV2::Rotate( const Quaternion &deltaRotation )
{
this->rotation *= deltaRotation;
}
void Camera_BasicV2::Rotate( const Float3 &deltaAngularAxis )
{
this->rotation *= Rotation( deltaAngularAxis );
}
const Float3 & Camera_BasicV2::GetPosition() const
{
return this->translation;
}
Float3 & Camera_BasicV2::GetAngularAxis( Float3 &targetMem ) const
{
return targetMem = AngularAxis( this->rotation );
}
Float3 Camera_BasicV2::GetNormalOf( const Float3 &axis ) const
{
return WorldAxisOf( this->rotation, axis );
}
const Quaternion & Camera_BasicV2::GetRotation() const
{
return this->rotation;
}
Float3x3 & Camera_BasicV2::GetRotationMatrix( Float3x3 &targetMem ) const
{
return RotationMatrix( this->rotation, targetMem );
}
Float4x4 & Camera_BasicV2::GetRotationMatrix( Float4x4 &targetMem ) const
{
return RotationMatrix( this->rotation, targetMem );
}
Float4x4 & Camera_BasicV2::GetViewMatrix( Float4x4 &targetMem ) const
{
return ViewMatrix( this->rotation, this->translation, targetMem );
}
const Float4x4 & Camera_BasicV2::GetProjectionMatrix() const
{
return this->projection;
}
Float4x4 & Camera_BasicV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
{
return TransformMatrix( this->projection, this->GetViewMatrix(), targetMem );
}

View File

@ -0,0 +1,42 @@
#ifndef CAMERA_BASIC_V2_H
#define CAMERA_BASIC_V2_H
#include "OysterMath.h"
class Camera_BasicV2
{
public:
Camera_BasicV2();
Camera_BasicV2( const ::Oyster::Math::Float3 &position, const ::Oyster::Math::Quaternion &rotation, const ::Oyster::Math::Float4x4 &projection );
virtual ~Camera_BasicV2();
Camera_BasicV2 & operator = ( const Camera_BasicV2 &camera );
void SetPosition( const ::Oyster::Math::Float3 &translation );
void SetRotation( const ::Oyster::Math::Quaternion &rotation );
void SetAngular( const ::Oyster::Math::Float3 &axis );
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
void Move( const ::Oyster::Math::Float3 &deltaPosition );
void Rotate( const ::Oyster::Math::Quaternion &deltaRotation );
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
const ::Oyster::Math::Float3 & GetPosition() const;
::Oyster::Math::Float3 & GetAngularAxis( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
::Oyster::Math::Float3 GetNormalOf( const ::Oyster::Math::Float3 &axis ) const;
const ::Oyster::Math::Quaternion & GetRotation() const;
::Oyster::Math::Float3x3 & GetRotationMatrix( ::Oyster::Math::Float3x3 &targetMem ) const;
::Oyster::Math::Float4x4 & GetRotationMatrix( ::Oyster::Math::Float4x4 &targetMem ) const;
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
private:
::Oyster::Math::Float3 translation;
mutable ::Oyster::Math::Quaternion rotation;
::Oyster::Math::Float4x4 projection;
};
#endif

View File

@ -0,0 +1,186 @@
#include "Camera_FPSV2.h"
#include "Utilities.h"
using namespace ::Oyster::Math3D;
using namespace ::Utility::Value;
Camera_FPSV2::Camera_FPSV2()
{ // this->head is default set to identity uniformprojection at origo
this->pitchUp = 0.0f;
this->headOffset =
this->body.translation = Float3::null;
this->body.rotation = Quaternion::identity;
}
Camera_FPSV2::~Camera_FPSV2() {}
Camera_FPSV2 & Camera_FPSV2::operator = ( const Camera_FPSV2 &camera )
{
this->head = camera.head;
this->pitchUp = camera.pitchUp;
this->headOffset = camera.headOffset;
this->body.translation = camera.body.translation;
this->body.rotation = camera.body.rotation;
return *this;
}
void Camera_FPSV2::SetHeadOffset( const Float3 &translation )
{
this->head.Move( translation - this->headOffset );
this->headOffset = translation;
}
void Camera_FPSV2::SetPosition( const Float3 &translation )
{
this->head.Move( translation - this->body.translation );
this->body.translation = translation;
}
void Camera_FPSV2::SetRotation( const Quaternion &rotation )
{
this->body.rotation = rotation;
this->head.SetRotation( rotation * Rotation(this->pitchUp, this->GetNormalOf(Float3::standard_unit_x) ) );
}
void Camera_FPSV2::SetAngular( const Float3 &axis )
{
this->SetRotation( Rotation(axis) );
}
void Camera_FPSV2::SetProjection( const Float4x4 &matrix )
{
this->head.SetProjection( matrix );
}
void Camera_FPSV2::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
{
this->head.SetOrthographicProjection( width, height, nearClip, farClip );
}
void Camera_FPSV2::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
{
this->head.SetPerspectiveProjection( verticalFoV, aspectRatio, nearClip, farClip );
}
void Camera_FPSV2::UpdateOrientation()
{
Float4x4 orientation;
OrientationMatrix( this->body.rotation, this->body.translation, orientation );
this->head.SetPosition( (orientation * Float4(this->headOffset, 1.0f)).xyz );
}
void Camera_FPSV2::SnapUpToNormal( const Float3 &normal )
{
this->body.rotation = Rotation( SnapAngularAxis(AngularAxis(this->body.rotation), WorldAxisOf(this->body.rotation, Float3::standard_unit_y), normal) );
this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp * Float3::standard_unit_x) );
}
void Camera_FPSV2::Move( const Float3 &deltaPosition )
{
this->head.Move( deltaPosition );
this->body.translation += deltaPosition;
}
void Camera_FPSV2::Rotate( const Quaternion &deltaRotation )
{
this->head.Rotate( deltaRotation );
this->body.rotation *= deltaRotation;
}
void Camera_FPSV2::Rotate( const Float3 &deltaAngularAxis )
{
this->Rotate( Rotation(deltaAngularAxis) );
}
void Camera_FPSV2::MoveForward( Float distance )
{
this->MoveBackward( -distance );
}
void Camera_FPSV2::MoveBackward( Float distance )
{
this->Move( distance * WorldAxisOf(this->body.rotation, Float3::standard_unit_z) );
}
void Camera_FPSV2::StrafeRight( Float distance )
{
this->Move( distance * WorldAxisOf(this->body.rotation, Float3::standard_unit_x) );
}
void Camera_FPSV2::StrafeLeft( Float distance )
{
this->StrafeRight( -distance );
}
void Camera_FPSV2::PitchUp( Float radian )
{
this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi );
this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, Float3::standard_unit_x) );
}
void Camera_FPSV2::PitchDown( Float radian )
{
this->PitchUp( -radian );
}
void Camera_FPSV2::YawRight( Float radian )
{
this->YawLeft( -radian );
}
void Camera_FPSV2::YawLeft( Float radian )
{
Quaternion deltaRotation = Rotation( radian, WorldAxisOf(this->body.rotation, Float3::standard_unit_y) );
this->Rotate( deltaRotation );
}
const Float3 & Camera_FPSV2::GetHeadOffset() const
{
return this->headOffset;
}
const Float3 & Camera_FPSV2::GetPosition() const
{
return this->body.translation;
}
Float4x4 & Camera_FPSV2::GetViewMatrix( Float4x4 &targetMem ) const
{
return this->head.GetViewMatrix( targetMem );
}
const Float4x4 & Camera_FPSV2::GetProjectionMatrix() const
{
return this->head.GetProjectionMatrix();
}
Float4x4 & Camera_FPSV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
{
return this->head.GetViewsProjMatrix( targetMem );
}
Float3 Camera_FPSV2::GetNormalOf( const Float3 &axis ) const
{
return this->head.GetNormalOf( axis );
}
Float3 Camera_FPSV2::GetRight() const
{
return WorldAxisOf( this->body.rotation, Float3::standard_unit_x );
}
Float3 Camera_FPSV2::GetUp() const
{
return WorldAxisOf( this->body.rotation, Float3::standard_unit_y );
}
Float3 Camera_FPSV2::GetLook() const
{
return this->head.GetNormalOf( -Float3::standard_unit_z );
}
Float3 Camera_FPSV2::GetForward() const
{
return WorldAxisOf( this->body.rotation, -Float3::standard_unit_z );
}

View File

@ -0,0 +1,63 @@
#ifndef CAMERA_FPSV2_H
#define CAMERA_FPSV2_H
#include "OysterMath.h"
#include "Camera_BasicV2.h"
class Camera_FPSV2
{
public:
Camera_FPSV2();
virtual ~Camera_FPSV2();
Camera_FPSV2 & operator = ( const Camera_FPSV2 &camera );
void SetHeadOffset( const ::Oyster::Math::Float3 &translation );
void SetPosition( const ::Oyster::Math::Float3 &translation );
void SetRotation( const ::Oyster::Math::Quaternion &rotation );
void SetAngular( const ::Oyster::Math::Float3 &axis );
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
void UpdateOrientation();
void SnapUpToNormal( const ::Oyster::Math::Float3 &normal );
void Move( const ::Oyster::Math::Float3 &deltaPosition );
void Rotate( const ::Oyster::Math::Quaternion &deltaRotation );
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
void MoveForward( ::Oyster::Math::Float distance );
void MoveBackward( ::Oyster::Math::Float distance );
void StrafeRight( ::Oyster::Math::Float distance );
void StrafeLeft( ::Oyster::Math::Float distance );
void PitchUp( ::Oyster::Math::Float radian );
void PitchDown( ::Oyster::Math::Float radian );
void YawRight( ::Oyster::Math::Float radian );
void YawLeft( ::Oyster::Math::Float radian );
const ::Oyster::Math::Float3 & GetHeadOffset() const;
const ::Oyster::Math::Float3 & GetPosition() const;
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
::Oyster::Math::Float3 GetNormalOf( const ::Oyster::Math::Float3 &axis ) const;
::Oyster::Math::Float3 GetRight() const;
::Oyster::Math::Float3 GetUp() const;
::Oyster::Math::Float3 GetLook() const;
::Oyster::Math::Float3 GetForward() const;
private:
Camera_BasicV2 head;
::Oyster::Math::Float pitchUp;
::Oyster::Math::Float3 headOffset;
struct
{
::Oyster::Math::Float3 translation;
::Oyster::Math::Quaternion rotation;
} body;
};
#endif

View File

@ -3,9 +3,14 @@
using namespace DanBias::Client;
using namespace ::Oyster::Network;
const GameClientState::NetEvent GameClientState::event_processed = GameClientState::NetEvent();
GameClientState::GameClientState() {}
GameClientState::~GameClientState() {}
void GameClientState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
{ /* do nothing */ }
const GameClientState::NetEvent & GameClientState::DataRecieved( const GameClientState::NetEvent &message )
{
/* do nothing */
return message;
}

View File

@ -22,7 +22,9 @@ namespace DanBias { namespace Client
ClientState_Quit
};
public:
typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent;
static const NetEvent event_processed;
GameClientState();
virtual ~GameClientState();
virtual bool Init( SharedStateContent &shared ) = 0;
@ -31,7 +33,11 @@ namespace DanBias { namespace Client
virtual bool Release() = 0;
virtual void ChangeState( ClientState next ) = 0;
virtual void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
/******************************************************************
* @param message of the event
* @return message or GameClientState::event_processed.
******************************************************************/
virtual const NetEvent & DataRecieved( const NetEvent &message );
};
} }

View File

@ -2,7 +2,7 @@
#include "DllInterfaces/GFXAPI.h"
#include <Protocols.h>
#include "NetworkClient.h"
#include "Camera_FPS.h"
#include "Camera_FPSV2.h"
#include <GameServerAPI.h>
#include "C_obj/C_Player.h"
@ -17,6 +17,7 @@ using namespace ::Oyster::Math3D;
using namespace ::GameLogic;
using namespace ::Utility::DynamicMemory;
using namespace ::Utility::String;
using namespace ::Utility::Value;
struct GameState::MyData
{
@ -35,8 +36,10 @@ struct GameState::MyData
bool key_Shoot;
bool key_Jump;
bool key_Reload_Shaders;
C_Player player;
Camera_FPS camera;
Camera_FPSV2 camera;
int myId;
@ -76,9 +79,14 @@ bool GameState::Init( SharedStateContent &shared )
this->privData->staticObjects = &shared.staticObjects;
this->privData->dynamicObjects = &shared.dynamicObjects;
Graphics::API::Option gfxOp = Graphics::API::GetOption();
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
this->privData->camera.SetPerspectiveProjection( Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
//tell server ready
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
return true;
}
@ -98,6 +106,9 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
{
this->privData->myId = id;
this->privData->camera.SetPosition( this->privData->player.getPos() );
Float3 offset = Float3( 0.0f );
offset.y = this->privData->player.getScale().y * 0.9f;
this->privData->camera.SetHeadOffset( offset );
this->privData->camera.UpdateOrientation();
}
}
@ -113,6 +124,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
GameClientState::ClientState GameState::Update( float deltaTime )
{
this->ReadKeyInput();
return this->privData->nextState;
}
@ -134,7 +146,8 @@ bool GameState::Render()
auto dynamicObject = this->privData->dynamicObjects->begin();
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
{
dynamicObject->second->Render();
if( dynamicObject->second )
dynamicObject->second->Render();
}
Oyster::Graphics::API::EndFrame();
@ -216,11 +229,25 @@ void GameState::ReadKeyInput()
else
this->privData->key_strafeRight = false;
if( this->privData->input->IsKeyPressed(DIK_R) )
{
if( !this->privData->key_Reload_Shaders )
{
//this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
#ifdef _DEBUG
Graphics::API::ReloadShaders();
#endif
this->privData->key_Reload_Shaders = true;
}
}
else
this->privData->key_Reload_Shaders = false;
//send delta mouse movement
{
this->privData->camera.YawRight( -this->privData->input->GetYaw() );
this->privData->camera.PitchUp( this->privData->input->GetPitch() );
this->privData->camera.YawRight( this->privData->input->GetYaw() * 0.017f );
this->privData->camera.PitchDown( this->privData->input->GetPitch() * 0.017f );
this->privData->camera.UpdateOrientation();
privData->nwClient->Send( Protocol_PlayerLook(this->privData->camera.GetLook(), this->privData->camera.GetRight()) );
@ -285,13 +312,22 @@ void GameState::ReadKeyInput()
// TODO: implement sub-menu
}
void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
{
CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data.
if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend )
{ // TODO: Reconnect
const char *breakpoint = "temp trap";
this->privData->nwClient->Disconnect();
this->ChangeState( GameClientState::ClientState_Main );
}
// fetching the id data.
short ID = message.args.data.protocol[0].value.netShort;
if( ProtocolIsGameplay(ID) )
{
CustomNetProtocol data = message.args.data.protocol;
switch(ID)
{
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
@ -307,13 +343,13 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
(*this->privData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position );
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectScale:
{
Protocol_ObjectScale decoded(data);
(*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale );
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectRotation:
{
Protocol_ObjectRotation decoded(data);
@ -321,11 +357,11 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
// if is this player. Remember to change camera
if( this->privData->myId == decoded.object_ID )
this->privData->camera.SetAngular( AngularAxis(rotation) );
this->privData->camera.SetRotation( rotation );
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectPositionRotation:
{
Protocol_ObjectPositionRotation decoded(data);
@ -336,14 +372,17 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
if( this->privData->myId == decoded.object_ID )
{
this->privData->camera.SetPosition( position );
this->privData->camera.SetAngular( AngularAxis(rotation) );
this->privData->camera.SetRotation( rotation );
}
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
object->setPos( position );
object->setRot( rotation );
if( object )
{
object->setPos( position );
object->setRot( rotation );
}
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectDisabled:
{
@ -356,7 +395,7 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
this->privData->dynamicObjects->erase( object );
}
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectCreate:
{
Protocol_ObjectCreate decoded(data);
@ -377,13 +416,13 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectCreatePlayer:
{
Protocol_ObjectCreatePlayer decoded(data);
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotation, decoded.scale, decoded.owner );
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner );
}
break;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
@ -402,4 +441,6 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
default: break;
}
}
return message;
}

View File

@ -26,7 +26,7 @@ namespace DanBias { namespace Client
bool Release()override;
void ChangeState( ClientState next );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
const NetEvent & DataRecieved( const NetEvent &message );
private:
struct MyData;

View File

@ -55,12 +55,13 @@ bool LanMenuState::Init( SharedStateContent &shared )
this->privData->nwClient = shared.network;
this->privData->input = shared.input;
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
// create guiElements
this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float4(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
this->privData->connectIP = new TextField<LanMenuState*>( L"color_white.png", Float4(1.0f), Float4(0.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
this->privData->connectIP->ReserveLines( 1 );
this->privData->connectIP->AppendText( L"127.0.0.1" );
//this->privData->connectIP->AppendText( L"127.0.0.1" );
this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server
this->privData->connectIP->SetFontHeight( 0.08f );
this->privData->connectIP->SetLineSpacing( 0.005f );
this->privData->connectIP->SetTopAligned();
@ -68,10 +69,10 @@ bool LanMenuState::Init( SharedStateContent &shared )
this->privData->guiElements.AddButton( this->privData->connectIP );
ButtonRectangle<LanMenuState*> *guiElements;
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float4(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
guiElements = new ButtonRectangle<LanMenuState*>( L"color_white.png", L"Connect", Float4(1.0f),Float4(0.0f),Float4(0.0f),Float4(0.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
this->privData->guiElements.AddButton( guiElements );
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Exit", Float4(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
guiElements = new ButtonRectangle<LanMenuState*>( L"color_white.png", L"Exit", Float4(1.0f),Float4(0.0f),Float4(0.0f),Float4(0.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
this->privData->guiElements.AddButton( guiElements );
// bind guiElements collection to the singleton eventhandler

View File

@ -50,7 +50,7 @@ bool LobbyAdminState::Init( SharedStateContent &shared )
// create buttons
ButtonRectangle<LobbyAdminState*> *button;
button = new ButtonRectangle<LobbyAdminState*>( L"earth_md.png", L"Ready", Float4(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
button = new ButtonRectangle<LobbyAdminState*>( L"earth_md.png", L"Ready", Float4(1.0f),Float4(0.0f),Float4(0.0f),Float4(0.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button );
// bind button collection to the singleton eventhandler
@ -112,10 +112,10 @@ void LobbyAdminState::ChangeState( ClientState next )
using namespace ::Oyster::Network;
void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
const GameClientState::NetEvent & LobbyAdminState::DataRecieved( const GameClientState::NetEvent &message )
{
CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data.
// fetching the id data.
short ID = message.args.data.protocol[0].value.netShort;
// Block irrelevant messages.
if( ProtocolIsLobby(ID) )
@ -141,6 +141,7 @@ void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::Clie
default: break;
}
}
return message;
}
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyAdminState*>& e )

View File

@ -29,8 +29,8 @@ namespace DanBias
bool Render();
bool Release();
void ChangeState( ClientState next );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
const NetEvent & DataRecieved( const NetEvent &message );
private:
struct MyData;
::Utility::DynamicMemory::UniquePointer<MyData> privData;

View File

@ -50,7 +50,7 @@ bool LobbyState::Init( SharedStateContent &shared )
// create buttons
ButtonRectangle<LobbyState*> *button;
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float4(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float4(1.0f), Float4(0.0f), Float4(0.0f), Float4(0.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button );
// bind button collection to the singleton eventhandler
@ -112,10 +112,10 @@ void LobbyState::ChangeState( ClientState next )
using namespace ::Oyster::Network;
void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
const GameClientState::NetEvent & LobbyState::DataRecieved( const GameClientState::NetEvent &message )
{
CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data.
// fetching the id data.
short ID = message.args.data.protocol[0].value.netShort;
// Block irrelevant messages.
if( ProtocolIsLobby(ID) )
@ -141,6 +141,8 @@ void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEve
default: break;
}
}
return message;
}
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyState*>& e )

View File

@ -31,7 +31,7 @@ namespace DanBias
bool Render();
bool Release();
void ChangeState( ClientState next );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
const NetEvent & DataRecieved( const NetEvent &message );
private:
struct MyData;

View File

@ -49,18 +49,22 @@ bool MainState::Init( SharedStateContent &shared )
this->privData->nwClient = shared.network;
this->privData->input = shared.input;
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
// create buttons
ButtonRectangle<MainState*> *button;
Float4 TextCol = Float4(1.0f,0.0f,1.0f,1.0f);
Float4 BackCol = Float4(1.0f,1.0f,1.0f,0.5f);
Float4 HoverCol = Float4(0.0f,1.0f,0.0f,1.0f);
Float4 PressCol = Float4(0.0f,0.0f,1.0f,1.0f);
button = new ButtonRectangle<MainState*>( L"earth_md.png", L"Create", Float4(1.0f), OnButtonInteract_Create, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
button = new ButtonRectangle<MainState*>( L"color_white.png", L"Create",TextCol, BackCol, HoverCol, PressCol, OnButtonInteract_Create, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f));
this->privData->guiElements.AddButton( button );
button = new ButtonRectangle<MainState*>( L"skysphere_md.png", L"Join", Float4(1.0f), OnButtonInteract_Join, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
button = new ButtonRectangle<MainState*>( L"color_white.png", L"Join", TextCol, BackCol, HoverCol, PressCol, OnButtonInteract_Join, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.1f));
this->privData->guiElements.AddButton( button );
button = new ButtonRectangle<MainState*>( L"plane_texture_md.png", L"Quit", Float4(1.0f), OnButtonInteract_Quit, this, Float3(0.5f, 0.8f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
button = new ButtonRectangle<MainState*>( L"color_white.png", L"Quit", TextCol, BackCol, HoverCol, PressCol, OnButtonInteract_Quit, this, Float3(0.5f, 0.8f, 0.5f), Float2(0.3f, 0.1f));
this->privData->guiElements.AddButton( button );
// bind button collection to the singleton eventhandler
@ -73,6 +77,11 @@ GameClientState::ClientState MainState::Update( float deltaTime )
{
MouseInput mouseState;
{
bool test = this->privData->input->IsMousePressed();
if(test)
{
int i = 0;
};
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
}
@ -87,7 +96,7 @@ bool MainState::Render()
Graphics::API::NewFrame();
Graphics::API::StartGuiRender();
Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) );
Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 0.9f), Float2(1.0f), Float4(63.0f/255.0f,73.0f/255.0f,127.0f/255.0f,0.6f) );
this->privData->guiElements.RenderTexture();
Graphics::API::StartTextRender();

View File

@ -90,16 +90,25 @@ void NetLoadState::ChangeState( ClientState next )
this->privData->nextState = next;
}
void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
const GameClientState::NetEvent & NetLoadState::DataRecieved( const GameClientState::NetEvent &message )
{
// fetching the id data.
short ID = e.args.data.protocol[0].value.netShort;
short ID = message.args.data.protocol[0].value.netShort;
if( ID == protocol_Lobby_CreateGame && !this->privData->loading )
if( ID == protocol_Lobby_CreateGame )
{
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
this->ChangeState( ClientState_Game );
this->privData->loading = false;
if( !this->privData->loading )
{
this->LoadGame( Protocol_LobbyCreateGame(message.args.data.protocol).mapName );
this->ChangeState( ClientState_Game );
this->privData->loading = false;
}
return GameClientState::event_processed;
}
else
{ // HACK: Debug trap
const char *breakPoint = "Being greedy.";
return message;
}
}
@ -107,7 +116,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{
this->privData->loading = true;
LevelLoader loader;
LevelLoader loader( "..\\Content\\Worlds\\" );
auto objects = loader.LoadLevel( fileName );
auto object = objects.begin();
ObjectTypeHeader *oth;

View File

@ -21,7 +21,7 @@ namespace DanBias
bool Release();
void ChangeState( ClientState next );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
const NetEvent & DataRecieved( const NetEvent &message );
private:
struct MyData;

View File

@ -170,12 +170,12 @@ using namespace GameLogic;
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
{
int damageDone = 0;
int forceThreashHold = 200000;
Oyster::Math::Float damageDone = 0;
Oyster::Math::Float forceThreashHold = 200000;
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
{
damageDone = (int)(kineticEnergyLoss * 0.10f);
damageDone = (kineticEnergyLoss * 0.10f);
damageDone += ExtraDamage;
//player.DamageLife(damageDone);
}

View File

@ -76,14 +76,12 @@ Game::PlayerData* Game::CreatePlayer()
return this->players[i];
}
Game::LevelData* Game::CreateLevel()
Game::LevelData* Game::CreateLevel(const wchar_t mapName[255])
{
if(this->level) return this->level;
this->level = new LevelData();
//this->level->level->InitiateLevel(1000);
this->level->level->InitiateLevel("../Content/Worlds/ccc.bias");
this->level->level->InitiateLevel(mapName);
return this->level;
}

View File

@ -58,9 +58,11 @@ namespace GameLogic
Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override;
ObjectSpecialType GetObjectType() const override;
ObjectSpecialType GetObjectType() const override;
int getNrOfDynamicObj()const override;
IObjectData* GetObjectAt(int ID) const override;
void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const override;
Level *level;
};
@ -70,7 +72,7 @@ namespace GameLogic
void GetAllPlayerPositions() const override;
PlayerData* CreatePlayer() override;
LevelData* CreateLevel() override;
LevelData* CreateLevel(const wchar_t mapName[255] ) override;
void CreateTeam() override;
bool NewFrame() override;
void SetFPS( int FPS ) override;

View File

@ -13,6 +13,7 @@
#include "GameLogicStates.h"
#include <OysterMath.h>
#include "LevelLoader\ObjectDefines.h"
#include "DynamicArray.h"
namespace GameLogic
@ -107,6 +108,7 @@ namespace GameLogic
public:
virtual int getNrOfDynamicObj()const = 0;
virtual IObjectData* GetObjectAt(int ID) const = 0;
virtual void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& destMem) const = 0;
};
class DANBIAS_GAMELOGIC_DLL GameAPI
@ -137,7 +139,7 @@ namespace GameLogic
/** Creates a level
* @return Returns a ILevelData container to use for level manipulation
*/
virtual ILevelData* CreateLevel( void ) = 0;
virtual ILevelData* CreateLevel( const wchar_t mapName[255] ) = 0;
/** Creates a team
* @return ?

View File

@ -50,4 +50,13 @@ int Game::LevelData::getNrOfDynamicObj()const
IObjectData* Game::LevelData::GetObjectAt(int ID) const
{
return this->level->GetObj(ID);
}
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
{
mem.Resize(level->dynamicObjects.Size());
for(int i = 0; i < (int)level->dynamicObjects.Size(); i++)
{
mem[i] = level->dynamicObjects[i];
}
}

View File

@ -27,9 +27,7 @@ Game::PlayerData::PlayerData()
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
Oyster::Physics::ICustomBody* rigidBody;
this->player = new Player();
}
Game::PlayerData::~PlayerData()
{

View File

@ -63,9 +63,9 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
break;
case ObjectSpecialType_RedExplosiveBox:
{
int dmg = 50;
Oyster::Math::Float dmg = 50;
Oyster::Math::Float force = 50;
int radie = 50;
Oyster::Math::Float radie = 50;
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
}
break;
@ -197,12 +197,16 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj)
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
return rigidBody;
}
void Level::InitiateLevel(std::string levelPath)
bool Level::InitiateLevel(std::wstring levelPath)
{
LevelLoader ll;
ll.SetFolderPath(L"..\\Content\\Worlds\\");
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
objects = ll.LoadLevel(levelPath);
if(objects.size() == 0)
return false;
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
API::Instance().SetGravity(200);
int objCount = objects.size();
@ -332,8 +336,9 @@ void Level::InitiateLevel(std::string levelPath)
break;
}
}
return true;
}
void Level::InitiateLevel(float radius)
bool Level::InitiateLevel(float radius)
{
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
API::Instance().SetGravity(200);
@ -353,7 +358,7 @@ void Level::InitiateLevel(float radius)
int offset = 0;
for(int i =0; i< nrOfBoxex; i ++)
{
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
}
@ -385,17 +390,18 @@ void Level::InitiateLevel(float radius)
}*/
// add crystal
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
// add house
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f);
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
// add jumppad
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1.0f, 1.0f, 1.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(4.0f, 600.3f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
return true;
}
void Level::AddPlayerToTeam(Player *player, int teamID)
@ -419,7 +425,7 @@ int Level::getNrOfDynamicObj()
}
Object* Level::GetObj( int ID) const
{
for (int i = 0; i < this->dynamicObjects.Size(); i++)
for (int i = 0; i < (int)this->dynamicObjects.Size(); i++)
{
if(this->dynamicObjects[i]->GetID() == ID)
return this->dynamicObjects[i];

View File

@ -30,8 +30,8 @@ namespace GameLogic
* Initiates a level for players to play on
* @param levelPath: Path to a file that contains all information on the level
********************************************************/
void InitiateLevel(std::string levelPath);
void InitiateLevel(float radius);
bool InitiateLevel(std::wstring levelPath);
bool InitiateLevel(float radius);
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);

View File

@ -11,17 +11,17 @@ using namespace GameLogic::LevelFileLoader;
struct LevelLoader::PrivData
{
LevelParser parser;
std::string folderPath;
std::wstring folderPath;
};
LevelLoader::LevelLoader()
: pData(new PrivData)
{
//standard path
pData->folderPath = "";
pData->folderPath = L"";
}
LevelLoader::LevelLoader(std::string folderPath)
LevelLoader::LevelLoader(std::wstring folderPath)
: pData(new PrivData)
{
pData->folderPath = folderPath;
@ -31,22 +31,22 @@ LevelLoader::~LevelLoader()
{
}
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName)
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::wstring fileName)
{
return pData->parser.Parse(pData->folderPath + fileName);
}
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
LevelMetaData LevelLoader::LoadLevelHeader(std::wstring fileName)
{
return pData->parser.ParseHeader(pData->folderPath + fileName);
}
std::string LevelLoader::GetFolderPath()
std::wstring LevelLoader::GetFolderPath()
{
return this->pData->folderPath;
}
void LevelLoader::SetFolderPath(std::string folderPath)
void LevelLoader::SetFolderPath(std::wstring folderPath)
{
this->pData->folderPath = folderPath;
}

View File

@ -20,7 +20,7 @@ namespace GameLogic
/***********************************************************
* Lets you set the standard folderpath for the levels
********************************************************/
LevelLoader(std::string folderPath);
LevelLoader(std::wstring folderPath);
~LevelLoader();
/********************************************************
@ -28,24 +28,24 @@ namespace GameLogic
* @param fileName: Path/name to the level-file that you want to load.
* @return: Returns all structs with objects and information about the level.
********************************************************/
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::wstring fileName);
/********************************************************
* Just for fast access for the meta information about the level.
* @param fileName: Path to the level-file that you want to load.
* @return: Returns the meta information about the level.
********************************************************/
LevelMetaData LoadLevelHeader(std::string fileName); //.
LevelMetaData LoadLevelHeader(std::wstring fileName); //.
/***********************************************************
* @return: Returns the current standard folder path
********************************************************/
std::string GetFolderPath();
std::wstring GetFolderPath();
/***********************************************************
* Sets the standard folder path
********************************************************/
void SetFolderPath(std::string folderPath);
void SetFolderPath(std::wstring folderPath);
private:
struct PrivData;

View File

@ -20,7 +20,7 @@ LevelParser::~LevelParser()
{
}
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filename)
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::wstring filename)
{
int bufferSize = 0;
int counter = 0;
@ -32,6 +32,12 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
Loader loader;
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
// Check if file was loaded, else return empty vector
if(!buffer)
{
return std::vector<SmartPointer<ObjectTypeHeader>>();
}
//Read format version
LevelLoaderInternal::FormatVersion levelFormatVersion;
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
@ -215,7 +221,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
}
//för meta information om leveln.
LevelMetaData LevelParser::ParseHeader(std::string filename)
LevelMetaData LevelParser::ParseHeader(std::wstring filename)
{
int bufferSize = 0;
int counter = 0;

View File

@ -17,10 +17,10 @@ namespace GameLogic
~LevelParser();
//
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> Parse(std::string filename);
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> Parse(std::wstring filename);
//
LevelMetaData ParseHeader(std::string filename);
LevelMetaData ParseHeader(std::wstring filename);
private:
LevelLoaderInternal::FormatVersion formatVersion;

View File

@ -9,13 +9,13 @@ using namespace GameLogic::LevelFileLoader;
using namespace Oyster::Resource;
using namespace std;
char* Loader::LoadFile(std::string fileName, int &size)
char* Loader::LoadFile(std::wstring fileName, int &size)
{
//convert from string to wstring
std::wstring temp(fileName.begin(), fileName.end());
//std::wstring temp(fileName.begin(), fileName.end());
//convert from wstring to wchar then loads the file
char* buffer = (char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
char* buffer = (char*)OysterResource::LoadResource(fileName.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
size = OysterResource::GetResourceSize(buffer);
return buffer;

View File

@ -17,7 +17,7 @@ namespace GameLogic
public:
Loader (){};
~Loader(){};
char* LoadFile(std::string fileName, int &size);
char* LoadFile(std::wstring fileName, int &size);
//TODO:
//Add functionality to load physicsObjects (hitboxes)

View File

@ -52,6 +52,7 @@ namespace GameLogic
CollisionGeometryType_Box,
CollisionGeometryType_Sphere,
CollisionGeometryType_Cylinder,
CollisionGeometryType_TriangleMesh,
CollisionGeometryType_Count,
CollisionGeometryType_Unknown = -1
@ -161,6 +162,12 @@ namespace GameLogic
float radius;
};
struct BoundingVolumeTriangleMesh : public BoundingVolumeBase
{
//Null terminated
wchar_t* filename;
};
struct BoundingVolume
{
CollisionGeometryType geoType;
@ -169,7 +176,16 @@ namespace GameLogic
LevelLoaderInternal::BoundingVolumeBox box;
LevelLoaderInternal::BoundingVolumeSphere sphere;
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
LevelLoaderInternal::BoundingVolumeTriangleMesh triangleMesh;
};
virtual ~BoundingVolume()
{
if(geoType == CollisionGeometryType_TriangleMesh)
{
delete[] triangleMesh.filename;
}
}
};
}

View File

@ -5,6 +5,7 @@
#include "ParseFunctions.h"
#include "Packing/Packing.h"
#include "Loader.h"
#include "Utilities.h"
#include <string>
using namespace Oyster::Packing;
@ -119,7 +120,7 @@ namespace GameLogic
int temp;
for(int i = 0; i < tempSize; i++)
for(int i = 0; i < (int)tempSize; i++)
{
memcpy(&temp, &buffer[start], 4);
start += 4;
@ -149,7 +150,7 @@ namespace GameLogic
//Läs in filen.
int fileLength = 0;
Loader loader;
char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength);
char* buf = loader.LoadFile(L"../Content/Worlds/cgf/" + Utility::String::StringToWstring(fileName, wstring()), fileLength);
start = 0;
LevelLoaderInternal::FormatVersion version;
@ -175,6 +176,17 @@ namespace GameLogic
start += sizeof(volume.cylinder);
break;
case CollisionGeometryType_TriangleMesh:
//Get string size
memcpy(&tempSize, &buf[start], sizeof(tempSize));
start += sizeof(tempSize);
//Get actual string
volume.triangleMesh.filename = new wchar_t[tempSize+1];
memcpy(volume.triangleMesh.filename, &buf[start], tempSize);
volume.triangleMesh.filename[tempSize] = '\0';
break;
default:
break;
}

View File

@ -90,7 +90,7 @@ void Player::BeginFrame()
forwardDir.Normalize();
rightDir.Normalize();
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2;
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f;
if (key_forward > 0.001)
{
@ -122,7 +122,7 @@ void Player::BeginFrame()
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
{
/* Dampen when on the ground and not being moved by the player */
linearVelocity *= 0.2;
linearVelocity *= 0.2f;
this->rigidBody->SetLinearVelocity (linearVelocity);
}
else

View File

@ -41,61 +41,41 @@ namespace GameLogic
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
{
short clientID; // The unuiqe id reprsenting a specific client
std::string modelName;
float worldMatrix[16];
char majorVersion;
char minorVersion;
std::string mapName;
Protocol_LobbyCreateGame()
{
int c = 0;
this->protocol[c].value = protocol_Lobby_CreateGame;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
for (int i = 0; i <= 16; i++)
{
this->protocol[c++].type = Oyster::Network::NetAttributeType_Float;
}
this->protocol[c++].type = Oyster::Network::NetAttributeType_CharArray;
this->protocol[0].value = protocol_Lobby_CreateGame;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
}
Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16])
Protocol_LobbyCreateGame(char majorVersion, char minorVersion, std::string name)
{
int c = 0;
this->protocol[c].value = protocol_Lobby_CreateGame;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value = protocol_Lobby_CreateGame;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
for (int i = 0; i <= 16; i++)
{
this->protocol[c++].type = Oyster::Network::NetAttributeType_Float;
}
this->protocol[c++].type = Oyster::Network::NetAttributeType_CharArray;
clientID = _clientID;
modelName = name;
memcpy(&worldMatrix[0], &world[0], sizeof(float) * 16);
this->majorVersion = majorVersion;
this->minorVersion = minorVersion;
this->mapName = name;
}
Protocol_LobbyCreateGame(Oyster::Network::CustomNetProtocol o)
{
int c = 1;
clientID = o[c++].value.netInt;
for (int i = 0; i <= 16; i++)
{
this->worldMatrix[i] = o[c++].value.netFloat;
}
modelName.assign(o[c++].value.netCharPtr);
this->majorVersion = o[1].value.netChar;
this->minorVersion = o[2].value.netChar;
this->mapName.assign(o[3].value.netCharPtr);
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
int c = 1;
protocol[c++].value = clientID;
for (int i = 0; i <= 16; i++)
{
this->protocol[c++].value = this->worldMatrix[i];
}
protocol.Set(c++, this->modelName);
protocol[1].value = this->majorVersion;
protocol[2].value = this->minorVersion;
protocol.Set(3, this->mapName);
return protocol;
}

View File

@ -5,6 +5,7 @@
#define DANBIASSERVER_CLIENT_OBJECT_H
#include <NetworkClient.h>
#include <NetworkSession.h>
#include <PostBox\PostBox.h>
#include <GameAPI.h>
#include <Utilities.h>
@ -17,27 +18,59 @@ namespace DanBias
class GameClient
{
public:
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client, GameLogic::IPlayerData* player);
enum ClientState
{
ClientState_CreatingGame,
ClientState_Ready,
};
public:
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient);
virtual~GameClient();
GameLogic::IPlayerData* GetPlayer();
GameLogic::IPlayerData* ReleasePlayer();
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> GetClient();
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> ReleaseClient();
inline bool operator==(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
inline bool operator==(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
float GetSinceLastResponse() const;
bool IsReady() const;
bool Equals(const Oyster::Network::NetworkClient* c);
inline bool Equals(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
inline bool Equals(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
inline float GetSinceLastResponse() const { return this->secondsSinceLastResponse; }
inline std::wstring GetAlias() const { return this->alias; }
inline std::wstring GetCharacter() const { return this->character; }
inline bool IsReady() const { return this->isReady; }
inline GameLogic::IPlayerData* GetPlayer() const { return this->player; }
Oyster::Network::NetClient GetClient() const { return this->client; }
ClientState GetState() const { return this->state; }
void SetPlayer(GameLogic::IPlayerData* player);
void SetReadyState(bool isReady);
void SetAlias(std::wstring alias);
void SetCharacter(std::wstring character);
void SetSinceLastResponse(float seconds);
void SetState(ClientState state);
GameLogic::IPlayerData* ReleasePlayer();
Oyster::Network::NetClient ReleaseClient();
//NetworkSpecific
void SetOwner(Oyster::Network::NetworkSession* owner);
void UpdateClient();
private:
GameLogic::IPlayerData* player;
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
Oyster::Network::NetClient client;
bool isReady;
float secondsSinceLastResponse;
};
std::wstring alias;
std::wstring character;
ClientState state;
};
}//End namespace DanBias
typedef Utility::DynamicMemory::SmartPointer<DanBias::GameClient> gClient;
#endif // !DANBIASSERVER_CLIENT_OBJECT_H

View File

@ -15,11 +15,18 @@ namespace DanBias
{
struct LobbyLevelData
{
int mapNumber;
int maxClients;
int gameMode;
int gameTime;
std::string gameName;
int gameTimeInMinutes;
std::wstring gameMode;
std::wstring mapName;
std::wstring gameName;
LobbyLevelData()
: maxClients(10)
, gameTimeInMinutes(10)
, gameMode(L"unknown")
, mapName(L"unknown")
, gameName(L"unknown")
{ }
};
class GameLobby :public Oyster::Network::NetworkSession
{
@ -31,35 +38,44 @@ namespace DanBias
void SetGameDesc(const LobbyLevelData& desc);
void GetGameDesc(LobbyLevelData& desc);
bool StartGameSession();
/**
* If param is true, the server will start a game session regardless of clients connected.
*/
bool StartGameSession( bool forceStart );
int GetGameSessionClientCount();
private:
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
//void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
//void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join:
void LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
void LobbyJoin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
private:
int FindClient(Oyster::Network::NetworkClient* c);
private:
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
void ProcessClients() override;
bool Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
private:
Utility::WinTimer timer;
float refreshFrequency;
//Utility::WinTimer timer;
//float refreshFrequency;
Utility::DynamicMemory::LinkedList<Oyster::Network::NetworkClient*> readyList;
GameSession gameSession;
LobbyLevelData description;
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> gClients;
};
}//End namespace DanBias
#endif // !DANBIASGAME_GAMELOBBY_H

View File

@ -55,16 +55,24 @@ namespace DanBias
static void NotifyWhenClientConnect(ClientConnectedNotify func);
static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
static void GameSetMapName(const wchar_t* val);
static void GameSetMaxClients(const int& val);
static void GameSetGameMode(const wchar_t* val);
static void GameSetGameTime(const int& val);
static int GameGetMapId();
static int GameGetMaxClients();
static int GameGetGameMode();
static void GameSetMaxClients(const int& val);
static void GameSetGameName(const wchar_t* val);
static void GameSetMapName(const wchar_t* val);
static void GameSetGameMode(const wchar_t* val);
static int GameGetGameTime();
static const char* GameGetGameName();
static bool GameStart();
static int GameGetMaxClients();
static const wchar_t* GameGetGameMode();
static const wchar_t* GameGetGameName();
static const wchar_t* GameGetMapName();
static int GetConnectedClientCount();
/* Starts a game
* @param forceStart If forceStart is true, server will start with or without clients.
* If there are clients not "ready" the will be stareted anyways.
*/
static bool GameStart(bool forceStart);
};//End class DanBiasServer

View File

@ -31,12 +31,12 @@ namespace DanBias
*/
struct GameDescription
{
int maxClients;
int mapNumber;
int gameMode;
int gameTime;
unsigned int maxClients;
std::wstring mapName;
std::wstring gameMode;
int gameTimeMinutes;
Oyster::Network::NetworkSession* owner;
Utility::DynamicMemory::DynamicArray<Oyster::Network::NetClient> clients;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
};
public:
@ -44,7 +44,7 @@ namespace DanBias
virtual~GameSession();
/** Initiates and creates a game session. */
bool Create(GameDescription& desc);
bool Create(GameDescription& desc, bool forceStart);
/** Runs the game session (ie starts the game loop). */
void Run();
@ -52,23 +52,27 @@ namespace DanBias
/** Join an existing/running game session
* @param client The client to attach to the session
*/
bool Attach(Oyster::Network::NetClient client) override;
void CloseSession( bool dissconnectClients ) override;
bool Join(gClient client);
//void CloseSession( bool dissconnectClients ) override;
inline bool IsCreated() const { return this->isCreated; }
inline bool IsRunning() const { return this->isRunning; }
operator bool() { return (this->isCreated && this->isCreated); }
operator bool() { return (this->isCreated && this->isRunning); }
//Private member functions
private:
// TODO: find out what this method does..
// Client event callback function
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
void ProcessClients() override;
bool Send(Oyster::Network::CustomNetProtocol& message) override;
bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID) override;
//Sends a client to the owner, if obj is NULL then all clients is sent
//Sends a client to the owner, if param is NULL then all clients is sent
void SendToOwner(DanBias::GameClient* obj);
//Derived from IThreadObject
void ThreadEntry() override;
void ThreadEntry( ) override;
bool DoWork ( ) override;
@ -98,8 +102,8 @@ namespace DanBias
//Private member variables
private:
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
Utility::DynamicMemory::DynamicArray<gClient> gClients;
gClient sessionOwner;
Oyster::Thread::OysterThread worker;
GameLogic::GameAPI& gameInstance;
GameLogic::ILevelData *levelData;
@ -115,6 +119,7 @@ namespace DanBias
//TODO: Remove this uggly hax
static GameSession* gameSession;
};//End GameSession
}//End namespace DanBias
#endif // !DANBIASSERVER_GAME_SESSION_H

View File

@ -12,51 +12,27 @@ using namespace DanBias;
using namespace GameLogic;
GameClient::GameClient(SmartPointer<NetworkClient> client, GameLogic::IPlayerData* player)
GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient)
{
this->client = client;
this->player = player;
this->client = nwClient;
this->player = 0;
isReady = false;
this->character = L"Unknown";
this->alias = L"Unknown";
this->secondsSinceLastResponse = 0.0f;
}
GameClient::~GameClient()
{
this->client->Disconnect();
this->player = 0;
isReady = false;
this->isReady = false;
this->character = L"Unknown";
this->alias = L"Unknown";
this->secondsSinceLastResponse = 0.0f;
}
GameLogic::IPlayerData* GameClient::GetPlayer()
void GameClient::SetPlayer(GameLogic::IPlayerData* player)
{
return this->player;
}
GameLogic::IPlayerData* GameClient::ReleasePlayer()
{
GameLogic::IPlayerData *temp = this->player;
this->player = 0;
return temp;
}
SmartPointer<Oyster::Network::NetworkClient> GameClient::GetClient()
{
return this->client;
}
SmartPointer<Oyster::Network::NetworkClient> GameClient::ReleaseClient()
{
SmartPointer<Oyster::Network::NetworkClient> temp = this->client;
this->client = 0;
return temp;
}
float GameClient::GetSinceLastResponse() const
{
return this->secondsSinceLastResponse;
}
bool GameClient::IsReady() const
{
return this->isReady;
}
bool GameClient::Equals(const NetworkClient* c)
{
return (c->GetID() == this->client->GetID());
this->player = player;
}
void GameClient::SetReadyState(bool r)
{
@ -66,5 +42,44 @@ void GameClient::SetSinceLastResponse(float s)
{
this->secondsSinceLastResponse = s;
}
void GameClient::SetAlias(std::wstring alias)
{
this->alias = alias;
}
void GameClient::SetCharacter(std::wstring character)
{
this->character = character;
}
void GameClient::SetState(ClientState state)
{
this->state = state;
}
void GameClient::SetOwner(Oyster::Network::NetworkSession* owner)
{
this->client->SetOwner(owner);
}
void GameClient::UpdateClient()
{
switch (this->state)
{
case ClientState_Ready:
this->client->Update();
break;
}
}
IPlayerData* GameClient::ReleasePlayer()
{
IPlayerData* temp = this->player;
this->player = 0;
return temp;
}
NetClient GameClient::ReleaseClient()
{
NetClient temp = this->client;
this->client = 0;
return temp;
}

View File

@ -14,10 +14,10 @@ using namespace GameLogic;
using namespace DanBias;
GameLobby::GameLobby()
{ }
{ }
GameLobby::~GameLobby()
{
this->clients.Clear();
this->gClients.Clear();
}
void GameLobby::Release()
{
@ -26,62 +26,86 @@ void GameLobby::Release()
}
void GameLobby::Update()
{
for (unsigned int i = 0; i < this->clients.Size(); i++)
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->clients[i])
if(this->gClients[i])
{
this->clients[i]->Update();
this->gClients[i]->GetClient()->Update();
}
}
}
void GameLobby::SetGameDesc(const LobbyLevelData& desc)
{
this->description.gameMode = desc.gameMode;
this->description.gameTime = desc.gameTime;
this->description.mapNumber = desc.mapNumber;
this->description.gameName = desc.gameName;
this->description.mapName = desc.mapName;
this->description.gameTimeInMinutes = desc.gameTimeInMinutes;
this->description.maxClients = desc.maxClients;
if(this->gClients.Size() > (unsigned int)desc.maxClients)
{
//Kick overflow
for (unsigned int i = (unsigned int)desc.maxClients - 1; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
this->gClients[i]->GetClient()->Disconnect();
}
}
}
this->gClients.Resize((unsigned int)desc.maxClients);
}
void GameLobby::GetGameDesc(LobbyLevelData& desc)
{
desc.gameMode = this->description.gameMode;
desc.gameTime = this->description.gameTime;
desc.mapNumber = this->description.mapNumber;
desc.gameTimeInMinutes = this->description.gameTimeInMinutes;
desc.maxClients = this->description.maxClients;
desc.mapName = this->description.mapName;
desc.gameName = this->description.gameName;
desc.gameMode = this->description.gameMode;
}
bool GameLobby::StartGameSession( )
bool GameLobby::StartGameSession( bool forceStart )
{
//Check if all clients is ready
if(this->GetClientCount() && this->GetClientCount() == this->readyList.Size())
//Check if all clients is ready, in not force start
if(!forceStart)
{
GameSession::GameDescription desc;
desc.maxClients = this->description.maxClients;
desc.gameMode = this->description.gameMode;
desc.gameTime = this->description.gameTime;
desc.mapNumber = this->description.mapNumber;
desc.owner = this;
desc.clients = this->clients;
if(!this->GetClientCount())
{ /*None connected*/ return false;}
else if( this->GetClientCount() != this->readyList.Size() )
{ /*Not enough connected*/ return false; }
}
if(desc.gameTime == 0.0f)
desc.gameTime = (int)(60.0f * 10.0f); //note: should be fetched from somewhere.
GameSession::GameDescription desc;
desc.maxClients = this->description.maxClients;
desc.gameMode = this->description.gameMode;
desc.gameTimeMinutes = this->description.gameTimeInMinutes;
desc.mapName = this->description.mapName;
desc.owner = this;
desc.clients = this->gClients;
if(desc.maxClients == 0)
desc.maxClients = 10; //note: should be fetched somewhere else..
if(desc.gameTimeMinutes == 0)
desc.gameTimeMinutes = 10; //note: should be fetched from somewhere.
this->clients.Clear(); //Remove clients from lobby list
if(desc.maxClients == 0)
desc.maxClients = 10; //note: should be fetched somewhere else..
this->gClients.Clear(); //Remove clients from lobby list
if(this->gameSession.Create(desc))
{
this->gameSession.Run();
return true;
}
}
else
if(this->gameSession.Create(desc, forceStart))
{
//?
this->gameSession.Run();
return true;
}
return false;
}
int GameLobby::GetGameSessionClientCount()
{
return this->gameSession.GetClientCount();
}
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
{
@ -95,9 +119,9 @@ void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::Clie
break;
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
e.sender->Disconnect();
this->readyList.Remove(e.sender);
this->clients.Remove(e.sender);
//e.sender->Disconnect();
//this->readyList.Remove(e.sender);
//this->gClients.Remove(e.sender);
break;
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
@ -111,21 +135,30 @@ void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster
if(this->gameSession)
{
Attach(client);
if(!this->Attach(client))
{
client->Disconnect();
}
}
else
{
Attach(client);
if(!this->Attach(client))
{
//Send message that lobby full
client->Disconnect();
return;
}
Protocol_LobbyClientData p1;
Protocol_LobbyGameData p2;
for (unsigned int i = 0; i < this->clients.Size(); i++)
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->clients[i])
if(this->gClients[i])
{
Protocol_LobbyClientData::PlayerData t;
t.id = this->clients[i]->GetID();
t.ip = this->clients[i]->GetIpAddress();
t.id = client->GetID();
t.ip = client->GetIpAddress();
t.team = 0;
t.name = "Dennis är kung tycker Erik!";
p1.list.Push(t);
@ -139,4 +172,44 @@ void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster
client->Send(p2.GetProtocol());
}
}
void GameLobby::ProcessClients()
{
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
this->gClients[i]->UpdateClient();
}
}
}
bool GameLobby::Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
{
if(this->clientCount == this->description.maxClients) return false;
client->SetOwner(this);
bool added = false;
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(!this->gClients[i])
{
added = true;
this->gClients[i] = new GameClient(client);
}
}
if(!added)
{
this->gClients.Push(new GameClient(client));
}
return true;
}

View File

@ -12,27 +12,23 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie
{
switch (p[0].value.netShort)
{
case protocol_General_Status: this->GeneralStatus (Protocol_General_Status (p), c);
case protocol_General_Status: this->GeneralStatus (Protocol_General_Status (p), c);
break;
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
break;
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
//break;
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
break;
//case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
//break;
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c);
case protocol_Lobby_JoinGame: this->LobbyJoin (Protocol_LobbyJoinGame (p), c);
break;
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
break;
case protocol_Lobby_GameData: this->LobbyGameData (Protocol_LobbyGameData (p), c);
case protocol_Lobby_GameData: this->LobbyGameData (Protocol_LobbyGameData (p), c);
break;
case protocol_Lobby_ClientData: this->LobbyMainData (Protocol_LobbyClientData (p), c);
case protocol_Lobby_ClientData: this->LobbyMainData (Protocol_LobbyClientData (p), c);
break;
case protocol_Lobby_ClientReadyState: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
case protocol_Lobby_ClientReadyState: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
break;
case protocol_Lobby_QuerryGameType: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
case protocol_Lobby_QuerryGameType: this->LobbyQuerryGameData (Protocol_QuerryGameType (), c);
break;
}
}
@ -44,52 +40,75 @@ void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Net
{
case Protocol_General_Status::States_ready:
{
int temp = FindClient(c);
if(temp != -1 )
{
switch (this->gClients[temp]->GetState())
{
case GameClient::ClientState_CreatingGame:
{
this->gameSession.Join(this->gClients[temp]);
this->gClients[temp] = 0;
}
break;
}
}
else
{
c->Disconnect();
}
}
break;
case Protocol_General_Status::States_idle:
{
}
break;
case Protocol_General_Status::States_leave:
break;
case Protocol_General_Status::States_disconected:
{
Detach(c)->Disconnect();
}
break;
}
}
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
{
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
this->gClients[i]->GetClient()->Send(p);
}
}
printf(p.text.c_str());
}
//void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
//{
//
//}
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
{
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
{
//Send countdown timer before lobby shuts down
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
this->gClients[i]->GetClient()->Send(Protocol_LobbyStartGame(3.0f));
}
}
else
{
//Someone else tried to start the server..
}
}
//void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c)
//{
// //for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
// //{
// // if (this->gameLobby[i]->GetID() == p.value)
// // {
// // this->gameLobby[i]->Attach(Detach(c));
// // return;
// // }
// //}
//}
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
{
//for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
//{
// if (this->gameLobby[i]->GetID() == p.value)
// {
// this->gameLobby[i]->Attach(Detach(c));
// return;
// }
//}
}
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
{
@ -112,31 +131,48 @@ void GameLobby::LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster:
else
{
this->readyList.Remove(c);
}
}
void GameLobby::LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c)
{
NetClient temp;
bool found = false;
//find client in waiting list
for (unsigned int i = 0; !found && i < this->clients.Size(); i++)
if(this->gameSession)
{
if(this->clients[i]->GetID() == c->GetID())
int temp = FindClient(c);
//Something is wrong
if(temp == -1)
{
temp = this->clients[i];
found = true;
c->Disconnect();
}
else
{
//Send game data
Protocol_LobbyCreateGame lcg((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
c->Send(lcg);
this->gClients[temp]->SetState(GameClient::ClientState_CreatingGame);
}
}
//Something is wrong
if(!found)
{
c->Disconnect();
}
else
{
//Send game data
this->gameSession.Attach(temp);
// Nothing.-
}
}
int GameLobby::FindClient(Oyster::Network::NetworkClient* c)
{
int temp = -1;
//find client in waiting list
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i]->GetClient()->GetID() == c->GetID())
{
temp = i;
break;
}
}
return temp;
}

View File

@ -118,69 +118,81 @@ void GameServerAPI::NotifyWhenClientDisconnect(ClientDisconnectedNotify func)
else clientDisconnectedCallback = func;
}
void GameServerAPI::GameSetMapName(const wchar_t* val)
void GameServerAPI::GameSetMapName(const wchar_t* val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
//d.mapNumber = val; //TODO: implement
d.mapName = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetMaxClients(const int& val)
void GameServerAPI::GameSetGameMode(const wchar_t* val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
d.gameMode = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetGameName(const wchar_t* val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
d.gameName = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetMaxClients(const int& val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
d.maxClients = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetGameMode(const wchar_t* val)
void GameServerAPI::GameSetGameTime(const int& val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
//d.gameMode = val; //TODO: implement
d.gameTimeInMinutes = val;
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetGameTime(const int& val)
const wchar_t* GameServerAPI::GameGetMapName()
{
LobbyLevelData d;
lobby.GetGameDesc(d);
d.gameTime = val;
lobby.SetGameDesc(d);
return d.mapName.c_str();
}
int GameServerAPI::GameGetMapId()
{
LobbyLevelData d;
lobby.GetGameDesc(d);
return d.mapNumber;
}
int GameServerAPI::GameGetMaxClients()
int GameServerAPI::GameGetMaxClients()
{
LobbyLevelData d;
lobby.GetGameDesc(d);
return d.maxClients;
}
int GameServerAPI::GameGetGameMode()
const wchar_t* GameServerAPI::GameGetGameMode()
{
LobbyLevelData d;
lobby.GetGameDesc(d);
return d.gameMode;
return d.gameMode.c_str();
}
int GameServerAPI::GameGetGameTime()
int GameServerAPI::GameGetGameTime()
{
LobbyLevelData d;
lobby.GetGameDesc(d);
return d.gameTime;
return d.gameTimeInMinutes;
}
const char* GameServerAPI::GameGetGameName()
const wchar_t* GameServerAPI::GameGetGameName()
{
LobbyLevelData d;
lobby.GetGameDesc(d);
return d.gameName.c_str();
}
bool GameServerAPI::GameStart()
int GameServerAPI::GetConnectedClientCount()
{
if(lobby.StartGameSession())
return lobby.GetGameSessionClientCount();
}
bool GameServerAPI::GameStart( bool forceStart )
{
if(lobby.StartGameSession( forceStart ))
{
return true;
}
return false;

View File

@ -19,11 +19,8 @@ using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
using namespace DanBias;
namespace DanBias
{
Utility::WinTimer testTimer;
int testID = -1;
bool GameSession::DoWork( )
{
@ -46,9 +43,9 @@ namespace DanBias
{
int temp = -1;
//Find the idiot
for (unsigned int i = 0; i < this->clients.Size(); i++)
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->clients[i]->Equals(e.sender))
if(this->gClients[i] && this->gClients[i]->Equals(e.sender))
{
temp = i;
}
@ -59,7 +56,7 @@ namespace DanBias
this->Detach(e.sender)->Disconnect();
return;
}
SmartPointer<GameClient> cl = this->clients[temp];
SmartPointer<GameClient> cl = this->gClients[temp];
switch (e.args.type)
{
@ -73,15 +70,48 @@ namespace DanBias
break;
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
testID = 2;
if(cl->GetPlayer()->GetID() == testID)//TODO: TEST
{
testTimer.reset();
}
this->ParseProtocol(e.args.data.protocol, cl);
break;
}
}
void GameSession::ProcessClients()
{
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i] )
{
this->gClients[i]->UpdateClient();
}
}
}
bool GameSession::Send(Oyster::Network::CustomNetProtocol& message)
{
bool returnValue = false;
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
this->gClients[i]->GetClient()->Send(message);
returnValue = true;
}
}
return returnValue;
}
bool GameSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
{
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID)
{
this->gClients[i]->GetClient()->Send(protocol);
return true;
}
}
return false;
}
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
{
@ -246,7 +276,6 @@ namespace DanBias
printf("Message recieved from (%i):\t %s\n", c->GetClient()->GetID(), p.text.c_str());
}
}//End namespace DanBias

View File

@ -3,6 +3,7 @@
/////////////////////////////////////////////////////////////////////
#include "..\GameSession.h"
#include "..\GameClient.h"
#include "..\GameLobby.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
@ -24,217 +25,253 @@ using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
using namespace DanBias;
namespace DanBias
GameSession* GameSession::gameSession = nullptr;
GameSession::GameSession()
:gameInstance(GameAPI::Instance())
{
GameSession* GameSession::gameSession = nullptr;
this->owner = 0;
this->isCreated = false;
this->isRunning = false;
this->gameSession = this;
this->logicFrameTime = DELTA_TIME_20;
this->networkFrameTime = DELTA_TIME_20;
this->networkTimer.reset();
this->logicTimer.reset();
GameSession::GameSession()
:gameInstance(GameAPI::Instance())
memset(&this->description, 0, sizeof(GameDescription));
}
GameSession::~GameSession()
{
this->worker.Terminate();
this->clients.Clear();
this->gameInstance;
this->owner = 0;
this->isCreated = false;
this->isRunning = false;
}
bool GameSession::Create(GameDescription& desc, bool forceStart)
{
this->description = desc;
/* Do some error checking */
if(!forceStart && desc.clients.Size() == 0) return false;
if(!desc.owner) return false;
if(this->isCreated) return false;
/* standard initialization of some data */
this->gClients.Resize((unsigned int)desc.maxClients);
for (unsigned int i = 0; i < desc.clients.Size(); i++)
{
this->owner = 0;
this->isCreated = false;
this->isRunning = false;
this->gameSession = this;
this->logicFrameTime = DELTA_TIME_20;
this->networkFrameTime = DELTA_TIME_20;
this->networkTimer.reset();
this->logicTimer.reset();
memset(&this->description, 0, sizeof(GameDescription));
}
GameSession::~GameSession()
{
this->worker.Terminate();
this->clients.Clear();
this->gameInstance;
this->owner = 0;
this->isCreated = false;
this->isRunning = false;
}
bool GameSession::Create(GameDescription& desc)
{
this->description = desc;
/* Do some error checking */
if(desc.clients.Size() == 0) return false;
if(!desc.owner) return false;
if(this->isCreated) return false;
/* standard initialization of some data */
NetworkSession::clients = desc.clients;
NetworkSession::clients.Resize((unsigned int)desc.maxClients);
this->clients.Resize((unsigned int)desc.maxClients);
this->owner = desc.owner;
/* Initiate the game instance */
if(!this->gameInstance.Initiate())
if(desc.clients[i])
{
printf("Failed to initiate the game instance\n");
this->clientCount++;
this->gClients[i] = desc.clients[i];
this->gClients[i]->SetOwner(this);
}
}
this->owner = desc.owner;
/* Create the players in the game instance */
GameLogic::IPlayerData* p = 0;
for (unsigned int i = 0; i < desc.clients.Size(); i++)
/* Initiate the game instance */
if(!this->gameInstance.Initiate())
{
printf("Failed to initiate the game instance\n");
}
/* Create the players in the game instance */
GameLogic::IPlayerData* p = 0;
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
if(desc.clients[i])
if( (p = this->gameInstance.CreatePlayer()) )
{
if( (p = this->gameInstance.CreatePlayer()) )
{
desc.clients[i]->SetOwner(this);
this->clients[i] = (new GameClient(desc.clients[i], p));
}
else
{
printf("Failed to create player (%i)\n", i);
}
this->gClients[i]->SetPlayer(p);
}
else
{
printf("Failed to create player (%i)\n", i);
}
}
/* Create the game level */
if(!(this->levelData = this->gameInstance.CreateLevel()))
{
printf("Level not created!");
return false;
}
/* Set some game instance data options */
this->gameInstance.SetSubscription(GameSession::ObjectMove);
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
this->gameInstance.SetFPS(60);
this->description.clients.Clear();
this->isCreated = true;
/* Create the worker thread */
if(this->worker.Create(this, false) != OYSTER_THREAD_ERROR_SUCCESS)
return false;
return this->isCreated;
}
void GameSession::Run()
/* Create the game level */
if(!(this->levelData = this->gameInstance.CreateLevel(this->description.mapName.c_str())))
{
if(this->isRunning) return;
if(this->clients.Size() > 0)
{
this->worker.Start();
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
this->isRunning = true;
}
printf("Level not created!");
return false;
}
void GameSession::ThreadEntry( )
{
//List with clients that we are waiting on..
DynamicArray<SmartPointer<GameClient>> readyList;// = this->clients;
/* Set some game instance data options */
this->gameInstance.SetSubscription(GameSession::ObjectMove);
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
this->gameInstance.SetFPS(60);
//First we need to clean invalid clients, if any, and tell them to start loading game data
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i])
{
if(this->clients[i]->IsReady())
{
readyList.Push(this->clients[i]);
Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_white.dan", readyList[i]->GetPlayer()->GetOrientation());
readyList[readyList.Size() - 1]->GetClient()->Send(p);
}
}
}
this->description.clients.Clear();
this->isCreated = true;
/* Create the worker thread */
if(this->worker.Create(this, false) != OYSTER_THREAD_ERROR_SUCCESS)
return false;
return this->isCreated;
}
void GameSession::Run()
{
if(this->isRunning) return;
this->worker.Start();
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
this->isRunning = true;
unsigned int readyCounter = readyList.Size();
}
//Sync with clients
while (readyCounter != 0)
void GameSession::ThreadEntry( )
{
//List with clients that we are waiting on..
DynamicArray<gClient> readyList;// = this->clients;
//First we need to clean invalid clients, if any, and tell them to start loading game data
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
this->ProcessClients();
for (unsigned int i = 0; i < readyList.Size(); i++)
readyList.Push(this->gClients[i]);
Protocol_LobbyCreateGame p((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
readyList[readyList.Size() - 1]->GetClient()->Send(p);
}
}
unsigned int readyCounter = readyList.Size();
//Sync with clients
while (readyCounter != 0)
{
this->ProcessClients();
for (unsigned int i = 0; i < readyList.Size(); i++)
{
if(readyList[i] && readyList[i]->IsReady())
{
if(readyList[i] && readyList[i]->IsReady())
//Need to send information about other players, to all players
for (unsigned int k = 0; k < this->gClients.Size(); k++)
{
//Need to send information about other players, to all players
for (unsigned int k = 0; k < this->clients.Size(); k++)
if((this->gClients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->gClients[k]->GetClient()->GetID())
{
if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID())
{
//Protocol_ObjectCreatePlayer
Protocol_ObjectCreate p( this->clients[k]->GetPlayer()->GetPosition(),
this->clients[k]->GetPlayer()->GetRotation(),
this->clients[k]->GetPlayer()->GetScale(),
this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later..
readyList[i]->GetClient()->Send(p);
}
IPlayerData* pl = this->gClients[k]->GetPlayer();
Protocol_ObjectCreatePlayer p( pl->GetPosition(), pl->GetRotation(), pl->GetScale(),
pl->GetID(), true, this->gClients[k]->GetPlayer()->GetTeamID(),
/*nwClient->GetAlias()*/"", /*playerData->GetMesh()*/"char_white.dan");
readyList[i]->GetClient()->Send(p);
}
readyCounter-- ;
readyList[i] = 0;
}
}
Sleep(5); //TODO: This might not be needed here.
}
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(this->clients[i])
{
this->clients[i]->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(5));
readyCounter-- ;
readyList[i] = 0;
}
}
Sleep(5); //TODO: This might not be needed here.
}
bool GameSession::Attach(Utility::DynamicMemory::SmartPointer<NetworkClient> client)
//Sync with clients before starting countdown
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(!this->isCreated) return false;
if(this->GetClientCount() == this->clients.Capacity()) return false;
client->SetOwner(this);
IPlayerData* player = this->gameInstance.CreatePlayer();
if(!player) return false;
SmartPointer<GameClient> obj = new GameClient(client, player);
// Send the chosen mesh name
Protocol_LobbyCreateGame lcg(obj->GetPlayer()->GetID(), "char_white.dan", obj->GetPlayer()->GetOrientation());
obj->GetClient()->Send(lcg);
// Send the player data only
for (unsigned int i = 0; i < this->clients.Capacity(); i++)
if(this->gClients[i])
{
if(this->clients[i])
{
IPlayerData* p = this->clients[i]->GetPlayer();
Protocol_ObjectCreate oc(p->GetPosition(), p->GetRotation(), p->GetScale(), p->GetID(), "char_white.dan");
//Protocol_ObjectCreatePlayer oc(p->GetPosition(), p->GetRotation(), p->GetScale(), p->GetID(), "char_white.dan");
this->clients[i]->GetClient()->Send(oc);
}
this->gClients[i]->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(5.0f));
}
obj->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(0));
for (unsigned int i = 0; i < this->clients.Size(); i++)
{
if(!clients[i])
{
NetworkSession::clients[i] = client;
clients[i] = obj;
return true;
}
}
return true;
}
}
void GameSession::CloseSession( bool dissconnectClients )
bool GameSession::Join(gClient gameClient)
{
if(!this->isCreated) return false;
if(this->GetClientCount() == this->gClients.Capacity()) return false;
gameClient->SetOwner(this);
IPlayerData* playerData = this->gameInstance.CreatePlayer();
if(!playerData) return false;
gameClient->SetPlayer(playerData);
NetworkClient* nwClient = gameClient->GetClient();
// Send the player data only
{
this->worker.Terminate();
NetworkSession::CloseSession(true);
this->clients.Clear();
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
playerData->GetID(), true, playerData->GetTeamID(),
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
nwClient->Send(oc);
}
}//End namespace DanBias
// Send information about other clients
{
for (unsigned int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i])
{
IPlayerData* temp = this->gClients[i]->GetPlayer();
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
temp->GetID(), false, temp->GetTeamID(),
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
nwClient->Send(oc);
}
}
}
//TODO: Need to be able to get the current gameplay data from the logic, to sync it with the client
{
DynamicArray<IObjectData*> objects;
this->levelData->GetAllDynamicObjects(objects);
for (unsigned int i = 0; i < objects.Size(); i++)
{
//Protocol_ObjectPosition p(movedObject->GetPosition(), id);
Protocol_ObjectPositionRotation p(objects[i]->GetPosition(), objects[i]->GetRotation(), objects[i]->GetID());
GameSession::gameSession->Send(p.GetProtocol());
}
}
// Insert the new client to the update list
bool added = false;
{
for (unsigned int i = 0; !added && i < this->gClients.Size(); i++)
{
if(!this->gClients[i])
{
this->gClients[i] = gameClient;
// Send the start signal
{
nwClient->Send(GameLogic::Protocol_LobbyStartGame(0));
}
added = true;
this->clientCount++;
}
}
}
gameClient->SetState(GameClient::ClientState_Ready);
return added;
}
//DynamicArray<gClient> GameSession::CloseSession( bool dissconnectClients )
//{
// this->worker.Terminate();
// //TODO: Send clients to lobby
//
// //for (unsigned int i = 0; i < this->gClients.Size(); i++)
// //{
// // if(this->gClients[i])
// // {
// // ((GameLobby*)this->owner)-> this->gClients[i]
// // }
// //}
//
// this->gClients.Clear();
//}

View File

@ -72,26 +72,32 @@ void StandaloneGameServerCLI::GameSetMapName(String^ value)
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
DanBias::GameServerAPI::GameSetMapName(wch);
}
void StandaloneGameServerCLI::GameSetGameMode(String^ value)
{
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
DanBias::GameServerAPI::GameSetGameMode(wch);
}
void StandaloneGameServerCLI::GameSetGameName(String^ value)
{
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
DanBias::GameServerAPI::GameSetGameName(wch);
}
void StandaloneGameServerCLI::GameSetMaxClients(const int val)
{
DanBias::GameServerAPI::GameSetMaxClients(val);
}
void StandaloneGameServerCLI::GameSetGameMode(String^ value)
{
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
DanBias::GameServerAPI::GameSetGameMode(wch);
}
void StandaloneGameServerCLI::GameSetGameTime(const int val)
{
DanBias::GameServerAPI::GameSetGameTime(val);
}
int StandaloneGameServerCLI::GameGetMapId()
String^ StandaloneGameServerCLI::GameGetMapName()
{
return DanBias::GameServerAPI::GameGetMapId();
return gcnew String( DanBias::GameServerAPI::GameGetMapName());
}
int StandaloneGameServerCLI::GameGetMaxClients()
@ -99,9 +105,9 @@ int StandaloneGameServerCLI::GameGetMaxClients()
return DanBias::GameServerAPI::GameGetMaxClients();
}
int StandaloneGameServerCLI::GameGetGameMode()
String^ StandaloneGameServerCLI::GameGetGameMode()
{
return DanBias::GameServerAPI::GameGetGameMode();
return gcnew String( DanBias::GameServerAPI::GameGetGameMode());
}
int StandaloneGameServerCLI::GameGetGameTime()
@ -111,10 +117,17 @@ int StandaloneGameServerCLI::GameGetGameTime()
String^ StandaloneGameServerCLI::GameGetGameName()
{
return gcnew String(DanBias::GameServerAPI::GameGetGameName());
return gcnew String( DanBias::GameServerAPI::GameGetGameName());
}
bool StandaloneGameServerCLI::GameStart()
bool StandaloneGameServerCLI::GameStart(bool f)
{
return DanBias::GameServerAPI::GameStart();
}
return DanBias::GameServerAPI::GameStart(f);
}
int StandaloneGameServerCLI::GetClientsConnectedCount()
{
return DanBias::GameServerAPI::GetConnectedClientCount();
}

View File

@ -47,15 +47,18 @@ namespace System { namespace Windows { namespace Interop
bool ServerIsRunning();
void GameSetMapName(String^ val);
void GameSetMaxClients(const int val);
void GameSetGameMode(String^ val);
void GameSetGameName(String^ val);
void GameSetMaxClients(const int val);
void GameSetGameTime(const int val);
int GameGetMapId();
int GameGetMaxClients();
int GameGetGameMode();
int GameGetGameTime();
System::String^ GameGetMapName();
System::String^ GameGetGameMode();
System::String^ GameGetGameName();
bool GameStart();
bool GameStart( bool forceStart );
int GetClientsConnectedCount();
};
} } }

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="StandAloneLauncher.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
@ -8,4 +13,11 @@
<probing privatePath="..\..\Bin\DLL\" />
</assemblyBinding>
</runtime>
<userSettings>
<StandAloneLauncher.Properties.Settings>
<setting name="Dennis" serializeAs="String">
<value>.\..\Content\</value>
</setting>
</StandAloneLauncher.Properties.Settings>
</userSettings>
</configuration>

View File

@ -36,32 +36,58 @@
this.label_listenPort = new System.Windows.Forms.Label();
this.panel_serverOptions = new System.Windows.Forms.Panel();
this.panel_commands = new System.Windows.Forms.Panel();
this.timeLimit = new System.Windows.Forms.NumericUpDown();
this.gameModes = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.forceStart = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.labelClientsConnected = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
this.buttonStartGame = new System.Windows.Forms.Button();
this.panel_clientArea = new System.Windows.Forms.Panel();
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
this.splitter1 = new System.Windows.Forms.Splitter();
this.clientInfoBox = new System.Windows.Forms.ListBox();
this.buttonStartGame = new System.Windows.Forms.Button();
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.gameModes = new System.Windows.Forms.ComboBox();
this.timeLimit = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.mapName = new System.Windows.Forms.TextBox();
this.panel_CommanArea = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label();
this.mapName = new System.Windows.Forms.ComboBox();
this.panelServerCommands = new System.Windows.Forms.Panel();
this.buttonExecuteSend = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.textBox1 = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.dataProtocolFields = new System.Windows.Forms.TableLayoutPanel();
this.buttonAddNewDataField = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.buttonsAtBottom = new System.Windows.Forms.TableLayoutPanel();
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
this.panel_serverOptions.SuspendLayout();
this.panel_commands.SuspendLayout();
this.panel_clientArea.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
this.panel_clientArea.SuspendLayout();
this.panel_CommanArea.SuspendLayout();
this.panelServerCommands.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
this.dataProtocolFields.SuspendLayout();
this.buttonsAtBottom.SuspendLayout();
this.SuspendLayout();
//
// serverToggle
//
this.serverToggle.Location = new System.Drawing.Point(9, 81);
this.serverToggle.Dock = System.Windows.Forms.DockStyle.Bottom;
this.serverToggle.Location = new System.Drawing.Point(0, 83);
this.serverToggle.Name = "serverToggle";
this.serverToggle.Size = new System.Drawing.Size(75, 23);
this.serverToggle.Size = new System.Drawing.Size(241, 20);
this.serverToggle.TabIndex = 0;
this.serverToggle.Text = "Start server";
this.serverToggle.UseVisualStyleBackColor = true;
@ -111,7 +137,7 @@
this.listenPort.Size = new System.Drawing.Size(95, 20);
this.listenPort.TabIndex = 5;
this.listenPort.Value = new decimal(new int[] {
2048,
15151,
0,
0,
0});
@ -133,83 +159,123 @@
this.panel_serverOptions.Controls.Add(this.label_listenPort);
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
this.panel_serverOptions.Controls.Add(this.label_serverName);
this.panel_serverOptions.Location = new System.Drawing.Point(12, 12);
this.panel_serverOptions.Dock = System.Windows.Forms.DockStyle.Top;
this.panel_serverOptions.Location = new System.Drawing.Point(0, 0);
this.panel_serverOptions.Name = "panel_serverOptions";
this.panel_serverOptions.Size = new System.Drawing.Size(183, 113);
this.panel_serverOptions.Size = new System.Drawing.Size(241, 103);
this.panel_serverOptions.TabIndex = 6;
//
// panel_commands
//
this.panel_commands.Controls.Add(this.mapName);
this.panel_commands.Controls.Add(this.timeLimit);
this.panel_commands.Controls.Add(this.mapName);
this.panel_commands.Controls.Add(this.gameModes);
this.panel_commands.Controls.Add(this.label3);
this.panel_commands.Controls.Add(this.forceStart);
this.panel_commands.Controls.Add(this.label2);
this.panel_commands.Controls.Add(this.label4);
this.panel_commands.Controls.Add(this.label5);
this.panel_commands.Controls.Add(this.labelClientsConnected);
this.panel_commands.Controls.Add(this.label1);
this.panel_commands.Controls.Add(this.nrOfClients);
this.panel_commands.Controls.Add(this.buttonStartGame);
this.panel_commands.Location = new System.Drawing.Point(12, 131);
this.panel_commands.Dock = System.Windows.Forms.DockStyle.Top;
this.panel_commands.Location = new System.Drawing.Point(0, 103);
this.panel_commands.Name = "panel_commands";
this.panel_commands.Size = new System.Drawing.Size(183, 230);
this.panel_commands.Size = new System.Drawing.Size(241, 188);
this.panel_commands.TabIndex = 7;
this.panel_commands.Visible = false;
//
// panel_clientArea
// timeLimit
//
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
this.panel_clientArea.Controls.Add(this.splitter1);
this.panel_clientArea.Controls.Add(this.clientInfoBox);
this.panel_clientArea.Location = new System.Drawing.Point(202, 12);
this.panel_clientArea.Name = "panel_clientArea";
this.panel_clientArea.Size = new System.Drawing.Size(303, 349);
this.panel_clientArea.TabIndex = 8;
this.timeLimit.Location = new System.Drawing.Point(112, 89);
this.timeLimit.Minimum = new decimal(new int[] {
5,
0,
0,
0});
this.timeLimit.Name = "timeLimit";
this.timeLimit.Size = new System.Drawing.Size(123, 20);
this.timeLimit.TabIndex = 11;
this.timeLimit.ThousandsSeparator = true;
this.timeLimit.Value = new decimal(new int[] {
15,
0,
0,
0});
//
// ServerInfoTextArea
// gameModes
//
this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
this.ServerInfoTextArea.ReadOnly = true;
this.ServerInfoTextArea.Size = new System.Drawing.Size(303, 197);
this.ServerInfoTextArea.TabIndex = 1;
this.ServerInfoTextArea.Text = "";
this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.gameModes.FormattingEnabled = true;
this.gameModes.Items.AddRange(new object[] {
"Free-for-all",
"Team death-match"});
this.gameModes.Location = new System.Drawing.Point(77, 61);
this.gameModes.Name = "gameModes";
this.gameModes.Size = new System.Drawing.Size(158, 21);
this.gameModes.TabIndex = 10;
//
// splitter1
// label3
//
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 147);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(303, 5);
this.splitter1.TabIndex = 2;
this.splitter1.TabStop = false;
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(8, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(95, 13);
this.label3.TabIndex = 9;
this.label3.Text = "Time limit (minutes)";
//
// clientInfoBox
// forceStart
//
this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
this.clientInfoBox.FormattingEnabled = true;
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
this.clientInfoBox.Name = "clientInfoBox";
this.clientInfoBox.Size = new System.Drawing.Size(303, 147);
this.clientInfoBox.TabIndex = 0;
this.forceStart.AutoSize = true;
this.forceStart.Checked = true;
this.forceStart.CheckState = System.Windows.Forms.CheckState.Checked;
this.forceStart.Location = new System.Drawing.Point(12, 120);
this.forceStart.Name = "forceStart";
this.forceStart.Size = new System.Drawing.Size(115, 17);
this.forceStart.TabIndex = 1;
this.forceStart.Text = "Ignore empty lobby";
this.forceStart.UseVisualStyleBackColor = true;
//
// buttonStartGame
// label2
//
this.buttonStartGame.Location = new System.Drawing.Point(53, 195);
this.buttonStartGame.Name = "buttonStartGame";
this.buttonStartGame.Size = new System.Drawing.Size(75, 23);
this.buttonStartGame.TabIndex = 6;
this.buttonStartGame.Text = "Start game";
this.buttonStartGame.UseVisualStyleBackColor = true;
this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 69);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 13);
this.label2.TabIndex = 9;
this.label2.Text = "Game mode";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(9, 15);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(57, 13);
this.label4.TabIndex = 8;
this.label4.Text = "Map name";
//
// labelClientsConnected
//
this.labelClientsConnected.AutoSize = true;
this.labelClientsConnected.Location = new System.Drawing.Point(131, 147);
this.labelClientsConnected.Name = "labelClientsConnected";
this.labelClientsConnected.Size = new System.Drawing.Size(80, 13);
this.labelClientsConnected.TabIndex = 8;
this.labelClientsConnected.Text = "Game clients: 0";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 13);
this.label1.TabIndex = 8;
this.label1.Text = "Client limit";
//
// nrOfClients
//
this.nrOfClients.Location = new System.Drawing.Point(78, 36);
this.nrOfClients.Location = new System.Drawing.Point(72, 34);
this.nrOfClients.Maximum = new decimal(new int[] {
20,
0,
@ -221,105 +287,307 @@
0,
0});
this.nrOfClients.Name = "nrOfClients";
this.nrOfClients.Size = new System.Drawing.Size(39, 20);
this.nrOfClients.Size = new System.Drawing.Size(163, 20);
this.nrOfClients.TabIndex = 7;
this.nrOfClients.Value = new decimal(new int[] {
2,
10,
0,
0,
0});
//
// label1
// buttonStartGame
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 13);
this.label1.TabIndex = 8;
this.label1.Text = "Client limit";
this.buttonStartGame.Dock = System.Windows.Forms.DockStyle.Bottom;
this.buttonStartGame.Location = new System.Drawing.Point(0, 166);
this.buttonStartGame.Name = "buttonStartGame";
this.buttonStartGame.Size = new System.Drawing.Size(241, 22);
this.buttonStartGame.TabIndex = 6;
this.buttonStartGame.Text = "Start game";
this.buttonStartGame.UseVisualStyleBackColor = true;
this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
//
// label2
// panel_clientArea
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 69);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 13);
this.label2.TabIndex = 9;
this.label2.Text = "Game mode";
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
this.panel_clientArea.Controls.Add(this.splitter1);
this.panel_clientArea.Controls.Add(this.clientInfoBox);
this.panel_clientArea.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_clientArea.Location = new System.Drawing.Point(241, 0);
this.panel_clientArea.Name = "panel_clientArea";
this.panel_clientArea.Size = new System.Drawing.Size(494, 616);
this.panel_clientArea.TabIndex = 8;
//
// gameModes
// ServerInfoTextArea
//
this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.gameModes.FormattingEnabled = true;
this.gameModes.Items.AddRange(new object[] {
"Free-for-all",
"Team death-match"});
this.gameModes.Location = new System.Drawing.Point(78, 66);
this.gameModes.Name = "gameModes";
this.gameModes.Size = new System.Drawing.Size(99, 21);
this.gameModes.TabIndex = 10;
this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 269);
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
this.ServerInfoTextArea.ReadOnly = true;
this.ServerInfoTextArea.Size = new System.Drawing.Size(494, 347);
this.ServerInfoTextArea.TabIndex = 1;
this.ServerInfoTextArea.Text = "";
//
// timeLimit
// splitter1
//
this.timeLimit.Location = new System.Drawing.Point(109, 94);
this.timeLimit.Minimum = new decimal(new int[] {
5,
0,
0,
0});
this.timeLimit.Name = "timeLimit";
this.timeLimit.Size = new System.Drawing.Size(68, 20);
this.timeLimit.TabIndex = 11;
this.timeLimit.ThousandsSeparator = true;
this.timeLimit.Value = new decimal(new int[] {
5,
0,
0,
0});
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 264);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(494, 5);
this.splitter1.TabIndex = 2;
this.splitter1.TabStop = false;
//
// label3
// clientInfoBox
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(8, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(95, 13);
this.label3.TabIndex = 9;
this.label3.Text = "Time limit (minutes)";
this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
this.clientInfoBox.FormattingEnabled = true;
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
this.clientInfoBox.Name = "clientInfoBox";
this.clientInfoBox.Size = new System.Drawing.Size(494, 264);
this.clientInfoBox.TabIndex = 0;
//
// label4
// panel_CommanArea
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(9, 15);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(57, 13);
this.label4.TabIndex = 8;
this.label4.Text = "Map name";
this.panel_CommanArea.Controls.Add(this.panelServerCommands);
this.panel_CommanArea.Controls.Add(this.panel_commands);
this.panel_CommanArea.Controls.Add(this.panel_serverOptions);
this.panel_CommanArea.Dock = System.Windows.Forms.DockStyle.Left;
this.panel_CommanArea.Location = new System.Drawing.Point(0, 0);
this.panel_CommanArea.Name = "panel_CommanArea";
this.panel_CommanArea.Size = new System.Drawing.Size(241, 616);
this.panel_CommanArea.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(23, 147);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(81, 13);
this.label5.TabIndex = 8;
this.label5.Text = "Lobby clients: 0";
//
// mapName
//
this.mapName.Location = new System.Drawing.Point(78, 7);
this.mapName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mapName.FormattingEnabled = true;
this.mapName.IntegralHeight = false;
this.mapName.Items.AddRange(new object[] {
"Set default"});
this.mapName.Location = new System.Drawing.Point(72, 7);
this.mapName.Name = "mapName";
this.mapName.Size = new System.Drawing.Size(98, 20);
this.mapName.TabIndex = 12;
this.mapName.Size = new System.Drawing.Size(163, 21);
this.mapName.TabIndex = 10;
//
// panelServerCommands
//
this.panelServerCommands.Controls.Add(this.dataProtocolFields);
this.panelServerCommands.Dock = System.Windows.Forms.DockStyle.Top;
this.panelServerCommands.Location = new System.Drawing.Point(0, 291);
this.panelServerCommands.Name = "panelServerCommands";
this.panelServerCommands.Size = new System.Drawing.Size(241, 85);
this.panelServerCommands.TabIndex = 8;
this.panelServerCommands.Visible = false;
//
// buttonExecuteSend
//
this.buttonExecuteSend.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonExecuteSend.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonExecuteSend.Location = new System.Drawing.Point(116, 0);
this.buttonExecuteSend.Margin = new System.Windows.Forms.Padding(0);
this.buttonExecuteSend.Name = "buttonExecuteSend";
this.buttonExecuteSend.Size = new System.Drawing.Size(117, 21);
this.buttonExecuteSend.TabIndex = 0;
this.buttonExecuteSend.Text = "Send";
this.buttonExecuteSend.UseVisualStyleBackColor = true;
//
// panel2
//
this.panel2.Controls.Add(this.button2);
this.panel2.Controls.Add(this.textBox1);
this.panel2.Controls.Add(this.comboBox1);
this.panel2.Controls.Add(this.numericUpDown1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(4, 32);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(233, 21);
this.panel2.TabIndex = 0;
//
// comboBox1
//
this.comboBox1.Dock = System.Windows.Forms.DockStyle.Left;
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.IntegralHeight = false;
this.comboBox1.Items.AddRange(new object[] {
"netBool;",
"netChar;",
"netUChar;",
"netShort;",
"netUShort;",
"netInt;",
"netUInt;",
"netInt64;",
"netUInt64;",
"netFloat;",
"netDouble;",
"netCharPtr;"});
this.comboBox1.Location = new System.Drawing.Point(42, 0);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(78, 21);
this.comboBox1.TabIndex = 10;
//
// numericUpDown1
//
this.numericUpDown1.Dock = System.Windows.Forms.DockStyle.Left;
this.numericUpDown1.Location = new System.Drawing.Point(0, 0);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(42, 20);
this.numericUpDown1.TabIndex = 11;
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Left;
this.textBox1.Location = new System.Drawing.Point(120, 0);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(64, 20);
this.textBox1.TabIndex = 12;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35.29412F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 64.70588F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 110F));
this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.label7, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.label8, 2, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 4);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 27.05882F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(233, 21);
this.tableLayoutPanel1.TabIndex = 9;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(4, 1);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(18, 13);
this.label6.TabIndex = 8;
this.label6.Text = "ID";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(46, 1);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(31, 13);
this.label7.TabIndex = 8;
this.label7.Text = "Type";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(123, 1);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(34, 13);
this.label8.TabIndex = 8;
this.label8.Text = "Value";
//
// dataProtocolFields
//
this.dataProtocolFields.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
this.dataProtocolFields.ColumnCount = 1;
this.dataProtocolFields.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 21F));
this.dataProtocolFields.Controls.Add(this.panel2, 0, 1);
this.dataProtocolFields.Controls.Add(this.tableLayoutPanel1, 0, 0);
this.dataProtocolFields.Controls.Add(this.buttonsAtBottom, 0, 2);
this.dataProtocolFields.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataProtocolFields.Location = new System.Drawing.Point(0, 0);
this.dataProtocolFields.Margin = new System.Windows.Forms.Padding(0);
this.dataProtocolFields.Name = "dataProtocolFields";
this.dataProtocolFields.RowCount = 3;
this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F));
this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.dataProtocolFields.Size = new System.Drawing.Size(241, 85);
this.dataProtocolFields.TabIndex = 9;
//
// buttonAddNewDataField
//
this.buttonAddNewDataField.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonAddNewDataField.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonAddNewDataField.Location = new System.Drawing.Point(0, 0);
this.buttonAddNewDataField.Margin = new System.Windows.Forms.Padding(0);
this.buttonAddNewDataField.Name = "buttonAddNewDataField";
this.buttonAddNewDataField.Size = new System.Drawing.Size(116, 21);
this.buttonAddNewDataField.TabIndex = 1;
this.buttonAddNewDataField.Text = "Add field";
this.buttonAddNewDataField.UseVisualStyleBackColor = true;
this.buttonAddNewDataField.Click += new System.EventHandler(this.buttonAddNewDataField_Click);
//
// button2
//
this.button2.Dock = System.Windows.Forms.DockStyle.Fill;
this.button2.FlatAppearance.BorderColor = System.Drawing.Color.Black;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.Location = new System.Drawing.Point(184, 0);
this.button2.Margin = new System.Windows.Forms.Padding(0);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(49, 21);
this.button2.TabIndex = 0;
this.button2.Text = "remove";
this.button2.UseVisualStyleBackColor = true;
//
// buttonsAtBottom
//
this.buttonsAtBottom.ColumnCount = 2;
this.buttonsAtBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.buttonsAtBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.buttonsAtBottom.Controls.Add(this.buttonAddNewDataField, 0, 0);
this.buttonsAtBottom.Controls.Add(this.buttonExecuteSend, 1, 0);
this.buttonsAtBottom.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonsAtBottom.Location = new System.Drawing.Point(4, 60);
this.buttonsAtBottom.Name = "buttonsAtBottom";
this.buttonsAtBottom.RowCount = 1;
this.buttonsAtBottom.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.buttonsAtBottom.Size = new System.Drawing.Size(233, 21);
this.buttonsAtBottom.TabIndex = 10;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(517, 373);
this.ClientSize = new System.Drawing.Size(735, 616);
this.Controls.Add(this.panel_clientArea);
this.Controls.Add(this.panel_commands);
this.Controls.Add(this.panel_serverOptions);
this.Controls.Add(this.panel_CommanArea);
this.Name = "Form1";
this.Text = "Form1";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClosingEvent);
((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit();
this.panel_serverOptions.ResumeLayout(false);
this.panel_serverOptions.PerformLayout();
this.panel_commands.ResumeLayout(false);
this.panel_commands.PerformLayout();
this.panel_clientArea.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
this.panel_clientArea.ResumeLayout(false);
this.panel_CommanArea.ResumeLayout(false);
this.panelServerCommands.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.dataProtocolFields.ResumeLayout(false);
this.buttonsAtBottom.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -346,7 +614,25 @@
private System.Windows.Forms.NumericUpDown timeLimit;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox mapName;
private System.Windows.Forms.CheckBox forceStart;
private System.Windows.Forms.Label labelClientsConnected;
private System.Windows.Forms.Panel panel_CommanArea;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox mapName;
private System.Windows.Forms.Panel panelServerCommands;
private System.Windows.Forms.Button buttonExecuteSend;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.TableLayoutPanel dataProtocolFields;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button buttonAddNewDataField;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TableLayoutPanel buttonsAtBottom;
}
}

View File

@ -9,6 +9,9 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Interop;
using System.Runtime.InteropServices;
using System.Threading;
using System.Timers;
using System.IO;
namespace StandAloneLauncher
{
@ -16,12 +19,22 @@ namespace StandAloneLauncher
{
System.Windows.Interop.StandaloneGameServerCLI gameServer;
bool serverIsRunning = false;
bool gameIsStarted = false;
public Form1()
{
InitializeComponent();
string[] maps = Directory.GetFiles("..\\Content\\Worlds\\");
for (int i = 0; i < maps.Length; i++)
{
string temp = maps[i].Split('\\').Last() ;
this.mapName.Items.Add(temp);
}
this.gameModes.SelectedIndex = 0;
this.mapName.SelectedIndex = 0;
}
public bool Initiate()
@ -30,17 +43,17 @@ namespace StandAloneLauncher
return true;
}
public void Run()
{
while (this.Created)
{
Application.DoEvents();
//Do some stuff
this.gameServer.ServerUpdate();
this.labelClientsConnected.Text = "Clients connected: " + this.gameServer.GetClientsConnectedCount().ToString();
}
}
private void button1_serverToggle_Click(object sender, EventArgs e)
{
if (this.serverIsRunning)
@ -53,6 +66,7 @@ namespace StandAloneLauncher
this.serverToggle.Text = "Start server";
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server terminated!\n");
this.panel_commands.Visible = false;
this.panelServerCommands.Visible = false;
}
else
{
@ -75,6 +89,7 @@ namespace StandAloneLauncher
this.gameServer.ServerStart();
this.panel_commands.Visible = true;
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server initiated!\n\tListening on port " + this.listenPort.Value.ToString() + "\n\tLocal IP: " + info.serverIp + "\n");
this.panelServerCommands.Visible = true;
}
else
{
@ -85,18 +100,59 @@ namespace StandAloneLauncher
private void buttonStartGame_Click(object sender, EventArgs e)
{
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
//this.gameServer.GameSetMapId(0);
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
if (!this.gameServer.GameStart())
if (!gameIsStarted)
{
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
this.gameServer.GameSetMapName(this.mapName.Text);
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
if (!(gameIsStarted = this.gameServer.GameStart(this.forceStart.Checked)))
{
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
}
else
{
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
this.buttonStartGame.Text = "Stop Game";
this.mapName.Enabled = false;
this.nrOfClients.Enabled = false;
this.gameModes.Enabled = false;
this.timeLimit.Enabled = false;
this.forceStart.Enabled = false;
}
}
else
{
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
this.gameIsStarted = false;
this.buttonStartGame.Text = "Start Game";
this.mapName.Enabled = true;
this.nrOfClients.Enabled = true;
this.gameModes.Enabled = true;
this.timeLimit.Enabled = true;
this.forceStart.Enabled = true;
}
}
private void FormClosingEvent(object sender, FormClosingEventArgs e)
{
if (serverIsRunning)
{
this.gameServer.ServerStop();
}
}
private void buttonAddNewDataField_Click(object sender, EventArgs e)
{
this.dataProtocolFields.RowCount++;
this.dataProtocolFields.SetRow(this.buttonsAtBottom, this.dataProtocolFields.RowCount - 1);
Panel p = new Panel();
p = this.panel2;
this.dataProtocolFields.RowStyles.Add(new RowStyle(SizeType.Absolute, 27));
}
}
}

View File

@ -8,23 +8,31 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace StandAloneLauncher.Properties
{
namespace StandAloneLauncher.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(".\\..\\Content\\")]
public string Dennis {
get {
return ((string)(this["Dennis"]));
}
set {
this["Dennis"] = value;
}
}
}
}

View File

@ -1,7 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="StandAloneLauncher.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Dennis" Type="System.String" Scope="User">
<Value Profile="(Default)">.\..\Content\</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -80,6 +80,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />

View File

@ -36,6 +36,7 @@ namespace LinearAlgebra
const ScalarType & operator [] ( int i ) const;
Quaternion<ScalarType> & operator = ( const Quaternion<ScalarType> &quaternion );
Quaternion<ScalarType> & operator *= ( const Quaternion<ScalarType> &quaternion );
Quaternion<ScalarType> & operator *= ( const ScalarType &scalar );
Quaternion<ScalarType> & operator /= ( const ScalarType &scalar );
Quaternion<ScalarType> & operator += ( const Quaternion<ScalarType> &quaternion );
@ -112,6 +113,12 @@ namespace LinearAlgebra
return *this;
}
template<typename ScalarType>
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const Quaternion<ScalarType> &quaternion )
{
return *this = *this * quaternion;
}
template<typename ScalarType>
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const ScalarType &scalar )
{

View File

@ -52,6 +52,8 @@ OHRESOURCE OysterResource::LoadResource(const wchar_t* filename, ResourceType ty
}
}
if(!resourceData) return 0;
return resourceData->GetResourceHandle();
}
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)

View File

@ -337,7 +337,11 @@ namespace Utility
template<typename ValueType>
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max )
{ return value < min ? Max( value, max ) : min; }
{
if( value < min ) return min;
if( value > max ) return max;
return value;
}
template<typename ValueType>
inline ValueType Average( const ValueType &valueA, const ValueType &valueB )

View File

@ -40,12 +40,13 @@ CustomNetProtocol::CustomNetProtocol()
{
this->privateData = new PrivateData();
}
CustomNetProtocol::CustomNetProtocol(CustomNetProtocol& o)
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
{
this->privateData = new PrivateData();
this->privateData->attributes = o.privateData->attributes;
}
const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
{
if(this->privateData)
{
@ -56,11 +57,29 @@ const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
this->privateData->attributes = o.privateData->attributes;
return *this;
}
CustomNetProtocol::~CustomNetProtocol()
{
delete this->privateData;
this->privateData = 0;
}
const NetAttributeContainer& CustomNetProtocol::operator[](int ID) const
{
//if(!this->privateData) this->privateData = new PrivateData();
if((unsigned int)ID >= this->privateData->attributes.Size())
{
NetAttributeContainer temp;
temp.type = NetAttributeType_UNKNOWN;
memset(&temp.value, 0, sizeof(NetAttributeValue));
this->privateData->attributes.Push(ID, temp);
}
return this->privateData->attributes[ID];
}
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
{
//if(!this->privateData) this->privateData = new PrivateData();

View File

@ -130,10 +130,12 @@ namespace Oyster
public:
CustomNetProtocol();
~CustomNetProtocol();
CustomNetProtocol(CustomNetProtocol& o);
const CustomNetProtocol& operator=(CustomNetProtocol& o);
CustomNetProtocol( const CustomNetProtocol& o);
CustomNetProtocol& operator=(const CustomNetProtocol& o);
const NetAttributeContainer& operator[](int ID) const;
NetAttributeContainer& operator[](int ID);
NetAttributeContainer& operator[](int ID);
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
void Set(int ID, std::string s);
const NetAttributeContainer& Get(int id);

View File

@ -96,6 +96,10 @@ struct NetworkClient::PrivateData : public IThreadObject
//printf("\t(%i)\n", this->sendQueue.Size());
OysterByte temp;
CustomNetProtocol p = this->sendQueue.Pop();
if(p[0].value.netShort == 304)
int i = 0;
this->translator.Pack(temp, p);
errorCode = this->connection.Send(temp);

View File

@ -133,13 +133,7 @@ namespace Oyster
*/
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
/** ! Deprecate !
* Do not use this furthermore, instead use void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
* @see DataRecieved
*/
//virtual void NetworkCallback(Oyster::Network::CustomNetProtocol& p);
virtual std::string GetIpAddress();
std::string GetIpAddress();
private:
NetworkClient(const NetworkClient& obj);

View File

@ -98,9 +98,9 @@ namespace Oyster
protected:
NetClientList clients;
private:
int clientCount;
private:
struct PrivateSessionData;
PrivateSessionData* data;
};

View File

@ -61,8 +61,7 @@ namespace Oyster
struct PostData
{
int x;
int y;
float Amb;
};
struct Text2D

View File

@ -19,11 +19,19 @@ namespace Oyster
Math::Float4x4 Projection;
std::vector<Definitions::Pointlight> Lights;
float deltaTime;
#ifdef _DEBUG
Model::Model* cube;
Model::Model* sphere;
ID3D11RasterizerState* wire;
#endif
}
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, API::Option o)
{
Core::resolution = resulotion;
Core::resolution = o.Resolution;
Core::modelPath = o.modelPath;
Core::texturePath = o.texturePath;
if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail)
{
@ -32,7 +40,33 @@ namespace Oyster
Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png");
Render::Resources::Init();
Definitions::PostData pd;
pd.Amb = o.AmbientValue;
void* data = Render::Resources::Post::Data.Map();
memcpy(data,&pd,sizeof(Definitions::PostData));
Render::Resources::Post::Data.Unmap();
Render::Preparations::Basic::SetViewPort();
#ifdef _DEBUG
//fix load model
cube = CreateModel(L"debug_cube.dan");
sphere = CreateModel(L"debug_sphere.dan");
D3D11_RASTERIZER_DESC desc;
desc.CullMode = D3D11_CULL_BACK;
desc.FillMode = D3D11_FILL_WIREFRAME;
desc.FrontCounterClockwise = false;
desc.DepthBias = 0;
desc.DepthBiasClamp = 0;
desc.DepthClipEnable = true;
desc.SlopeScaledDepthBias = 0;
desc.ScissorEnable = false;
desc.MultisampleEnable = false;
desc.AntialiasedLineEnable = false;
Core::device->CreateRasterizerState(&desc,&wire);
#endif
return API::Sucsess;
}
@ -77,6 +111,14 @@ namespace Oyster
{
Core::modelPath = option.modelPath;
Core::texturePath = option.texturePath;
Definitions::PostData pd;
pd.Amb = option.AmbientValue;
void* data = Render::Resources::Post::Data.Map();
memcpy(data,&pd,sizeof(Definitions::PostData));
Render::Resources::Post::Data.Unmap();
return API::Sucsess;
}
@ -113,6 +155,11 @@ namespace Oyster
void API::Clean()
{
#ifdef _DEBUG
DeleteModel(cube);
DeleteModel(sphere);
SAFE_RELEASE(wire);
#endif
DeleteTexture(Render::Resources::Gui::Text::Font);
SAFE_DELETE(Core::viewPort);
Core::loader.Clean();
@ -127,6 +174,7 @@ namespace Oyster
SAFE_RELEASE(Core::swapChain);
SAFE_RELEASE(Core::deviceContext);
SAFE_RELEASE(Core::device);
}
void API::AddLight(Definitions::Pointlight light)
@ -145,6 +193,24 @@ namespace Oyster
Render::Resources::InitShaders();
return State::Sucsess;
}
void API::StartRenderWireFrame()
{
Core::deviceContext->RSSetState(wire);
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
}
void API::RenderDebugCube(Math::Matrix world)
{
cube->WorldMatrix = world;
Render::DefaultRenderer::RenderScene(cube,1,View,Projection);
}
void API::RenderDebugSphere(Math::Matrix world)
{
sphere->WorldMatrix = world;
Render::DefaultRenderer::RenderScene(sphere,1,View,Projection);
}
#endif
API::Option API::GetOption()
@ -153,6 +219,7 @@ namespace Oyster
o.BytesUsed = Core::UsedMem;
o.modelPath = Core::modelPath;
o.texturePath = Core::texturePath;
o.Resolution = Core::resolution;
return o;
}

View File

@ -27,13 +27,30 @@ namespace Oyster
struct Option
{
std::wstring modelPath, texturePath;
//between 0-1
float AmbientValue;
Math::Float2 Resolution;
//Bytes on the GPU
int BytesUsed;
};
typedef void* Texture;
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options);
#ifdef _DEBUG
static State ReloadShaders();
//should be called after rendered normal models, before GUI or Text rendering
static void StartRenderWireFrame();
//Render a unit cube with the presented WorldMatrix
static void RenderDebugCube(Math::Matrix world);
//Render a unit Sphere with the presented WorldMatrix
static void RenderDebugSphere(Math::Matrix world);
static void StartRenderFullModel();
#endif
//! @todo Memory Leaks

View File

@ -1,6 +1,6 @@
<?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>
</Project>

View File

@ -16,7 +16,8 @@ namespace Oyster
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
{
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,0));
Preparations::Basic::ClearDepthStencil(Resources::Gui::depth);
Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0));
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass);
Lights[1];
@ -38,14 +39,6 @@ namespace Oyster
data = Resources::Light::PointLightsData.Map();
memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights);
Resources::Light::PointLightsData.Unmap();
Definitions::PostData pd;
pd.x = (int)lc.Pixels.x;
pd.y = (int)lc.Pixels.y;
data = Resources::Post::Data.Map();
memcpy(data, &pd, sizeof(Definitions::PostData));
Resources::Post::Data.Unmap();
}
void DefaultRenderer::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float deltaTime)
@ -57,8 +50,8 @@ namespace Oyster
if(models[i].Visible)
{
Definitions::PerModel pm;
pm.WV = View * models[i].WorldMatrix;
pm.WVP = Projection * pm.WV;
pm.WV = View * models[i].WorldMatrix.GetTranspose().GetInverse();
pm.WVP = Projection * View * models[i].WorldMatrix;
Model::ModelInfo* info = models[i].info;

View File

@ -9,7 +9,7 @@ namespace Oyster
namespace Render
{
const int TEXT_NR_LETTERS=95;
const float TEXT_SPACING=1.8f;
const float TEXT_SPACING=2.0f;
void Gui::Begin2DRender()
{
@ -20,8 +20,8 @@ namespace Oyster
{
Core::deviceContext->PSSetShaderResources(0,1,&tex);
pos *= 2;
pos -= 1;
pos.xy *= 2;
pos.xy -= 1;
pos.y *= -1;
Definitions::GuiData gd;

View File

@ -62,6 +62,7 @@ namespace Oyster
ID3D11BlendState* Resources::RenderStates::bs = NULL;
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
ID3D11DepthStencilView* Resources::Gui::depth = NULL;
#pragma endregion
@ -159,7 +160,7 @@ namespace Oyster
D3D11_RASTERIZER_DESC rdesc;
rdesc.CullMode = D3D11_CULL_BACK;
rdesc.FillMode = D3D11_FILL_SOLID;
rdesc.FrontCounterClockwise = false;
rdesc.FrontCounterClockwise = true;
rdesc.DepthBias = 0;
rdesc.DepthBiasClamp = 0;
rdesc.DepthClipEnable = true;
@ -304,6 +305,7 @@ namespace Oyster
ID3D11Texture1D *pTexture1;
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 );
Core::UsedMem += T1desc.Width * 16;
Core::device->CreateShaderResourceView( pTexture1, 0, &Light::SSAOKernel );
pTexture1->Release();
@ -323,8 +325,33 @@ namespace Oyster
ID3D11Texture2D *pTexture2;
Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 );
Core::UsedMem += T2desc.Height * T2desc.Width * 16;
Core::device->CreateShaderResourceView( (pTexture2), 0, &Light::SSAORandom );
pTexture2->Release();
//create Depth Buffer
D3D11_TEXTURE2D_DESC dTDesc;
dTDesc.MipLevels=1;
dTDesc.ArraySize=1;
dTDesc.Format = DXGI_FORMAT_D32_FLOAT;
dTDesc.Usage = D3D11_USAGE_DEFAULT;
dTDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
dTDesc.CPUAccessFlags=0;
dTDesc.MiscFlags=0;
dTDesc.Height = (UINT)Core::resolution.y;
dTDesc.Width = (UINT)Core::resolution.x;
dTDesc.SampleDesc.Count=1;
dTDesc.SampleDesc.Quality=0;
ID3D11Texture2D* depthstencil;
Core::device->CreateTexture2D(&dTDesc,0,&depthstencil);
Core::UsedMem += dTDesc.Height * dTDesc.Width * 4;
Core::device->CreateDepthStencilView(depthstencil,NULL,&Gui::depth);
depthstencil->Release();
D3D11_DEPTH_STENCIL_DESC dDesc;
return Core::Init::Success;
}
@ -390,10 +417,13 @@ namespace Oyster
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
Gui::Pass.RTV.push_back(GBufferRTV[2]);
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
Gui::Pass.CBuffers.Pixel.push_back(Color);
Gui::Pass.depth = Gui::depth;
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
@ -405,6 +435,7 @@ namespace Oyster
Gui::Pass.RenderStates.SampleCount = 1;
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
Gui::Pass.RenderStates.BlendState = RenderStates::bs;
Gui::Pass.RenderStates.DepthStencil = RenderStates::dsState;
////---------------- Blur Pass Setup ----------------------------
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
@ -442,9 +473,13 @@ namespace Oyster
Gui::Text::Pass.CBuffers.Pixel.push_back(Color);
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
Gui::Text::Pass.depth = Gui::depth;
Gui::Text::Pass.RenderStates.SampleCount = 1;
Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss;
Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs;
Gui::Text::Pass.RenderStates.DepthStencil = RenderStates::dsState;
return Core::Init::Success;
}
@ -510,6 +545,8 @@ namespace Oyster
SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState);
SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout);
SAFE_RELEASE(Gui::depth);
}
}
}

View File

@ -64,6 +64,7 @@ namespace Oyster
{
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Data;
static ID3D11DepthStencilView* depth;
struct Text
{
static Core::PipelineManager::RenderPass Pass;

View File

@ -4,19 +4,19 @@
void main(point Vertex2DIn input[1],inout TriangleStream<Pixel2DIn> Quads)
{
Pixel2DIn output;
output.Pos = mul(float4(-1,-1,1,1) ,Translation);
output.Pos = mul(float4(-1,-1,0,1) ,Translation);
output.Uv = float2(0,1);
Quads.Append(output);
output.Pos = mul(float4(-1,1,1,1), Translation);
output.Pos = mul(float4(-1,1,0,1), Translation);
output.Uv = float2(0,0);
Quads.Append(output);
output.Pos = mul(float4(1,-1,1,1), Translation);
output.Pos = mul(float4(1,-1,0,1), Translation);
output.Uv = float2(1,1);
Quads.Append(output);
output.Pos = mul(float4(1,1,1,1), Translation);
output.Pos = mul(float4(1,1,0,1), Translation);
output.Uv = float2(1,0);
Quads.Append(output);
}

View File

@ -7,22 +7,22 @@ void main(point Text2DIn input[1],inout TriangleStream<Pixel2DIn> Quads)
float endoff=startoff+input[0].coff;
Pixel2DIn output;
output.Pos = mul(float4(-1,-1,1,1), Translation);
output.Pos = mul(float4(-1,-1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(startoff,1);
Quads.Append(output);
output.Pos = mul(float4(-1,1,1,1), Translation);
output.Pos = mul(float4(-1,1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(startoff,0);
Quads.Append(output);
output.Pos = mul(float4(1,-1,1,1), Translation);
output.Pos = mul(float4(1,-1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(endoff,1);
Quads.Append(output);
output.Pos = mul(float4(1,1,1,1), Translation);
output.Pos = mul(float4(1,1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(endoff,0);
Quads.Append(output);

View File

@ -27,7 +27,7 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
blurCol +=Weights[i + blurRadius] * gCache[k];
}
outTex[ThreadID.xy + Start] = blurCol * BlurMask + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);
outTex[min(ThreadID.xy + Start, Stop-1)] = blurCol * BlurMask + inTex[min(ThreadID.xy + Start, Stop-1)] * ( float4(1,1,1,1) - BlurMask);
//outTex[ThreadID.xy + Start] = inTex[ThreadID.xy + Start];
}

View File

@ -11,10 +11,10 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
}
if(gThreadID.y >= N-blurRadius)
{
int y = min(ThreadID.y+blurRadius, Stop.y-1);
int y = min(ThreadID.y +blurRadius, Stop.y-1);
gCache[gThreadID.y+2*blurRadius] = inTex[int2(ThreadID.x,y) + Start];
}
gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy + Start, Stop.xy-1)];
gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy + Start, Stop-1)];
GroupMemoryBarrierWithGroupSync();
@ -27,6 +27,6 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
blurCol +=Weights[i + blurRadius] * gCache[k];
}
outTex[ThreadID.xy + Start] = blurCol + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);;
outTex[min(ThreadID.xy + Start, Stop-1)] = blurCol * BlurMask + inTex[min(ThreadID.xy + Start, Stop-1)] * ( float4(1,1,1,1) - BlurMask);;
//outTex[ThreadID.xy + Start] = inTex[ThreadID.xy+ Start];
}

View File

@ -8,11 +8,9 @@ SamplerState S1 : register(s0);
cbuffer Size : register(b0)
{
int2 Pixels;
float AmbFactor;
}
#define AmbFactor 0.1f;
float4 SuperSample(float4 Glow, uint3 DTid)
{
// Line X
@ -20,7 +18,7 @@ float4 SuperSample(float4 Glow, uint3 DTid)
index += float2(0,Output.Length.y/2);
index = index / Output.Length;
Glow = Ambient.SampleLevel(S1, index,1);
Glow = Glow * Glow.w*10;
Glow = Glow;
return Glow;
}
@ -30,13 +28,10 @@ void main( uint3 DTid : SV_DispatchThreadID )
{
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0);
//float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
Glow = SuperSample(Glow,DTid);
float4 GUI;
uint2 index = DTid.xy/2 + uint2((uint)Pixels.x/(uint)2,0);
uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);
float3 PostLight = Amb.xyz * AmbFactor;
PostLight = PostLight + Light.xyz + Glow;
GUI = float4(Ambient[index]);
@ -44,4 +39,5 @@ void main( uint3 DTid : SV_DispatchThreadID )
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(0,Output.Length.y*0.5f)].xyz,1);
//Output[DTid.xy] = Ambient[DTid.xy];
}