Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2009, 5:54:42 PM (16 years ago)
Author:
Aurelian
Message:

Final commit of gametype asteroids for presentation. everything working. New gadget: Radar displays the next checkpoint to reach!

Location:
code/trunk/src/orxonox/objects
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/Radar.cc

    r2896 r3064  
    114114            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
    115115            {
    116                 if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
    117                     (*itListener)->displayObject(*itElement, *itElement == this->focus_);
     116                if ((*itElement)->getRadarVisibility())
     117                    if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
     118                        (*itListener)->displayObject(*itElement, *itElement == this->focus_);
    118119            }
    119120        }
  • code/trunk/src/orxonox/objects/RadarViewable.cc

    r2662 r3064  
    4747    {
    4848        RegisterRootObject(RadarViewable);
     49
     50        this->bVisibility_ = true;
    4951    }
    5052
  • code/trunk/src/orxonox/objects/RadarViewable.h

    r2662 r3064  
    7070            { return this->radarObjectDescription_; }
    7171
     72        inline void setRadarVisibility(bool b)
     73            { this->bVisibility_ = b; }
     74        inline bool getRadarVisibility() const
     75            { return this->bVisibility_; }
     76
    7277        virtual const WorldEntity* getWorldEntity() const = 0;
    7378
     
    8994            }
    9095        }
    91 
     96       
     97        bool bVisibility_;
    9298        float radarObjectCamouflage_;
    9399        Shape radarObjectShape_;
  • code/trunk/src/orxonox/objects/gametypes/Asteroids.h

    r3056 r3064  
    4848
    4949            inline void firstCheckpointReached(bool reached)
    50               { this->firstCheckpointReached_ = reached; }
     50                { this->firstCheckpointReached_ = reached; }
    5151
    5252        protected:
  • code/trunk/src/orxonox/objects/worldentities/ForceField.cc

    r3033 r3064  
    3535namespace orxonox
    3636{
    37   CreateFactory(ForceField);
     37    CreateFactory(ForceField);
    3838
    3939    ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
    4040    {
    41       RegisterObject(ForceField);
     41        RegisterObject(ForceField);
    4242
    43       //Standard Values
    44       this->setDirection(Vector3::ZERO);
    45       velocity_ = 100;
    46       diameter_ = 500;
    47       length_ = 2000;
     43        //Standard Values
     44        this->setDirection(Vector3::ZERO);
     45        velocity_ = 100;
     46        diameter_ = 500;
     47        length_ = 5000;
    4848    }
    4949
     
    5252    void ForceField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5353    {
    54       SUPER(ForceField, XMLPort, xmlelement, mode);
    55 
    56       //For correct xml import use: position, direction, velocity, scale
    57 
    58       XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
    59       XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
    60       XMLPortParam(ForceField, "length"  , setLength  , getLength  , xmlelement, mode).defaultValues(2000);
     54        SUPER(ForceField, XMLPort, xmlelement, mode);
     55 
     56        //For correct xml import use: position, direction, velocity, scale
     57        XMLPortParam(ForceField, "velocity", setVelocity, getVelocity, xmlelement, mode).defaultValues(100);
     58        XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
     59        XMLPortParam(ForceField, "length"  , setLength  , getLength  , xmlelement, mode).defaultValues(2000);
    6160    }
    6261
    6362    void ForceField::tick(float dt)
    6463    {
     64        for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
     65        {
     66            //calculate from
     67            Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
     68            directionVec.normalise();
    6569
    66       for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    67       {
     70            Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
    6871
    69         //calculate from
    70         Vector3 directionVec = this->getOrientation() * WorldEntity::FRONT;
    71         directionVec.normalise();
     72            //distance from centervector of the field (
     73            float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
    7274
    73         Vector3 distanceVec = it->getWorldPosition() - (this->getWorldPosition() + (this->length_ / 2 * directionVec));
    74 
    75         //distance from centervector of the field (
    76         float distFromCenterVec = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(directionVec)).length();
    77 
    78         if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
    79         {
    80           //normalize distance from center
    81           it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
     75            if (distanceVec.length() < this->length_ / 2 && distFromCenterVec < diameter_ / 2)
     76            {
     77                //normalize distance from center
     78                it->applyCentralForce(((diameter_ / 2 - distFromCenterVec) / (diameter_ / 2)) * directionVec * velocity_);
     79            }
    8280        }
    83 
    84       }
    85   }
     81    }
    8682}
    8783
  • code/trunk/src/orxonox/objects/worldentities/ForceField.h

    r3033 r3064  
    3636namespace orxonox
    3737{
    38   class _OrxonoxExport ForceField : public StaticEntity, public Tickable
    39   {
     38    class _OrxonoxExport ForceField : public StaticEntity, public Tickable
     39    {
    4040    public:
    41       ForceField(BaseObject* creator);
    42       virtual ~ForceField();
    43       virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
    44       virtual void tick(float dt);
     41        ForceField(BaseObject* creator);
     42        virtual ~ForceField();
     43        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
     44        virtual void tick(float dt);
    4545
    46       inline void setVelocity(float vel)
    47         { this->velocity_ = vel; }
     46        inline void setVelocity(float vel)
     47            { this->velocity_ = vel; }
    4848   
    49       inline float getVelocity()
    50         { return velocity_; }
     49        inline float getVelocity()
     50            { return velocity_; }
    5151   
    52       inline void setDiameter(float diam)
    53         { this->diameter_ = diam; }
     52        inline void setDiameter(float diam)
     53            { this->diameter_ = diam; }
    5454
    55       inline float getDiameter()
    56         { return diameter_; }
     55        inline float getDiameter()
     56            { return diameter_; }
    5757 
    58       inline void setLength(float l)
    59         { this->length_ = l; }
     58        inline void setLength(float l)
     59            { this->length_ = l; }
    6060
    61       inline float getLength()
    62         { return length_; }
     61        inline float getLength()
     62            { return length_; }
    6363
    6464    private:
    65       float velocity_;
    66       float diameter_;
    67       float length_;
     65        float velocity_;
     66        float diameter_;
     67        float length_;
    6868  };
    6969}
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc

    r3033 r3064  
    8080            if (victim)
    8181            {
    82                 victim->damage(this->collisionDamage_ * victim->getVelocity().dotProduct(this->getVelocity()));
     82                victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length());
    8383            }
    8484        }
  • code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc

    r3033 r3064  
    3838namespace orxonox
    3939{
    40   CreateFactory(CheckPoint);
     40    CreateFactory(CheckPoint);
    4141
    42   CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
    43   {
    44     RegisterObject(CheckPoint);
     42    CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
     43    {
     44        RegisterObject(CheckPoint);
    4545
    46     this->setStayActive(true);
    47     this->setDistance(50);
    48     this->bIsFirst_ = false;
    49     this->bIsDestination_ = false;
    50     //this->setVisible(true);
     46        this->setStayActive(true);
     47        this->setDistance(50);
     48        this->bIsFirst_ = false;
     49        this->bIsDestination_ = false;
    5150
    52     this->notifyMaskUpdate();
    53   }
     51        this->setRadarObjectColour(ColourValue::Green);
     52        this->setRadarObjectShape(RadarViewable::Dot);
     53        this->setRadarVisibility(false);
    5454
    55   CheckPoint::~CheckPoint()
    56   {
    57   }
     55        this->notifyMaskUpdate();
     56    }
    5857
    59   void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    60   {
    61     SUPER(CheckPoint, XMLPort, xmlelement, mode);
     58    CheckPoint::~CheckPoint()
     59    {
     60    }
    6261
    63     XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false);
    64     XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false);
    65     XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30);
    66   }
     62    void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     63    {
     64        SUPER(CheckPoint, XMLPort, xmlelement, mode);
    6765
    68   void CheckPoint::triggered(bool bIsTriggered)
    69   {
    70     DistanceTrigger::triggered(bIsTriggered);
     66        XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false);
     67        XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false);
     68        XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30);
     69    }
    7170
    72     Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
    73     if (gametype)
     71    void CheckPoint::changedActivity()
    7472    {
    75         gametype->addTime(addTime_);
     73        SUPER(CheckPoint, changedActivity);
     74       
     75        if (this->BaseObject::isActive())
     76        {
     77COUT(0) << "active " << this << std::endl;
     78            this->setRadarVisibility(true);
     79        }
     80        else
     81        {
     82COUT(0) << "inactive " << this << std::endl;
     83            this->setRadarVisibility(false);
     84        }
     85    }
    7686
    77         if (bIsTriggered && bIsFirst_)
     87    void CheckPoint::triggered(bool bIsTriggered)
     88    {
     89        DistanceTrigger::triggered(bIsTriggered);
     90
     91        Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
     92        if (gametype)
    7893        {
    79             gametype->setTimeLimit(addTime_);
    80             gametype->firstCheckpointReached(true);
     94            gametype->addTime(addTime_);
     95            this->setRadarVisibility(false);
     96
     97            if (bIsTriggered && bIsFirst_)
     98            {
     99                gametype->setTimeLimit(addTime_);
     100                gametype->firstCheckpointReached(true);
     101            }
     102
     103            if (bIsTriggered && bIsDestination_)
     104            {
     105                gametype->end();
     106            }
    81107        }
     108    }
    82109
    83         if (bIsTriggered && bIsDestination_)
    84         {
    85             gametype->end();
    86         }
    87      }
    88   }
    89 
    90   void CheckPoint::notifyMaskUpdate()
    91   {
    92       this->targetMask_.exclude(Class(BaseObject));
    93       this->targetMask_.include(Class(Pawn));
    94   }
     110    void CheckPoint::notifyMaskUpdate()
     111    {
     112        this->targetMask_.exclude(Class(BaseObject));
     113        this->targetMask_.include(Class(Pawn));
     114    }
    95115}
  • code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h

    r3033 r3064  
    3636
    3737#include "DistanceTrigger.h"
     38#include "objects/RadarViewable.h"
    3839
    3940namespace orxonox
    4041{
    41   class _OrxonoxExport CheckPoint : public DistanceTrigger
    42   {
     42    class _OrxonoxExport CheckPoint : public DistanceTrigger, public RadarViewable
     43    {
    4344    public:
    44       CheckPoint(BaseObject* creator);
    45       virtual ~CheckPoint();
     45        CheckPoint(BaseObject* creator);
     46        virtual ~CheckPoint();
    4647
    47       virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
     48        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
     49        virtual void changedActivity();
    4850
    4951    private:
    50       virtual void triggered(bool bIsTriggered);
    51       virtual void notifyMaskUpdate();
     52        virtual void triggered(bool bIsTriggered);
     53        virtual void notifyMaskUpdate();
    5254
    53       inline void setDestination(bool isDestination)
    54         { bIsDestination_ = isDestination; }
     55        inline void setDestination(bool isDestination)
     56            { bIsDestination_ = isDestination; }
    5557
    56       inline bool getDestination()
    57         { return bIsDestination_; }
     58        inline const WorldEntity* getWorldEntity() const
     59            { return this; }
    5860
    59       inline void setFirst(bool isFirst)
    60         { this->bIsFirst_ = isFirst; }
     61        inline bool getDestination()
     62            { return bIsDestination_; }
    6163
    62       inline bool getFirst()
    63         { return this->bIsFirst_; }
     64        inline void setFirst(bool isFirst)
     65            { this->bIsFirst_ = isFirst; }
    6466
    65       inline void setAddTime(float time)
    66         { this->addTime_ = time; }
     67        inline bool getFirst()
     68            { return this->bIsFirst_; }
    6769
    68       inline bool getAddTime()
    69         { return this->addTime_; }
     70        inline void setAddTime(float time)
     71            { this->addTime_ = time; }
    7072
    71       bool bIsFirst_;
    72       bool bIsDestination_;
    73       float addTime_;
    74   };
     73        inline bool getAddTime()
     74            { return this->addTime_; }
     75
     76        bool bIsFirst_;
     77        bool bIsDestination_;
     78        float addTime_;
     79    };
    7580}
    7681
Note: See TracChangeset for help on using the changeset viewer.