Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11027


Ignore:
Timestamp:
Jan 3, 2016, 5:48:18 PM (8 years ago)
Author:
fvultier
Message:

Implemented a feature that was requested during PPS: Vulnerability can be switched on/off using the event system. Also: Resolved a TODO in CommandNotification.cc .

Location:
code/branches/fabienHS15
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/fabienHS15/data/levels/notifications.oxw

    r9348 r11027  
    1919    <?lua include("includes/notifications.oxi") ?>
    2020
     21    <NotificationQueueCEGUI
     22      name="narrative"
     23      targets="simpleNotification,commandNotification"
     24      size=3
     25      displayTime=3.9
     26      position="0.2, 0, 0.1, 0"
     27      fontSize="23"
     28      fontColor="0.3, 1, 0.2, 0.8"
     29      alignment="HorzCentred"
     30      displaySize="0.6, 0, 0, 0"
     31      />
     32
    2133    <Scene
    2234        ambientlight = "0.5, 0.5, 0.5"
     
    2537
    2638    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
     39    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    2740
    28     <CommandNotification preMessage="Open the PickupInventory by pressing '" postMessage="'." command="OrxonoxOverlay toggleVisibility PickupInventory">
     41    <CommandNotification preMessage="Open the PickupInventory by pressing '" postMessage="'." command="OrxonoxOverlay show PickupInventory">
    2942        <events>
    3043            <trigger>
     
    4457    <Billboard position="0,0,100" colour="1.0,0,1.0" material="Examples/Flare" />
    4558
    46     <?lua
    47       for i = 1, 10, 1 do
    48     ?>
    49         <SpawnPoint position="<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    50     <?lua end ?>
    51 
    5259  </Scene>
    5360</Level>
  • code/branches/fabienHS15/src/libraries/core/input/KeyBinder.cc

    r10624 r11027  
    359359    /**
    360360    @brief
     361        Return the first key name for a specific command in a human readable form
     362    */
     363    const std::string& KeyBinder::getBindingReadable(const std::string& commandName)
     364    {
     365        const std::string& binding = this->getBinding(commandName);
     366
     367        SubString substring = SubString(binding, ".");
     368        std::string name;
     369        std::string group;
     370        switch(substring.size())
     371        {
     372            case 0:
     373                return binding;
     374            case 1:
     375                return binding;
     376            case 2:
     377                group = substring[0];
     378            default:
     379                name = substring.subSet(1).join(".");
     380        }
     381
     382        std::stringstream stream;
     383        if(group.compare("Keys") == 0)
     384            stream << "Key " << name.substr(3);
     385        else if(group.compare("MouseButtons") == 0)
     386            stream << "Mouse " << name;
     387        else if(group.compare("JoyStickButtons") == 0)
     388            stream << "Joystick " << name;
     389        else if(group.compare("JoyStickAxes") == 0)
     390            stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
     391        else if(group.compare("MouseAxes") == 0)
     392            stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
     393        else
     394            return binding;
     395
     396        return *(new std::string(stream.str()));
     397    }
     398
     399    /**
     400    @brief
    361401        Get the number of different key bindings of a specific command.
    362402    @param commandName
  • code/branches/fabienHS15/src/libraries/core/input/KeyBinder.h

    r9978 r11027  
    6868        const std::string& getBinding(const std::string& commandName); //tolua_export
    6969        const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export
     70        const std::string& getBindingReadable(const std::string& commandName); //tolua_export
    7071        unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export
    7172
  • code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.cc

    r9667 r11027  
    101101        std::stringstream stream;
    102102        stream << this->getPreMessage();
    103         stream << this->bindingNiceifyer(KeyBinderManager::getInstance().getCurrent()->getBinding(this->getCommand()));
     103        stream << KeyBinderManager::getInstance().getCurrent()->getBindingReadable(this->getCommand());
    104104        stream << this->getPostMessage();
    105105        return *(new std::string(stream.str()));
    106106    }
    107 
    108     /**
    109     @brief
    110         Transforms the input binding into a human readable form.
    111     @param binding
    112         The binding to be transformed
    113     @return
    114         Returns a human readable version of the input binding.
    115     */
    116     //TODO: Move to KeyBinderManager...
    117     const std::string& CommandNotification::bindingNiceifyer(const std::string& binding)
    118     {
    119         SubString substring = SubString(binding, ".");
    120         std::string name;
    121         std::string group;
    122         switch(substring.size())
    123         {
    124             case 0:
    125                 return binding;
    126             case 1:
    127                 return binding;
    128             case 2:
    129                 group = substring[0];
    130             default:
    131                 name = substring.subSet(1).join(".");
    132         }
    133 
    134         std::stringstream stream;
    135         if(group.compare("Keys") == 0)
    136             stream << "Key " << name.substr(3);
    137         else if(group.compare("MouseButtons") == 0)
    138             stream << "Mouse " << name;
    139         else if(group.compare("JoyStickButtons") == 0)
    140             stream << "Joystick " << name;
    141         else if(group.compare("JoyStickAxes") == 0)
    142             stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
    143         else if(group.compare("MouseAxes") == 0)
    144             stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
    145         else
    146             return binding;
    147 
    148         return *(new std::string(stream.str()));
    149     }
    150 
    151107}
  • code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.h

    r9667 r11027  
    122122            void setPostMessage(const std::string& message)
    123123                 { this->postMessage_ = message; }
    124 
    125             const std::string& bindingNiceifyer(const std::string& binding); //!< Transforms the input binding into a human readable form.
    126 
    127124    };
    128125
  • code/branches/fabienHS15/src/orxonox/weaponsystem/WeaponMode.cc

    r10791 r11027  
    7575        this->muzzleOrientation_ = Quaternion::IDENTITY;
    7676
    77         hudImageString_ = "WSHUD_WM_Unknown";
     77        hudImageString_ = "Orxonox/WSHUD_WM_Unknown";
    7878
    7979        if( GameMode::isMaster() )
  • code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc

    r10814 r11027  
    3434#include "core/GameMode.h"
    3535#include "core/XMLPort.h"
     36#include "core/EventIncludes.h"
    3637#include "network/NetworkFunction.h"
    3738
     
    6263
    6364        this->bAlive_ = true;
     65        this->bVulnerable_ = true;
    6466
    6567        this->health_ = 0;
     
    134136        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
    135137
     138        XMLPortParam(Pawn, "vulnerable", setVulnerable, isVulnerable, xmlelement, mode).defaultValues(true);
     139
    136140        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
    137141        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     
    149153
    150154        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
     155    }
     156
     157    void Pawn::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     158    {
     159        SUPER(Pawn, XMLEventPort, xmlelement, mode);
     160
     161        XMLPortEventState(Pawn, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
    151162    }
    152163
     
    242253    }
    243254
     255    void Pawn::changedVulnerability()
     256    {
     257
     258    }
     259
    244260    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
    245261    {
     262        // A pawn can only get damaged if it is vulnerable
     263        if (!isVulnerable())
     264        {
     265            return;
     266        }
     267
    246268        // Applies multiplier given by the DamageBoost Pickup.
    247269        if (originator)
  • code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h

    r10814 r11027  
    6262
    6363            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     64            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    6465            virtual void tick(float dt);
    6566
     
    131132
    132133            virtual void decreaseShieldRechargeCountdownTime(float dt);
     134
     135            /** @brief Sets the state of the pawns vulnerability. @param bVulnerable */
     136            inline void setVulnerable(bool bVulnerable)
     137            {
     138                if (this->bVulnerable_ != bVulnerable)
     139                {
     140                    this->bVulnerable_ = bVulnerable;
     141                    this->changedVulnerability();
     142                }
     143            }
     144            /** @brief Returns the state of the pawns vulnerability. @return The state of the vulnerability */
     145            inline const bool& isVulnerable() const { return this->bVulnerable_; }
     146            /** @brief This function gets called if the vulnerability of the pawn changes. */
     147            virtual void changedVulnerability();
    133148
    134149            inline ControllableEntity* getLastHitOriginator() const
     
    212227
    213228            bool bAlive_;
     229            bool bVulnerable_; ///< If false the pawn may not ged damaged
    214230
    215231            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
Note: See TracChangeset for help on using the changeset viewer.