Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/menu/src/orxonox/pickup/items/Jump.cc @ 5944

Last change on this file since 5944 was 5929, checked in by rgrieder, 15 years ago

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

  • Property svn:eol-style set to native
File size: 2.9 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 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Implementation of Jump.
32*/
33
34#include "Jump.h"
35
36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38#include "pickup/DroppedItem.h"
39#include "worldentities/pawns/Pawn.h"
40
41namespace orxonox
42{
43    CreateFactory(Jump);
44
45    /**
46        @brief Constructor
47        @param creator Object that created this item.
48    */
49    Jump::Jump(BaseObject* creator) : UsableItem(creator)
50    {
51        RegisterObject(Jump);
52
53        this->velocity_ = Vector3(0.0f, 0.0f, 0.0f);
54        this->jumpsAvailable_ = 1;
55    }
56    //! Deconstructor
57    Jump::~Jump()
58    {
59    }
60    /**
61        @brief XMLPort for Jump.
62        @param xmlelement Element of the XML-file.
63        @param mode XMLPort mode to use.
64    */
65    void Jump::XMLPort(Element& xmlelement, XMLPort::Mode mode)
66    {
67        SUPER(Jump, XMLPort, xmlelement, mode);
68
69        XMLPortParam(Jump, "velocity", setVelocity, getVelocity, xmlelement, mode);
70        XMLPortParam(Jump, "jumpsAvailable", setJumpsAvailable, getJumpsAvailable, xmlelement, mode);
71    }
72    /**
73        @brief Called when the item is used, makes the user "jump".
74        @param pawn Pawn which used the item.
75    */
76    void Jump::used(Pawn* pawn)
77    {
78        if (this->jumpsAvailable_ > 0){
79            pawn->setVelocity(pawn->getVelocity() + pawn->getOrientation() * this->velocity_);
80        }
81
82        this->jumpsAvailable_--;
83        if (this->jumpsAvailable_ <= 0)
84        {
85            this->removeFrom(pawn);
86            this->destroy();
87        }
88    }
89    /**
90        @brief Called when the item is picked up.
91        @param pawn Pawn which picked up the item.
92    */
93    bool Jump::pickedUp(Pawn* pawn)
94    {
95        return this->addTo(pawn);
96    }
97    /**
98        @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
99        @param pawn Pawn which dropped the item.
100    */
101    bool Jump::dropped(Pawn* pawn)
102    {
103        DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 30.0f);
104        return this->removeFrom(pawn);
105    }
106}
Note: See TracBrowser for help on using the repository browser.