Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12151 for code


Ignore:
Timestamp:
Dec 5, 2018, 11:54:24 AM (5 years ago)
Author:
linggj
Message:

it works

Location:
code/branches/WorldMap_HS18
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/WorldMap_HS18/data/gui/layouts/CampaignMenu.layout

    r12106 r12151  
    99             
    1010
    11         <Window name="RightButton" type="MenuWidgets/Button">
    12             <Property name="Text" value="F" />
    13             <Property name="MaxSize" value="{{1,0},{1,0}}" />
    14             <Property name="Area" value="{{0.350,0},{0.9,0},{0.45,0},{0.95,0}}" />
    15            
    16         </Window>
    17 
    18          <Window name="LeftButton" type="MenuWidgets/Button">
    19             <Property name="Text" value="B" />
    20             <Property name="MaxSize" value="{{1,0},{1,0}}" />
    21             <Property name="Area" value="{{0.55,0},{0.9,0},{0.65,0},{0.95,0}}" />
    22            
    23         </Window>
    24 
    25         <Window name="SelectButton" type="MenuWidgets/Button">
    26             <Property name="Text" value="Play" />
    27             <Property name="MaxSize" value="{{1,0},{1,0}}" />
    28             <Property name="Area" value="{{0.45,0},{0.9,0},{0.55,0},{0.95,0}}" />
    29            
    30         </Window>
     11       
    3112
    3213        <Window name="Mission1Text" type="MenuWidgets/Button">
  • code/branches/WorldMap_HS18/data/levels/StoryModeMap.oxw

    r12131 r12151  
    1616
    1717<Level
    18 gametype = Deathmatch
     18gametype = StoryMode
    1919>
    2020
     
    3131    skybox       = "Orxonox/Starbox"
    3232  >
    33    <StoryModeController position="0,0,0" collisionType="dynamic" mass=42000000 >
    34 
    35           <attached>
    36               <Model position="0,0,0" mesh="assff.mesh" scale=20  visible="true" />
    37           </attached>
    38           <CameraPosition position="0,0,1000" direction="0, -1, 0" drag=false />
    39           <collisionShapes>
    40               <BoxCollisionShape position="0,0,0" halfExtents="3,1,10" />
    41           </collisionShapes>
    42       </StoryModeController>
    43   <!--   <MovableEntity>
    44         <attached>
    45             <StaticEntity name=asdfasdf figureTemplate=smCont>
    46                 <attached>
    47                 </attached>
    48             </StaticEntity>
    49         </attached>
    50     </MovableEntity> -->
     33   
    5134   
    5235   
     
    5942        <Billboard colour="1,0,0.05" position="550,300,-80"  material="Flares/lensflare" scale=4.5 />
    6043
    61         <Model name="a" position="600,370,0" mesh="planets/moon.mesh" scale=100 visible="false" />
     44        <Model name="a" position="600,370,0" mesh="planets/moon.mesh" scale=100 visible="true" />
    6245         
    6346       
     
    6851
    6952        <Model position="100,350,-250" mesh="planets/moon.mesh" scale=100  visible="true"/>
    70          <Model position="50,300,-250" mesh="assff.mesh" scale=20  visible="false" orientation="-0.015,0.091,0.038,-0.995"/>
     53         
    7154        <Billboard colour="1,1,0.05" position="100,350,-330"  material="Flares/lensflare" scale=4.5 />
    7255
    73         <Model position="-600,250,-500" mesh="planets/moon.mesh" scale=100 visible="false"/>
     56        <Model position="-600,250,-500" mesh="planets/moon.mesh" scale=100 visible="true"/>
    7457        <Billboard colour="1,1,0.05" position="-600,250,-580"  material="Flares/lensflare" scale=5 />
    7558
     
    9982    <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"/>
    10083
    101     <SpawnPoint position="000.000, 000.000, 1000.000" orientation="0, 0, 0, -1" spawnclass=StoryModeController pawndesign=StoryMode />
     84    <SpawnPoint position="000.000, 000.000, 1000.000" orientation="0, 0, 0, -1" spawnclass=StoryMode pawndesign=StoryMode />
    10285   
    10386   
  • code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.cc

    r12131 r12151  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Joel Lingg
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "SMCoord.h"
    230
    331namespace orxonox {
    4     SMCoord::SMCoord() {
    5         set(0);
     32  SMCoord::SMCoord() {
     33    set(0);
     34  }
     35
     36  SMCoord::~SMCoord() {
     37
     38  }
     39
     40  SMCoord::SMCoord(int x) {
     41    set(x);
     42  }
     43
     44  //sets the index. the boundaries neeed to set higher when you want more games.
     45  void SMCoord::set(int index) {
     46    if (index < 0) {
     47      this -> index = 0;
     48    } else if (index > 3) {
     49      this -> index = 3;
     50    } else {
     51      this -> index = index;
    652    }
     53  }
     54  //Returns the 3dcoordinate of the symbol which is choosen at the moment
     55  Vector3 SMCoord::get3dcoordinate() {
     56    Vector3 coord;
     57    switch (this -> index) {
     58    case 0:
     59      coord.x = 550;
     60      coord.y = 300;
     61      coord.z = 0;
     62      break;
     63    case 1:
     64      coord.x = 600;
     65      coord.y = 300;
     66      coord.z = 0;
     67      break;
     68    case 2:
     69      coord.x = 650;
     70      coord.y = 300;
     71      coord.z = 0;
     72      break;
     73    case 3:
     74      coord.x = 700;
     75      coord.y = 300;
     76      coord.z = 0;
     77      break;
    778
    8      SMCoord::~SMCoord() {
    9        
     79    default:
     80      coord.x = 550;
     81      coord.y = 300;
     82      coord.z = 0;
     83      break;
    1084    }
     85    return coord;
     86  }
    1187
    12     SMCoord::SMCoord(int x) {
    13         set(x);
    14     }
    15 
    16     void SMCoord::set(int index) {
    17         if(index<0) return;
    18         if(index>8) return;
    19         this->index = index;
    20     }
    21 
    22     Vector3 SMCoord::get3dcoordinate() {
    23         Vector3 coord;
    24        switch(this->index)
    25        {
    26         case 0:
    27             coord.x= 550;
    28             coord.y = 300;
    29             coord.z = 0;
    30             break;
    31         case 1:
    32             coord.x= 100;
    33             coord.y = 350;
    34             coord.z = -250;
    35             break;
    36         case 2:
    37             coord.x= -600;
    38             coord.y = 250;
    39             coord.z = -500;
    40             break;
    41         case 3:
    42             coord.x= -1000;
    43             coord.y = 50;
    44             coord.z = -750;
    45             break;
    46         case 4:
    47             coord.x= -900;
    48             coord.y = -400;
    49             coord.z = -1000;
    50             break;
    51         case 5:
    52             coord.x= -500;
    53             coord.y = -700;
    54             coord.z = -1250;
    55             break;
    56         case 6:
    57             coord.x= 0;
    58             coord.y = -900;
    59             coord.z = -1500;
    60             break;
    61         case 7:
    62             coord.x= 700;
    63             coord.y = -1100;
    64             coord.z = -1750;
    65             break;
    66         case 8:
    67             coord.x= 1500;
    68             coord.y = 1300;
    69             coord.z = -2000;
    70             break;
    71         default:
    72             coord.x= 0;
    73             coord.y = 0;
    74             coord.z = 0;
    75        }
    76        return coord;
    77     }
    78 
    79     int SMCoord::getIndex() {
    80         return this->index;
    81     }
     88  int SMCoord::getIndex() {
     89    return this -> index;
     90  }
    8291}
  • code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.h

    r12110 r12151  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Joel Lingg
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    128#ifndef _SMCoord_H__
    229#define _SMCoord_H__
     
    532#include "gametypes/Deathmatch.h"
    633
    7 namespace orxonox
    8 {
     34namespace orxonox {
    935
    10         class _OrxonoxExport SMCoord
    11     {
    12         public:
    13             SMCoord();
    14             SMCoord(int x);
    15              void set(int index);
    16             virtual int getIndex();
    17             virtual Vector3 get3dcoordinate();
    18             virtual ~SMCoord();
     36  class _OrxonoxExport SMCoord {
     37    public: SMCoord();
     38    SMCoord(int x);
     39    void set(int index);
     40    virtual int getIndex();
     41    virtual Vector3 get3dcoordinate();
     42    virtual~SMCoord();
    1943
    20 
    21         private:
    22             int index;
    23     };
    24 
     44    private: int index;
     45  };
    2546
    2647}
  • code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc

    r12131 r12151  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Joel Lingg
    2424 *   Co-authors:
    2525 *      ...
     
    2929#include "StoryModeController.h"
    3030
     31namespace orxonox {
     32  RegisterClass(StoryModeController);
    3133
    32 #include "core/CoreIncludes.h"
    33 #include "worldentities/ControllableEntity.h"
    34 #include "graphics/Camera.h"
    35 #include "SMCoord.h"
    36 #include "core/XMLPort.h"
    37 #include "gamestates/GSLevel.h"
    38 namespace orxonox
    39 {
    40     RegisterClass(StoryModeController);
     34  StoryModeController::StoryModeController(Context * context): SpaceShip(context) {
    4135
    42    StoryModeController::StoryModeController(Context* context) : SpaceShip(context)
    43     {
    44         RegisterObject(StoryModeController);
    45         float time_;
    46         selectedPos_ = new SMCoord(0);
    47         moveForward_= false;
    48         moveBackward_=false;                     
    49         boostPressed_=false;
    50         dtime_=50;
     36    RegisterObject(StoryModeController);
    5137
    52      
    53     }
    54     StoryModeController::~StoryModeController()
    55     {
    56         delete selectedPos_;
    57         selectedPos_ = nullptr;
     38    //initiate all variables according to our needs
     39    selectedPos_ = new SMCoord(0);
     40    moveForward_ = false;
     41    moveBackward_ = false;
     42    boostPressed_ = false;
     43    init_ = true;
     44    dtime_ = 50;
     45    time_ = dtime_ + 1;
     46    updatePosition();
    5847
    59     }
    60     //void StoryModeController:: switchCamera(){};
    61     void StoryModeController::updatePosition(){
    62         Vector3 pos = selectedPos_->get3dcoordinate();
    63         setPosition(pos);
    64     }
    65     void StoryModeController::setLocation(int index){
    66          selectedPos_->set(index);
     48  }
     49  StoryModeController::~StoryModeController() {
     50    delete selectedPos_;
     51    selectedPos_ = nullptr;
     52
     53  }
     54
     55  //Pre:selectedPos_ needs to be defined
     56  // Post: the position of the camera will be updated
     57  void StoryModeController::updatePosition() {
     58    Vector3 pos = selectedPos_ -> get3dcoordinate();
     59    setPosition(pos);
     60  }
     61
     62  //Pre: @index integer
     63  //post: our new position is updated in selectedPos_
     64  void StoryModeController::setLocation(int index) {
     65    selectedPos_ -> set(index);
     66  }
     67
     68  //Function which is repeated anz dt.
     69  void StoryModeController::tick(float dt) {
     70    //Passing arguments to SpaceShip
     71    SUPER(StoryModeController, tick, dt);
     72
     73    Camera * camera = this -> getCamera();
     74
     75    if (init_ && camera != nullptr) {
     76      camera -> setPosition(0, 0, 200);
     77      camera -> setOrientation(Vector3::UNIT_Z, Degree(0));
     78      init_ = false;
    6779    }
    6880
    69     void StoryModeController::tick(float dt)
    70     {
    71         //orxout(internal_error) << "Hi" << endl;
    72         SUPER(StoryModeController, tick, dt);
    73         time_ +=dt;
    74            Camera* camera = this->getCamera();
    75            
    76        
     81    //As I dont want to update positions every time (to prevent multiple key presses) time_ is raised untill a sertain dtime_
     82    time_++;
     83    if (time_ >= dtime_) {
    7784
    78         if(time_>= dtime_*dt){
    79            
    80             time_=0;       
    81          
    82             if(moveForward_ == true){
    83                 orxout(internal_error) << "Position update" << endl;
    84                 moveForward_ = false;
    85                 selectedPos_->set(selectedPos_->getIndex()+1);
    86                 updatePosition();
    87             }
     85      time_ = 0;
    8886
    89             if(moveBackward_ == true){
    90                 orxout(internal_error) << "Position update" << endl;
    91                     moveBackward_ = false;
    92                     selectedPos_->set(selectedPos_->getIndex()-1);
    93                     updatePosition();
    94                }
     87      if (moveForward_ == true) {
     88        moveForward_ = false;
     89        selectedPos_ -> set(selectedPos_ -> getIndex() + 1);
     90        updatePosition();
     91      }
    9592
    96                if(boostPressed_ == true){
    97                     boostPressed_ = false;
    98                     chooseGame();
    99                }
     93      if (moveBackward_ == true) {
     94        moveBackward_ = false;
     95        selectedPos_ -> set(selectedPos_ -> getIndex() - 1);
     96        updatePosition();
     97      }
    10098
    101                
    102              if (camera != nullptr)
    103             {
     99      if (boostPressed_ == true) {
     100        boostPressed_ = false;
     101        chooseGame();
     102      }
    104103
    105                 Vector3 epos = selectedPos_->get3dcoordinate();
    106                 orxout(internal_error) << "ex: "<< epos.x <<" ey: "<< epos.y << " ez: " << epos.z<< endl;
    107                 camera->setPosition(-(epos.x),-(epos.y),-(epos.z)+1000);
    108                 camera->setOrientation(Vector3::UNIT_Z, Degree(0));
     104      //updates the cameraposition
     105      if (camera != nullptr) {
    109106
    110             }
    111        }
    112        
     107        camera -> setPosition(0, 0, 200);
     108        camera -> setOrientation(Vector3::UNIT_Z, Degree(0));
     109
     110      }
    113111    }
    114112
    115     void StoryModeController::moveFrontBack(const Vector2& value)
    116     {
    117           // orxout(internal_error) << "moveFrontBack" << endl;         
     113  }
     114
     115  //Post: The game is choosen acording to the index in selectedPos_. This one must be extended if more games want to be loaded
     116  void StoryModeController::chooseGame() {
     117    int ind = selectedPos_ -> getIndex();
     118    std::string name = "changeGame ";
     119    switch (ind) {
     120    case 0:
     121      name = name + "gallery.oxw";
     122      break;
     123    case 1:
     124      name = name + "pong.oxw";
     125      break;
     126    case 2:
     127      name = name + "towerDefense.oxw";
     128      break;
     129    case 3:
     130      name = name + "SOB.oxw";
     131      break;
     132
     133    default:
     134      name = name + "MapExample.oxw";
     135      break;
     136    }
     137    CommandExecutor::execute(name);
     138
     139  }
     140
     141  //decides if we move left or right
     142  void StoryModeController::moveRightLeft(const Vector2 & value) {
     143    if (!moveForward_ && !moveBackward_ && !boostPressed_) {
     144      if (value.x > 0) {
     145        moveForward_ = false;
     146        moveBackward_ = true;
     147      } else {
     148        moveBackward_ = false;
     149        moveForward_ = true;
     150      }
    118151    }
    119152
    120     void StoryModeController::chooseGame()
    121     {
    122        int ind = selectedPos_->getIndex();
    123        std::string name =   "changeGame ";
    124        switch(ind){
    125             case 0:
    126             name = name + "pong.oxw";
    127                 break;
    128             case 1:
    129                
    130                 break;
    131             case 2:
    132                
    133                 break;
    134             case 3:
    135                
    136                 break;
    137             case 4:
    138                
    139                 break;
    140             case 5:
    141                
    142                 break;
    143             case 6:
    144                
    145                 break;
    146             case 7:
    147                
    148                 break;
    149             case 8:
    150                
    151                 break;
    152             default:
    153                 break;   
    154        } 
    155        CommandExecutor::execute(name);
    156        /*for (GSLevel* level : ObjectList<GSLevel>())
    157             level->changeGame(name);*/
    158        //hideAllMenuSheets();     
     153  }
     154
     155  //decides to choose the game
     156  void StoryModeController::boost(bool bBoost) {
     157    if (!moveForward_ && !moveBackward_ && !boostPressed_) {
     158      boostPressed_ = true;
    159159    }
     160  }
    160161
     162  //Some functions I didn't use, but can be used to enhance your map. Just orientate at the function above
     163  void StoryModeController::rotateYaw(const Vector2 & value) {}
     164  void StoryModeController::rotatePitch(const Vector2 & value) {}
     165  void StoryModeController::rotateRoll(const Vector2 & value) {}
     166  void StoryModeController::moveFrontBack(const Vector2 & value) {}
     167  void StoryModeController::fire(unsigned int a) {}
     168  void StoryModeController::fired(unsigned int b) {}
    161169
    162     void StoryModeController::moveRightLeft(const Vector2& value)
    163     {
    164         if(!moveForward_&&!moveBackward_){
    165             if (value.x>0){
    166                 orxout(internal_error) << "Right" << endl;
    167                 moveForward_ =true;
    168                 moveBackward_ =false;
    169             } else {
    170                  orxout(internal_error) << "Left" << endl;
    171                 moveBackward_ = true;
    172                 moveForward_ = false;
    173             }
    174         }
    175 
    176     }
    177 
    178     void StoryModeController::rotateYaw(const Vector2& value){
    179         //orxout(internal_error) << "RightLeft" << endl;
    180     }
    181     void StoryModeController::rotatePitch(const Vector2& value){
    182         //orxout(internal_error) << "RightLeft" << endl;
    183     }
    184     void StoryModeController::rotateRoll(const Vector2& value){
    185         //orxout(internal_error) << "RightLeft" << endl;
    186     }
    187     void StoryModeController::fire(unsigned int a){}
    188     void StoryModeController::fired(unsigned int b){}
    189     void StoryModeController::boost(bool bBoost){
    190         orxout(internal_error) << "Boost" << endl;
    191         boostPressed_ = true;
    192     }
    193170}
  • code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.h

    r12131 r12151  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Joel Lingg
    2424 *   Co-authors:
    2525 *      ...
     
    3939#include "worldentities/ControllableEntity.h"
    4040#include "worldentities/pawns/SpaceShip.h"
     41
     42
     43#include "core/CoreIncludes.h"
     44
     45#include "graphics/Camera.h"
    4146#include "SMCoord.h"
     47//#include "core/XMLPort.h"
     48//#include "gamestates/GSLevel.h"
    4249
    4350//#include <gtest/gtest.h>
    4451#include "core/class/Identifier.h"
    4552#include "core/class/IdentifierManager.h"
    46 #include "core/command/ConsoleCommandIncludes.h"
     53//#include "core/command/ConsoleCommandIncludes.h"
    4754#include "core/command/CommandExecutor.h"
    4855#include "core/object/Destroyable.h"
     
    5461    {
    5562        public:
     63            // Implementation of a Controller needs the two following lines
    5664            StoryModeController(Context* context);
    5765            virtual ~StoryModeController();
    58 
     66            //  As we extend SpaceShip but just are interested in the moment of function
     67            // calling, we mark all the functions of spaceship to be override
    5968            virtual void tick(float dt) override;           
    6069            virtual void moveFrontBack(const Vector2& value) override;
     
    6675            virtual void fired(unsigned int firemode) override;
    6776            virtual void boost(bool bBoost) override;
    68             //virtual void switchCamera() override;
     77           
    6978
     79           
     80        private:
     81            //Add to function to set and update the Position. As setPosition isn't available, we used setLocation
    7082            virtual void setLocation(int index);
    71             bool moveRight_ ;
    72             bool moveLeft_ ;
    73             SMCoord* selectedPos_;
    74         private:
    75             virtual void updatePosition();                       
     83            virtual void updatePosition(); 
     84
     85            //According to the position, this function starts the game.
     86            virtual void chooseGame();
     87
     88             SMCoord* selectedPos_;
     89
     90             //Variables to keep track of time
    7691            float time_;
    7792            int dtime_;
     93
     94            //Bools which get true as soon as the event they are named after has occured
     95            bool moveRight_ ;
     96            bool moveLeft_ ;                                       
    7897            bool moveForward_;
    7998            bool moveBackward_;                     
    8099            bool boostPressed_;
    81             virtual void chooseGame();
     100            bool init_;
     101           
    82102
    83103    };
Note: See TracChangeset for help on using the changeset viewer.