Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

flak collision in place

  • Loading branch information...
commit d877a8455c66c97b5bd2c3d4d25453d8fe164565 1 parent 1e10fae
@dantastic dantastic authored
View
10 src/engine/EffectTypes.cpp
@@ -34,6 +34,16 @@ void CannonEffect::apply() {
((NPC*)unit_)->setHealth(((NPC*)unit_)->getHealth() + healthChangeValue_);
}
+FlakEffect::FlakEffect(Unit* unit) : Effect(unit, FLAK_TIME){
+ velocityChangeValue_ = QVector2D(0, 0);
+ healthChangeValue_ = -15;
+}
+
+void FlakEffect::apply(){
+ unit_->setVelocity(velocityChangeValue_);
+ ((NPC*)unit_)->setHealth(((NPC*)unit_)->getHealth() + healthChangeValue_);
+}
+
PlayerTerrainEffect::PlayerTerrainEffect(Unit* unit):Effect(unit, NO_TIME) {
velocityChangeValue_ = QVector2D(0,0);
}
View
10 src/engine/EffectTypes.h
@@ -36,6 +36,16 @@ class CannonEffect : public Effect {
void apply();
};
+class FlakEffect : public Effect {
+ Q_OBJECT
+
+public:
+ explicit FlakEffect(Unit* unit);
+ virtual ~FlakEffect() {}
+
+ void apply();
+};
+
class PlayerTerrainEffect : public Effect {
Q_OBJECT
View
47 src/input/ProjectileInputComponentTypes.cpp
@@ -39,6 +39,17 @@ void CannonProjectileInputComponent::update() {
makeForce();
}
+void FlakProjectileInputComponent::update() {
+ if (parent_->getEnemy() != NULL) {
+ QPointF* start = new QPointF(parent_->getPos().x(),
+ parent_->getPos().y());
+ QPointF* end = new QPointF(parent_->getEnemy()->getPos().x(),
+ parent_->getEnemy()->getPos().y());
+ setPath(start, end);
+ }
+ makeForce();
+}
+
void ArrowProjectileInputComponent::checkNPCCollision(QSet<Unit*> npcs){
((NPC*)parent_->getEnemy())->createEffect(new ArrowEffect(parent_->getEnemy()));
}
@@ -83,42 +94,10 @@ void TarProjectileInputComponent::checkNPCCollision(QSet<Unit*> npcs){
}
void FlakProjectileInputComponent::checkNPCCollision(QSet<Unit*> npcs){
- QSet<Unit*>::iterator it;
- QPolygonF projBounds;
- QPolygonF npcBounds;
-
-//Note: for arrow/flak/other autohit projectiles
-// Just need to add effect to this->getEnemy()
-
- for (it = npcs.begin(); it != npcs.end(); ++it) {
- if ((((*it)->getID() & 0xFF000000)>>24) == NPC::clsIdx()) {
- // Check to see if this projectile can damage this unit
- if ((parent_->getType() == PROJ_FLAK) && (((NPC*)*it)->getType() != NPC_FLY))
- {
- continue;
- }
- if ((((NPC*)*it)->getType() == NPC_FLY)
- && ((parent_->getType() == PROJ_CANNON) || (parent_->getType() == PROJ_FIRE)
- || (parent_->getType() == PROJ_TAR)))
- {
- continue;
- }
-
- projBounds = parent_->getBounds();
- npcBounds = (*it)->getBounds();
- if(parent_->getBounds().intersected((*it)->getBounds()).count() != 0){
- //create projectile effect
- //add effect to npc
- //qDebug("Enemy hit");
- ((NPC*)(*it))->createEffect(new NPCTarEffect(*it));
- break;
- }else{
- //qDebug("No hit");
- }
- }
+ if(((NPC*)parent_->getEnemy())->getType() == NPC_FLY){
+ ((NPC*)parent_->getEnemy())->createEffect(new ArrowEffect(parent_->getEnemy()));
}
-
}
void FireProjectileInputComponent::checkNPCCollision(QSet<Unit*> npcs){
View
1  src/input/ProjectileInputComponentTypes.h
@@ -55,6 +55,7 @@ class FlakProjectileInputComponent : public ProjectileInputComponent {
FlakProjectileInputComponent() : ProjectileInputComponent() {}
virtual ~FlakProjectileInputComponent() {}
+ void update();
void checkNPCCollision(QSet<Unit *> npcs);
};
Please sign in to comment.
Something went wrong with that request. Please try again.