void Actor::die() { // any on-death actions should happen here. // class removal/cleanup/GC should happen at a higher level static ActorEvent ae; ae.a = this; ae.type = ActorEvent::DEATH_EVENT; ofNotifyEvent(ActorEvent::actorEvent, ae); // TODO:remove all items in possesion Weapon * w = melee(); if (w!=NULL) { delete w; }; w = offHand(); if (w!=NULL) { delete w; }; w = ranged(); if (w!=NULL) { delete w; }; delete this; }
void sword:: weaponControl() { if(swording && canAttack == true) { melee(); Mix_PlayChannel( -1, swordSound, 0 ); } else if(!swording) { canAttack = true; } if(up) { look_up = true; } else { look_up = false; } if(down) { look_down = true; } else { look_down = false; } }
Weapon * Actor::activeWeapon() { if (weaponSet==0) { return melee(); } else { return ranged(); } return NULL; }
bool Actor::withinRangedRange() { if (target==NULL) return false; Weapon * w = melee(); if (w!=NULL) { ofVec2i d = ofVec2i(target->x, target->y) - ofVec2i(x,y); return d.length()<(w->data.range / 5); } return false; }
void gun:: shoot(Dot myDot, enemy *monsters[], Tile *tiles[], Converter conv) { melee(); if(look_up) box.y -= speed; else if(look_down) { shoot_down = true; box.y += speed; } else if(right) box.x += speed; // take away speed, creates little mines else if(left) box.x -= speed; shot = true; shot_dis++; for(int i = 0; i < monster_count; i++) { if(check_collision( box, monsters[i]->box) == true && monsters[i]->alive) { // shot = false; shot_dis = 0; } } for( int i = 0; i < NORMAL_TILES; i++ ) { //If the tile is a wall type tile if( ( tiles[ i ]->get_type() == Solid_Tile ) ) { if(check_collision( box, tiles[i]->box) == true) { if(look_up) { if(perPixel(conv.pixel_array10, conv.size10, tiles[i]->get_box())) { shot = false; shot_dis = 0; } } else if(look_down) { if(perPixel(conv.pixel_array9, conv.size9, tiles[i]->get_box())) { shot = false; shot_dis = 0; } } else if(!direction) { if(perPixel(conv.pixel_array8, conv.size8, tiles[i]->get_box())) { shot = false; shot_dis = 0; } } else { if(perPixel(conv.pixel_array7, conv.size7, tiles[i]->get_box())) { shot = false; shot_dis = 0; } } } } } }