genesis-3d_engine/Engine/players/Demo/Common/GameBuilding.h

124 lines
2.8 KiB
C
Raw Normal View History

/** \file: GameBuilding.h
* \brief: building logic
* Copyright (c) 2011,WebJet Enterprise Department.ChangYou
* All rights reserved.
* Date Ver Who Comment
* 2011/12/07 1.0 SunHao
*/
#ifndef __GAMEBUILDING_H__
#define __GAMEBUILDING_H__
#include "core/refcounted.h"
#include "appframework/app_fwd_decl.h"
#include "appframework/actor.h"
#include "DemoFwdDecl.h"
namespace App
{
class RenderComponent;
}
namespace Demo
{
class Estates : public Core::RefCounted
{
__DeclareSubClass( Demo::Estates, Core::RefCounted )
public:
Estates()
: m_pBuilding()
, m_iType( 0 )
, m_RollRadian( 0 )
, m_Pos()
{}
~Estates();
void Init( App::TActorPtr pBuilding, TEstateType iType, const Math::float3& pos, Math::scalar radian );
void Rotate( Math::scalar radian );
// - set method
void SetRadian( Math::scalar radian ) { m_RollRadian =radian; }
// - get method
App::Actor::FastId GetId( void ) { return m_pBuilding->GetFastId();}
App::TActorPtr GetBuilding( void ) { return m_pBuilding; }
Math::scalar GetRadian( void ) { return m_RollRadian; }
TEstateType GetType( void ) { return m_iType; }
Math::float3 GetPos( void ) { return m_Pos; }
private:
App::TActorPtr m_pBuilding;
TEstateType m_iType;
Math::scalar m_RollRadian;
Math::float3 m_Pos;
};
class LandAgent
{
public:
LandAgent()
: m_Buildings()
{}
~LandAgent()
{}
TEstatesPtr Find( App::Actor::FastId iFastId );
TEstatesPtr Find( IndexT iIndex );
bool Add( TEstatesPtr pBuilding );
bool Add( App::TActorPtr pBuilding, TEstateType iType, const Math::float3& pos, Math::scalar radian );
void Remove( App::Actor::FastId iFastId );
SizeT Size( void );
void Clear( void );
private:
Util::Dictionary<App::Actor::FastId, TEstatesPtr> m_Buildings;
};
class BuildingAnimationManager: public Core::RefCounted
{
__DeclareClass(BuildingAnimationManager )
public:
BuildingAnimationManager();
virtual ~BuildingAnimationManager();
/// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
void Open();
/// <20>ر<EFBFBD>
void Close();
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>building<6E><67><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD>building<6E>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>Խ<EFBFBD><D4BD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD><EFBFBD>Actor
void BeignAnimtion( App::TActorPtr pBlock );
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A3><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>
void OnFrame( float32 fTime );
protected:
float32 GetMaxHouseHeight( const Util::String& housename , float32 offSet ) const;
void AddAnimationInfo( const App::TActorPtr& actor, float32 offSet );
protected:
struct AnimInfo
{
App::TActorPtr m_house;
Ptr<App::RenderComponent> m_render;
float32 m_curHeight; // <09><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ǰ<EFBFBD>߶<EFBFBD>
float32 m_maxHeight; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>
};
typedef Util::Array<AnimInfo> AnimInfos;
AnimInfos m_AnimInfos; // <09><>ǰ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ
Util::Dictionary<Util::String, float> m_heightLimit; // <09><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ĸ߶<C4B8><DFB6><EFBFBD><EFBFBD><EFBFBD>
Util::String m_animationShader;
Util::StringAtom m_animationShaderParamName;
};
}
#endif // __GAMEBUILDING_H__