Merge pull request #99 from teamfisk/Menu

Menu
This commit is contained in:
Adam Byléhn
2016-02-11 15:44:17 +01:00
7 changed files with 20 additions and 265 deletions
+6 -3
View File
@@ -17,7 +17,7 @@
struct SpriteJob : RenderJob
{
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage)
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted)
: RenderJob()
{
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
@@ -34,8 +34,11 @@ struct SpriteJob : RenderJob
Color = cSprite["Color"];
Entity = cSprite.EntityID;
Position = Transform::AbsolutePosition(world, cSprite.EntityID);
glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1));
Depth = viewpos.z;
Depth = 0;
if (depthSorted) {
glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1));
Depth = viewpos.z;
}
World = world;
FillColor = fillColor;
@@ -17,33 +17,6 @@ public:
virtual void Update(double dt) override;
private:
//methods which will take care of specific events
/* EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
EventRelay<CapturePointSystem, Events::TriggerLeave> m_ETriggerLeave;
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
bool CapturePointSystem::OnCaptured(const Events::Captured& e);*/
//bool m_WinnerWasFound = false;
////need to track these variables for the captureSystem to work as per design!
//const int m_NotACapturePoint = 999;
//int m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint;
//int m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint;
//int m_RedTeamHomeCapturePoint = m_NotACapturePoint;
//int m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
//int m_NumberOfCapturePoints = 0;
//std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
////std::vector<ComponentWrapper>
//const double m_CaptureTimeToTakeOver = 15.0;
//bool m_ResetTimers = false;
////vectors which will keep track of enter/leave changes
//std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
//std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerLeaveVector;
};
#endif
+1
View File
@@ -4,4 +4,5 @@
<GlowMap></GlowMap>
<Color R="1" G="1" B="1" A="1"/>
<Visible>true</Visible>
<DepthSort>true</DepthSort>
</Sprite>
+3
View File
@@ -21,6 +21,9 @@
<xs:element name="Visible" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="DepthSort" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
+4 -1
View File
@@ -623,9 +623,12 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
for(auto& job : jobs) {
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
RenderState jobState;
if (spriteJob) {
if(spriteJob->Depth == 0) {
jobState.Disable(GL_DEPTH_TEST);
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
+3 -1
View File
@@ -62,6 +62,7 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
std::string diffuseResource = cSprite["DiffuseTexture"];
std::string glowResource = cSprite["GlowMap"];
bool depthSorted = cSprite["DepthSort"];
if (diffuseResource.empty() && glowResource.empty()) {
continue;
}
@@ -77,7 +78,8 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world);
//modelMatrix *= m_Camera->BillboardMatrix();
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage));
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted));
jobs.push_back(spriteJob);
}
+3 -233
View File
@@ -4,10 +4,6 @@ CapturePointHUDSystem::CapturePointHUDSystem(SystemParams params)
: System(params)
, ImpureSystem()
{
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
//EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
//EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
//EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
}
@@ -21,12 +17,12 @@ void CapturePointHUDSystem::Update(double dt)
auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD");
auto CapturePoints = m_World->GetComponents("CapturePoint");
for(auto& cCapturePointHUD : *CapturePointHUDElements) {
for (auto& cCapturePointHUD : *CapturePointHUDElements) {
int HUD_ID = cCapturePointHUD["CapturePointNumber"];
EntityWrapper entityHUD = EntityWrapper(m_World, cCapturePointHUD.EntityID);
EntityWrapper entityHUDparent = entityHUD.Parent();
for(auto& cCapturePoint : *CapturePoints) {
for (auto& cCapturePoint : *CapturePoints) {
EntityWrapper entityCP = EntityWrapper(m_World, cCapturePoint.EntityID);
//Check if the HUD corresponds to the Capture Point Number
@@ -53,230 +49,4 @@ void CapturePointHUDSystem::Update(double dt)
}
}
}
//if (m_WinnerWasFound) {
// return;
//}
//const int capturePointNumber = cCapturePoint["CapturePointNumber"];
//const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
////if point doesnt have a teamComponent yet, add one. since:
////what if capture point has no team -> we cant get/use the team enum from it...
//if (!hasTeamComponent) {
// m_World->AttachComponent(cCapturePoint.EntityID, "Team");
// ComponentWrapper& teamComponent = capturePointEntity["Team"];
// teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator");
//}
//ComponentWrapper& teamComponent = capturePointEntity["Team"];
//const int redTeam = (int)teamComponent["Team"].Enum("Red");
//const int blueTeam = (int)teamComponent["Team"].Enum("Blue");
//const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator");
//int homePointForTeam = (int)cCapturePoint["HomePointForTeam"];
//if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) {
// m_NumberOfCapturePoints = capturePointNumber + 1;//ex 2 -> 0,1,2 = 3
// if (homePointForTeam == redTeam) {
// m_RedTeamHomeCapturePoint = capturePointNumber;
// m_BlueTeamHomeCapturePoint = 0;
// } else {
// m_BlueTeamHomeCapturePoint = capturePointNumber;
// m_RedTeamHomeCapturePoint = 0;
// }
//}
////if we havent received all capturepoints yet, just return
//if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) {
// m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
// return;
//}
////we have all capturepoints now - process stuff
//int ownedBy = teamComponent["Team"];
//int redTeamPlayersStandingInside = 0;
//int blueTeamPlayersStandingInside = 0;
//if (capturePointEntity.HasComponent("Model")) {
// //Now sets team color to the capturepoint, or white if it is uncaptured.
// capturePointEntity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3);
//}
////calculate next possible capturePoint for both teams
//std::map<std::string, int> nextPossibleCapturePoint;
//nextPossibleCapturePoint["Red"] = -1;
//nextPossibleCapturePoint["Blue"] = -1;
//for (int i = 0; i < m_NumberOfCapturePoints; i++)
//{
// if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
// continue;
// }
// ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"];
// if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
// nextPossibleCapturePoint["Red"] = i + 1;
// }
// if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint == 0) {
// nextPossibleCapturePoint["Blue"] = i + 1;
// }
//}
//for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
//{
// if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
// continue;
// }
// ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"];
// if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
// nextPossibleCapturePoint["Red"] = i - 1;
// }
// if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint != 0) {
// nextPossibleCapturePoint["Blue"] = i - 1;
// }
//}
////reset timers and reset the bool that triggers this
//if (m_ResetTimers) {
// for (int i = 0; i < m_NumberOfCapturePoints; i++)
// {
// ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"];
// if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
// (int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) {
// capturePoint["CaptureTimer"] = 0.0;
// }
// }
// m_ResetTimers = false;
//}
////colorize next possible capturepoint
//if (nextPossibleCapturePoint["Red"] == capturePointNumber) {
// capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3);
//}
//if (nextPossibleCapturePoint["Blue"] == capturePointNumber) {
// capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3);
//}
////check how many players are standing inside and are healthy
//for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--)
//{
// auto triggerTouched = m_ETriggerTouchVector[i - 1];
// if (std::get<1>(triggerTouched) == capturePointEntity) {
// //some player has touched this - lets figure out: what team, health
// EntityWrapper player = std::get<0>(triggerTouched);
// //check if its really a player that has triggered the touch
// if (!player.HasComponent("Player")) {
// //if a non-player has entered the capturePoint, just erase that event and continue
// m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1);
// continue;
// }
// bool hasHealthComponent = player.HasComponent("Health");
// if (hasHealthComponent) {
// double currentHealth = player["Health"]["Health"];
// //check if player is dead
// if ((int)currentHealth == 0) {
// continue;
// }
// }
// //check team - spectatorNumber = "no team"
// int teamNumber = player["Team"]["Team"];
// if (teamNumber == redTeam) {
// redTeamPlayersStandingInside++;
// } else if (teamNumber == blueTeam) {
// blueTeamPlayersStandingInside++;
// }
// continue;
// }
//}
////create data to be used in option B
////check so this is the next possible capture point for the take-over team and see if only one team is standing inside it
//double timerDeltaChange = 0.0;
//int currentTeam = 0;
//bool canCapture = false;
//if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) {
// timerDeltaChange = redTeamPlayersStandingInside*dt;
// currentTeam = redTeam;
// canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber;
//}
//if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) {
// timerDeltaChange = -blueTeamPlayersStandingInside*dt;
// currentTeam = blueTeam;
// canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber;
//}
//if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside == 0) {
// //A.nobodys standing inside
// //do nothing (?)
//} else if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside > 0) {
// //C.both teams have players inside
// //do nothing (?)
//} else {
// //B. at most one of the teams have players inside
// //if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly
// if (ownedBy != currentTeam && canCapture) {
// if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) {
// LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently.
// }
// cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
// }
// //if capturePoint is owned by the team, and the other team has been trying to take it, then increase/decrease the timer towards 0.0
// if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < 0.0) ||
// (ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > 0.0)) {
// cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
// }
// //check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event
// if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) {
// teamComponent["Team"] = currentTeam;
// cCapturePoint["CaptureTimer"] = 0.0;
// //publish Captured event
// LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently.
// Events::Captured e;
// e.CapturePointID = cCapturePoint.EntityID;
// e.TeamNumberThatCapturedCapturePoint = currentTeam;
// m_EventBroker->Publish(e);
// //NextPossibleCapturePoint will be calculated in the next update...
// }
//}
////check for possible winCondition = check if the homebase is owned by the other team
//bool checkForWinner = false;
//if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam)
//{
// checkForWinner = true;
//}
//if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam)
//{
// checkForWinner = true;
//}
//if (checkForWinner && !m_WinnerWasFound)
//{
// //publish Win event
// Events::Win e;
// e.TeamThatWon = ownedBy;
// m_EventBroker->Publish(e);
// m_WinnerWasFound = true;
//}
}
//
//bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
//{
// //personEntered = e.Entity, thingEntered = e.Trigger
// m_ETriggerTouchVector.push_back(std::make_tuple(e.Entity, e.Trigger));
// return true;
//}
//
//bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e)
//{
// for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++)
// {
// auto triggerTouched = m_ETriggerTouchVector[i];
// if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) {
// m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i);
// break;
// }
// }
// return true;
//}
//bool CapturePointSystem::OnCaptured(const Events::Captured& e)
//{
// //reset the timers in the next update since a capture has changed the "nextCapturePoint" for 1-2 teams
// m_ResetTimers = true;
// return true;
//}
}