home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / nails.py < prev    next >
Encoding:
Python Source  |  2000-10-27  |  5.9 KB  |  189 lines

  1. #----------------------------------------------------------------------
  2. #   Proposito : Futil intento de automatizar la trampa 
  3. #              de pinchos para las futuras generaciones
  4. #
  5. #   Culpable  : Jose Dario Halle Cano
  6. #
  7. #   ToDo      : Sonidos y Polvo
  8. #----------------------------------------------------------------------
  9. """
  10. --------------------------------------------------------
  11. ---                      Ejemplo                     ---
  12. --------------------------------------------------------
  13.  
  14. import nails
  15.  
  16. #  crea la trampa
  17.  
  18. trampa =   nails.NailTrap(5000,2000,15000)
  19.  
  20. # Agrega las puertas
  21. trampa.AddSector(       19058, 10085, -4519 )
  22. trampa.AddSector(       19027, 10085, -1514 )
  23. trampa.AddSector(       18521, 10085, 1049  )
  24.  
  25. #define que sectores activaran la trampa
  26. trampa.ActivationSector(19027, 10085, -1514 )
  27.  
  28. # Agrega todo los objetos Pincho o afines asociados a la trampa
  29. trampa.AddPincho("Pinch1")
  30. trampa.AddPincho("Pinch2")
  31. trampa.AddPincho("Pinch3")
  32. trampa.AddPincho("Pinch4")
  33. trampa.AddPincho("Pinch5")
  34. trampa.AddPincho("Pinch6")
  35.  
  36. ------------------------------------------------------------------------
  37. """
  38.  
  39. import Doors
  40. import Bladex
  41. import Room
  42. import Sounds
  43.  
  44. TP_Opened   = 0
  45. TP_Working  = 1
  46.  
  47. ################################################################################################################
  48.  
  49. Sonido_Trampa_Activada = Bladex.CreateSound('..\\..\\Sounds\\trap-clicked.wav', 'SonidoActivacion')
  50. Sonido_Trampa_Activada.Volume=1
  51. Sonido_Trampa_Activada.MinDistance=15000
  52. Sonido_Trampa_Activada.MaxDistance=20000
  53.  
  54. Sonido_Trampa_Bajando    = Sounds.CreateEntitySound('..\\..\\Sounds\\stone-slide-and-hit.wav', 'SonidoPiedra')
  55. Sonido_Trampa_Bajando.Volume=1
  56. Sonido_Trampa_Bajando.MinDistance=15000
  57. Sonido_Trampa_Bajando.MaxDistance=20000
  58.  
  59. Sonido_Trampa_Subiendo   = Sounds.CreateEntitySound('..\\..\\Sounds\\drawbridge-loop.wav', 'SonidoCadena1')
  60. Sonido_Trampa_Subiendo.Volume=1
  61. Sonido_Trampa_Subiendo.MinDistance=15000
  62. Sonido_Trampa_Subiendo.MaxDistance=20000
  63.  
  64. Sonido_Trampa_Reactivada = Sounds.CreateEntitySound('..\\..\\Sounds\\metal-lever3.wav', 'SonidoReactivacion')
  65. Sonido_Trampa_Reactivada.Volume=1
  66. Sonido_Trampa_Reactivada.MinDistance=15000
  67. Sonido_Trampa_Reactivada.MaxDistance=20000
  68.  
  69. Sonido_Trampa_Hit        = Sounds.CreateEntitySound('..\\..\\Sounds\\Stone-door-shut.wav', 'Hit2')
  70. Sonido_Trampa_Hit.Volume=1
  71. Sonido_Trampa_Hit.MinDistance=15000
  72. Sonido_Trampa_Hit.MaxDistance=20000
  73.  
  74. ################################################################################################################
  75.  
  76. TrapList={}
  77.  
  78. def PinchosSiguenTecho(self):    
  79.  
  80.      for Puert in self.agujas:
  81.         Pincho = Bladex.GetEntity(Puert)
  82.         X      = Pincho.Position[0]
  83.         Z      = Pincho.Position[2]
  84.         D      = self.sectores[0].sld_area().Displacement    
  85.         Y      = self.ypos + D
  86.         Pincho.Position = X,Y,Z
  87.  
  88.      if self.State <> TP_Opened:
  89.         Bladex.AddScheduledFunc(Bladex.GetTime()+0.025, PinchosSiguenTecho, (self,))
  90.   
  91.   
  92.  
  93. def SeteaElValue(self):
  94.   self.State = TP_Opened
  95.  
  96. def AbreteSesamus(self):
  97.   self.OpenTrap()  
  98.   Bladex.AddScheduledFunc(Bladex.GetTime()+10.0, SeteaElValue, (self,))
  99.     
  100.     
  101. def MataAlJugador():
  102.   char      = Bladex.GetEntity("Player1")
  103.   #char.Life = 0
  104.  
  105. def EntroElIluso(sectorindex,entityname):
  106.   # Muere estupido Iluso  
  107.   sec = TrapList[sectorindex]
  108.   if sec.Active:
  109.      if sec.State == TP_Opened:
  110.         sec.CloseTrap()
  111.         if entityname == "Player1":
  112.           Bladex.AddScheduledFunc(Bladex.GetTime()+1.0, MataAlJugador, ())
  113.  
  114.  
  115. #
  116. # Clase que implementa una trampa de pinchos
  117. #---------------------------------------------
  118. class NailTrap:
  119.    
  120.    def __init__(self,Tam,Ups,Downs):
  121.      self.agujas      = [ ]
  122.      self.sectores    = [ ]
  123.      self.size        = Tam
  124.      self.Active      = 1
  125.      self.SpeedOn     = Downs
  126.      self.SpeedOff    = Ups
  127.      self.State       = TP_Opened     
  128.      
  129.  
  130.    def AddPincho(self,Name):
  131.      self.agujas.append(Name)
  132.      ob = Bladex.GetEntity(Name)
  133.      self.ypos = ob.Position[1]
  134.       
  135.    
  136.    def AddSector(self,x,y,z):
  137.      
  138.      Puerta_Pinchos=Doors.CreateDoor("PuertaPinchos"+`len(self.sectores)`, (x,y,z), (0,1,0), 50, self.size, Doors.OPENED)
  139.      Puerta_Pinchos.Squezze = 1
  140.      
  141.      Puerta_Pinchos.opentype       = Doors.UNIF
  142.      Puerta_Pinchos.o_med_vel      = -abs(self.SpeedOff)
  143.      Puerta_Pinchos.o_med_displ    = self.size
  144.      Puerta_Pinchos.OnEndOpenFunc  = ""
  145.      
  146.      Puerta_Pinchos.closetype      = Doors.AC
  147.      Puerta_Pinchos.c_init_vel     = 0
  148.      Puerta_Pinchos.c_init_displ   = self.size
  149.      Puerta_Pinchos.c_med_vel      = abs(self.SpeedOn)
  150.      Puerta_Pinchos.OnEndCloseFunc = ""
  151.      
  152.      if(len(self.sectores) == 0):
  153.           Puerta_Pinchos.SetWhileOpenSound(Sonido_Trampa_Subiendo)
  154.           Puerta_Pinchos.SetEndOpenSound(Sonido_Trampa_Reactivada)
  155.           
  156.           Puerta_Pinchos.SetWhileCloseSound(Sonido_Trampa_Bajando)
  157.           Puerta_Pinchos.SetEndCloseSound(Sonido_Trampa_Hit)
  158.  
  159.      
  160.      self.sectores.append(Puerta_Pinchos)
  161.      
  162.    def ActivationSector(self,x,y,z):
  163.      
  164.      Sec                                = Bladex.GetSector(x,y,z)
  165.      Sec.OnEnter                        = EntroElIluso
  166.      TrapList[Sec.Index]                = self
  167.      self.SoundX                        = x
  168.      self.SoundY                        = y
  169.      self.SoundZ                        = z
  170.  
  171.  
  172.    def OpenTrap(self):
  173.       self.State = TP_Working      
  174.       # sectors
  175.       for Puert in self.sectores:
  176.          Puert.OpenDoor()
  177.  
  178.    def CloseTrap(self):      
  179.       self.State = TP_Working
  180.       PinchosSiguenTecho(self)
  181.       
  182.       # Pinchos
  183.       Sonido_Trampa_Activada.Play(self.SoundX,self.SoundY,self.SoundZ)
  184.       
  185.       # sectors
  186.       for Puert in self.sectores:
  187.          Puert.CloseDoor()
  188.          Bladex.AddScheduledFunc(Bladex.GetTime()+3.0, AbreteSesamus, (self,))
  189.