FYP  1.0.0
Final Year Project -- Alexander Meuer
Minion Class Reference

Pawn that follows a path, keeps its distance from flockmembers and has a monetary reward for killing it. More...

#include <Minion.hpp>

Inheritance diagram for Minion:
Inheritance graph
Collaboration diagram for Minion:
Collaboration graph

Public Member Functions

 Minion (tinyxml2::XMLElement *xml)
 
virtual ~Minion ()
 Removes self from mFlock.
 
void setPath (std::shared_ptr< const Node > const &pathNode)
 Sets the path that the Minion will follow. More...
 
void clearPath ()
 
void addToFlock (std::shared_ptr< std::list< std::weak_ptr< Pawn >>> const &flock)
 Adds ourself to the flock and stores a shared pointer to the flock.
 
virtual void update (sf::Time const &elapsedTime) override
 Extends Pawn::update() to make Minion follow path.
 
unsigned int getMonetaryValue () const
 Gets the amount of money that this Minion is worth.
 
bool reachedEndOfPath () const
 
- Public Member Functions inherited from Pawn
 Pawn (tinyxml2::XMLElement *xml)
 Constructs a pawn from an xml element. Parses members from child xml tags. Requires child <Actor> tag for base class construction. More...
 
void makeSelfAware (std::shared_ptr< Pawn > const &smartThis)
 
sf::Vector2f getDestination () const
 
virtual void setDestination (sf::Vector2f const &destination)
 Sets the Pawn's destination. More...
 
int getMovementSpeed () const
 
void setMovementSpeed (int newSpeed)
 
void kill ()
 Kills the Pawn outright. Sets the Pawn's health to 0 and the state to DEAD.
 
bool takeDamage (int amount, Damage::Type type)
 
bool takeDamage (int amount, Damage::Type type, std::shared_ptr< Pawn > const &sender)
 Same as takeDamage() Used when taking damage from another pawn, so that we can choose to retaliate if we so wish. More...
 
void heal (int amount)
 Heals for the specified amount. Heals for the specified amount. Cannot heal beyond max health. More...
 
void stun (sf::Time const &duration)
 Get stunned. Become stunned for the specified amount of time. Stuns do not stack. If a subsequant stun is applied, the stun with the longer duration is used. i.e. A stun of 1 second cannot cancel out a 5 second stun, nor does it becoe a 6 second stun. More...
 
void beTaunted (std::shared_ptr< Pawn > const &taunter)
 Become forced to attack th taunter. Changes combat target to be the taunter. Has no associated duration so subsequent taunts will override each other. More...
 
bool offerTarget (std::shared_ptr< Pawn > const &target)
 Offer a potential target to the Pawn. Offer a target to the Pawn, who then decides whether to accept it or not. More...
 
bool targetIsDead () const
 
void wait (float seconds)
 Disallows the pawn to march for the specified time. More...
 
int getHealth () const
 
State getState () const
 Gets the current state of the Pawn. More...
 
bool isDead () const
 
Faction getFaction () const
 
void setOnDeath (std::function< void(Pawn *)> const &callback)
 
std::weak_ptr< Pawn > const & getCombatTarget () const
 
Damage::Reduction const & getArmour () const
 
Damage::Reduction const & getMagicResist () const
 
sf::Color getBloodColor () const
 
virtual void onCollide (std::shared_ptr< Collidable > &other, sf::Vector2f const &mtv)
 Called whenever the Pawn collides with something. Virtual method that is invoked whenver this Pawn collides with something. Moves the Pawn a portion of the minimum translation vector. More...
 
- Public Member Functions inherited from Actor
 Actor (sf::Texture &texture, sf::Shape *collisionMask, sf::Vector2f const &maskOffset)
 
 Actor (tinyxml2::XMLElement *xml)
 
void animate (sf::Time const &elapsedTime)
 Updates the animator and applies it to ourself.
 
bool isPlayingAnimation () const
 Returns true if an animation is currently playing.
 
std::string getPlayingAnimation () const
 Gets the name of the playing animation. Undefined behaviour if no animation playing.
 
void playAnimation (std::string const &name, bool loop=false)
 Begins playing an animation by name.
 
void setVisible (bool isVisible=true)
 
