add hit "animation"
This commit is contained in:
@@ -51,21 +51,21 @@ void Mob::Walk(std::uint64_t delta, World* world) {
|
||||
|
||||
switch (GetDirection()) {
|
||||
case Direction::NegativeX: {
|
||||
SetCenterX(GetCenterX() - walkAmount);
|
||||
break;
|
||||
}
|
||||
SetCenterX(GetCenterX() - walkAmount);
|
||||
break;
|
||||
}
|
||||
case Direction::PositiveX: {
|
||||
SetCenterX(GetCenterX() + walkAmount);
|
||||
break;
|
||||
}
|
||||
SetCenterX(GetCenterX() + walkAmount);
|
||||
break;
|
||||
}
|
||||
case Direction::NegativeY: {
|
||||
SetCenterY(GetCenterY() - walkAmount);
|
||||
break;
|
||||
}
|
||||
SetCenterY(GetCenterY() - walkAmount);
|
||||
break;
|
||||
}
|
||||
case Direction::PositiveY: {
|
||||
SetCenterY(GetCenterY() + walkAmount);
|
||||
break;
|
||||
}
|
||||
SetCenterY(GetCenterY() + walkAmount);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -104,21 +104,21 @@ void Mob::Move(std::uint64_t delta, World* world) {
|
||||
void Mob::MoveBack(const TeamCastle& enemyCastle, World* world) {
|
||||
switch (GetDirection()) {
|
||||
case Direction::NegativeX: {
|
||||
SetCenterX(enemyCastle.GetBottomRight().GetX() + GetWidth() / 2.0f);
|
||||
break;
|
||||
}
|
||||
SetCenterX(enemyCastle.GetBottomRight().GetX() + GetWidth() / 2.0f);
|
||||
break;
|
||||
}
|
||||
case Direction::PositiveX: {
|
||||
SetCenterX(enemyCastle.GetTopLeft().GetX() - GetWidth() / 2.0f);
|
||||
break;
|
||||
}
|
||||
SetCenterX(enemyCastle.GetTopLeft().GetX() - GetWidth() / 2.0f);
|
||||
break;
|
||||
}
|
||||
case Direction::NegativeY: {
|
||||
SetCenterY(enemyCastle.GetBottomRight().GetY() + GetHeight() / 2.0f);
|
||||
break;
|
||||
}
|
||||
SetCenterY(enemyCastle.GetBottomRight().GetY() + GetHeight() / 2.0f);
|
||||
break;
|
||||
}
|
||||
case Direction::PositiveY: {
|
||||
SetCenterY(enemyCastle.GetTopLeft().GetY() - GetHeight() / 2.0f);
|
||||
break;
|
||||
}
|
||||
SetCenterY(enemyCastle.GetTopLeft().GetY() - GetHeight() / 2.0f);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -133,64 +133,64 @@ void Mob::ChangeDirection(const WalkableTile& tile, World* world) {
|
||||
switch (GetDirection()) {
|
||||
|
||||
case Direction::PositiveY: {
|
||||
if (tile.direction == Direction::NegativeX) {
|
||||
if (GetTileY() > GetTileX()) {
|
||||
SetCenterY(tileY + GetTileX());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile->direction = Direction::PositiveX
|
||||
if (GetTileY() > 1 - GetTileX()) {
|
||||
SetCenterY(tileY + (1 - GetTileX()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
if (tile.direction == Direction::NegativeX) {
|
||||
if (GetTileY() > GetTileX()) {
|
||||
SetCenterY(tileY + GetTileX());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile->direction = Direction::PositiveX
|
||||
if (GetTileY() > 1 - GetTileX()) {
|
||||
SetCenterY(tileY + (1 - GetTileX()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case Direction::NegativeY: {
|
||||
if (tile.direction == Direction::PositiveX) {
|
||||
if (GetTileY() < GetTileX()) {
|
||||
SetCenterY(tileY + GetTileX());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile.direction = Direction::NegativeX
|
||||
if (GetTileY() < 1 - GetTileX()) {
|
||||
SetCenterY(tileY + (1 - GetTileX()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
if (tile.direction == Direction::PositiveX) {
|
||||
if (GetTileY() < GetTileX()) {
|
||||
SetCenterY(tileY + GetTileX());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile.direction = Direction::NegativeX
|
||||
if (GetTileY() < 1 - GetTileX()) {
|
||||
SetCenterY(tileY + (1 - GetTileX()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case Direction::PositiveX: {
|
||||
if (tile.direction == Direction::NegativeY) {
|
||||
if (GetTileX() > GetTileY()) {
|
||||
SetCenterX(tileX + GetTileY());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile.direction = Direction::PositiveY
|
||||
if (GetTileX() > 1 - GetTileY()) {
|
||||
SetCenterX(tileX + (1 - GetTileY()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
if (tile.direction == Direction::NegativeY) {
|
||||
if (GetTileX() > GetTileY()) {
|
||||
SetCenterX(tileX + GetTileY());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile.direction = Direction::PositiveY
|
||||
if (GetTileX() > 1 - GetTileY()) {
|
||||
SetCenterX(tileX + (1 - GetTileY()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case Direction::NegativeX: {
|
||||
if (tile.direction == Direction::PositiveY) {
|
||||
if (GetTileX() < GetTileY()) {
|
||||
SetCenterX(tileX + GetTileY());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile.direction = Direction::NegativeY
|
||||
if (GetTileX() < 1 - GetTileY()) {
|
||||
SetCenterX(tileX + (1 - GetTileY()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
if (tile.direction == Direction::PositiveY) {
|
||||
if (GetTileX() < GetTileY()) {
|
||||
SetCenterX(tileX + GetTileY());
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
} else { // tile.direction = Direction::NegativeY
|
||||
if (GetTileX() < 1 - GetTileY()) {
|
||||
SetCenterX(tileX + (1 - GetTileY()));
|
||||
SetDirection(tile.direction);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -203,6 +203,7 @@ bool Mob::IsTouchingCastle(const TeamCastle& enemyCastle) const {
|
||||
}
|
||||
|
||||
void Mob::Tick(std::uint64_t delta, World* world) {
|
||||
m_HitCooldown = std::max(0.0f, m_HitCooldown - static_cast<float>(delta / 1000.0f));
|
||||
UpdateEffects(delta, world);
|
||||
Move(delta, world);
|
||||
AttackCastle(delta, world);
|
||||
@@ -217,18 +218,18 @@ void Mob::UpdateEffects(std::uint64_t delta, World* world) {
|
||||
m_Effects.erase(m_Effects.begin() + static_cast<int>(i));
|
||||
switch (effect.type) {
|
||||
case EffectType::Fire: {
|
||||
m_EffectFireTimer.Reset();
|
||||
break;
|
||||
}
|
||||
m_EffectFireTimer.Reset();
|
||||
break;
|
||||
}
|
||||
|
||||
case EffectType::Poison: {
|
||||
m_EffectPoisonTimer.Reset();
|
||||
break;
|
||||
}
|
||||
m_EffectPoisonTimer.Reset();
|
||||
break;
|
||||
}
|
||||
|
||||
case EffectType::Heal: {
|
||||
m_EffectHealTimer.Reset();
|
||||
}
|
||||
m_EffectHealTimer.Reset();
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user