Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cegui0.8_ogre1.9/src/modules/asteroids2D/Asteroids2DWeapon.cc @ 12112

Last change on this file since 12112 was 11781, checked in by landauf, 7 years ago

eol-style native (no changes in code)

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Viviane Yang
24 *   Co-authors:
25 *      --
26 *
27 */
28
29/**
30    @file Asteroids2DWeapon.h
31    @brief Implementation of the Asteroids2DWeapon class.
32*/
33
34#include "Asteroids2DWeapon.h"
35
36#include "core/CoreIncludes.h"
37
38#include "graphics/Model.h"
39#include "weaponsystem/Weapon.h"
40#include "weaponsystem/WeaponPack.h"
41#include "weaponsystem/WeaponSystem.h"
42
43#include "weapons/projectiles/Projectile.h"
44#include "weapons/MuzzleFlash.h"
45
46namespace orxonox
47{
48    RegisterClass(Asteroids2DWeapon);
49
50    Asteroids2DWeapon::Asteroids2DWeapon(Context* context) : HsW01(context)
51    {
52        RegisterObject(Asteroids2DWeapon);
53
54
55    }
56
57    Asteroids2DWeapon::~Asteroids2DWeapon()
58    {
59
60    }
61
62    void Asteroids2DWeapon::shot()
63    {
64        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
65
66        // Create the projectile.
67        Projectile* projectile = new Projectile(this->getContext());
68        Model* model = new Model(projectile->getContext());
69        model->setMeshSource(mesh_);
70        model->setCastShadows(false);
71        projectile->attach(model);
72        model->setScale(5);
73
74        //get position and orientation of the ship to know in which direction the projectile needs to fire off
75        Pawn* player = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn();
76
77        projectile->setOrientation(player->getOrientation());
78        projectile->setPosition(player->getPosition());
79
80        //Velocity & position of the projectile must be y = 0 since the game takes place in the x-z plane
81        Vector3 muzzle2D = player->getOrientation()* WorldEntity::FRONT ;
82        muzzle2D.y = 0; 
83        projectile->setVelocity(muzzle2D * this->speed_);
84
85        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
86        projectile->setDamage(this->getDamage());
87        projectile->setShieldDamage(this->getShieldDamage());
88        projectile->setHealthDamage(this->getHealthDamage());
89
90        // Display the muzzle flash.
91        this->HsW01::muzzleflash();
92    }
93   
94}
Note: See TracBrowser for help on using the repository browser.