diff --git a/codetower-25.blend b/codetower-25.blend new file mode 100644 index 0000000..7c4c004 Binary files /dev/null and b/codetower-25.blend differ diff --git a/ct.py b/ct.py index 2eb2add..28a2c60 100644 --- a/ct.py +++ b/ct.py @@ -193,12 +193,12 @@ def points_maj (cont): if scene.objects['Points']['level'] == scene.objects['Points']['level_max']: scene.objects['Level_text'].color = color_text - # Ramasse minions perdues ou zombis + # Ramassage des minions perdues ou zombis if scene.objects['Terrain']['run'] == True: # Pas en pause if scene.objects['Points']['tics']%240 == 0: # Toutes les 4 secondes scene.objects['Points']['minions_lost']=[] for obj_i in scene.objects: - if "type_minion" in obj_i.getPropertyNames() and "type_towerminion" not in obj_i.getPropertyNames(): + if "type_minion" in obj_i.getPropertyNames() and "type_towerminion" not in obj_i.getPropertyNames() and obj_i.visible==True: # print ("Minion lost : (dist, dist_old, x, last_x, y, last_y) : ", obj_i.name, obj_i['dist'], obj_i['dist_old'], obj_i.worldPosition.x, obj_i['dist_last_x'], obj_i.worldPosition.y, obj_i['dist_last_y']) if obj_i['dist']==obj_i['dist_old'] and obj_i['dist_new']==False: print ("Minion lost : dist =dist_old (dist, dist_old) : ", obj_i.name, obj_i['dist'], obj_i['dist_old']) diff --git a/ct_lib.py b/ct_lib.py index 30d5cd6..7c11c31 100644 --- a/ct_lib.py +++ b/ct_lib.py @@ -176,14 +176,14 @@ def sound_play (sound): # Minion 3d object : body (male,female,old, ...), variante (A,B,C,D, ...), level # Création d'un minion -def ct_minion(x,y,cat,level): +def ct_minion_create(x,y,cat,level): category=cat+"-lv"+str(level) minion_3d= scene.objects['Terrain']['minion_3d'] body = random.choice(minion_3d[category][0])+"_"+random.choice(minion_3d[category][1])+"_"+random.choice(minion_3d[category][2]) - ct_minion_details(x,y,cat,level,body) + return (ct_minion_create_details(x,y,cat,level,body)) # Création d'un minion détaillée -def ct_minion_details(x,y,cat,level,body="Knight_m_A_common"): +def ct_minion_create_details(x,y,cat,level,body="Knight_m_A_common"): category=cat+"-lv"+str(level) # Pause @@ -202,6 +202,8 @@ def ct_minion_details(x,y,cat,level,body="Knight_m_A_common"): minion= scene.addObject(body, scene.objects['Terrain']) minion.worldScale=[0.25,0.25,0.25] minion.worldPosition=[x,y,0.1] + minion.suspendPhysics (True) + minion.setVisible(False) scene.objects['Terrain']['idm']=scene.objects['Terrain']['idm']+1 minion['id']=scene.objects['Terrain']['idm'] minion.name="wm("+str(minion['id'])+")" # Wave minion (wm), identifier minion (idm) @@ -237,7 +239,14 @@ def ct_minion_details(x,y,cat,level,body="Knight_m_A_common"): # Déblocage des autres threads après l'apparition du minion scene.objects['Terrain']['thread_cmd_lock'] = False + return minion.name +# Activation du minion (steering) +def ct_minion_go(minion_name): + minion=scene.objects[minion_name] + minion.restorePhysics() + minion.setVisible(True) + # Destruction d'un minion def scn_minion_dead(cont): obj = cont.owner diff --git a/ct_map1.py b/ct_map1.py index a1511ba..fa50d6c 100644 --- a/ct_map1.py +++ b/ct_map1.py @@ -127,39 +127,53 @@ def minion_definition(): # Wave 1 def wave1(): ct_map_text_wave(1) + wave_minion_name=[] for i in range (15): # ct_minion(14,3,"Orc",1) - ct_minion_details(14,3,"Orc",1, "Orc_A_common") + # ct_minion_details(14,3,"Orc",1, "Orc_A_common") + wave_minion_name.append(ct_minion_create_details(14,3,"Orc",1, "Orc_A_common")) + for i in range (len(wave_minion_name)): + ct_minion_go(wave_minion_name[i]) ct_sleep (2) end() # Wave 2 def wave2(): ct_map_text_wave(2) + wave_minion_name=[] for i in range (20): - ct_minion(14,3,"Orc",1) + wave_minion_name.append(ct_minion_create(14,3,"Orc",1)) # ct_minion_details(14,3,"Orc",1, "Orc_A_common") + for i in range (len(wave_minion_name)): + ct_minion_go(wave_minion_name[i]) ct_sleep (1) end() # Wave 3 def wave3(): ct_map_text_wave(3) + wave_minion_name=[] for i in range (30): - ct_minion(14,3,"Orc",1) + wave_minion_name.append(ct_minion_create(14,3,"Orc",1)) # ct_minion_details(14,3,"Orc",1, "Orc_A_common") # ct_minion(14,3,"Knight",1) + for i in range (len(wave_minion_name)): + ct_minion_go(wave_minion_name[i]) ct_sleep (1) end() # Wave 4 def wave4(): ct_map_text_wave(4) + wave_minion_name_group1=[] + wave_minion_name_group2=[] for i in range (20): # ct_minion(14,3,"Orc",1) - ct_minion(14,2.5,"Orc",1) - # ct_minion_details(14,3,"Orc",1, "Orc_A_common") - ct_minion(14,3,"Knight",1) + wave_minion_name_group1.append(ct_minion_create(14,2.5,"Orc",1)) + wave_minion_name_group2.append(ct_minion_create(14,3,"Knight",1)) + for i in range (len(wave_minion_name_group1)): + ct_minion_go(wave_minion_name_group1[i]) + ct_minion_go(wave_minion_name_group2[i]) ct_sleep (0.5) end() @@ -192,7 +206,7 @@ def tower_definition(): # Map ############################################################################### -# Initialization +# Initialization def map_init(): # Base