Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2289


Ignore:
Timestamp:
Nov 26, 2008, 7:48:26 PM (15 years ago)
Author:
dsommer
Message:

Added ShipEquipment to Pawn and various funtions for it -not compiling, because private…

Location:
code/branches/pickups2/src/orxonox/objects
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickups2/src/orxonox/objects/pickup/Item.cc

    r2227 r2289  
    2929void Item::addTo (Pawn* player)
    3030{
    31         //player->Equipment.insert ( std::pair<std::string, Item*>(this->itemname,this) );
     31        if(checkSlot(player)==true)
     32        player->pickUp.Equipment.insert ( std::pair<std::string, Item*>(this->getName(),this) );
     33        else
     34        COUT(3) << "swap?" << std::endl;
    3235}
    33 
     36bool Item::remove(Pawn* player)
     37{
     38        if(player->pickUp.Equipment.find(this->getName())!= player->pickUp.Equipment.end())
     39        {
     40        std::multimap<std::string,Item*>::iterator it;
     41        it=player->pickUp.Equipment.find(this->getName());
     42        player->pickUp.Equipment.erase (it);
     43        return true;
     44        }
     45        else
     46        return false;
     47}
     48bool Item::checkSlot(Pawn* player)
     49{
     50        std::multimap<std::string,Item*>::iterator it;
     51        for ( it=player->pickUp.Equipment.begin() ; it != player->pickUp.Equipment.end(); it++ )
     52        {
     53        if((*it).second->playerBaseClass_==this->playerBaseClass_)
     54        return false;
     55        }
     56        return true;
     57}
    3458void Item::setPlayerBaseClassName(const std::string& name)
    3559{
  • code/branches/pickups2/src/orxonox/objects/pickup/Item.h

    r2227 r2289  
    1212        Item( BaseObject* creator);
    1313        virtual ~Item();
    14 
     14        bool checkSlot(Pawn* player);
    1515        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    16 
     16       
    1717        virtual bool pickedUp(Pawn* player) { return true; }
    1818        virtual bool dropped(Pawn* player) { return true; } //erst bei festen Items
     19        bool remove(Pawn* player);
    1920        void addTo(Pawn* player);
    2021
     
    2829        const std::string& getPlayerBaseClassName() const;
    2930
    30         Identifier* playerBaseClass_; //class(...)
     31        Identifier* playerBaseClass_;
    3132        };
    3233}
  • code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.h

    r2094 r2289  
    33#define _ShipEquipment_H__
    44#include <string>
    5 #include <multimap>
     5#include <map>
     6#include "Item.h"
    67
    78
     
    1112
    1213
     14/*          std::map<std::itemtype, Item*> EQClasses;
     15            EQClasses["jacke"] = 0;
     16            Item* item = itemMap_["jacke"];
     17
     18           if (itemMap_["jacke"])
     19           if (itemMap_.find("jacke") != itemMap_.end()) */
    1320namespace orxonox
    1421{
     
    1623    {
    1724        public:
    18             void AddItem(Shipitem toAddItem);
    19             void RemoveItem(Shipitem toRemoveItem);
    20             bool CheckifValid(Shipitem toBeChecked);
    21             int
     25        inline int getSpace()
     26        {
     27        return Usable.size()+Trunk.size();
     28        };
     29
     30//      const std::multimap<std::string, Item*>& getEquipment() const { return this->Equipment; }
    2231
    2332        private:
    2433            std::multimap<std::string, Item*> Equipment;
     34            std::multimap<std::string, Item*> Usable;
     35            std::multimap<std::string, Item*> Trunk;
    2536    };
    2637}
     
    3950
    4051
    41 
    42 
    43 
    44 
    4552#endif
  • code/branches/pickups2/src/orxonox/objects/pickup/Turbo.cc

    r2227 r2289  
    1919                this->duration_ = 0;
    2020                this->accboost_ = 1;
     21                this->rotacc_= 0;
    2122        }
    2223
     
    3233        XMLPortParam(Turbo, "duration", setDuration, getDuration, xmlelement, mode);
    3334        XMLPortParam(Turbo, "accboost", setAccBoost, getAccBoost, xmlelement, mode);
     35        XMLPortParam(Turbo, "rotacc", setRotAcc, getRotAcc, xmlelement, mode);
     36       
    3437    }
    3538
     
    5356        ship->setMaxSpeed( ship->getMaxSpeed() - this->boost_);
    5457        ship->setTransAcc( ship->getTransAcc()/this->accboost_);
     58        ship->setMaxRotation( ship->getMaxRotation()-this->rotacc_);
     59        ship->setRotAcc( ship->getRotAcc()-this->rotacc_);
    5560        COUT(3)<<"PickUp Timer expired"<<std::endl;
    5661        }
     
    6065        ship->setMaxSpeed( ship->getMaxSpeed() + this->boost_);
    6166        ship->setTransAcc( ship->getTransAcc()*this->accboost_);
     67        ship->setMaxRotation( ship->getMaxRotation()+this->rotacc_);
     68        ship->setRotAcc( ship->getRotAcc()+this->rotacc_);
    6269        if( this->duration_ != 0)
    6370        {
     
    7279                if (this->duration_ == 0)
    7380                {
    74                         //player->Equipment.erase ( std::pair<std::string, Item*>(this->itemname,this) );
     81                        if(remove(player)==true);
     82                        {
    7583                        SpaceShip* ship = dynamic_cast <SpaceShip*>(player);
    7684                        this->unsetSpeedBoost(ship);
     85                        }       
    7786                }
    7887                return true;
  • code/branches/pickups2/src/orxonox/objects/pickup/Turbo.h

    r2227 r2289  
    55#include "Item.h"
    66#include "OrxonoxPrereqs.h"
     7#include "util/Math.h"
    78
    89namespace orxonox
     
    3334                { return this->duration_; }
    3435
     36        inline void setRotAcc(Degree rotacc)
     37                { this->rotacc_ = rotacc; }
     38        inline Degree getRotAcc() const
     39                { return this->rotacc_; }
     40
    3541       
    3642        inline void setAccBoost(float accboost)
     
    4450        float duration_;
    4551        float accboost_;
     52        Degree rotacc_;
    4653        };
    4754}
  • code/branches/pickups2/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2098 r2289  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
     33#include "objects/pickup/ShipEquipment.h"
    3434#include "objects/worldentities/ControllableEntity.h"
    3535
     
    7575
    7676            virtual void fire();
    77 
     77            ShipEquipment pickUp;
    7878            virtual void postSpawn();
    7979
     
    8383
    8484            bool bAlive_;
     85           
    8586
    8687            float health_;
  • code/branches/pickups2/src/orxonox/objects/worldentities/pawns/SpaceShip.h

    r2087 r2289  
    7474            inline float getMaxSecondarySpeed() const
    7575                { return this->maxSecondarySpeed_; }
    76             inline float getMaxRotation() const
    77                 { return this->maxRotation_.valueDegrees(); }
     76            inline const Degree& getMaxRotation() const
     77                { return this->maxRotation_; }
    7878            inline float getTransAcc() const
    7979                { return this->translationAcceleration_; }
    80             inline float getRotAcc() const
    81                 { return this->rotationAcceleration_.valueDegrees(); }
     80            inline const Degree& getRotAcc() const
     81                { return this->rotationAcceleration_; }
    8282            inline float getTransDamp() const
    8383                { return this->translationDamping_; }
     
    9090            float translationAcceleration_;
    9191            float translationDamping_;
    92 
    9392            Degree maxRotation_;
    9493            Degree rotationAcceleration_;
Note: See TracChangeset for help on using the changeset viewer.