fix warnings
This commit is contained in:
@@ -66,6 +66,8 @@ void Mob::Walk(std::uint64_t delta, World* world) {
|
||||
SetCenterY(GetCenterY() + walkAmount);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +119,8 @@ void Mob::MoveBack(const TeamCastle& enemyCastle, World* world) {
|
||||
SetCenterY(enemyCastle.GetTopLeft().GetY() - GetHeight() / 2.0f);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +192,9 @@ void Mob::ChangeDirection(const WalkableTile& tile, World* world) {
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,12 +209,12 @@ void Mob::Tick(std::uint64_t delta, World* world) {
|
||||
}
|
||||
|
||||
void Mob::UpdateEffects(std::uint64_t delta, World* world) {
|
||||
float deltaSec = (float)delta / 1000.0f;
|
||||
float deltaSec = static_cast<float>(delta / 1000.0f);
|
||||
for (std::size_t i = 0; i < m_Effects.size(); i++) {
|
||||
EffectDuration& effect = m_Effects[i];
|
||||
effect.duration -= deltaSec;
|
||||
if (effect.duration < 0) { // effect has gone
|
||||
m_Effects.erase(m_Effects.begin() + i);
|
||||
m_Effects.erase(m_Effects.begin() + static_cast<int>(i));
|
||||
switch (effect.type) {
|
||||
case EffectType::Fire: {
|
||||
m_EffectFireTimer.Reset();
|
||||
@@ -254,7 +261,7 @@ bool Mob::HasEffect(EffectType type) {
|
||||
|
||||
typedef std::pair<MobType, std::uint8_t> MobKey;
|
||||
|
||||
const std::map<MobKey, MobStats> MobConstants = {
|
||||
static const std::map<MobKey, MobStats> MobConstants = {
|
||||
// damage speed size money_cost exp_cost exp_reward max_health
|
||||
{{MobType::Zombie, 1},{MobStats{1, 1.6, {1, 1}, 15, 0, 7, 40}}},
|
||||
{{MobType::Zombie, 2},{MobStats{1, 1.6, {1, 1}, 18, 88, 9, 56}}},
|
||||
@@ -321,7 +328,7 @@ const MobStats* GetMobStats(MobType type, std::uint8_t level) {
|
||||
return &MobConstants.at(MobKey{ type, level });
|
||||
}
|
||||
|
||||
const std::map<MobKey, TowerImmunities> MobsTowerImmunities = {
|
||||
static const std::map<MobKey, TowerImmunities> MobsTowerImmunities = {
|
||||
{{MobType::Zombie, 1},{}},
|
||||
{{MobType::Zombie, 2},{}},
|
||||
{{MobType::Zombie, 3},{}},
|
||||
@@ -387,7 +394,7 @@ const TowerImmunities& GetMobTowerImmunities(MobType type, std::uint8_t level) {
|
||||
return MobsTowerImmunities.at({ type, level });
|
||||
}
|
||||
|
||||
const std::map<MobKey, EffectImmunities> MobsEffectImmunities = {
|
||||
static const std::map<MobKey, EffectImmunities> MobsEffectImmunities = {
|
||||
{{MobType::Zombie, 1},{}},
|
||||
{{MobType::Zombie, 2},{}},
|
||||
{{MobType::Zombie, 3},{}},
|
||||
@@ -453,10 +460,10 @@ const EffectImmunities& GetMobEffectImmunities(MobType type, std::uint8_t level)
|
||||
return MobsEffectImmunities.at({ type, level });
|
||||
}
|
||||
|
||||
MobPtr MobFactory::CreateMob(MobID id, MobType type, std::uint8_t level, PlayerID sender) {
|
||||
MobPtr MobFactory::CreateMob(MobID mobId, MobType mobType, std::uint8_t mobLevel, PlayerID mobSender) {
|
||||
using MobCreator = std::function<std::shared_ptr<Mob>(MobID, std::uint8_t, PlayerID)>;
|
||||
|
||||
static std::map<MobType, MobCreator> mobFactory = {
|
||||
static const std::map<MobType, MobCreator> mobFactory = {
|
||||
{MobType::Zombie, [](MobID id, std::uint8_t level, PlayerID sender) -> MobPtr {return std::make_shared<Zombie>(id, level, sender);} },
|
||||
{MobType::Spider, [](MobID id, std::uint8_t level, PlayerID sender) -> MobPtr {return std::make_shared<Spider>(id, level, sender);} },
|
||||
{MobType::Skeleton, [](MobID id, std::uint8_t level, PlayerID sender) -> MobPtr {return std::make_shared<Skeleton>(id, level, sender);} },
|
||||
@@ -469,7 +476,7 @@ MobPtr MobFactory::CreateMob(MobID id, MobType type, std::uint8_t level, PlayerI
|
||||
{MobType::Giant, [](MobID id, std::uint8_t level, PlayerID sender) -> MobPtr {return std::make_shared<Giant>(id, level, sender);} },
|
||||
};
|
||||
|
||||
return mobFactory[type](id, level, sender);
|
||||
return mobFactory.at(mobType)(mobId, mobLevel, mobSender);
|
||||
}
|
||||
|
||||
std::string MobFactory::GetMobName(MobType type) {
|
||||
|
||||
Reference in New Issue
Block a user