Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

load_npc.py 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import bge
  2. from mathutils import Vector
  3. def rot_deck(cont):
  4. scene = bge.logic.getCurrentScene()
  5. deck = scene.objects['npc_ed_deck']
  6. #rot = [ 0.0, 0.0, -1.570796327]
  7. print('rotating')
  8. deck.alignAxisToVect(Vector([1,0,0]),2,.25)
  9. #rot = [ 0.0, 0.0, -0.10796327]
  10. #deck.applyRotation(rot,True)
  11. #print('rotating')
  12. def collect_npc(cont):
  13. #add ed
  14. own = cont.owner
  15. scene = bge.logic.getCurrentScene()
  16. dict = bge.logic.globalDict
  17. objList = scene.objects
  18. try:
  19. spawned_list = dict['spawned_npc_list']
  20. to_spawn = dict['to_spawn']
  21. except:
  22. dict['spawned_npc_list'] = []
  23. dict['to_spawn'] = []
  24. to_spawn = []
  25. own['npc_index'] = 0
  26. npc_index = 0
  27. for x in objList:
  28. if 'npc_skater' in x:
  29. dict['to_spawn'].append(x)
  30. print(x.name, 'added to list')
  31. def spawn_npc(cont):
  32. own = cont.owner
  33. scene = bge.logic.getCurrentScene()
  34. dict = bge.logic.globalDict
  35. objList = scene.objects
  36. to_spawn = dict['to_spawn']
  37. #print(to_spawn)
  38. npc_index = own['npc_index']
  39. if to_spawn:
  40. x = dict['to_spawn'][0]
  41. print(x)
  42. x['rpStartLoc'] = [0.0,0.0,0.0]
  43. x['rpStartLoc_set'] = False
  44. x['move'] = False
  45. x['npc_rotate'] = False
  46. x['rotate_in'] = False
  47. x['move_to'] = False
  48. x['rotate_out'] = False
  49. obj = scene.addObject('npc_ed_deck', own, 0)
  50. obj.setParent(x, False, False)
  51. dict['spawned_npc_decks'].append(obj)
  52. obj = scene.addObject('npc_ed_trucks', own, 0)
  53. obj.setParent(x, False, False)
  54. dict['spawned_npc_trucks'].append(obj)
  55. obj = scene.addObject('npc_ed_arm', own, 0)
  56. obj.setParent(x, False, False)
  57. dict['spawned_npcs'].append(obj)
  58. if npc_index == 0:
  59. shirt = obj.children["npc:Zshirtt1"]
  60. shirt.color = [.9,.1,.1,1]
  61. if npc_index == 1:
  62. shirt = obj.children["npc:Zshirtt1"]
  63. shirt.color = [.1,.9,.1,1]
  64. if npc_index == 2:
  65. shirt = obj.children["npc:Zshirtt1"]
  66. shirt.color = [.1,.1,.9,1]
  67. #rot = [ 0.0, 0.0, 1.570796327]
  68. x['npc_index'] = npc_index
  69. npc_index += 1
  70. own['npc_index'] = npc_index
  71. print('adding npc character: ', x.name, obj.name)
  72. dict['to_spawn'].remove(x)
  73. shirt = scene.objects["npc:Zshirtt1"]
  74. shirt.color = [255,0,0,1]
  75. def main():
  76. cont = bge.logic.getCurrentController()
  77. own = cont.owner
  78. scene = bge.logic.getCurrentScene()
  79. #actu = cont.actuators['start_level']
  80. dict = bge.logic.globalDict
  81. objList = scene.objects
  82. mainDir = bge.logic.expandPath("//")
  83. skater = 'ai_ed'
  84. fileName = mainDir + "npc_skaters/" + str(skater) + '.blend'
  85. path = bge.logic.expandPath(fileName)
  86. try:
  87. bge.logic.LibLoad(path, 'Scene')
  88. except:
  89. print('trying to load', fileName, 'twice')
  90. # get object named MainCharacter
  91. #armature = objList["npc_ed_arm"]
  92. #deck = objList['npc_ed_deck']
  93. #trucks = objList['npc_ed_trucks']
  94. # combine child's shape with parent's
  95. compound = False
  96. # child is solid
  97. ghost = False
  98. # rotate the game object 1.570796327 radians (90 degrees)
  99. #rot = [ 0.0, 0.0, -1.570796327]
  100. #deck.applyRotation(rot,False)
  101. # set parent
  102. #for x in [armature, deck, trucks]:
  103. #x.setParent( own, compound, ghost)
  104. #rot = [ 0.0, 0.0, -1.570796327]
  105. #deck.applyRotation(rot,True)
  106. #rot = [ 0.0, 0.0, -1.570796327]
  107. #deck.applyRotation(rot,True)
  108. print('loading ai')
  109. main()