home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 July & August / PCWorld_2006-07-08_cd.bin / temacd / planearcade / planearcade.exe / Tank3.bmp / structures.cpp < prev    next >
C/C++ Source or Header  |  2004-10-08  |  3KB  |  151 lines

  1.  
  2. #include "main.h"
  3.  
  4.  
  5. //incializacia
  6. //-----------------------------------------------------------
  7. void STRUCTURE::Initialize()
  8. {
  9.     Reset();
  10. }
  11.  
  12. //reset
  13. //-----------------------------------------------------------
  14. void STRUCTURE::Reset()
  15. {
  16.  
  17.     Pos = Get3D(0.0f,0.0f,0.0f);
  18.     Rot = Get3D(0.0f,0.0f,0.0f);
  19.  
  20.     ModelIndex = 0;
  21.     
  22.     //aktivacia
  23.     Active = false;
  24.     ActiveTime = 0.0f;
  25.     Life = 1;
  26.  
  27.     //mody
  28.     Normal = true;
  29.     Destroyed = false;
  30.     
  31.  
  32. }
  33. //render a obnovenie
  34. //-----------------------------------------------------------
  35. void STRUCTURE::Refresh()
  36. {
  37.  
  38.     if (Active == false)
  39.         return;
  40.     
  41.     //---------
  42.     //Process
  43.     //---------
  44.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  45.  
  46.     if (Life <= 0)
  47.     {
  48.         if (Normal == true)
  49.         {
  50.             //particle
  51.             //pretransformuj vybusne body
  52.             for (int i=0;i<NumSmokePoints;i++)
  53.             {
  54.                 TransformSmokePoint[i] = TransformPoint(SmokePoint[i],Matrix);
  55.                 Explo.SpawnExplosion(TransformSmokePoint[i]);
  56.                 Explo.SpawnParticle(TransformSmokePoint[i]);
  57.                 Explo.F_Plane.Spawn(Get3D(TransformSmokePoint[i].X,
  58.                                           TransformSmokePoint[i].Y,
  59.                                           TransformSmokePoint[i].Z));
  60.                 Explo.F_Ball.Spawn(TransformSmokePoint[i]);
  61.                 
  62.             }
  63.                 
  64.  
  65.             //zvuk
  66.             SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
  67.             SoundLib.ExplodeLarge.Play();
  68.  
  69.             
  70.             if (Target == true)
  71.             {
  72.                 //vypusti score particle
  73.                 Score.DrawScore(Score_Structure,Pos);
  74.  
  75.                 //pripocita score
  76.                 SpitFire.Score += Score_Structure;
  77.             }
  78.             
  79.         }
  80.  
  81.         Normal = false;
  82.         Destroyed = true;
  83.     }
  84.  
  85.     //---------
  86.     //Render
  87.     //---------
  88.  
  89.     //ak je strom zapni blending
  90.     if (ModelIndex >= Index_Structure_Strom1)
  91.     {
  92.         Engine.SetBlendTrans();
  93.         Engine.SetAlphaTest(true);
  94.         Engine.SetFilter(0,D3DTEXF_POINT);
  95.     }
  96.  
  97.     if (Normal == true)
  98.     {
  99.         ModelLib.GetStructure(ModelIndex)->Pos = Pos;
  100.         ModelLib.GetStructure(ModelIndex)->Rot = Rot;
  101.         ModelLib.GetStructure(ModelIndex)->Render();
  102.     }
  103.     if (Destroyed == true)
  104.     {
  105.  
  106.         ModelLib.GetDestroyedStructure(ModelIndex)->Pos = Pos;
  107.         ModelLib.GetDestroyedStructure(ModelIndex)->Rot = Rot;
  108.         ModelLib.GetDestroyedStructure(ModelIndex)->Render();
  109.     
  110.         if (ActiveTime < Structure_DestroyTime)
  111.         {
  112.             ActiveTime += PowerTime(1.0f);
  113.  
  114.             //pretransformuj vybusne body
  115.             for (int i=0;i<NumSmokePoints;i++)
  116.             {
  117.                 TransformSmokePoint[i] = TransformPoint(SmokePoint[i],Matrix);
  118.                 Explo.SpawnSmokeGround(TransformSmokePoint[i]);
  119.             }
  120.         }
  121.     }
  122.  
  123.     //ak je strom vypni blending
  124.     if (ModelIndex >= Index_Structure_Strom1)
  125.     {
  126.         Engine.SetBlendNone();
  127.         Engine.SetAlphaTest(false);
  128.         Engine.SetFilter(0,D3DTEXF_LINEAR);
  129.     }
  130. }
  131.  
  132. //kolizia box
  133. //-----------------------------------------------------------
  134. bool STRUCTURE::CollisionBox(VECTOR3D P1, VECTOR3D P2)
  135. {
  136.     if (Active == false)
  137.         return false;
  138.  
  139.     return ModelLib.GetStructure(ModelIndex)->CollisionBox(P1,P2,Matrix);
  140. }
  141.  
  142. //kolizia detail
  143. //-----------------------------------------------------------
  144. bool STRUCTURE::CollisionDetail(VECTOR3D P1, VECTOR3D P2)
  145. {
  146.     if (Active == false)
  147.         return false;
  148.  
  149.     return ModelLib.GetStructure(ModelIndex)->CollisionDetail(P1,P2,Matrix);
  150. }
  151.