Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8493


Ignore:
Timestamp:
May 16, 2011, 6:21:05 PM (13 years ago)
Author:
sven
Message:

Added docking animations, skeletton for DockingController..

Location:
code/branches/dockingsystem2
Files:
6 added
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem2/data/gui/scripts/DockingDialog.lua

    r8487 r8493  
    1010
    1111function P.onShow()
    12     orxonox.CommandExecutor:execute("pause")
     12    orxonox.execute("setPause 1")
    1313    P.update()
    1414end
    1515
    1616function P.onHide()
    17     orxonox.CommandExecutor:execute("pause")
     17    orxonox.execute("setPause 0")
    1818end
    1919
     
    4242        local index = listbox:getItemIndex(choice)
    4343        local dock = P.docks[index+1]
    44         cout(0, index )--.. ": " .. P.docks[index])
    4544        if dock ~= nil then
    46             cout(0, "LUA>Docking")
    4745            dock:dock()
    4846        end
     
    5250
    5351function P.cancelButton_clicked(e)
    54     --P.hideMe()
    5552    hideMenuSheet(P.name)
    5653end
  • code/branches/dockingsystem2/data/levels/docking.oxw

    r8487 r8493  
    3535
    3636
    37 
    3837    <Dock>
    39         <animation>
     38        <animations>
    4039            <MoveToDockingTarget target="destroyer" position="10,150,40" />
    41         </animation>
     40        </animations>
    4241        <effects>
    43             <DockToShip target="destroyer" />
     42            <DockToShip target="spaceShip" />
    4443        </effects>
    4544        <events>
     
    4948        </events>
    5049        <attached>
    51             <DistanceTrigger position="0,0,0" distance="30" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
     50            <DistanceTrigger position="0,0,0" distance="30" target="Pawn" beaconMode="exclude" targetname="bcnSpaceShip" name="dockMe" />
    5251            <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
    5352        </attached>
     
    7978  >
    8079    <attached>
    81         <DistanceTriggerBeacon name="bcnSpaceShip1" />
    82         <DockingTarget name="spaceShip1" />
     80        <DistanceTriggerBeacon name="bcnSpaceShip" />
     81        <DockingTarget name="spaceShip" />
    8382
    8483      <Model position="0,0,0" yaw="90" pitch="-90" roll="0" scale="4" mesh="assff.mesh" />
  • code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt

    r8434 r8493  
    22  DockingTarget.cc
    33  DockingEffect.cc
     4  DockingAnimation.cc
    45  DockToShip.cc
     6  MoveToDockingTarget.cc
     7  DockingController.cc
    58  Dock.cc
    69)
  • code/branches/dockingsystem2/src/modules/docking/Dock.cc

    r8434 r8493  
    5757    {
    5858        RegisterObject(Dock);
    59         COUT(0) << "Registering dock..." << std::endl;
    6059    }
    6160
     
    7069
    7170        XMLPortObject(Dock, DockingEffect, "effects", addEffect, getEffect, xmlelement, mode);
     71        XMLPortObject(Dock, DockingAnimation, "animations", addAnimation, getAnimation, xmlelement, mode);
    7272        XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode);
    73 
    74         COUT(0) << "Dock created.." << std::endl;
    7573    }
    7674
     
    9694            }
    9795            pawn = pTrigger->getTriggeringPlayer();
    98         } else {
     96        }
     97        else
     98        {
    9999            COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
    100100            return false;
     
    110110        if(player == NULL)
    111111        {
    112             COUT(2) << "The PlayerInfo* is NULL." << std::endl;
    113             return false;
    114         }
    115 
    116         COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
     112            COUT(2) << "Docking::execute The PlayerInfo* is NULL." << std::endl;
     113            return false;
     114        }
    117115
    118116        if(bTriggered)
     
    123121            // Show docking dialog
    124122            GUIManager::showGUI("DockingDialog");
    125             //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
    126123        }
    127124        else
     
    129126            // Remove player from candidates list
    130127            candidates.erase(player);
    131 
    132             //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
    133128        }
    134129
     
    163158        if(candidates.find(player) == candidates.end())
    164159        {
    165             COUT(0) << "Player is not a candidate!" << std::endl;
    166             return false;
    167         }
    168 
    169         // Remove player from candidates, add to docked players and invoke docking effect
     160            COUT(0) << "Dock::dock Player is not a candidate!" << std::endl;
     161            return false;
     162        }
     163
    170164        candidates.erase(player);
    171165        docked.insert(player);
    172         DockingEffect::invokeEffect(docking::ATTACH, player, effects);
     166
     167        if (animations.empty())
     168            return dockingAnimationFinished(player);
     169        else
     170            DockingAnimation::invokeAnimation(true, player, animations);
     171
     172        return true;
     173    }
     174
     175    bool Dock::dockingAnimationFinished(PlayerInfo* player)
     176    {
     177        if(docked.find(player) == docked.end())
     178        {
     179            COUT(0) << "Dock::dockingAnimationFinished Player is not currently docked." << std::endl;
     180            return false;
     181        }
     182
     183        DockingEffect::invokeEffect(true, player, effects);
    173184        return true;
    174185    }
     
    179190        if(docked.find(player) == docked.end())
    180191        {
    181             COUT(0) << "Player is not docked to this Dock." << std::endl;
    182             return false;
    183         }
    184 
    185         // Remove player from docked, add to candidates and reverse DockingEffect
     192            COUT(0) << "Dock::undock Player is not docked to this Dock." << std::endl;
     193            return false;
     194        }
     195
    186196        docked.erase(player);
    187197        candidates.insert(player);
    188         DockingEffect::invokeEffect(docking::RELEASE, player, effects);
     198
     199        DockingEffect::invokeEffect(false, player, effects);
     200
     201        if (animations.empty())
     202            return undockingAnimationFinished(player);
     203        else
     204            DockingAnimation::invokeAnimation(false, player, animations);
     205
     206        return true;
     207    }
     208
     209    bool Dock::undockingAnimationFinished(PlayerInfo* player) {
     210        COUT(0) << "Dock::undockingAnimationFinished executed" << std::endl;
    189211        return true;
    190212    }
     
    226248    }
    227249
    228     const DockingEffect* Dock::getEffect(unsigned int index) const
    229     {
    230         int i = index;
     250    const DockingEffect* Dock::getEffect(unsigned int i) const
     251    {
    231252        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect)
    232253        {
     
    237258        return NULL;
    238259    }
     260
     261    bool Dock::addAnimation(DockingAnimation* animation)
     262    {
     263        assert(animation);
     264        animation->setParent(this);
     265        animations.push_back(animation);
     266        return true;
     267    }
     268
     269    const DockingAnimation* Dock::getAnimation(unsigned int i) const
     270    {
     271        for (std::list<DockingAnimation*>::const_iterator animation = this->animations.begin(); animation != this->animations.end(); ++animation)
     272        {
     273            if(i == 0)
     274               return *animation;
     275            i--;
     276        }
     277        return NULL;
     278    }
    239279}
  • code/branches/dockingsystem2/src/modules/docking/Dock.h

    r8434 r8493  
    4646
    4747#include "DockingEffect.h"
     48#include "DockingAnimation.h"
    4849#include "DockingPrereqs.h"
    4950
     
    5859        virtual ~Dock();
    5960
     61        // Trigger interface
     62        bool execute(bool bTriggered, BaseObject* trigger);
     63
     64        // XML interface
    6065        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    6166        virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    6267
    63         bool execute(bool bTriggered, BaseObject* trigger);
    64 
     68        // XML functions
    6569        bool addEffect(DockingEffect* effect); //!< Add a DockingEffect to the Dock.
    6670        const DockingEffect* getEffect(unsigned int index) const; //!< Get the DockingEffect at a given index.
     71        bool addAnimation(DockingAnimation* animation); //!< Add a DockingAnimation to the Dock.
     72        const DockingAnimation* getAnimation(unsigned int index) const; //!< Get the DockingAnimation at a given index.
    6773
     74        // Docking/undocking logic, checks conditions and invokes the DockingAnimations
    6875        bool dock(PlayerInfo* player); //!< Returns true if given player docked successfully (player must be a candidate)
    6976        bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked)
    7077
     78        // Animation logic
     79        bool dockingAnimationFinished(PlayerInfo* player); //!< Called when a docking animation finished
     80        bool undockingAnimationFinished(PlayerInfo* player); //!< Called when a undocking animation finished
     81
     82        // LUA interface
    7183        void dock() { this->dock(HumanController::getLocalControllerSingleton()->getPlayer()); } // tolua_export
    7284        static unsigned int getNumberOfActiveDocks(); // tolua_export
    7385        static Dock* getActiveDockAtIndex(unsigned int index); // tolua_export
    7486
     87        // Console commands
    7588        static void cmdDock();
    7689        static void cmdUndock();
     
    7992        std::set<PlayerInfo*> candidates; //!< A set of all players which are allowed to dock using the console command.
    8093        std::set<PlayerInfo*> docked; //!< A set of all docked players
     94
    8195        std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks.
     96        std::list<DockingAnimation*> animations; //!< The list of DockingAnimations to be executed before a player docks
    8297    }; // tolua_export
    8398} // tolua_export
  • code/branches/dockingsystem2/src/modules/docking/DockToShip.cc

    r8382 r8493  
    2121 *
    2222 *   Author:
    23  *      Damian 'Mozork' Frick
     23 *      Sven Stucki
    2424 *   Co-authors:
    2525 *      ...
     
    6969    bool DockToShip::docking(PlayerInfo* player)
    7070    {
    71         COUT(0) << "DockToShip::docking" << endl;
    72         return true;
    73     }
    74 
    75     bool DockToShip::attach(PlayerInfo* player)
    76     {
    7771        COUT(0) << "DockToShip::attach" << endl;
    7872
  • code/branches/dockingsystem2/src/modules/docking/DockToShip.h

    r8257 r8493  
    6161
    6262            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    63             virtual void setTargetId(std::string str);
    64             virtual std::string getTargetId();
     63            void setTargetId(std::string str);
     64            std::string getTargetId();
    6565
    6666            virtual bool docking(PlayerInfo* player); //!< Called when docking starts
    67             virtual bool attach(PlayerInfo* player); //!< Called after docking animation
    6867            virtual bool release(PlayerInfo* player); //!< Called when player wants undock
    69 
    7068        private:
    7169            std::string target;
  • code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc

    r8487 r8493  
    2121 *
    2222 *   Author:
    23  *      Damian 'Mozork' Frick
     23 *      Sven Stucki
    2424 *   Co-authors:
    2525 *      ...
     
    4646    }
    4747
    48     bool DockingEffect::invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects)
     48    bool DockingEffect::invokeEffect(bool dock, PlayerInfo* player, std::list<DockingEffect*> & effects)
    4949    {
    5050        bool check = true;
    5151
    52         COUT(4) << "Invoking DockingEffects on player: " << player << " ."  << std::endl;
    53 
    5452        for (std::list<DockingEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
    5553        {
    56             switch(event)
    57             {
    58                 case docking::DOCKING:
    59                     check &= (*effect)->docking(player);
    60                     break;
    61                 case docking::RELEASE:
    62                     check &= (*effect)->release(player);
    63                     break;
    64                 default:
    65                     assert(0);
    66             }
     54            if (dock)
     55                check &= (*effect)->docking(player);
     56            else
     57                check &= (*effect)->release(player);
    6758        }
    6859
  • code/branches/dockingsystem2/src/modules/docking/DockingEffect.h

    r8487 r8493  
    4949namespace orxonox
    5050{
    51     namespace docking {
    52         enum event {
    53             DOCKING,
    54             RELEASE
    55         };
    56     }
    5751
    5852    /**
     
    7468            virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants to undock
    7569
    76             static bool invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
     70            static bool invokeEffect(bool dock, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
    7771            static DockingTarget *findTarget(std::string name); //!< Iterates through all DockingTarget objects to find the one with name=target
    7872    };
  • code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h

    r8257 r8493  
    6666{
    6767    class Dock;
     68    class DockingAnimation;
    6869    class DockingTarget;
    6970    class DockingEffect;
    7071    class DockToShip;
     72    class MoveToDockingTarget;
    7173}
    7274
  • code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.cc

    r7801 r8493  
    381381            }
    382382        }
     383
     384        if (distance < 10)
     385        {
     386            this->positionReached();
     387        }
    383388    }
    384389
     
    386391    {
    387392        this->moveToPosition(this->targetPosition_);
     393    }
     394
     395    void ArtificialController::positionReached()
     396    {
     397        // Override me !
    388398    }
    389399
  • code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.h

    r7163 r8493  
    9797            void moveToTargetPosition();
    9898
     99            virtual void positionReached();
     100
    99101            void removeFromFormation();
    100102            void unregisterSlave();
Note: See TracChangeset for help on using the changeset viewer.