bool toggleVisible ()
 
bool getVisible () const
 
virtual void draw (sf::RenderTarget &target) const
 
- Public Member Functions inherited from collision::Collidable
 Collidable (sf::Shape *mask, sf::Vector2f offset)
 
 Collidable (Collidable const &other)
 
 Collidable (tinyxml2::XMLElement *xml)
 Constructs a Collidable from an xml tag. Tag requires pointCoint and type attributes in addition to child tags depending on type specified. More...
 
const sf::Shape * getMask () const
 
void setMask (sf::Shape *mask, sf::Vector2f offset)
 
virtual void onCollide (std::shared_ptr< Collidable > &other, sf::Vector2f const &mtv)
 Called when we collide with something.
 
void setDebugColour (sf::Color const &c)
 
void debug_draw (sf::RenderTarget &target)
 
void getAxies (std::vector< sf::Vector2f > &axiesVector)
 Gets all axies of the mask. Gets all axies of the mask. Currently inefficient due to the fact that it iterates over all points and returns all axies (a duplicate of each axis is included!). More...
 
size_t getPointCount () const
 Gets the number of points in the mask. Calls mask->getPoint() and returns the result.
 
sf::Vector2f projectOntoAxis (sf::Vector2f &axis) const
 Projects the mask onto an axis. Projects each point of the mask onto an axis and returns the min and max points it covers on that axis. More...
 

Protected Member Functions

void doMarch (sf::Vector2f const &goalDisplacement, float secondsElapsed) override
 Calls separation() to steer away from local flockmates and then invokes Pawn::doMarch()
 
sf::Vector2f seekEnemy ()
 
- Protected Member Functions inherited from Pawn
void turnToFaceDirection (sf::Vector2f const &dir)
 
virtual void calculateAnimation ()
 
virtual void calculateState (sf::Vector2f const &goalDisplacement)
 
virtual void doAttack (float secondsElapsed)
 
void stopWaiting ()
 
- Protected Member Functions inherited from collision::Collidable
void updateCollidableMask (sf::Vector2f const &newPosition)
 Updates the position of the mask. Updates the position of the mask to equal newPosition plus the offset. More...
 

Private Member Functions

sf::Vector2f separation () const
 Steers Minion away from local flockmates.
 
sf::Vector2f cohesion () const
 Steers Minion toward local flockmates.
 

Private Attributes

std::weak_ptr< const NodemPathNode
 
sf::Vector2f mPathWaypoint
 
std::shared_ptr< std::list< std::weak_ptr< Pawn > > > mFlock
 Shared pointer to flock.
 
const unsigned int mMonetaryValue
 Amout of money to award player when this Minion dies.
 
bool mReachedEndOfPath
 
const float M_DESTINATION_WEIGHT
 
const float M_SEPARATION_WEIGHT
 
const float M_COHESION_WEIGHT
 
const float M_SEEK_WEIGHT
 

Additional Inherited Members

- Public Types inherited from Pawn
enum  Faction { PLAYER, ENEMY, NEUTRAL }
 
enum  State {
  IDLE, MARCHING, ATTACKING, STUNNED,
  DEAD
}
 
- Protected Attributes inherited from Pawn
Faction mFaction
 
State mState
 
int mHealth
 
const int M_MAX_HEALTH
 
Damage::Reduction mArmour
 
Damage::Reduction mMagicResist
 
Damage::Type mDamageType
 
float mAttackRange
 
int mMovementSpeed
 
int mAttackDamage
 
float mAttacksPerSecond
 
float mTimeSinceAttack
 
std::weak_ptr< PawnmCombatTarget
 
sf::Time mStunDuration
 
sf::Time mTimeStunned
 
sf::Vector2f mDestination
 
sf::Sound mAttackSound
 
std::weak_ptr< Pawnself
 
- Protected Attributes inherited from Actor
bool mVisible
 

Detailed Description

Pawn that follows a path, keeps its distance from flockmembers and has a monetary reward for killing it.

Member Function Documentation

void Minion::setPath ( std::shared_ptr< const Node > const &  pathNode)

Sets the path that the Minion will follow.

Parameters
pathNodeFirst node in that path that we should follow.

The documentation for this class was generated from the following file: