topical media & game development

talk show tell print

lib-game-delta3d-demos-fireFighter-gameitemactor.h / h



  /* -*-c++-*-
   * Delta3D Open Source Game and Simulation Engine
   * Copyright (C) 2006, Alion Science and Technology, BMH Operation
   *
   * This library is free software; you can redistribute it and/or modify it under
   * the terms of the GNU Lesser General Public License as published by the Free
   * Software Foundation; either version 2.1 of the License, or (at your option)
   * any later version.
   *
   * This library is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
   * details.
   *
   * You should have received a copy of the GNU Lesser General Public License
   * along with this library; if not, write to the Free Software Foundation, Inc.,
   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   *
   * William E. Johnson II 
   */
  ifndef DELTA_FIRE_FIGHTER_GAME_ITEM_ACTOR
  define DELTA_FIRE_FIGHTER_GAME_ITEM_ACTOR
  
  include <dtActors/gamemeshactor.h>
  include <fireFighter/export.h>
  include <dtAudio/sound.h>
  include <dtDAL/actorproxyicon.h>
  
  class FIRE_FIGHTER_EXPORT GameItemActor : public dtActors::GameMeshActor
  {
     public:
        
  
Constructor GameItemActor(dtGame::GameActorProxy &proxy);

        
Base class method for activating a game item
parameter: enable true to enable the item

  
        virtual void Activate(bool enable = true);
  
        
Returns true is this item is activated
returns: mIsActivated

  
        bool IsActivated() const { return mIsActivated; }
  
        
Returns true if this game item is collectable
returns: mCollectable

  
        bool IsCollectable() const { return mCollectable; }
        
        
Sets if this item is collectable
parameter: enable true for collectable

  
        void SetCollectable(bool enable) { mCollectable = enable; }
  
        
Sets the sound played when the item is acquired
parameter: fileName The sound file name

  
        void SetInventoryAddSnd(const std::string &fileName); 
        
        
Returns the file name of the inventory sound
returns: The file name

  
        std::string GetInventoryAddSnd()  { return mInventoryAddSnd->GetFilename(); }
        
        
Plays the inventory add sound

  
        void PlayInventoryAddSnd() { mInventoryAddSnd->Play(); }
        
        
Stops the inventory add sound

  
        void StopInventoryAddSnd() { mInventoryAddSnd->Stop(); }
  
        
Sets the sound used when the item is activated/used
parameter: fileName The sound file to use

  
        void SetItemUseSnd(const std::string &fileName); 
        
        
Returns the file name of the item use sound
returns: The file name

  
        std::string GetItemUseSnd() { return mItemUseSnd->GetFilename(); }
        
        
Plays the item use sound

  
        void PlayItemUseSnd() { mItemUseSnd->Play(); }
        
        
Stops the item use sound

  
        void StopItemUseSnd() { mItemUseSnd->Stop(); }
  
        
Returns the index this item uses as its key into the inventory map on the player class.
see: class PlayerActor
returns: mItemIndex

  
        virtual int GetItemIndex() const { return mItemIndex; }
  
     protected:
  
  
Called when the actor is added to the GM virtual void OnEnteredWorld();

  
Destructor virtual ~GameItemActor();

        dtCore::RefPtr<dtAudio::Sound> mInventoryAddSnd; 
        dtCore::RefPtr<dtAudio::Sound> mItemUseSnd; 
        int mItemIndex;
  
     private:
        
        bool mCollectable;
        bool mIsActivated;
   };
  
  class FIRE_FIGHTER_EXPORT GameItemActorProxy : public dtActors::GameMeshActorProxy
  {
     public:
  
  
Constructor GameItemActorProxy();

  
Builds the actor properties virtual void BuildPropertyMap();

  
Builds the invokables virtual void BuildInvokables();

  
Instantiates the actor virtual void CreateActor() { SetActor(*new GameItemActor(*this)); }

        // Used in STAGE
        dtDAL::ActorProxyIcon* GetBillBoardIcon();
  
        virtual const dtDAL::ActorProxy::RenderMode& GetRenderMode()
        {
           return dtDAL::ActorProxy::RenderMode::DRAW_ACTOR;
        }
  
     protected:
  
  
Destructor virtual ~GameItemActorProxy();

     private:
  
        dtCore::RefPtr<dtDAL::ActorProxyIcon> mBillBoardIcon; 
  };
  
  endif
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.