Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc @ 11660

Last change on this file since 11660 was 11660, checked in by vyang, 6 years ago

Projektile fliegen in 2D Ebene, jedoch in eine falsche Richtung. Kommentare hinzugefuegt

File size: 3.3 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// #include "core/XMLPort.h"
38// #include "core/command/Executor.h"
39
40#include "graphics/Model.h"
41#include "weaponsystem/Weapon.h"
42#include "weaponsystem/WeaponPack.h"
43#include "weaponsystem/WeaponSystem.h"
44#include "worldentities/WorldEntity.h"
45#include "worldentities/pawns/Pawn.h"
46
47#include "weapons/projectiles/Projectile.h"
48#include "weapons/MuzzleFlash.h"
49
50#include "Asteroids2D.h"
51
52namespace orxonox
53{
54    RegisterClass(Asteroids2DWeapon);
55
56    Asteroids2DWeapon::Asteroids2DWeapon(Context* context) : HsW01(context)
57    {
58        RegisterObject(Asteroids2DWeapon);
59
60
61    }
62
63    Asteroids2DWeapon::~Asteroids2DWeapon()
64    {
65
66    }
67
68    Asteroids2D* Asteroids2DWeapon::getGame()
69    {
70        if (game == nullptr)
71        {
72            for (Asteroids2D* race : ObjectList<Asteroids2D>())
73            {
74                game = race;
75            }
76        }
77        return game;
78    }
79
80
81    void Asteroids2DWeapon::shot()
82    {
83        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
84
85        // Create the projectile.
86        Projectile* projectile = new Projectile(this->getContext());
87        Model* model = new Model(projectile->getContext());
88        model->setMeshSource(mesh_);
89        model->setCastShadows(false);
90        projectile->attach(model);
91        model->setScale(5);
92
93        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
94
95        //projectile->setOrientation(this->getGame()->getPlayer()->getOrientation());
96        projectile->setPosition(this->getMuzzlePosition());
97
98
99        //auf 2D Ebene druecken
100        Vector3 muzzle2D = this->getMuzzleDirection();
101        muzzle2D.y = 0; 
102
103        projectile->setVelocity(muzzle2D * this->speed_);
104
105        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
106        projectile->setDamage(this->getDamage());
107        projectile->setShieldDamage(this->getShieldDamage());
108        projectile->setHealthDamage(this->getHealthDamage());
109
110        // Display the muzzle flash.
111        this->HsW01::muzzleflash();
112    }
113   
114}
Note: See TracBrowser for help on using the repository browser.