FYP  1.0.0
Final Year Project -- Alexander Meuer
tower::ProjectileTower Class Reference

Tower that fires a projectile toward a target. Fires in an arc and takes account for moving targets. More...

#include <BasicTower.h>

Inheritance diagram for tower::ProjectileTower:
Inheritance graph
Collaboration diagram for tower::ProjectileTower:
Collaboration graph

Public Member Functions

 ProjectileTower (sf::Vector2f const &position, tinyxml2::XMLElement *xmlDef)
 Consructs a Projectile Tower. More...
 
bool shoot (std::shared_ptr< std::list< std::shared_ptr< Pawn >>> const &possibleTargets) override
 Tries to fire at the members of possibleTargets. More...
 
void setProjectileManager (std::shared_ptr< ProjectileManager > projectileMgr)
 
- Public Member Functions inherited from tower::Tower
 Tower (sf::Vector2f const &position, tinyxml2::XMLElement *xmlDef)
 
virtual void update (sf::Time const &elapsedTime)
 
virtual int getCost () const
 
- 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

sf::Vector2f leadTarget (Pawn *target, float time) const
 Predicts where a marching Pawn will be after a certain number of seconds. More...
 
- 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...
 

Protected Attributes

float mRange
 Radius that the tower can fire within.
 
Damage::Type mDamageType
 The type of damage to inflict (PHYSICAL or MAGICAL)
 
int mDamage
 The amount of damage each projectile inflicts.
 
sf::Vector2f mProjectileSpawnOffset
 Relative position at which to fire the projectile from.
 
std::list< std::weak_ptr< Pawn > > mTargetList
 
std::function< bool(std::weak_ptr< Pawn > &, std::weak_ptr< Pawn > &)> mTargetingSortPredicate
 
std::shared_ptr< ProjectileManagermProjectileManager
 
- Protected Attributes inherited from tower::Tower
const float mSecondsPerAttack
 
float mSecondsSinceLastAttack
 
const int mCost
 
- Protected Attributes inherited from Actor
bool mVisible
 

Detailed Description

Tower that fires a projectile toward a target. Fires in an arc and takes account for moving targets.

Constructor & Destructor Documentation

tower::ProjectileTower::ProjectileTower ( sf::Vector2f const &  position,
tinyxml2::XMLElement *  xmlDef 
)

Consructs a Projectile Tower.

Parameters
positionPosition to create the tower at.
xmlDefXml element containing tower definition.

Member Function Documentation

sf::Vector2f tower::ProjectileTower::leadTarget ( Pawn target,
float  time 
) const
protected

Predicts where a marching Pawn will be after a certain number of seconds.

Returns
A vector of where the Pawn will be if it keeps moving in its current direction.
bool tower::ProjectileTower::shoot ( std::shared_ptr< std::list< std::shared_ptr< Pawn >>> const &  possibleTargets)
overridevirtual

Tries to fire at the members of possibleTargets.

Returns
True if a target was chosen and fired upon.

Implements tower::Tower.

Reimplemented in tower::MageTower.


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