BuildingManager.cpp
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:2k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. // BuildingManager.cpp: implementation of the CBuildingManager class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "BuildingManager.h"
  6. #include "texmanager.h"
  7. //////////////////////////////////////////////////////////////////////
  8. // Construction/Destruction
  9. //////////////////////////////////////////////////////////////////////
  10. CBuildingManager::CBuildingManager()
  11. {
  12. m_numHouse=0;
  13. m_cHouse=NULL;
  14. }
  15. CBuildingManager::~CBuildingManager()
  16. {
  17. if(m_cHouse!=NULL)
  18. {
  19. delete [] m_cHouse;
  20. m_cHouse=NULL;
  21. }
  22. }
  23. bool CBuildingManager::InitBuilding()
  24. {
  25. if(!m_ms3dHouse.Load("model/ms3d/house.ms3d",1))
  26. {
  27. MessageBox(0, "Load building file error", "Error", MB_OK | MB_ICONERROR);
  28. return FALSE;
  29. }
  30. m_cSmoke.InitParticle(CTexManager::GetTextureID(TEX_SMOKE_0),0,50,1);
  31. //////////////////////////////////////////////////
  32. m_numHouse=m_cHmap.m_numBuilding;
  33. m_cHouse=new CHouse [m_numHouse];
  34. bool bSmoke=false;
  35. int  texID=TEX_HOUSE_0;
  36. for(int i=0;i<m_numHouse;i++)
  37. {
  38.         bSmoke=!bSmoke;
  39. texID++;
  40. if(texID>TEX_HOUSE_2)texID=TEX_HOUSE_0;
  41.      m_cHouse[i].InitHouse(&m_ms3dHouse,&m_cSmoke,m_cHmap.m_buildingPos[i],
  42.                   0,CTexManager::GetTextureID(texID),bSmoke);
  43.      m_cHmap.m_bigBndyBuilding[i] = &m_cHouse[i].m_bigBoundary;
  44.      m_cHmap.m_smallBndyBuilding[i] = &m_cHouse[i].m_smallBoundary;
  45. }
  46. //////////////////////////////////////////////////
  47. return true;
  48. }
  49. void CBuildingManager::RenderBuilding()
  50. {
  51. for(int i=0;i<m_numHouse;i++)
  52.      m_cHouse[i].DrawHouse();
  53. }
  54. void CBuildingManager::RenderSmoke()
  55. {
  56. for(int i=0;i<m_numHouse;i++)
  57.        m_cHouse[i].DrawSmoke();
  58. }