Bugfix : only one type property per object (type_minion with type_towerminion)

This commit is contained in:
Philippe Roy 2022-07-19 00:49:24 +02:00
parent a338239e62
commit 53de5b73a9
2 changed files with 7 additions and 6 deletions

10
ct.py
View File

@ -198,7 +198,7 @@ def points_maj (cont):
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() and obj_i.visible==True:
if "type_minion" 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'])
@ -322,7 +322,7 @@ def terrain_run ():
scene.objects['Cmd-text']['Text']= "Run (F5)"
scene.objects['Cmd-text'].setVisible(True,False) # FIXME : suppresion de du message
for obj_i in scene.objects: # Pause des Steerings
if "type_minion" in obj_i.getPropertyNames() and "type_towerminion" not in obj_i.getPropertyNames():
if "type_minion" in obj_i.getPropertyNames() :
obj_i.actuators['Steering'].velocity=0
# Run
@ -371,7 +371,7 @@ def terrain_run ():
# Arrêt de la pause
else:
for obj_i in scene.objects: # Relance des Steerings
if "type_minion" in obj_i.getPropertyNames() and "type_towerminion" not in obj_i.getPropertyNames():
if "type_minion" in obj_i.getPropertyNames():
obj_i.actuators['Steering'].velocity=obj_i['speed_base']*scene.objects['Terrain']['speed']
# Arrêt et réinitialisation du cycle
@ -387,7 +387,7 @@ def terrain_stop ():
# Supprimer les enemis
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():
obj_i.endObject()
scene.objects['Points']['minions']=0
scene.objects['Points']['minions_run']=0
@ -480,7 +480,7 @@ def terrain_speed (obj):
if "type_tower" in obj_i.getPropertyNames() and "Near" in obj_i.sensors :
obj_i.sensors['Near'].skippedTicks =round(1/(obj_i['speed']*scene.objects['Terrain']['speed']))
if scene.objects['Terrain']['run'] == True: # Pas en pause
if "type_minion" in obj_i.getPropertyNames() and "type_towerminion" not in obj_i.getPropertyNames():
if "type_minion" in obj_i.getPropertyNames():
obj_i.actuators['Steering'].velocity=obj_i['speed_base']*scene.objects['Terrain']['speed']
# Configuration du moteur de rendu

View File

@ -337,7 +337,8 @@ def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_pu
tour.name="tower("+str(x)+','+str(y)+")"
scene.objects['Terrain']['scene_tile_tower'].append([x,y])
tower_minion= scene.addObject(body, scene.objects['Terrain'])
tower_minion["type_towerminion"]=False
tower_minion['type_towerminion']=False
del tower_minion['type_minion']
tower_minion.name="tm("+str(x)+','+str(y)+")" # Tower minion (tm)
tower_minion.worldPosition=[x,y,1]
tower_minion.worldScale=[0.25,0.25,0.25]