Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9728 for code


Ignore:
Timestamp:
Oct 29, 2013, 8:56:38 PM (11 years ago)
Author:
jo
Message:

Making a Mission endable by a ConsoleCommand such that it can be ended from within a level.

Location:
code/trunk/src/orxonox/gametypes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/gametypes/Mission.cc

    r9667 r9728  
    3232
    3333#include "core/CoreIncludes.h"
     34#include "core/command/ConsoleCommand.h"
    3435#include "network/Host.h"
    3536#include "worldentities/pawns/Pawn.h"
     
    3738namespace orxonox
    3839{
     40    SetConsoleCommand("Mission", "endMission", &Mission::endMission);
    3941    RegisterUnloadableClass(Mission);
    4042
     
    7880    {
    7981        Gametype::end();
    80         /*if (this->missionAccomplished_)
     82        if (this->missionAccomplished_)
    8183            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    8284        else
    8385            this->gtinfo_->sendAnnounceMessage("Mission failed!");
    84         */
    8586    }
    8687
     
    9495        }
    9596    }
    96 
     97    void Mission::endMission(bool accomplished)
     98    {
     99        for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
     100        {//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions!
     101            it->setMissionAccomplished(accomplished);
     102            it->end();
     103        }
     104    }
    97105
    98106
  • code/trunk/src/orxonox/gametypes/Mission.h

    r9667 r9728  
    5252            inline unsigned int getLives()
    5353                {return this->lives_;}
     54            inline void setMissionAccomplished(bool acc)
     55                {this->missionAccomplished_ = acc;}
     56            static void endMission(bool accomplished);
    5457
    5558        protected:
     
    5760            bool missionAccomplished_; //<! indicates if player successfully finsihed the mission;
    5861            int lives_; //<! amount of player's lives <-> nr. of retries
     62            //Make end() a callback function to the event "END"
     63            //or create a console command.
    5964
    6065    };
Note: See TracChangeset for help on using the changeset viewer.