Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2007, 3:05:01 AM (17 years ago)
Author:
patrick
Message:

merged playability. but got strange bug

Location:
branches/playability.new
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/playability.new

    • Property svn:ignore
      •  

        old new  
        1010autom4te.cache
        1111aclocal.m4
         12tags
         13test.bmp
         14config.sub
         15config.guess
         16OrxonoxPlayability.kdevses
         17OrxonoxPlayability.kdevelop.pcs
  • branches/playability.new/src/world_entities/weapons/weapon.cc

    r9869 r10362  
    3333#include "resource_sound_buffer.h"
    3434
    35 #include "elements/glgui_energywidget.h"
     35#include "elements/glgui_energywidgetvertical.h"
    3636
    3737ObjectListDefinition(Weapon);
     
    119119  }
    120120
    121   this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource.
    122   this->emissionPoint.setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
    123   this->emissionPoint.setName("EmissionPoint");
    124   this->emissionPoint.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     121  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource
     122
     123  this->barrels = 1;
     124  this->segs = 1;
     125
     126  this->shootAnim = new Animation3D**[this->getBarrels()];
     127  for (int i = 0; i < this->getBarrels(); i++)
     128    this->shootAnim[i] = new Animation3D* [this->getSegs()];
     129
     130  this->emissionPoint = new PNode*[this->barrels];
     131  for(int i = 0; i < this->barrels; i++){
     132    this->emissionPoint[i] = new PNode;
     133    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     134    this->emissionPoint[i]->setName("EmissionPoint");
     135    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     136  }
    125137
    126138  this->defaultTarget = NULL;                      //< Nothing is Targeted by default.
     
    145157
    146158/**
     159 * needed, if there are more than one barrel or segments
     160 */
     161void Weapon::init2()
     162{
     163  if (this->barrels == 1 && this->segs == 1)
     164    return;
     165
     166  delete this->emissionPoint[0];
     167  delete this->emissionPoint;
     168  delete this->shootAnim[0];
     169  delete this->shootAnim;
     170
     171  this->shootAnim = new Animation3D**[this->barrels];
     172  this->emissionPoint = new PNode*[this->barrels];
     173  for(int i = 0; i < this->barrels; i++){
     174    this->emissionPoint[i] = new PNode;
     175    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     176    this->emissionPoint[i]->setName("EmissionPoint");
     177    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     178    this->shootAnim[i] = new Animation3D* [this->segs];
     179  }
     180}
     181
     182/**
     183 * deconstructor for init2
     184 */
     185void Weapon::deconstr()
     186{
     187  for(int i = 0; i < this->barrels; i++) {
     188    delete this->emissionPoint[i];
     189    for (int j = 0; j < this->segs; j++)
     190      delete this->shootAnim[i][j];
     191    delete this->shootAnim[i];
     192  }
     193
     194  delete this->emissionPoint;
     195  delete this->shootAnim;
     196}
     197
     198/**
    147199 * loads the Parameters of a Weapon
    148200 * @param root the XML-Element to load the Weapons settings from
     
    154206  LoadParam(root, "projectile", this, Weapon, setProjectileTypeC)
    155207  .describe("Sets the name of the Projectile to load onto the Entity");
    156 
     208/*
    157209  LoadParam(root, "emission-point", this, Weapon, setEmissionPoint)
    158   .describe("Sets the Point of emission of this weapon");
     210  .describe("Sets the Point of emission of this weapon (1: EmmsionVector; 2: EmissionPoint)");*/
    159211
    160212  LoadParam(root, "state-duration", this, Weapon, setStateDuration)
     
    253305 * @param point the Point relative to the mass-point of the Weapon
    254306 */
     307void Weapon::setEmissionPoint(const Vector& point, int barrel)
     308{
     309  this->emissionPoint[barrel]->setRelCoor(point);
     310}
     311
    255312void Weapon::setEmissionPoint(const Vector& point)
    256313{
    257   this->emissionPoint.setRelCoor(point);
    258 }
    259 
     314  this->emissionPoint[0]->setRelCoor(point);
     315}
    260316
    261317/**
     
    315371}
    316372
     373Animation3D* Weapon::getAnimation(int barrel, int seg, PNode* node)
     374{
     375  if (barrel >= this->getBarrels() || seg >= this->getSegs()) // if the state is not known
     376    return NULL;
     377
     378  if (unlikely(this->shootAnim[barrel][seg] == NULL)) // if the animation does not exist yet create it.
     379  {
     380    if (likely(node != NULL))
     381      return this->shootAnim[barrel][seg] = new Animation3D(node);
     382    else
     383    {
     384//       PRINTF(2)("Node not defined for the Creation of the 3D-animation of state %s\n", stateToChar(state));
     385      return NULL;
     386    }
     387  }
     388  else
     389    return this->shootAnim[barrel][seg];
     390}
     391
    317392OrxGui::GLGuiWidget* Weapon::getEnergyWidget()
    318393{
    319   if (this->energyWidget == NULL)
    320   {
    321     this->energyWidget = new OrxGui::GLGuiEnergyWidget();
    322     this->energyWidget->setDisplayedName(this->getClassCName());
     394  if ( this->energyWidget == NULL)
     395  {
     396    this->energyWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     397    //this->energyWidget->setDisplayedName(this->getClassCName());
    323398    this->energyWidget->setSize2D( 20, 100);
    324399    this->energyWidget->setMaximum(this->getEnergyMax());
     
    352427  if (likely(this->isActive()))
    353428  {
     429    /** Disabled for releaseFire() from WM*/
    354430    if (this->requestedAction != WA_NONE)
    355431      return;
     
    378454  {
    379455    this->energy += energyToAdd;
     456    this->updateWidgets();
    380457    return 0.0;
    381458  }
     
    383460  {
    384461    this->energy += maxAddEnergy;
     462    this->updateWidgets();
    385463    return energyToAdd - maxAddEnergy;
    386464  }
     465 
    387466}
    388467
     
    431510    break;
    432511    default:
    433     PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
     512    PRINTF(5)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
    434513    return false;
    435514  }
     
    507586bool Weapon::fireW()
    508587{
     588//   printf("fireW Weapon\n");
    509589  //if (likely(this->currentState != WS_INACTIVE))
    510590  if (this->minCharge <= this->energy)
     
    513593    if (this->soundBuffers[WA_SHOOT].loaded())
    514594      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    515     this->updateWidgets();
    516595    // fire
    517596    this->energy -= this->minCharge;
     
    519598    // setting up for the next state
    520599    this->enterState(WS_SHOOTING);
     600    this->updateWidgets();
    521601  }
    522602  else  // reload if we still have the charge
     
    538618      unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge))
    539619  {
    540     this->requestAction(WA_DEACTIVATE);
     620    //this->requestAction(WA_DEACTIVATE);
    541621    this->execute();
    542622    return false;
Note: See TracChangeset for help on using the changeset viewer.