Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9777


Ignore:
Timestamp:
Nov 11, 2013, 4:01:44 PM (10 years ago)
Author:
zifloria
Message:

enemies

Location:
code/branches/invaders
Files:
2 added
7 edited

Legend:

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

    r9724 r9777  
    1616  include("templates/spaceshipPirate.oxt")
    1717  include("templates/spaceshipInvader.oxt")
     18  include("templates/enemyInvader.oxt")
    1819?>
    1920
     
    5556   
    5657    <?lua
    57       for i = 1, 250, 1
    58       do
    59       j = math.random()
     58      for i = 1, 300, 1 do
     59        j = math.random()
    6060    ?>
    6161
    6262    <MovableEntity
    63       position = "<?lua print(math.random()* 15000 - 1000) ?>,-1000,<?lua print(math.random() * 12000 - 4000) ?>"
     63      position = "<?lua print(math.random()* 30000 - 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"
    6464      collisionType = dynamic
    6565      linearDamping = 0.8
    6666      angularDamping = 0
    6767      scale = "<?lua print(j * 150)?>"
    68       collisiondamage = 1
     68      collisiondamage = 0
    6969      enablecollisiondamage = true
    7070    >
  • code/branches/invaders/src/modules/invader/CMakeLists.txt

    r9744 r9777  
    44  InvaderCenterPoint.cc
    55  InvaderShip.cc
     6  InvaderEnemy.cc
    67  InvaderWeapon.cc
    78END_BUILD_UNIT
  • code/branches/invaders/src/modules/invader/Invader.cc

    r9709 r9777  
    4242#include "chat/ChatManager.h"
    4343
    44 #include "InvaderShip.h"
    4544// ! HACK
    4645#include "infos/PlayerInfo.h"
    4746
    4847#include "InvaderCenterPoint.h"
     48#include "InvaderShip.h"
     49
     50#include "core/command/ConsoleCommand.h"
    4951
    5052namespace orxonox
     
    5557    {
    5658        RegisterObject(Invader);
     59        this->center_ = 0;
    5760
    58         this->center_ = 0;
     61        this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) );
    5962        //this->context = context;
     63
     64        enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
    6065    }
    6166
    6267    Invader::~Invader()
    6368    {
     69    }
     70
     71    void Invader::spawnEnemy()
     72    {
     73        if (player == NULL)
     74        {
     75            for (ObjectList<InvaderShip>::iterator it = ObjectList<InvaderShip>::begin(); it != ObjectList<InvaderShip>::end(); ++it)
     76                player = *it;
     77        }
     78        if (player == NULL)
     79            return;
     80
     81        Pawn* newPawn = new Pawn(this->center_->getContext());
     82        newPawn->addTemplate("enemyinvader");
     83
     84        newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0));
    6485    }
    6586
  • code/branches/invaders/src/modules/invader/Invader.h

    r9709 r9777  
    4242#include "InvaderCenterPoint.h"
    4343
     44#include "tools/Timer.h"
     45
    4446namespace orxonox
    4547{
     
    5658            //virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
    5759
     60            void spawnEnemy();
     61
    5862            void setCenterpoint(InvaderCenterPoint* center)
    5963            { this->center_ = center; }
    6064        private:
    6165            WeakPtr<InvaderCenterPoint> center_;
     66            InvaderShip * player;
     67
     68            ConsoleCommand* console_addEnemy;
     69
     70            Timer enemySpawnTimer;
    6271            //Context* context;
    6372    };
  • code/branches/invaders/src/modules/invader/InvaderPrereqs.h

    r9744 r9777  
    7171    class InvaderCenterPoint;
    7272    class InvaderShip;
     73    class InvaderEnemy;
    7374    class InvaderWeapon;
    7475}
  • code/branches/invaders/src/modules/invader/InvaderShip.cc

    r9744 r9777  
    5252        isFireing = false;
    5353        damping = 10;
    54 
    5554    }
    5655
     
    7574            ControllableEntity::fire(0);
    7675
     76        if (getPosition().x > 30000)
     77        {
     78            //level++
     79            setPosition(getPosition() - Vector3(30000, 0, 0));
     80        }
     81
     82        // if ((int(getPosition().x) % 1000) < 5)
     83        // {
     84        //     for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
     85        //         it->spawnEnemy();
     86        // }
    7787
    7888        // camera->setOrientation(Vector3::UNIT_X, Degree(0));
     
    8191        SUPER(InvaderShip, tick, dt);
    8292    }
     93
     94
    8395
    8496    void InvaderShip::moveFrontBack(const Vector2& value)
  • code/branches/invaders/src/modules/invader/InvaderShip.h

    r9744 r9777  
    5959            virtual void rotatePitch(const Vector2& value){};
    6060            virtual void rotateRoll(const Vector2& value){};
     61
     62            // *InvaderShip getShip(){return this;}
    6163        private:
    6264            Camera* camera;
Note: See TracChangeset for help on using the changeset viewer.