Test pickup
This commit is contained in:
parent
25b5c1e492
commit
6d07285f43
@ -196,19 +196,21 @@ void Player::ApplyTransformation(Transformation& transformation, bool rel, bool
|
||||
if (rel) transformation.ApplyTranslation(-GetPOV());
|
||||
}
|
||||
|
||||
void Player::TakeBooster(std::unordered_map<uint64_t, Booster*> booster_table, float elapsedtime)
|
||||
uint64_t Player::TakeBooster(std::unordered_map<uint64_t, Booster*> booster_table, float elapsedtime)
|
||||
{
|
||||
uint64_t boostid = 0;
|
||||
Vector3f playerpos = GetPosition();
|
||||
for (auto& [key, booster]: booster_table) {
|
||||
Vector3f pos = booster->GetPosition();
|
||||
if (booster->GetAvailability() && abs(playerpos.x - pos.x) <= 0.5f && abs(playerpos.y - pos.y) <= 1.0f && abs(playerpos.z - pos.z) <= 0.5f)
|
||||
{
|
||||
std::cout << "booster got" << std::endl;
|
||||
boostid = booster->GetId();
|
||||
GetBooster(booster->GetType(), elapsedtime);
|
||||
booster->SetAvailability(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return boostid;
|
||||
}
|
||||
|
||||
void Player::GetBooster(BOOST_TYPE boosttype, float elapsedtime)
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
void TurnTopBottom(float value, float sensitivity);
|
||||
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
||||
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime, std::unordered_map<uint64_t, Booster*> booster_table);
|
||||
void TakeBooster(std::unordered_map<uint64_t, Booster*> booster_table, float elapsedTime);
|
||||
uint64_t TakeBooster(std::unordered_map<uint64_t, Booster*> booster_table, float elapsedTime);
|
||||
void GetBooster(BOOST_TYPE boosttype, float elapsedTime);
|
||||
void RemoveBooster(float elapsedtime);
|
||||
void ApplyTransformation(Transformation& transformation, bool rel = true, bool rot = true) const;
|
||||
|
@ -1343,7 +1343,7 @@ void Engine::Render(float elapsedTime) {
|
||||
|
||||
static bool leftright = false;
|
||||
if (pollTime >= .005f) {
|
||||
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime, m_boosters);
|
||||
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime);
|
||||
switch (snd) {
|
||||
case Player::Sound::STEP:
|
||||
if (leftright)
|
||||
@ -1361,6 +1361,9 @@ void Engine::Render(float elapsedTime) {
|
||||
// son vecteur de velocite (pour l'effet Doppler)
|
||||
pollTime = 0;
|
||||
}
|
||||
uint64_t boostid = m_player.TakeBooster(m_boosters, elapsedTime);
|
||||
|
||||
m_boost_manifest.insert(boostid);
|
||||
|
||||
m_player.ApplyTransformation(all);
|
||||
|
||||
@ -1511,7 +1514,17 @@ void Engine::Render(float elapsedTime) {
|
||||
if (Deserialize(&pmod, pck, &bsize)) {
|
||||
if (m_boosters.count(pmod.id)) {
|
||||
Booster* boost = m_boosters.at(pmod.id);
|
||||
std::cout << "Ramassé booster selon serveur " << (pmod.boost.damage ? "damage" : "") << (pmod.boost.hp ? "heal" : "") << (pmod.boost.invincible ? "invincible" : "");
|
||||
if (m_boost_manifest.count(boost->GetId())) {
|
||||
std::string str = "Picked up ";
|
||||
if (pmod.boost.damage)
|
||||
str.append("Damage Booster");
|
||||
else if (pmod.boost.hp)
|
||||
str.append("Healing");
|
||||
else if (pmod.boost.invincible)
|
||||
str.append("Invincibility");
|
||||
else break;
|
||||
SystemNotification(str);
|
||||
}
|
||||
boost->SetAvailability(pmod.available);
|
||||
}
|
||||
else {
|
||||
|
@ -259,6 +259,7 @@ private:
|
||||
netprot::Buffer m_buf, m_bufout;
|
||||
netprot::ChunkMod* m_chunkmod = nullptr;
|
||||
std::unordered_map<uint64_t, Booster*> m_boosters;
|
||||
std::set<uint64_t> m_boost_manifest;
|
||||
|
||||
std::unordered_map<uint64_t, netprot::Sync> m_syncs;
|
||||
std::string m_messageNotification = "";
|
||||
|
Loading…
Reference in New Issue
Block a user