Commit 82a114c4 authored by AL's avatar AL

preparing amera class for evolution

parent 4649c380
......@@ -16,7 +16,7 @@ DirectX::XMMATRIX Camera::GetMatrix() const noexcept
const dx::XMVECTOR forwardBaseVector = XMVectorSet( 0.0f,0.0f,1.0f,0.0f );
// apply the camera rotations to a base vector
const auto lookVector = XMVector3Transform( forwardBaseVector,
XMMatrixRotationRollPitchYaw( 0.0f,yaw,0.0f )
XMMatrixRotationRollPitchYaw( roll,pitch,yaw)
);
// generate camera transform (applied to all objects to arrange them relative
// to camera position/orientation in world) from cam position and direction
......@@ -53,8 +53,17 @@ void Camera::SpawnControlWindow() noexcept
void Camera::Reset() noexcept
{
pos = { 1.0f,1.0f,1.0f };
pitch = 0.0f;
yaw = PI/2;
roll = 0.0f;
pitch = PI/2.0f;
yaw = 0.0f;
}
void Camera::SetFullTransform(CamTilt in_tilt, CamMove in_move)
{
Translate({ in_move.x, in_move.y, in_move.z });
roll = in_tilt.roll;
pitch = in_tilt.pitch;
yaw = in_tilt.yaw;
}
void Camera::Rotate( float dx,float dy ) noexcept
......
#pragma once
#include "./Framework/DXGraphics.h"
struct CamTilt
{
float roll;
float pitch;
float yaw;
};
struct CamMove
{
float x;
float y;
float z;
};
class Camera
{
public:
......@@ -9,10 +21,12 @@ public:
DirectX::XMFLOAT3 GetPosition() const noexcept;
void SpawnControlWindow() noexcept;
void Reset() noexcept;
void SetFullTransform(CamTilt in_tilt, CamMove in_move);
void Rotate( float dx,float dy ) noexcept;
void Translate( DirectX::XMFLOAT3 translation ) noexcept;
private:
DirectX::XMFLOAT3 pos;
float roll;
float pitch;
float yaw;
static constexpr float travelSpeed = 7.0f;
......
#include "CameraManager.h"
void CameraManager::PendScenario(Scenario s)
{
pendingScenarios.push_back(s);
}
DirectX::XMMATRIX CameraManager::GetMatrix() const noexcept
{
return cam.GetMatrix();
}
DirectX::XMFLOAT3 CameraManager::GetPosition() const noexcept
{
return cam.GetPosition();
}
CameraManager::CameraScenario::CameraScenario(CameraManager::CamSequence cs):stages(std::move(cs))
{}
bool CameraManager::CameraScenario::Update(float dt)
{
stageTime += dt;
if (stageTime > std::get<float>(stages.front()))
{
stages.pop();
stageTime = 0.0f;
}
if (stages.empty())return true;
else return false;
}
std::pair<CamTilt, CamMove> CameraManager::CameraScenario::GetCamData()
{
return std::make_pair(std::get<CamTilt>(stages.front()), std::get<CamMove>(stages.front()));
}
std::vector<CameraManager::Scenario> CameraManager::pendingScenarios;
\ No newline at end of file
#pragma once
#include "Camera.h"
#include <queue>
class CameraManager
{
typedef std::queue<std::tuple<CamTilt, CamMove, float>> CamSequence;
class CameraScenario
{
public:
CameraScenario(CameraManager::CamSequence cs);
CameraScenario(CameraScenario&&) = default;
CameraScenario(const CameraScenario&) = default;
CameraScenario& operator=(CameraScenario&&) = default;
CameraScenario& operator=(const CameraScenario&) = default;
bool Update(float dt); //returns 1 if all stages are passed
std::pair<CamTilt, CamMove>GetCamData();
private:
CameraManager::CamSequence stages;
float stageTime = 0.0f;
};
public:
enum class Scenario
{
ThrowSand,
UnsettleDust,
Strike,
Defend
};
static void PendScenario(Scenario s);
DirectX::XMMATRIX GetMatrix() const noexcept;
DirectX::XMFLOAT3 GetPosition() const noexcept;
private:
CamTilt baseCamTilt;
CamMove baseCamPos;
Camera cam;
std::vector<CameraScenario> scenarious;
static std::vector<Scenario> pendingScenarios;
};
\ No newline at end of file
......@@ -514,7 +514,7 @@ void CombatManager::HandleEvent(SkillEvent ev)
playerProduced = true;
attacked = true;
fRoll = RU.GetFloat0to1();
enMan->SetState(EnemyCombat::State::GhoulCovering);
enMan->SetState(EnemyCombat::State::GhoulPreparingCover);
if (fRoll < playMan->GetCritMod())
{
sDmg = 2u * RU.GetUInt((size_t)ev.valLow, (size_t)ev.valHigh); //crit
......@@ -544,7 +544,7 @@ void CombatManager::HandleEvent(SkillEvent ev)
fRoll = RU.GetFloat0to1();
if (fRoll < playMan->GetCritMod())
{
enMan->SetState(EnemyCombat::State::GhoulCovering);
enMan->SetState(EnemyCombat::State::GhoulPreparingCover);
sDmg = 2u*RU.GetUInt((size_t)ev.valLow, (size_t)ev.valHigh); //crit
if (enMan->GetBlock() < sDmg)
{
......
......@@ -178,6 +178,7 @@
<ItemGroup>
<ClInclude Include="AchievementManager.h" />
<ClInclude Include="AchievementsScreen.h" />
<ClInclude Include="CameraManager.h" />
<ClInclude Include="HPBar.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="ChiliXM.h" />
......@@ -353,6 +354,7 @@
<ClCompile Include="AchievementManager.cpp" />
<ClCompile Include="AchievementsScreen.cpp" />
<ClCompile Include="ActionBox.cpp" />
<ClCompile Include="CameraManager.cpp" />
<ClCompile Include="EffectHandler.cpp" />
<ClCompile Include="Framework\FrameCommander.cpp" />
<ClCompile Include="HPBar.cpp" />
......
......@@ -579,6 +579,9 @@
<ClInclude Include="HudTranslucent.h">
<Filter>Header Files\commentedOut</Filter>
</ClInclude>
<ClInclude Include="CameraManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game.cpp">
......@@ -884,6 +887,9 @@
<ClCompile Include="HudTranslucent.cpp">
<Filter>Header Files\commentedOut</Filter>
</ClCompile>
<ClCompile Include="CameraManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="PhongVSNormalMap.hlsl">
......
......@@ -288,3 +288,13 @@ void LevelLayout::UpdateAndBindLight(float dt, DirectX::XMMATRIX cameraTransform
{
sl.UpdateAndBind(dt, gfx, cameraTransform);
}
DirectX::XMMATRIX LevelLayout::GetCameraMatrix() const noexcept
{
return camMan.GetMatrix();
}
DirectX::XMFLOAT3 LevelLayout::GetCameraPosition() const noexcept
{
return camMan.GetPosition();
}
......@@ -6,6 +6,7 @@
#include <unordered_map>
#include "../CombatManager.h"
#include "../SceneLight.h"
#include "../CameraManager.h"
class LevelLayout
{
......@@ -109,6 +110,8 @@ public:
}
void SubmitDrawables();
void UpdateAndBindLight(float dt, DirectX::XMMATRIX cameraTransform);
DirectX::XMMATRIX GetCameraMatrix() const noexcept; //only called from Game class
DirectX::XMFLOAT3 GetCameraPosition() const noexcept;
private:
void RemoveCorpses();
DXGraphics& gfx; //to reduce the amount of argument passing
......@@ -120,5 +123,6 @@ private:
std::vector<std::pair<std::vector<PositionData>, std::vector<Enemy::Model>>> enemiesForDrawing;
bool enemyWasDead = false;
SceneLight sl;
CameraManager camMan;
EnemyCombat::State previousState;
};
\ No newline at end of file
......@@ -29,7 +29,7 @@ Game::Game():
am.Init();
//TextDrawingUnit::Init();
//CombatManager::StartBattle(0);
wnd.DXGfx().SetCamera(dx::XMMatrixTranslation(8.0f, 7.0f, 3.0f));
//wnd.DXGfx().SetCamera(dx::XMMatrixTranslation(8.0f, 7.0f, 3.0f));
wnd.DXGfx().SetProjection(dx::XMMatrixPerspectiveLH(1.0f, 9.0f / 16.0f, 0.5f, 400.0f));
}
......@@ -75,9 +75,9 @@ int Game::Go()
}
const auto dt = timer.Mark() * speed_factor;
wnd.DXGfx().BeginFrame(0.07f, 0.0f, 0.12f);
wnd.DXGfx().SetCamera(cam.GetMatrix());
wnd.DXGfx().SetCamPos(cam.GetPosition());
ll.UpdateAndBindLight(dt, cam.GetMatrix());
wnd.DXGfx().SetCamera(ll.GetCameraMatrix());
ll.UpdateAndBindLight(dt, ll.GetCameraMatrix());
wnd.DXGfx().SetCamPos(ll.GetCameraPosition());
......@@ -117,13 +117,13 @@ int Game::Go()
}
}*/
while (const auto delta = wnd.mouse.ReadRawDelta())
{
if (!wnd.CursorEnabled())
{
cam.Rotate((float)delta->x, (float)delta->y);
}
}
//while (const auto delta = wnd.mouse.ReadRawDelta())
//{
// if (!wnd.CursorEnabled())
// {
// cam.Rotate((float)delta->x, (float)delta->y);
// }
//}
// imgui windows
//cam.SpawnControlWindow();
......
......@@ -15,7 +15,6 @@
#include "./Framework/Drawable.h"
#include"./Framework/SolidSphere.h"
#include "Camera.h"
#include "Framework/FrameCommander.h"
#include "./Framework/PointLight.h"
#include "./Framework/PlaneTexNorm.h"
......@@ -49,7 +48,6 @@ private:
SoundPlayer snd;
FrameTimer timer;
float speed_factor = 1.0f;
Camera cam;
//PointLight light;
float dt=0.0f;
FrameCommander fc;
......
......@@ -14,7 +14,7 @@ public:
{
id = 1001;
valLow = 5.0f;
valHigh = 10.0f;
valHigh = 7.0f;
succChance = 0.0f;
type = AbilityType::Attack;
};
......@@ -33,8 +33,8 @@ public:
break;
default:
break;
}
owner->AddEvent(SkillEvent(EventType::Player_PhysicalDamage, valLow, valHigh));
}
owner->AddEvent(SkillEvent(EventType::Player_PhysicalAttackedWithBleed, valLow, valHigh));
dynamic_cast<EnemyCombat*>(owner)->SetState(EnemyCombat::State::GhoulAttack); //only enemy can have these skills
SceneLight::PendDistortion(SceneLight::LightDistortionType::DarkeningFlicker);
}
......@@ -104,7 +104,7 @@ public:
default:
break;
}
owner->AddEvent(SkillEvent(EventType::Player_PhysicalAttackedWithBleed, valLow, valHigh));
owner->AddEvent(SkillEvent(EventType::Player_PhysicalDamage, valLow, valHigh));
dynamic_cast<EnemyCombat*>(owner)->SetState(EnemyCombat::State::GhoulAttack);
SceneLight::PendDistortion(SceneLight::LightDistortionType::DarkeningFlicker);
}
......@@ -112,7 +112,7 @@ public:
Ghoul::Ghoul()
{
HP = 1u;
HP = 75u;
maxHP = 75u;
speed = 1.0f;
block = 0u;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment