Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8257 for code/branches


Ignore:
Timestamp:
Apr 18, 2011, 4:35:01 PM (14 years ago)
Author:
sven
Message:

First working dock example..

Location:
code/branches/dockingsystem2
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem2/data/levels/docking.oxw

    r8206 r8257  
    3030      <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    3131    <?lua end ?>
    32    
    33     <Destroyer
     32
     33    <Dock position="-50,-100,50">
     34            <effects>
     35                <DockToShip target="asdf" />
     36            </effects>
     37            <events>
     38                <execute>
     39                    <EventListener event="dockMe" />
     40                </execute>
     41            </events>
     42            <attached>
     43                <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" />
     44                <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
     45            </attached>
     46        </Dock>
     47
     48
     49      <SpaceShip
     50   hudtemplate            = spaceshiphud
     51   camerapositiontemplate = spaceshipassffcameras
     52   engine                 = spaceshipassffengine
     53   spawnparticlesource    = "Orxonox/fairytwirl"
     54   spawnparticleduration  = 3
     55   explosionchunks        = 6
     56
     57   health            = 100
     58   maxhealth         = 200
     59   initialhealth     = 100
     60
     61   primaryThrust     = 100;
     62   auxilaryThrust    = 30;
     63   rotationThrust    = 25;
     64
     65   collisionType     = "dynamic"
     66   mass              = 100
     67   linearDamping     = 0.7
     68   angularDamping    = 0.9999999
     69  >
     70    <attached>
     71        <DistanceTriggerBeacon name="beacon1" />
     72        <DockingTarget name="asdf" />
     73
     74      <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
     75      <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
     76      <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
     77      <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTrigger-->
     78    </attached>
     79    <collisionShapes>
     80      <BoxCollisionShape position="0,0,0"      halfExtents="10, 3, 5" />
     81      <BoxCollisionShape position="13,-1.3,0"  halfExtents="3, 1, 2" />
     82      <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
     83      <BoxCollisionShape position="0,0,7"      halfExtents="3, 2, 2" />
     84      <BoxCollisionShape position="0,0.1,-11"  halfExtents="2.2, 1.8, 6" />
     85      <BoxCollisionShape position="0,0.1,-19"  halfExtents="1.4, 1, 2" />
     86    </collisionShapes>
     87<?lua
     88  include("includes/weaponSettingsAssff.oxi")
     89?>
     90  </SpaceShip>
     91
     92
     93    <!--  <Destroyer
    3494      position          = "100,150,0"
    3595      collisionType     = dynamic
     
    43103
    44104      <attached>
    45         <Dock>
    46             <effects>
    47                 <DockToShip />
    48             </effects>
    49             <events>
    50                 <execute>
    51                     <EventListener event="dockMe" />
    52                 </execute>
    53             </events>
    54             <attached>
    55                 <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" />
    56                 <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
    57             </attached>
    58         </Dock>
     105       
    59106        <DistanceTriggerBeacon name="beacon1" />
    60      
     107        <DockingTarget name="asdf" />
     108
     109
    61110        <TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
    62111        <TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90"  yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
     
    145194      </collisionShapes>
    146195    </Destroyer>
    147    
     196    //-->
    148197
    149198  </Scene>
  • code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt

    r8196 r8257  
    11SET_SOURCE_FILES(DOCKING_SRC_FILES
     2  DockingTarget.cc
    23  DockingEffect.cc
    34  DockToShip.cc
  • code/branches/dockingsystem2/src/modules/docking/Dock.cc

    r8197 r8257  
    7373    bool Dock::execute(bool bTriggered, BaseObject* trigger)
    7474    {
    75         //TODO: Handle DistanceMultiTrigger
    76 
    7775        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    7876        Pawn* pawn = NULL;
     
    104102        }
    105103
    106         // Try to get HumanPlayer
    107         if(!player->isHumanPlayer()) {
    108             COUT(0) << "Docking::execute Not triggered by a human." << std::endl;
    109             return false;
    110         }
    111         HumanPlayer* human = orxonox_cast<HumanPlayer*>(player);
    112         if(human == NULL) {
    113             COUT(0) << "Docking::execute Player was not as human as expected.." << std::endl;
    114         }
    115         COUT(0) << "Dock triggered by player: " << human->getName() << ".." << std::endl;
     104        COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
    116105
    117         //TODO: This is waaay too oversimplified
    118106        if(bTriggered) {
    119107            DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
    120             //DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
     108            DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
    121109        } else {
    122110            DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
  • code/branches/dockingsystem2/src/modules/docking/DockToShip.cc

    r8196 r8257  
    5151    }
    5252
     53
     54    void DockToShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) {
     55        SUPER(DockToShip, XMLPort, xmlelement, mode);
     56
     57        XMLPortParam(DockToShip, "target", setTargetId, getTargetId, xmlelement, mode);
     58    }
     59
     60    void DockToShip::setTargetId(std::string str) {
     61        this->target = str;
     62    }
     63
     64    std::string DockToShip::getTargetId() {
     65        return this->target;
     66    }
     67
     68
    5369    bool DockToShip::docking(PlayerInfo* player)
    5470    {
     
    6076    {
    6177        COUT(0) << "DockToShip::attach" << endl;
     78
     79        DockingTarget *target = DockingEffect::findTarget(this->target);
     80        if (target == NULL) {
     81            COUT(0) << "Can't retrieve target for '" << this->target << "'.." << std::endl;
     82            return false;
     83        }
     84
     85        ControllableEntity *dockTo = (ControllableEntity*) target->getParent();
     86        if (dockTo == NULL) {
     87            COUT(0) << "Parent is not a ControllableEntity.." << std::endl;
     88            return false;
     89        }
     90
     91        player->startTemporaryControl(dockTo);
     92
    6293        return true;
    6394    }
  • code/branches/dockingsystem2/src/modules/docking/DockToShip.h

    r8196 r8257  
    3939#include "DockToShip.h"
    4040
     41#include "worldentities/ControllableEntity.h"
     42
    4143
    4244namespace orxonox
     
    5860            virtual ~DockToShip();
    5961
     62            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void setTargetId(std::string str);
     64            virtual std::string getTargetId();
     65
    6066            virtual bool docking(PlayerInfo* player); //!< Called when docking starts
    6167            virtual bool attach(PlayerInfo* player); //!< Called after docking animation
    6268            virtual bool release(PlayerInfo* player); //!< Called when player wants undock
     69
     70        private:
     71            std::string target;
    6372    };
    6473
  • code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc

    r8196 r8257  
    3333
    3434#include "DockingEffect.h"
    35 #include "core/CoreIncludes.h"
    3635
    3736namespace orxonox
     
    7170        return check;
    7271    }
     72
     73    DockingTarget *DockingEffect::findTarget(std::string name) {
     74        for (ObjectList<DockingTarget>::iterator it = ObjectList<DockingTarget>::begin();
     75                                 it != ObjectList<DockingTarget>::end(); ++it)
     76        {
     77            if ((*it)->getName().compare(name) == 0)
     78                return (*it);
     79        }
     80        return NULL;
     81    }
    7382}
  • code/branches/dockingsystem2/src/modules/docking/DockingEffect.h

    r8196 r8257  
    3636#define _DockingEffect_H__
    3737
     38#include "core/CoreIncludes.h"
     39#include "core/XMLPort.h"
     40
     41#include "infos/PlayerInfo.h"
     42
    3843#include "DockingPrereqs.h"
     44#include "DockingTarget.h"
    3945
    4046#include <list>
     
    6874            virtual bool docking(PlayerInfo* player) = 0; //!< Called when docking starts
    6975            virtual bool attach(PlayerInfo* player) = 0; //!< Called after docking animation
    70             virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants undock
     76            virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants to undock
    7177
    7278            static bool invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
     79            static DockingTarget *findTarget(std::string name); //!< Iterates through all DockingTarget objects to find the one with name=target
    7380    };
    7481
  • code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h

    r8196 r8257  
    6666{
    6767    class Dock;
     68    class DockingTarget;
    6869    class DockingEffect;
    6970    class DockToShip;
Note: See TracChangeset for help on using the changeset viewer.