Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F130799
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/ButcherEntity.cpp b/src/ButcherEntity.cpp
index 5d958f8..8fe1db4 100644
--- a/src/ButcherEntity.cpp
+++ b/src/ButcherEntity.cpp
@@ -1,136 +1,141 @@
#include "ButcherEntity.h"
#include "BoltEntity.h"
#include "PlayerEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
#include "TextMapper.h"
ButcherEntity::ButcherEntity(float x, float y)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_BUTCHER), x, y)
{
width = 80;
height = 160;
sprite.setOrigin(40, 115);
creatureSpeed = BUTCHER_VELOCITY;
velocity = Vector2D(creatureSpeed);
computeFacingDirection();
hp = BUTCHER_HP;
hpMax = BUTCHER_HP;
hpDisplay = BUTCHER_HP;
meleeDamages = BUTCHER_DAMAGES;
type = ENTITY_ENEMY_BOSS;
bloodColor = BloodRed;
shadowFrame = 4;
dyingFrame = 3;
deathFrame = FRAME_CORPSE_BUTCHER;
agonizingSound = SOUND_BUTCHER_DIE;
hurtingSound = SOUND_BUTCHER_HURT;
enemyType = EnemyTypeButcher;
timer = (rand() % 50) / 10.0f;
age = -1.5f;
frame = 1;
resistance[ResistanceFrozen] = ResistanceHigh;
resistance[ResistanceRecoil] = ResistanceHigh;
canExplode = false;
}
void ButcherEntity::animate(float delay)
{
if (age > 0.0f && !isAgonising)
{
sprite.setColor(sf::Color(255,255,255,255));
timer = timer - delay;
if (timer <= 0.0f)
{
creatureSpeed = BUTCHER_VELOCITY + (hpMax - hp) * 0.8f;
timer = (rand() % 50) / 10.0f;
setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), creatureSpeed ));
if (rand()%2 == 0)
SoundManager::getInstance().playSound(SOUND_BUTCHER_00);
else
SoundManager::getInstance().playSound(SOUND_BUTCHER_01);
}
frame = ((int)(age * creatureSpeed / 25)) % 4;
if (frame == 3) frame = 1;
if (velocity.x > 1.0f) isMirroring = true;
else if (velocity.x < -1.0f) isMirroring = false;
}
EnemyEntity::animate(delay);
z = y + 30;
}
void ButcherEntity::calculateBB()
{
boundingBox.left = (int)x - 22;
boundingBox.width = 44;
boundingBox.top = (int)y - 18;
boundingBox.height = 48;
}
void ButcherEntity::collideMapRight()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
}
void ButcherEntity::collideMapLeft()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
}
void ButcherEntity::collideMapTop()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
}
void ButcherEntity::collideMapBottom()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
}
void ButcherEntity::collideWithEnemy(EnemyEntity* entity)
{
if (recoil.active && recoil.stun) return;
if (entity->getMovingStyle() == movWalking )
{
Vector2D vel = Vector2D(entity->getX(), entity->getY()).vectorTo(Vector2D(x, y), 100.0f );
giveRecoil(false, vel, 0.3f);
}
}
void ButcherEntity::drop()
{
ItemEntity* newItem = new ItemEntity(ItemSilverCoin, x, y);
newItem->setMap(map, TILE_WIDTH, TILE_HEIGHT, 0, 0);
newItem->setVelocity(Vector2D(100.0f + rand()% 250));
newItem->setViscosity(0.96f);
}
void ButcherEntity::render(sf::RenderTarget* app)
{
EnemyEntity::render(app);
renderLifeBar(app, tools::getLabel("enemy_butcher"));
}
int ButcherEntity::hurt(StructHurt hurtParam)
{
creatureSpeed = BUTCHER_VELOCITY + hpMax - hp;
setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), creatureSpeed ));
return EnemyEntity::hurt(hurtParam);
}
+
+bool ButcherEntity::isAttacking()
+{
+ return true;
+}
diff --git a/src/ButcherEntity.h b/src/ButcherEntity.h
index 62604fb..5ae0316 100644
--- a/src/ButcherEntity.h
+++ b/src/ButcherEntity.h
@@ -1,28 +1,29 @@
#ifndef BUTCHERENTITY_H
#define BUTCHERENTITY_H
#include "EnemyEntity.h"
#include "PlayerEntity.h"
class ButcherEntity : public EnemyEntity
{
public:
ButcherEntity(float x, float y);
virtual void animate(float delay);
virtual void render(sf::RenderTarget* app);
virtual void calculateBB();
+ virtual bool isAttacking();
protected:
virtual void collideMapRight();
virtual void collideMapLeft();
virtual void collideMapTop();
virtual void collideMapBottom();
virtual int hurt(StructHurt hurtParam) override;
virtual void collideWithEnemy(EnemyEntity* entity) override;
virtual void drop();
private:
float timer;
};
#endif // BUTCHERENTITY_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Jun 15, 11:36 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70144
Default Alt Text
(4 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline