Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lindell86 committed Mar 18, 2015
2 parents 805a5a2 + 8ea701b commit b88de03
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
2 changes: 1 addition & 1 deletion TurbulentArena/BSetWanderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace bjoernligan
return EBNodeStatus::Invalid;

//Set new Max velocity depending on injury
float MoveSpeed = 50.f + 100.0f * m_xAgent->getOwner()->GetCombat()->GetHealthPercentage();
float MoveSpeed = 100.f + 50.0f * m_xAgent->getOwner()->GetCombat()->GetHealthPercentage();
m_xAgent->getOwner()->GetMovementStats().SetMaxVelocity(MoveSpeed);
m_xAgent->ChooseWanderPos(true, 20);

Expand Down
27 changes: 23 additions & 4 deletions TurbulentArena/Physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Physics.hpp"
#include "ContactListener.hpp"
#include "Box2DWorldDraw.h"
#include "UserData.hpp"

namespace bjoernligan
{
Expand Down Expand Up @@ -30,13 +31,31 @@ namespace bjoernligan

float32 Physics::Raycast::ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction)
{
if (m_result.bodies.empty())
m_result.bodies.push_back(fixture->GetBody());
else
m_result.bodies[0] = fixture->GetBody();
normal;
point;
fraction;

B2UserData* userData = static_cast<B2UserData*>(fixture->GetBody()->GetUserData());

if (userData->type == B2UserData::NATURE)
{
NatureUD* nature = static_cast<NatureUD*>(userData);
if (!nature->m_see_through)
{
if (m_result.bodies.empty())
m_result.bodies.push_back(fixture->GetBody());
else
m_result.bodies[0] = fixture->GetBody();
}
}
else if (userData->type == B2UserData::CLANMEMBER)
{
if (m_result.bodies.empty())
m_result.bodies.push_back(fixture->GetBody());
else
m_result.bodies[0] = fixture->GetBody();
}

return fraction;
}
void Physics::Body::setPosition(const sf::Vector2f& p_position)
Expand Down
2 changes: 2 additions & 0 deletions TurbulentArena/Physics.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "UserData.hpp"

namespace bjoernligan
{
Expand All @@ -14,6 +15,7 @@ namespace bjoernligan
void setPosition(float x, float y);

b2Body* m_body;
std::unique_ptr<B2UserData> m_b2UserData;
};

enum EB2ShapeType
Expand Down
13 changes: 11 additions & 2 deletions TurbulentArena/PlayState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ namespace bjoernligan

Physics::Body* body = m_physics->createBody(xParams);
body->setPosition(x * tileSize.x + tileSize.x * 0.5f, y * tileSize.y + tileSize.y * 0.5f);

bool seeThrough = false;
if (tile->getTileInfo()->m_properties.hasProperty("see_through"))
{
seeThrough = true;
}

body->m_b2UserData = std::make_unique<NatureUD>(seeThrough);
body->m_body->SetUserData(body->m_b2UserData.get());
}
}
}
Expand All @@ -124,10 +133,10 @@ namespace bjoernligan
++teamSpawnsIt;
}

m_xPlayerClan = m_clanManager->createClan("MacDonald", sf::Color(70, 70, 255), 20, 3);
m_xPlayerClan = m_clanManager->createClan("MacDonald", sf::Color(70, 70, 255), 1, 0);
m_xGameOverChecker.AddClan(m_xPlayerClan);

m_xGameOverChecker.AddClan(m_clanManager->createClan("MacMuffin", sf::Color(255, 70, 70), 20, 3));
m_xGameOverChecker.AddClan(m_clanManager->createClan("MacMuffin", sf::Color(255, 70, 70), 1, 0));

std::vector<Clan*> clans = m_clanManager->getClans();
std::vector<ClanMember*> members;
Expand Down
17 changes: 17 additions & 0 deletions TurbulentArena/UserData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,21 @@ namespace bjoernligan

ClanMember* clanMember;
};

struct NatureUD : public B2UserData
{
NatureUD(bool see_through) :
B2UserData(NATURE),
m_see_through(see_through)
{

}

~NatureUD()
{

}

bool m_see_through;
};
}

0 comments on commit b88de03

Please sign in to comment.