Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9868


Ignore:
Timestamp:
Dec 3, 2013, 8:18:15 PM (10 years ago)
Author:
zifloria
Message:

End game screen. Eye candy. Gameplay tweaks

Location:
code/branches/invaders
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • code/branches/invaders/data/levels/Invaders.oxw

    r9866 r9868  
    2525  <?lua include("includes/notifications.oxi") ?>
    2626
     27    <!-- ambientlight = "0.8, 0.8, 0.8"
     28    skybox       = "Orxonox/Starbox" -->
    2729  <Scene
    28     ambientlight = "0.8, 0.8, 0.8"
    29     skybox       = "Orxonox/Starbox"
     30    ambientlight = "0.8, 0.7, 0.4"
     31    skybox     = "Orxonox/skyBoxBasic"
    3032  >
    3133
    32     <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"/>
     34    <!-- <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"/> -->
     35    <Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
    3336    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=InvaderShip pawndesign=spaceshipinvader />
    34     <MovableEntity
    35       position = "-200,0,0"
    36       velocity = "975.7, 0, 0"
    37     >
    38       <events>
    39         <activity>
    40           <EventListener event="start" />
    41         </activity>
    42       </events>
    43       <attached>
    44 
    45         <Model mass="1000" mesh="ast1.mesh" />
    46       </attached>
    47       <camerapositions>
    48         <CameraPosition position="0,300,-100" direction="0, -1, 0" drag=false mouselook=true />
    49       </camerapositions>
    50     </MovableEntity>
    5137
    5238    <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 />
  • code/branches/invaders/data/levels/includes/invaderWeapon.oxi

    r9862 r9868  
    1515        <Weapon>
    1616          <InvaderWeapon mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" projectileMesh="laserbeam.mesh" />
    17           <!--InvaderWeapon mode=0 munitionpershot=0 delay=0   
    18 
    19           LaserBeam2
    20 
    21             damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" projectileMesh="LaserBeam.mesh" /-->
    2217        </Weapon>
    2318        <Weapon>
    2419          <InvaderWeapon mode=0 munitionpershot=0 delay=0     damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 1.6, 1.3, -2.0" projectileMesh="laserbeam.mesh" />
    25           <!--InvaderWeapon mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.1, 1.6, -2.0" projectileMesh="LaserBeam.mesh" /-->
    2620        </Weapon>
    2721      </WeaponPack>
  • code/branches/invaders/data/levels/templates/enemyInvader.oxt

    r9854 r9868  
    77   explosionchunks        = 4
    88
    9    health            = 100
    10    maxhealth         = 100
    11    initialhealth     = 100
     9   health            = 10
     10   maxhealth         = 10
     11   initialhealth     = 10
    1212
    13    shieldhealth        = 35
    14    initialshieldhealth = 35
    15    maxshieldhealth     = 60
     13   shieldhealth        = 10
     14   initialshieldhealth = 10
     15   maxshieldhealth     = 10
    1616   shieldabsorption    = 0.9
    1717   reloadrate          = 1
  • code/branches/invaders/data/overlays/InvaderHUD.oxo

    r9854 r9868  
    6969    />
    7070
    71 
    72     <OverlayText
    73      position  = "0.4, 0.1"
    74      pickpoint = "0.0, 0.0"
    75      font      = "ShareTechMono"
    76      textsize  = 0.04
    77      colour    = "1.0, 1.0, 1.0, 1.0"
    78      align     = "left"
    79      caption   = "X"
    80     />
    8171    <InvaderHUDinfo
    82      position  = "0.42, 0.1"
     72     position  = "0.25, 0.1"
    8373     pickpoint = "0.0, 0.0"
    8474     font      = "ShareTechMono"
  • code/branches/invaders/src/modules/invader/Invader.cc

    r9866 r9868  
    5959        RegisterObject(Invader);
    6060        this->center_ = 0;
     61        init();
     62        this->setHUDTemplate("InvaderHUD");
     63    }
    6164
    62         this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) );
    63         //this->context = context;
    64         this->setHUDTemplate("InvaderHUD");
    65 
     65    void Invader::init()
     66    {
     67        bEndGame = false;
    6668        lives = 3;
     69        // TODO:
    6770        level = 1;
    6871        point = 0;
    6972        multiplier = 1;
    7073        b_combo = false;
     74        // spawn enemy every 2 seconds
    7175        enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
    7276        comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
    73     }
    74 
    75     Invader::~Invader()
    76     {
    7777    }
    7878
     
    9494            newPawn->setPlayer(player);
    9595            newPawn->level = level;
     96            // spawn enemy at random points in front of player.
    9697            newPawn->setPosition(player->getPosition() + Vector3(500 + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
    9798        }
     
    101102    {
    102103        lives--;
    103         multiplier = 0;
    104         if (lives <= 0) end();
     104        multiplier = 1;
     105        // end the game in 30 seconds.
     106        if (lives <= 0)
     107            enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this)));
    105108    };
    106109
     
    109112        if (b_combo)
    110113            multiplier++;
     114        // if no combo was performed before, reset multiplier
    111115        else
    112116            multiplier = 1;
     
    114118    }
    115119
    116     // inject custom player controller
    117  /**   void Invader::spawnPlayer(PlayerInfo* player)
    118     {
    119         assert(player);
    120 
    121         //player->startControl(new InvaderShip(this->center_->getContext() ) );
    122     }*/
    123 
    124120    void Invader::start()
    125121    {
     122        init();
    126123        // Set variable to temporarily force the player to spawn.
    127124        this->bForceSpawn_ = true;
     
    137134    }
    138135
     136
    139137    void Invader::end()
    140138    {
    141         orxout() << "STOP THE GAME, CHEATER!!!" << endl;
    142         // Call end for the parent class.
    143         // Deathmatch::end();
     139        // DON'T CALL THIS!
     140        //      Deathmatch::end();
     141        // It will misteriously crash the game!
     142        // Instead startMainMenu, this won't crash.
     143        GSLevel::startMainMenu();
    144144    }
    145145}
  • code/branches/invaders/src/modules/invader/Invader.h

    r9866 r9868  
    2929/**
    3030    @file Invader.h
    31     @brief Declaration of the Invader class.
     31    @brief Gametype.
    3232    @ingroup Invader
    3333*/
     
    5050    {
    5151        public:
    52             Invader(Context* context); //!< Constructor. Registers and initializes the object.
    53             virtual ~Invader(); //!< Destructor. Cleans up, if initialized.
     52            Invader(Context* context);
    5453
    55             virtual void start(); //!< Starts the Invader minigame.
    56             virtual void end(); ///!< Ends the Invader minigame.
    57 
    58             //virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
     54            virtual void start();
     55            virtual void end();
    5956
    6057            void spawnEnemy();
     
    7168            void levelUp(){level++;}
    7269            void addPoints(int numPoints){point += numPoints * multiplier; b_combo = true;}
     70            // checks if multiplier should be reset.
    7371            void comboControll();
     72            void init();
    7473            int lives;
     74            int multiplier;
     75            bool bEndGame;
    7576        private:
    7677            WeakPtr<InvaderCenterPoint> center_;
    7778            WeakPtr<InvaderShip> player;
    7879
    79             ConsoleCommand* console_addEnemy;
    8080            Timer enemySpawnTimer;
    8181            Timer comboTimer;
     
    8484            int point;
    8585            bool b_combo;
    86             int multiplier;
    8786    };
    8887}
  • code/branches/invaders/src/modules/invader/InvaderCenterPoint.cc

    r9725 r9868  
    4242    RegisterClass(InvaderCenterPoint);
    4343
    44     /**
    45     @brief
    46         Constructor. Registers and initializes the object and checks whether the gametype is actually Invader.
    47     */
    4844    InvaderCenterPoint::InvaderCenterPoint(Context* context) : StaticEntity(context)
    4945    {
     
    5349    }
    5450
    55     /**
    56     @brief
    57         Method to create a InvaderCenterPoint through XML.
    58     */
    5951    void InvaderCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6052    {
    6153        SUPER(InvaderCenterPoint, XMLPort, xmlelement, mode);
    62 
    63 //        XMLPortParam(InvaderCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
    64 
    6554    }
    6655
    67     /**
    68     @brief
    69         Is called when the gametype has changed.
    70     */
    7156    void InvaderCenterPoint::changedGametype()
    7257    {
     
    7762    }
    7863
    79     /**
    80     @brief
    81         Checks whether the gametype is Invader and if it is, sets its centerpoint.
    82     */
    8364    void InvaderCenterPoint::checkGametype()
    8465    {
  • code/branches/invaders/src/modules/invader/InvaderCenterPoint.h

    r9725 r9868  
    4545    {
    4646        public:
    47             InvaderCenterPoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Invader.
    48             virtual ~InvaderCenterPoint() {}
     47            InvaderCenterPoint(Context* context); //checks whether the gametype is actually Invader.
    4948
    50 
    51             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML.
     49            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5250
    5351            virtual void changedGametype(); //!< Is called when the gametype has changed.
    5452        private:
    55             void checkGametype(); //!< Checks whether the gametype is Pong and if it is, sets its centerpoint.
     53            void checkGametype();
    5654
    5755    };
  • code/branches/invaders/src/modules/invader/InvaderEnemy.cc

    r9866 r9868  
    5050    {
    5151        lifetime += dt;
     52        // die after 5 seconds.
    5253        if (lifetime > 5000)
    53         {
    5454            removeHealth(2000);
    55         }
     55
    5656        if (player != NULL)
    5757        {
    5858            float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01, 2) + 1) * (player->getPosition().z - getPosition().z);
    59             // if (newZ < 0)
    60             //     newZ = (-100 < newZ)?-100:newZ;
    61             // else
    62             //     newZ = (100 > newZ)?100:newZ;
    6359            setVelocity(Vector3(1000 - level * 100 , 0, newZ));
    6460        }
     
    6864    inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    6965    {
    70         // setVelocity(Vector3(1500,0,0));
    71         removeHealth(2000);
     66        if(orxonox_cast<Pawn*>(otherObject))
     67            removeHealth(2000);
    7268        return false;
    7369    }
     
    8783        if (getGame())
    8884            getGame()->addPoints(42);
    89         // SUPER(InvaderEnemy, damage, damage, healthdamage, shielddamage, originator);
     85        Pawn::damage(damage, healthdamage, shielddamage, originator);
    9086    }
    9187}
  • code/branches/invaders/src/modules/invader/InvaderEnemy.h

    r9854 r9868  
    4545        public:
    4646            InvaderEnemy(Context* context);
    47             // virtual ~InvaderEnemy() {}
    4847
    4948            virtual void tick(float dt);
  • code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc

    r9866 r9868  
    4747    }
    4848
    49     InvaderHUDinfo::~InvaderHUDinfo()
    50     {
    51     }
    52 
    5349    void InvaderHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5450    {
     
    7571            {
    7672                const std::string& Level = multi_cast<std::string>(this->InvaderGame->getLevel());
    77                 this->setCaption(Level);
     73                if (this->InvaderGame->lives <= 0)
     74                {
     75                    setPosition(Vector2(0.1, 0.65));
     76                    this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart press space.");
     77                    setTextSize(0.05);
     78                    this->InvaderGame->bEndGame = true;
     79                }
     80                else
     81                {
     82                    setTextSize(0.04);
     83                    setPosition(Vector2(0.14, 0.055));
     84                    this->setCaption(Level);
     85                }
    7886            }
    7987            else if(this->bShowPoints_)
     
    8290                if (this->InvaderGame->lives <= 0)
    8391                {
    84                     setTextSize(0.1);
    85                     setPosition(Vector2(0.2, 0.5));
     92                    setTextSize(0.2);
     93                    setPosition(Vector2(0.1, 0.25));
     94                    this->setCaption("Final score:\n" + points);
     95                    this->setColour(ColourValue(1, 0, 0, 1));
    8696                }
    87                 this->setCaption(points);
     97                else
     98                {
     99                    setTextSize(0.04);
     100                    setPosition(Vector2(0.14, 0.1));
     101                    this->setColour(ColourValue(1, 1, 1, 1));
     102                    this->setCaption(points);
     103                }
    88104            }
    89105            else if(this->bShowMultiplier_)
    90106            {
    91                 const std::string& Multiplier = multi_cast<std::string>(this->InvaderGame->getMultiplier());
     107                int mult = this->InvaderGame->getMultiplier();
     108                const std::string& Multiplier = "X " + multi_cast<std::string>(mult);
    92109                this->setCaption(Multiplier);
     110                this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f)));
     111                this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01 + 0.04);
    93112            }
    94113        }
  • code/branches/invaders/src/modules/invader/InvaderHUDinfo.h

    r9854 r9868  
    3939        public:
    4040            InvaderHUDinfo(Context* context);
    41             virtual ~InvaderHUDinfo();
    4241
    4342            virtual void tick(float dt);
  • code/branches/invaders/src/modules/invader/InvaderPrereqs.h

    r9828 r9868  
    2121 *
    2222 *   Author:
    23  *      Reto Grieder
     23 *      Florian Zinggeler
    2424 *   Co-authors:
    2525 *      ...
  • code/branches/invaders/src/modules/invader/InvaderShip.cc

    r9829 r9868  
    4242    RegisterClass(InvaderShip);
    4343
    44     /**
    45     @brief
    46         Constructor. Registers and initializes the object.
    47     */
    4844    InvaderShip::InvaderShip(Context* context) : SpaceShip(context)
    4945    {
     
    7874            if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
    7975                velocity.x = 0;
    80             // this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x));
    8176            pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
    8277        }
    8378
     79        // shoot!
    8480        if (isFireing)
    8581            ControllableEntity::fire(0);
     
    9187            camera->setPosition(Vector3(-pos.z, -posforeward, 0));
    9288            camera->setOrientation(Vector3::UNIT_Z, Degree(90));
    93             // orxout() << "asbhajskjasjahg" << pos << endl;
    9489        }
    9590
     
    9792
    9893        // bring back on track!
    99         // if (pos.z > 42*2.5)
    100         //     pos.z = 42*2.5;
    101         // else if (pos.z < -42*3)
    102         //     pos.z = -42*3;
    10394        if(pos.y != 0)
    10495            pos.y = 0;
    105            
    10696
    10797        setPosition(pos);
     
    122112        lastTime = 0;
    123113        if (getGame())
    124         {
    125114            getGame()->levelUp();
    126             // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());
    127            
    128         }
    129         //level++
    130115    }
    131116
     
    144129    {
    145130        isFireing = bBoost;
     131        // restart if game ended
     132        if (getGame())
     133            if (getGame()->bEndGame)
     134                getGame()->start();
    146135    }
    147136    inline bool InvaderShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    148137    {
    149138        // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
    150 
    151139        WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
     140        // ensure that this gets only called once per enemy.
    152141        if (enemy != NULL && lastEnemy != enemy)
    153142        {
    154143            lastEnemy = enemy;
    155             orxout() << "Enemy!!!! " << endl;
     144
    156145            removeHealth(20);
    157             if (getHealth() <= 0)
     146            if (getGame())
    158147            {
    159                 orxout() << "DIED!!!! " << endl;
    160                 if (getGame())
    161                 {
    162                     getGame()->costLife();
    163                     // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());
    164                    
    165                 }
     148                getGame()->multiplier = 1;
     149                if (getHealth() <= 0)
     150                    getGame()->costLife();                   
    166151            }
    167152            return false;
  • code/branches/invaders/src/modules/invader/InvaderShip.h

    r9829 r9868  
    4545    {
    4646        public:
    47             InvaderShip(Context* context); //!< Constructor. Registers and initializes the object.
    48             virtual ~InvaderShip() {}
     47            InvaderShip(Context* context);
    4948
    5049            virtual void tick(float dt);
    5150
     51            // overwrite for 2d movement
    5252            virtual void moveFrontBack(const Vector2& value);
    5353            virtual void moveRightLeft(const Vector2& value);
    5454
    55             virtual void boost(bool bBoost); // Starts or stops fireing
     55            // Starts or stops fireing
     56            virtual void boost(bool bBoost);
    5657
    5758            //no rotation!
    5859            virtual void rotateYaw(const Vector2& value){};
    5960            virtual void rotatePitch(const Vector2& value){};
    60             virtual void rotateRoll(const Vector2& value){};
     61            //return to main menu if game has ended.
     62            virtual void rotateRoll(const Vector2& value){if (getGame()) if (getGame()->bEndGame) getGame()->end();};
    6163
    6264            virtual void updateLevel();
    6365
    64             // *InvaderShip getShip(){return this;}
    6566            virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    6667        private:
    67 
    6868            WeakPtr<Invader> getGame();
    6969            WeakPtr<Invader> game;
  • code/branches/invaders/src/modules/invader/InvaderWeapon.cc

    r9744 r9868  
    6161    void InvaderWeapon::shot()
    6262    {
    63         // orxout(internal_error) << "shotttttt" << endl;
    64 
    6563        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
    6664
     
    7472
    7573        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
    76         projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0)); //this->getMuzzleOrientation()   Quaternion::IDENTITY
     74        // only shoot in foreward direction
     75        projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0));
    7776        projectile->setPosition(this->getMuzzlePosition());
    78         projectile->setVelocity(Vector3(1, 0, 0) * 2000); //this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_
     77        // only shoot in foreward direction
     78        projectile->setVelocity(Vector3(1, 0, 0) * 2000);
    7979
    8080        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
  • code/branches/invaders/src/modules/invader/InvaderWeapon.h

    r9744 r9868  
    4242namespace orxonox
    4343{
    44 
    45     /**
    46     @brief
    47         Shoots laser beams.
    48     @author
    49         Hagen Seifert
    50     @ingroup WeaponsHsW01s
    51     */
    5244    class _InvaderExport InvaderWeapon : public HsW01
    5345    {
  • code/branches/invaders/src/orxonox/gametypes/Gametype.cc

    r9667 r9868  
    171171                    entity->setOrientation(oldentity->getWorldOrientation());
    172172                }
    173 
    174173                it->first->startControl(entity);
    175174            }
  • code/branches/invaders/src/orxonox/worldentities/BigExplosion.cc

    r9837 r9868  
    148148        this->debrisEntity4_->attach(debris4_);
    149149
     150        // particleSpawner is a static entity. It should probably be dynamic, for better explosions.
     151        // effect->SetVelocity(this->getVelocity() + Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10,100))
    150152        ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    151153        effect->setDestroyAfterLife(true);
Note: See TracChangeset for help on using the changeset viewer.