Arcade Shooter
Weapon.h
1 
2 /* . ,'`. .
3  . .." _.-;' ⁄‚ `. . `
4  _.-"`.##%"_.--" ,' ⁄` `. "#" ___,,od000
5  ,'"-_ _.-.--"\ ,' `-_ '%#%',,/00000000000
6  ,' |_.' )`/- __..--""`-_`-._ J L/00000000000000
7  . + ,' _.-" / / _-"" `-._`-_/___\///0000 000M
8  .'_.-"" ' :_/_.-' _,`-/__V__\0000 00MMM
9  . _-"" . ' _,/000\ | /000 0MMMMM
10 _-" . ' . . ,/ 000\ | /000000000MMMMM
11  ` Shooter Library ' ,/ 000\|/000000000MMMMMM
12 . © 2017 - Shuriken Studios LLC ,/0 00000|0000000000MMMMMM */
13 
14 #pragma once
15 
16 namespace ShooterLibrary
17 {
19  class Weapon
20  {
21  public:
22 
25  Weapon(bool isActive = true)
26  {
27  m_isActive = isActive;
29  }
30 
31  virtual ~Weapon() { }
32 
35  virtual void Update(const GameTime *pGameTime) { };
36 
39  virtual void Draw(SpriteBatch *pSpriteBatch) { };
40 
43  virtual void Fire(TriggerType triggerType) = 0;
44 
47  virtual void SetGameObject(GameObject *pGameObject) { m_pGameObject = pGameObject; }
48 
51  virtual void SetOffset(Vector2 offset) { m_offset = offset; }
52 
55  virtual void SetTriggerType(TriggerType triggerType) { m_triggerType = triggerType; }
56 
59  virtual void SetProjectilePool(ProjectilePool *pPool) = 0;
60 
62  virtual void Activate() { m_isActive = true; }
63 
65  virtual void Dectivate() { m_isActive = false; }
66 
69  virtual bool IsActive() const { return m_isActive && m_pGameObject->IsActive(); }
70 
71 
72  protected:
73 
76  virtual TriggerType GetTriggerType() const { return m_triggerType; }
77 
80  virtual Vector2 GetPosition() const { return m_pGameObject->GetPosition() + m_offset; }
81 
82 
83  private:
84 
85  bool m_isActive;
86 
87  GameObject *m_pGameObject;
88 
89  Vector2 m_offset;
90 
91  TriggerType m_triggerType;
92 
93  };
94 }
Used to recycle projectiles.
Definition: ProjectilePool.h:20
virtual bool IsActive() const
Determines if the weapon is active.
Definition: Weapon.h:69
Defines how different types of weapons should be triggered.
Definition: TriggerType.h:20
virtual void Dectivate()
Deactivates the weapon.
Definition: Weapon.h:65
virtual void SetOffset(Vector2 offset)
Sets the position on the parented game object.
Definition: Weapon.h:51
Base class for all objects that will be updated and rendered on a GameplayScreen. ...
Definition: GameObject.h:29
virtual void Activate()
Activates the weapon.
Definition: Weapon.h:62
Shooter Library is a library of classes, interfaces, and value types that provides a foundation for d...
Definition: Background.h:16
virtual void Draw(SpriteBatch *pSpriteBatch)
Called when the game determines it is time to draw a frame.
Definition: Weapon.h:39
virtual void SetProjectilePool(ProjectilePool *pPool)=0
Sets the pool where the weapon gets it's projectiles.
static const TriggerType PRIMARY
Represents a primary weapon trigger.
Definition: TriggerType.h:30
virtual Vector2 GetPosition() const
Gets the weapon's position.
Definition: Weapon.h:80
virtual Vector2 & GetPosition()
Gets the position of the game object.
Definition: GameObject.h:78
virtual TriggerType GetTriggerType() const
Gets the action that triggers the weapon.
Definition: Weapon.h:76
Weapon(bool isActive=true)
Instantiates a new weapon object.
Definition: Weapon.h:25
Base class for all Weapons.
Definition: Weapon.h:19
virtual bool IsActive() const
Determines if the game object is active.
Definition: GameObject.h:68
virtual void SetTriggerType(TriggerType triggerType)
Sets how the weapon is triggered.
Definition: Weapon.h:55
virtual void SetGameObject(GameObject *pGameObject)
Sets the game object that the weapon is attached to.
Definition: Weapon.h:47
virtual void Fire(TriggerType triggerType)=0
Fires the weapon.
virtual void Update(const GameTime *pGameTime)
Called when the game determines it is time to draw a frame.
Definition: Weapon.h:35