Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc @ 12402

Last change on this file since 12402 was 12396, checked in by pomselj, 6 years ago

Jesus safed our souls and stopped the crashing. Hallowed be his name and hallowed be his followers sevy and aryo, first of their names, saviors of the andals the raynars and the first nerds. Fourier is love btw

File size: 1.9 KB
RevLine 
[12295]1#include "OrxoBloxCanon.h"
2
3#include "core/CoreIncludes.h"
4
5#include "graphics/Model.h"
6#include "weaponsystem/Weapon.h"
7#include "weaponsystem/WeaponPack.h"
8#include "weaponsystem/WeaponSystem.h"
9
10#include "weapons/projectiles/BallProjectile.h"
11#include "weapons/MuzzleFlash.h"
12
13namespace orxonox
14{
15    RegisterClass(OrxoBloxCanon);
16
17    OrxoBloxCanon::OrxoBloxCanon(Context* context) : HsW01(context)
18    {
19        RegisterObject(OrxoBloxCanon);
20
21
22    }
23
24    OrxoBloxCanon::~OrxoBloxCanon()
25    {
26
27    }
28
29    void OrxoBloxCanon::shot()
30    {
31        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
32
33        // Create the projectile.
34        Projectile* projectile = new BallProjectile(this->getContext());
35        Model* model = new Model(projectile->getContext());
36        model->setMeshSource(mesh_);
37        model->setCastShadows(false);
38        projectile->attach(model);
39        model->setScale(5);
40
41        //get position and orientation of the ship to know in which direction the projectile needs to fire off
42        Pawn* player = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn();
43
44        projectile->setOrientation(player->getOrientation());
45        projectile->setPosition(player->getPosition());
46
47        //Velocity & position of the projectile must be y = 0 since the game takes place in the x-z plane
48        Vector3 muzzle2D = player->getOrientation()* WorldEntity::FRONT ;
49        muzzle2D.y = 0; 
50        projectile->setVelocity(muzzle2D * this->speed_);
51
52        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
53        projectile->setDamage(this->getDamage());
54        projectile->setShieldDamage(this->getShieldDamage());
55        projectile->setHealthDamage(this->getHealthDamage());
56
57        // Display the muzzle flash.
58        this->HsW01::muzzleflash();
59    }
60   
61}
Note: See TracBrowser for help on using the repository browser.