Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2145


Ignore:
Timestamp:
Nov 5, 2008, 7:57:16 PM (15 years ago)
Author:
polakma
Message:

added firemodes and a lot of other things

Location:
code/branches/weapon2/src/orxonox/objects
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapon2/src/orxonox/objects/controllers/HumanController.cc

    r2087 r2145  
    103103    {
    104104        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    105             HumanController::localController_s->controllableEntity_->fire();
     105            HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire);
    106106    }
    107107
     
    109109    {
    110110        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    111             HumanController::localController_s->controllableEntity_->altFire();
     111            HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire);
    112112    }
    113113
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc

    r2098 r2145  
    3535#include "Weapon.h"
    3636
     37
    3738namespace orxonox
    3839{
     
    4041    {
    4142        RegisterObject(Weapon);
    42 
    43         this->loadingTime_ = 0;
    44         this->munition_ = 0;
     43        this->weaponReadyToShoot_ = true;
     44        //this->setParentWeaponSystem();
    4545
    4646    }
     
    5050    }
    5151
    52     void Weapon::addMunition()
    53     {
    54 
    55     }
    5652
    5753    void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    6460
    6561    }
     62
     63    void Weapon::reloaded()
     64    {
     65        this->weaponReadyToShoot_ = true;
     66    }
     67
     68    void Weapon::attachNeededMunition(Munition *PointerToMunition)
     69    {
     70
     71    }
     72/*
     73    void Weapon::setParentWeaponSystem()
     74    {
     75        this->parentWeaponSystem_ = this->parentWeaponSlot_->parentWeaponSet_->parentWeaponSystem_;
     76    }
     77*/
     78
    6679}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h

    r2106 r2145  
    3333
    3434#include "core/BaseObject.h"
    35 
     35#include "tools/BillboardSet.h"
     36#include "tools/Timer.h"
    3637
    3738namespace orxonox
     
    4546            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4647
    47             void addMunition();
    4848            virtual void fire();
     49            void reloaded();
     50            virtual void attachNeededMunition(Munition *PointerToMunition);
     51
     52            inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot)
     53                { parentWeaponSlot_=parentWeaponSlot; };
     54            inline WeaponSlot * getParentWeaponSlot()
     55                { return parentWeaponSlot_; };
     56
     57            //void setParentWeaponSystem();
    4958
    5059        private:
    51             int loadingTime_;
    52             Munition *munition_;
    53 
     60            bool weaponReadyToShoot_;
     61            float loadingTime_;
     62            Munition *pointerToMunition_;
     63            WeaponSlot *parentWeaponSlot_;
     64            //WeaponSystem *parentWeaponSystem_;
     65            Timer<Weapon> reloadTimer_;
    5466
    5567
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2098 r2145  
    5454    }
    5555
    56     //Vorwärtsdeklaration
    57     WeaponSystem * parentWeaponSystem_;
    58 
    5956    void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot)
    6057    {
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc

    r2098 r2145  
    3636
    3737
    38 
    3938namespace orxonox
    4039{
    41     WeaponSlot::WeaponSlot(BaseObject* creator) : BaseObject(creator)
     40    WeaponSlot::WeaponSlot(BaseObject* creator) : PositionableEntity(creator)
    4241    {
    4342        RegisterObject(WeaponSlot);
    4443
    4544        this->unlimitedAmmo_ = false;
    46 
    4745        this->attachedWeapon_ = 0;
    4846        this->parentWeaponSet_ = 0;
     47        this->setObjectMode(0x0);
    4948    }
    5049
     
    5352    }
    5453
    55     void WeaponSlot::attachWeapon(Weapon *weaponName)
     54    void WeaponSlot::attachWeapon(Weapon *weaponPointer)
    5655    {
     56        this->attachedWeapon_ = weaponPointer;
     57    }
    5758
    58     }
    5959
    6060    /*sets the munition type
     
    6969    void WeaponSlot::fire()
    7070    {
    71 
     71        this->attachedWeapon_->fire();
    7272    }
    7373
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h

    r2106 r2145  
    3636
    3737#include "Weapon.h"
    38 
     38#include "../worldentities/PositionableEntity.h"
    3939
    4040namespace orxonox
    4141{
    42     class _OrxonoxExport WeaponSlot : public BaseObject
     42    class _OrxonoxExport WeaponSlot : public PositionableEntity
    4343    {
    4444        public:
     
    4848            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4949
    50             void attachWeapon(Weapon *weaponName);
     50            void attachWeapon(Weapon *weaponPointer);
    5151            void setAmmoType(bool isUnlimited);
    5252            void fire();
     
    5656            inline WeaponSet * getParentWeaponSet()
    5757                { return parentWeaponSet_; }
    58 
    5958
    6059
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2106 r2145  
    4545namespace orxonox
    4646{
     47
    4748    WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator)
    4849    {
     
    5152        this->activeWeaponSet_ = 0;
    5253        this->parentSpaceShip_ = 0;
     54        //this->attachedMunition_ =0;
    5355    }
    5456
     
    5759    }
    5860
    59     //creates empty weaponSet
    6061    void WeaponSystem::attachWeaponSet(WeaponSet *wSet)
    6162    {
     
    6465    }
    6566
     67/*
    6668    //the first weaponSet is at n=0
    6769    void WeaponSystem::setActiveWeaponSet(unsigned int n)
     
    6971        if (n < this->weaponSets_.size())
    7072            this->activeWeaponSet_ = this->weaponSets_[n];
     73        else
     74            this->activeWeaponSet_ = this->weaponSets_[0];
    7175    }
     76*/
    7277
    7378    //n is the n'th weaponSet, starting with zero
    74     //Spaceship.cc only needs to have the keybinding to a specific Set-number n
    75     void WeaponSystem::fire(unsigned int n)
     79    //SpaceShip.cc only needs to have the keybinding to a specific Set-number n
     80    void WeaponSystem::fire(WeaponMode::Enum n)
    7681    {
    7782        if (n < this->weaponSets_.size())
     
    7984    }
    8085
    81     void WeaponSystem::fire()
    82     {
    83         if (this->activeWeaponSet_)
    84             this->activeWeaponSet_->fire();
    85     }
    8686
    8787    WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n)
     
    9898    }
    9999
     100    /*
     101    void WeaponSystem::addMunitionType(Munition *munitionPointer)
     102    {
     103
     104
     105        if (munitionPointer != NULL)  //gewährleiste, dass munitionPointer auf etwas sinnvolles zeigt
     106            this->attachedMunition_ = munitionPointer;
     107        else
     108            this->unlimitedAmmo_ = true;
     109
     110    }
     111    */
     112
    100113}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h

    r2107 r2145  
    3939namespace orxonox
    4040{
     41    //put here all existing munitionTypes
     42    namespace MunitionType
     43    {
     44        enum Enum
     45        { LaserGunMunition };
     46    }
     47
     48    //put here all weapon fire modes.
     49    //they have to be added to Pawn and HumanController, too.
     50    namespace WeaponMode
     51    {
     52        enum Enum
     53        { fire, altFire, altFire2 };
     54    }
     55
    4156    class _OrxonoxExport WeaponSystem : public BaseObject
    4257    {
     
    4863
    4964            void attachWeaponSet(WeaponSet *wSet);
     65            void addMunitionType(Munition *munitionPointer);
    5066            void fire();
    51             void fire(unsigned int n);
    52             void setActiveWeaponSet(unsigned int n);
     67            void fire(WeaponMode::Enum fireMode);
     68            //void setActiveWeaponSet(unsigned int n);
    5369            WeaponSet * getWeaponSetPointer(unsigned int n);
    5470
     
    6177        private:
    6278            std::vector<WeaponSet *> weaponSets_;
     79            std::map<MunitionType::Enum,Munition *> munitionSet_;
    6380            WeaponSet *activeWeaponSet_;
    64 
    6581            SpaceShip *parentSpaceShip_;
    6682    };
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h

    r2106 r2145  
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport LaserGunMunition : public BaseObject
     39    class _OrxonoxExport LaserGunMunition : public Munition
    4040    {
    4141        public:
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2097 r2145  
    4141        RegisterObject(LaserGun);
    4242
    43         projectileColor_ = ColourValue(1.0, 1.0, 0.5)
     43        this->attachNeededMunition();
     44
     45        //set weapon properties here
     46        this->projectileColor_ = ColourValue(1.0, 1.0, 0.5)
     47        this->loadingTime_ = 0.5;
    4448    }
    4549
     
    5054    LaserGun::fire()
    5155    {
     56        if { this->weaponReadyToShoot_ }
     57        {
     58            this->weaponReadyToShoot_ = false;
     59            //take munition
     60            //this->pointerToMunition_->
     61
     62            this->reloadTimer_.setTimer( loadingTime_ , false , this , &this->reloaded );
     63
    5264            BillboardProjectile* projectile = new ParticleProjectile(this);
    53             projectile->setColour(this->projectileColor_);
    54             projectile->create();
    55             if (projectile->getClassID() == 0)
    56             {
    57               COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
    58             }
    59 
    60             projectile->setObjectMode(0x3);
    61     }
    62 
    63     LaserGun::addMunition()
    64     {
    65         //this->munition_ = ;
     65            projectile->setColour(this->getProjectileColour());
     66        }
     67        else
     68        {
     69            //actions, when weapon is not reloaded
     70        }
    6671    }
    6772
     
    7580        return projectileColor_;
    7681    }
     82
     83    void attachNeededMunition(Munition *pointerToMunition)
     84    {
     85        //if munition type already exist attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
     86        if ( this->parentWeaponSystem_->munitionSet_[laserGunMunition] )
     87            this->pointerToMunition_ = pointerToMunition;
     88        else
     89        {
     90            this->pointerToMunition_ = new LaserGunMunition;
     91
     92        }
     93    }
    7794}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h

    r2106 r2145  
    3535
    3636#include "LaserGunMunition.h"
    37 #include "tools/BillboardSet.h"
    3837#include "util/Math.h"
    3938
     
    4847            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4948
     49            void fire();
    5050            ColourValue LaserGun::getProjectileColour();
    5151
     
    5353            ColorValue projectileColor_;
    5454
    55 
    56 
    5755    };
    5856}
  • code/branches/weapon2/src/orxonox/objects/worldentities/ControllableEntity.h

    r2087 r2145  
    3434#include "WorldEntity.h"
    3535#include "objects/Tickable.h"
     36#include "objects/weaponSystem/WeaponSystem.h"
    3637
    3738namespace orxonox
     
    6566            virtual void rotateRoll(const Vector2& value) {}
    6667
    67             virtual void fire() {}
    68             virtual void altFire() {}
     68            virtual void fire(WeaponMode::Enum fireMode) {}
     69            virtual void altFire(WeaponMode::Enum fireMode) {}
    6970
    7071            virtual void greet() {}
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2106 r2145  
    3535#include "objects/infos/PlayerInfo.h"
    3636#include "objects/gametypes/Gametype.h"
    37 #include "objects/weaponSystem/WeaponSystem.h"
     37
    3838
    3939namespace orxonox
     
    5454        this->weaponSystem_ = 0;
    5555
     56        //WeaponSystem
     57        weaponSystem_ = new WeaponSystem(this);
    5658        /*
    57         //WeaponSystem
    58         weaponSystem_ = new WeaponSystem();
    5959        WeaponSet * weaponSet1 = new WeaponSet(1);
    6060        this->weaponSystem_->attachWeaponSet(weaponSet1);
     
    137137    }
    138138
    139     void Pawn::fire()
     139    void Pawn::fire(WeaponMode::Enum fireMode)
    140140    {
    141141        if (this->weaponSystem_)
    142             this->weaponSystem_->fire();
     142            this->weaponSystem_->fire(fireMode);
    143143    }
    144144
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2098 r2145  
    3333
    3434#include "objects/worldentities/ControllableEntity.h"
     35#include "objects/weaponSystem/WeaponSystem.h"
    3536
    3637namespace orxonox
     
    7475            virtual void kill();
    7576
    76             virtual void fire();
     77            virtual void fire(WeaponMode::Enum fireMode);
    7778
    7879            virtual void postSpawn();
Note: See TracChangeset for help on using the changeset viewer.