Logic in CapturePointSystem is working again. Need to update all Tests!
This commit is contained in:
@@ -61,6 +61,7 @@ public:
|
||||
|
||||
iterator begin() const;
|
||||
iterator end() const;
|
||||
size_t size() const;
|
||||
|
||||
//Dumps information about what the pool memory looks like right now
|
||||
//into an output stream (e.g. file/std::cout, anything that has an operator<<)
|
||||
|
||||
@@ -28,15 +28,23 @@ private:
|
||||
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_Team1NextPossibleCapturePoint = m_NotACapturePoint;
|
||||
int m_Team2NextPossibleCapturePoint = m_NotACapturePoint;
|
||||
int m_Team1HomeCapturePoint = m_NotACapturePoint;
|
||||
int m_Team2HomeCapturePoint = m_NotACapturePoint;
|
||||
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, EntityID> m_CapturePointNumberToEntityIDMap;
|
||||
|
||||
//std::vector<ComponentWrapper>
|
||||
|
||||
std::map<std::string, int> m_NextPossibleCapturePoint;
|
||||
const double m_CaptureTimeToTakeOver = 15.0;
|
||||
|
||||
//vectors which will keep track of enter/leave changes
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
<CapturePoint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePoint.xsd">
|
||||
<CapturePointNumber>0</CapturePointNumber>
|
||||
<CaptureTimer>0</CaptureTimer>
|
||||
<HomePointForTeam><Spectator/></HomePointForTeam>
|
||||
</CapturePoint>
|
||||
@@ -3,6 +3,18 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
|
||||
<xs:complexType name="TeamEnum" mixed="true">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="t:enum">
|
||||
<xs:choice>
|
||||
<xs:element name="Spectator" type="xs:integer" fixed="1" minOccurs="0"/>
|
||||
<xs:element name="Red" type="xs:integer" fixed="2" minOccurs="0"/>
|
||||
<xs:element name="Blue" type="xs:integer" fixed="3" minOccurs="0"/>
|
||||
</xs:choice>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:element name="CapturePoint">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A Capture Point. Add a Team Component to specify who currently owns it</xs:documentation>
|
||||
@@ -19,6 +31,13 @@
|
||||
<xs:documentation>CapturePointNumber specify an int number for this</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="HomePointForTeam" type="TeamEnum" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specify if this is a HomePoint for either team</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/DummyScene.obj</Resource>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Health>
|
||||
<Health>60</Health>
|
||||
</c:Health>
|
||||
<c:AABB/>
|
||||
<c:Camera/>
|
||||
<c:Listener/>
|
||||
<c:Player/>
|
||||
<c:Team>
|
||||
<Team>3</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-2.38960934" Y="11.7122087" Z="11.4659815"/>
|
||||
<Orientation X="-0.715584457" Y="0.122161396" Z="1.65143504e-07"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:CapturePoint>
|
||||
<HomePointForTeam>3</HomePointForTeam>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
|
||||
<Color A="1" B="0" G="1" R="1"/>
|
||||
</c:Model>
|
||||
<c:Team>
|
||||
<Team>3</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="5.48757935" Y="2.62824345" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:CapturePoint>
|
||||
<CaptureTimer>-3.9175623281664684</CaptureTimer>
|
||||
<CapturePointNumber>1</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
|
||||
<Color A="1" B="1" G="1" R="0"/>
|
||||
</c:Model>
|
||||
<c:Team>
|
||||
<Team>2</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="1.38422918" Y="2.32191443" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:CapturePoint>
|
||||
<CaptureTimer>-1.8667072838033221</CaptureTimer>
|
||||
<CapturePointNumber>2</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
|
||||
<Color A="1" B="0" G="0.200000003" R="1"/>
|
||||
</c:Model>
|
||||
<c:Team>
|
||||
<Team>2</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-1.79222715" Y="2.16289616" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:CapturePoint>
|
||||
<HomePointForTeam>2</HomePointForTeam>
|
||||
<CapturePointNumber>3</CapturePointNumber>
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/Core/UnitSphere.obj</Resource>
|
||||
<Color A="1" B="0" G="0.200000003" R="1"/>
|
||||
</c:Model>
|
||||
<c:Team>
|
||||
<Team>2</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-4.27947044" Y="1.99913001" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Health/>
|
||||
<c:AABB/>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/Core/UnitCube.obj</Resource>
|
||||
<Color A="1" B="0.482352942" G="0.490196079" R="1"/>
|
||||
</c:Model>
|
||||
<c:Player/>
|
||||
<c:Team>
|
||||
<Team>2</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-0.154032111" Y="2.23822045" Z="-0.0577065349"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Health/>
|
||||
<c:AABB/>
|
||||
<c:Model>
|
||||
<Resource>../assets/Models/Core/UnitCube.obj</Resource>
|
||||
<Color A="1" B="1" G="0.196078435" R="0.196078435"/>
|
||||
</c:Model>
|
||||
<c:Player/>
|
||||
<c:Team>
|
||||
<Team>3</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="3.2779336" Y="2.02053547" Z="-0.0348547697"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
@@ -72,6 +72,11 @@ ComponentPool::iterator ComponentPool::end() const
|
||||
return iterator(m_ComponentInfo, m_Pool.end(), m_Pool.end());
|
||||
}
|
||||
|
||||
size_t ComponentPool::size() const
|
||||
{
|
||||
return m_Pool.size();
|
||||
}
|
||||
|
||||
template <typename InterpretType /*= char*/>
|
||||
void ComponentPool::Dump() const
|
||||
{
|
||||
|
||||
@@ -14,20 +14,80 @@ CapturePointSystem::CapturePointSystem(EventBroker* eventBroker)
|
||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||
void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& capturePoint, double dt)
|
||||
{
|
||||
bool hasTeamComponent = world->HasComponent(capturePoint.EntityID, "Team");
|
||||
const int capturePointNumber = capturePoint["CapturePointNumber"];
|
||||
const bool hasTeamComponent = world->HasComponent(capturePoint.EntityID, "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) {
|
||||
world->AttachComponent(capturePoint.EntityID, "Team");
|
||||
ComponentWrapper& teamComponent = world->GetComponent(capturePoint.EntityID, "Team");
|
||||
teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator");
|
||||
}
|
||||
ComponentWrapper& teamComponent = world->GetComponent(capturePoint.EntityID, "Team");
|
||||
int firstTeamPlayersStandingInside = 0;
|
||||
int secondTeamPlayersStandingInside = 0;
|
||||
//what if capture point has no TEAM? -> NO ENUM.
|
||||
const int redTeam = (int)teamComponent["Team"].Enum("Red");//"team 1"
|
||||
const int blueTeam = (int)teamComponent["Team"].Enum("Blue");//"team 2"
|
||||
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)capturePoint["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_CapturePointNumberToEntityIDMap.size()) {
|
||||
m_CapturePointNumberToEntityIDMap.insert(std::make_pair(capturePointNumber, capturePoint.EntityID));
|
||||
return;
|
||||
}
|
||||
|
||||
//we have all capturepoints now - process stuff
|
||||
int ownedBy = teamComponent["Team"];
|
||||
int redTeamPlayersStandingInside = 0;
|
||||
int blueTeamPlayersStandingInside = 0;
|
||||
if (entity.HasComponent("Model")) {
|
||||
//Now sets team color to the capturepoint, or white if it is uncaptured.
|
||||
entity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 1) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 1) : glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
//calculate next possible capturePoint for both teams
|
||||
m_NextPossibleCapturePoint["Red"] = -1;
|
||||
m_NextPossibleCapturePoint["Blue"] = -1;
|
||||
for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
|
||||
{
|
||||
ComponentWrapper& capturePointOwnedBy = world->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
||||
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
|
||||
m_NextPossibleCapturePoint["Red"] = i + 1;
|
||||
}
|
||||
if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint == 0) {
|
||||
m_NextPossibleCapturePoint["Blue"] = i + 1;
|
||||
}
|
||||
}
|
||||
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
|
||||
{
|
||||
ComponentWrapper& capturePointOwnedBy = world->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
||||
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
|
||||
m_NextPossibleCapturePoint["Red"] = i - 1;
|
||||
}
|
||||
if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint != 0) {
|
||||
m_NextPossibleCapturePoint["Blue"] = i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
//colorize next possible capturepoint
|
||||
if (m_NextPossibleCapturePoint["Red"] == capturePointNumber) {
|
||||
entity["Model"]["Color"] = glm::vec4(1, 1, 0, 1);
|
||||
}
|
||||
if (m_NextPossibleCapturePoint["Blue"] == capturePointNumber) {
|
||||
entity["Model"]["Color"] = glm::vec4(0, 1, 1, 1);
|
||||
}
|
||||
|
||||
//check how many players are standing inside and are healthy
|
||||
for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--)
|
||||
{
|
||||
@@ -51,70 +111,40 @@ void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, Co
|
||||
//check team - spectatorNumber = "no team"
|
||||
int teamNumber = world->GetComponent(playerID, "Team")["Team"];
|
||||
if (teamNumber == redTeam) {
|
||||
firstTeamPlayersStandingInside++;
|
||||
redTeamPlayersStandingInside++;
|
||||
} else if (teamNumber == blueTeam) {
|
||||
secondTeamPlayersStandingInside++;
|
||||
blueTeamPlayersStandingInside++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
int ownedBy = teamComponent["Team"];
|
||||
//Probably want to distinguish the capturepoint depending on team affiliation.
|
||||
if (entity.HasComponent("Model")) {
|
||||
//Now sets team color to the capturepoint, or white if it is uncaptured.
|
||||
entity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 1) :
|
||||
ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 1) :
|
||||
glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
//om ej next satt, förvänta sig att en capturepoint med en viss team färg kommer in...
|
||||
//sätt isåfall next och kör på..
|
||||
//gör inget tills man fått den infon
|
||||
|
||||
/*check what capturePoint can be taken over next:
|
||||
no capturepoint taken yet for at least one of the teams <->
|
||||
at the start of the match the system is unaware of what capturePoint is the first one for each team*/
|
||||
if (m_Team1NextPossibleCapturePoint == m_NotACapturePoint && (int)teamComponent["Team"] == redTeam) {
|
||||
m_Team1HomeCapturePoint = capturePoint["CapturePointNumber"];//needed to calculate next m_Team1NextPossibleCapturePoint
|
||||
if (m_Team1HomeCapturePoint == 0) {
|
||||
m_Team1NextPossibleCapturePoint = 1;
|
||||
} else {
|
||||
m_Team1NextPossibleCapturePoint = (int)capturePoint["CapturePointNumber"] - 1;
|
||||
}
|
||||
} else if (m_Team2NextPossibleCapturePoint == m_NotACapturePoint && (int)teamComponent["Team"] == blueTeam) {
|
||||
m_Team2HomeCapturePoint = capturePoint["CapturePointNumber"];//needed to calculate next m_Team2NextPossibleCapturePoint
|
||||
if (m_Team2HomeCapturePoint == 0) {
|
||||
m_Team2NextPossibleCapturePoint = 1;
|
||||
} else {
|
||||
m_Team2NextPossibleCapturePoint = (int)capturePoint["CapturePointNumber"] - 1;
|
||||
}
|
||||
}
|
||||
//at least one capturepoint has been taken over
|
||||
//do nothing, its being handled inside the next code:
|
||||
|
||||
//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;
|
||||
if (firstTeamPlayersStandingInside > 0 && secondTeamPlayersStandingInside == 0
|
||||
&& m_Team1NextPossibleCapturePoint == (int)capturePoint["CapturePointNumber"])
|
||||
{
|
||||
timerDeltaChange = firstTeamPlayersStandingInside*dt;
|
||||
bool canCapture = false;
|
||||
if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) {
|
||||
timerDeltaChange = redTeamPlayersStandingInside*dt;
|
||||
currentTeam = redTeam;
|
||||
} else if (firstTeamPlayersStandingInside == 0 && secondTeamPlayersStandingInside > 0
|
||||
&& m_Team2NextPossibleCapturePoint == (int)capturePoint["CapturePointNumber"])
|
||||
{
|
||||
timerDeltaChange = -secondTeamPlayersStandingInside*dt;
|
||||
canCapture = m_NextPossibleCapturePoint["Red"] == capturePointNumber;
|
||||
}
|
||||
if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) {
|
||||
timerDeltaChange = -blueTeamPlayersStandingInside*dt;
|
||||
currentTeam = blueTeam;
|
||||
canCapture = m_NextPossibleCapturePoint["Blue"] == capturePointNumber;
|
||||
}
|
||||
|
||||
if (firstTeamPlayersStandingInside == 0 && secondTeamPlayersStandingInside == 0) {
|
||||
if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside == 0) {
|
||||
//A.nobodys standing inside
|
||||
//do nothing (?)
|
||||
} else if (currentTeam == blueTeam || currentTeam == redTeam) {
|
||||
//B. at most one of the teams have players inside (this means datavariable currentTeam is not 0)
|
||||
} 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) {
|
||||
if (ownedBy != currentTeam && canCapture) {
|
||||
if (abs((double)capturePoint["CaptureTimer"]) < 0.001f) {
|
||||
LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently.
|
||||
}
|
||||
@@ -126,7 +156,7 @@ void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, Co
|
||||
capturePoint["CaptureTimer"] = (double)capturePoint["CaptureTimer"] + timerDeltaChange;
|
||||
}
|
||||
//check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event
|
||||
if (abs((double)capturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver)) {
|
||||
if (abs((double)capturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) {
|
||||
teamComponent["Team"] = currentTeam;
|
||||
capturePoint["CaptureTimer"] = 0.0;
|
||||
//publish Captured event
|
||||
@@ -135,53 +165,17 @@ void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, Co
|
||||
e.CapturePointID = capturePoint.EntityID;
|
||||
e.TeamNumberThatCapturedCapturePoint = currentTeam;
|
||||
m_EventBroker->Publish(e);
|
||||
//modify nextPossibleCapturePoint, depending on, example: if team 1 has "0" as homebase or team 1 has "7" as homebase
|
||||
|
||||
//0 = false 1 = true
|
||||
bool team1HasTheZeroCapturePoint = m_Team1HomeCapturePoint < m_Team2HomeCapturePoint;
|
||||
|
||||
if (team1HasTheZeroCapturePoint) {
|
||||
if (currentTeam == redTeam) {
|
||||
m_Team1NextPossibleCapturePoint++;
|
||||
} else {
|
||||
m_Team2NextPossibleCapturePoint--;
|
||||
}
|
||||
//adjust flag for other team if their previous point has just been taken
|
||||
//this depends on what team has what homepoint ("side")
|
||||
if (m_Team2NextPossibleCapturePoint == m_Team1NextPossibleCapturePoint - 2) {
|
||||
m_Team2NextPossibleCapturePoint = m_Team2NextPossibleCapturePoint + 1;
|
||||
}
|
||||
if (m_Team1NextPossibleCapturePoint == m_Team2NextPossibleCapturePoint + 2) {
|
||||
m_Team1NextPossibleCapturePoint = m_Team1NextPossibleCapturePoint - 1;
|
||||
}
|
||||
} else {
|
||||
if (currentTeam == redTeam) {
|
||||
m_Team1NextPossibleCapturePoint--;
|
||||
} else {
|
||||
m_Team2NextPossibleCapturePoint++;
|
||||
}
|
||||
//adjust flag for other team if their previous point has just been taken
|
||||
//this depends on what team has what homepoint ("side")
|
||||
if (m_Team2NextPossibleCapturePoint == m_Team1NextPossibleCapturePoint + 2) {
|
||||
m_Team2NextPossibleCapturePoint = m_Team2NextPossibleCapturePoint - 1;
|
||||
}
|
||||
if (m_Team1NextPossibleCapturePoint == m_Team2NextPossibleCapturePoint - 2) {
|
||||
m_Team1NextPossibleCapturePoint = m_Team1NextPossibleCapturePoint + 1;
|
||||
}
|
||||
}
|
||||
//NextPossibleCapturePoint will be calculated in the next update...
|
||||
}
|
||||
} else if (firstTeamPlayersStandingInside > 0 && secondTeamPlayersStandingInside > 0) {
|
||||
//C.both teams have players inside
|
||||
//do nothing (?)
|
||||
}
|
||||
|
||||
//check for possible winCondition = check if the homebase is owned by the other team
|
||||
bool checkForWinner = false;
|
||||
if ((int)capturePoint["CapturePointNumber"] == m_Team1HomeCapturePoint && (int)teamComponent["Team"] != redTeam)
|
||||
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam)
|
||||
{
|
||||
checkForWinner = true;
|
||||
}
|
||||
if ((int)capturePoint["CapturePointNumber"] == m_Team2HomeCapturePoint && (int)teamComponent["Team"] != blueTeam)
|
||||
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam)
|
||||
{
|
||||
checkForWinner = true;
|
||||
}
|
||||
@@ -190,7 +184,7 @@ void CapturePointSystem::UpdateComponent(World* world, EntityWrapper& entity, Co
|
||||
{
|
||||
//publish Win event
|
||||
Events::Win e;
|
||||
e.TeamThatWon = teamComponent["Team"];
|
||||
e.TeamThatWon = ownedBy;
|
||||
m_EventBroker->Publish(e);
|
||||
m_WinnerWasFound = true;
|
||||
}
|
||||
@@ -216,3 +210,7 @@ bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CapturePointSystem::OnCaptured(const Events::Captured& e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ bool CapturePointTest::CapturePoint_Game_Loop_OneHundredTimes() {
|
||||
Tick();
|
||||
NumLoops++;
|
||||
if (TestSucceeded) {
|
||||
success = true;
|
||||
break;
|
||||
//success = true;
|
||||
//break;
|
||||
}
|
||||
loops--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user