diff --git a/UML.xmi b/UML.xmi index 5e111db..8158606 100644 --- a/UML.xmi +++ b/UML.xmi @@ -1,918 +1,974 @@ - + umbrello uml modeller http://umbrello.kde.org 1.6.12 UnicodeUTF8 - + - + - - + + - + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - + - - - - - - + + + + + + - + - + - + - + - + - + - - - + + + - - - + + + - + - - - - - - + + + + + + - - - - - - - + + + + + + + - + - - - - - - - - + + + + + + + + - + - - + + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - - + + + - + - + - - + + - + - - - - - - + + + + + + - + - - + + - + - - + + - + - + - + - + - - + + - + - - + + - + - + - - + + - + - - - + + + - + - + - - + + - + - - + + - - + + - + - + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - + + + - + - + - + - - + + - + - - + + - + - - + + + - + - - + + + - + - - + + - + - - + + - + - - + + + - + - - + + - + - - - + + + - + - - - + + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + - + - - + + + - + - - + + - + - + - - + + - + - + - - + + + - + - - + + - + - + - - + + - + - + - - + + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - - - - - - - - - - + + + + + + + + + + - - - + + - - + + + + - - - + + + + - - - + + + + - - - - + + + + - - - - + + + + - - - + + + + - - - - + + - - + + + - - - + + + + + + + - - - - - - - + + + + - - - - - - - - - + + + + + + + + - - - + + + - - - - + + + + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + - - - - + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/codetower-27.blend b/codetower-27.blend new file mode 100644 index 0000000..61dee57 Binary files /dev/null and b/codetower-27.blend differ diff --git a/ct.py b/ct.py index 28a2c60..53eae9d 100644 --- a/ct.py +++ b/ct.py @@ -118,7 +118,7 @@ def cmd_tower_construct(cont): scene.objects['Tower_construc_mode'].setVisible(True,False) scene.objects['Tower_construc_mode'].color = color_cmd text_info ("Tower position : ") - scene.objects['Cmd_text']['Text']= "" + scene.objects['Cmd-text']['Text']= "" ############################################################################### # User interface : texte info et compteurs @@ -127,16 +127,16 @@ def cmd_tower_construct(cont): # Affichage sur la boite de texte sur 6 lignes def text_info (text): if text=="": - scene.objects['Text_info-1'].setVisible(False,False) - scene.objects['Text_info-2'].setVisible(False,False) + scene.objects['Info-1-text'].setVisible(False,False) + scene.objects['Info-2-text'].setVisible(False,False) else: lines_txt=text.split("\n", 6) for i in range (len(lines_txt),6): lines_txt.append("") - scene.objects['Text_info-1'].setVisible(True,False) - scene.objects['Text_info-2'].setVisible(True,False) - scene.objects['Text_info-1']['Text']=lines_txt[0]+"\n"+lines_txt[1]+"\n"+lines_txt[2] - scene.objects['Text_info-2']['Text']=lines_txt[3]+"\n"+lines_txt[4]+"\n"+lines_txt[5] + scene.objects['Info-1-text'].setVisible(True,False) + scene.objects['Info-2-text'].setVisible(True,False) + scene.objects['Info-1-text']['Text']=lines_txt[0]+"\n"+lines_txt[1]+"\n"+lines_txt[2] + scene.objects['Info-2-text']['Text']=lines_txt[3]+"\n"+lines_txt[4]+"\n"+lines_txt[5] # Mise à jour de l'affichage des compteurs def points_maj (cont): @@ -149,25 +149,25 @@ def points_maj (cont): time.sleep(0.01) # Texte - scene.objects['Lifes_text']['Text']=str(scene.objects['Points']['lifes'])+"/"+str(scene.objects['Points']['lifes_max']) - scene.objects['Coins_text']['Text']=str(scene.objects['Points']['coins']) - scene.objects['Level_text']['Text']=str(scene.objects['Points']['level'])+"/"+str(scene.objects['Points']['level_max']) - scene.objects['Minions_text']['Text']=str(scene.objects['Points']['minions']) + scene.objects['Points-Lifes-text']['Text']=str(scene.objects['Points']['lifes'])+"/"+str(scene.objects['Points']['lifes_max']) + scene.objects['Points-Coins-text']['Text']=str(scene.objects['Points']['coins']) + scene.objects['Points-Level-text']['Text']=str(scene.objects['Points']['level'])+"/"+str(scene.objects['Points']['level_max']) + scene.objects['Points-Minions-text']['Text']=str(scene.objects['Points']['minions']) scene.objects['Points']['tics'] +=1 # Texte de la vague - if scene.objects['Map_text']['anim']: - if scene.objects['Map_text']['timer']<120: + if scene.objects['Points-Map-text']['anim']: + if scene.objects['Points-Map-text']['timer']<120: decal = 0.1 - vect=scene.objects['Map_text'].getVectTo(scene.objects['Camera'])[1] - scene.objects['Map_text'].applyMovement((vect[0]*decal, vect[1]*decal, vect[2]*decal), False) - scene.objects['Map_text']['timer']+=1 - if int(scene.objects['Map_text']['timer'])>=120: - scene.objects['Map_text'].color = color_text - scene.objects['Map_text'].worldPosition.x= scene.objects['Points'].worldPosition.x+ scene.objects['Map_text']['init_relativ_lx'] - scene.objects['Map_text'].worldPosition.y= scene.objects['Points'].worldPosition.y+ scene.objects['Map_text']['init_relativ_ly'] - scene.objects['Map_text'].worldPosition.z= scene.objects['Points'].worldPosition.z+ scene.objects['Map_text']['init_relativ_lz'] - scene.objects['Map_text']['anim']=False + vect=scene.objects['Points-Map-text'].getVectTo(scene.objects['Camera'])[1] + scene.objects['Points-Map-text'].applyMovement((vect[0]*decal, vect[1]*decal, vect[2]*decal), False) + scene.objects['Points-Map-text']['timer']+=1 + if int(scene.objects['Points-Map-text']['timer'])>=120: + scene.objects['Points-Map-text'].color = color_text + scene.objects['Points-Map-text'].worldPosition.x= scene.objects['Points'].worldPosition.x+ scene.objects['Points-Map-text']['init_relativ_lx'] + scene.objects['Points-Map-text'].worldPosition.y= scene.objects['Points'].worldPosition.y+ scene.objects['Points-Map-text']['init_relativ_ly'] + scene.objects['Points-Map-text'].worldPosition.z= scene.objects['Points'].worldPosition.z+ scene.objects['Points-Map-text']['init_relativ_lz'] + scene.objects['Points-Map-text']['anim']=False # Gestion du FPS - Tous les tics if scene.objects['Commands']['debug_fps']: @@ -187,11 +187,11 @@ def points_maj (cont): # Level trop élevé if scene.objects['Points']['level'] > scene.objects['Points']['level_max'] : - scene.objects['Level_text'].color = color_text_red + scene.objects['Points-Level-text'].color = color_text_red if scene.objects['Points']['level'] < scene.objects['Points']['level_max'] : - scene.objects['Level_text'].color = color_text_yellow + scene.objects['Points-Level-text'].color = color_text_yellow if scene.objects['Points']['level'] == scene.objects['Points']['level_max']: - scene.objects['Level_text'].color = color_text + scene.objects['Points-Level-text'].color = color_text # Ramassage des minions perdues ou zombis if scene.objects['Terrain']['run'] == True: # Pas en pause @@ -244,7 +244,7 @@ def scn_terrain_mo (cont): scene.objects['Tower_construc_mode'].worldPosition.y=round(hitPosition.y) scene.objects['Tower_construc_mode'].worldPosition.z=0.2 text_info ("Tower position : "+str(round(hitPosition.x))+","+str(round(hitPosition.y))) - scene.objects['Cmd_text']['Text']= "" + scene.objects['Cmd-text']['Text']= "" # Affiche les informations sur la tour # FIXME : High-light sur la tower sélectionnée @@ -262,7 +262,7 @@ def scn_terrain_mo (cont): text_info ("") # Initialisation lors du chargement du terrain -def terrain_init (cont): +def terrain_init (): # Cacher la bannière de fin scene.objects['End'].setVisible(False,True) @@ -270,9 +270,11 @@ def terrain_init (cont): scene.objects['Doc'].setVisible(False,True) # Pile des draws - scene.objects['Terrain']['draw_process']=False - scene.objects['Terrain']['draw_list']=[] - + scene.objects['Terrain']['draw2d_process']=False + scene.objects['Terrain']['draw2d_list']=[] + scene.objects['Terrain']['draw3d_process']=False + scene.objects['Terrain']['draw3d_list']=[] + # Ramasse-miettes scene.objects['Points']['minions_lost']=[] @@ -297,7 +299,7 @@ def terrain_init (cont): # Init de la carte ct_map.map_init() ct_map.map_reset() - scene.objects['Level_text'].color = color_text + scene.objects['Points-Level-text'].color = color_text # Mise en route et pause du cycle def terrain_run (): @@ -312,8 +314,8 @@ def terrain_run (): scene.objects['Pause-Hl'].setVisible(False,False) scene.objects['Run']. restorePhysics() scene.objects['Run-Hl'].setVisible(True,False) - scene.objects['Cmd_text']['Text']= "Run (F5)" - scene.objects['Cmd_text'].setVisible(True,False) # FIXME : suppresion de du message + 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(): obj_i.actuators['Steering'].velocity=0 @@ -327,8 +329,8 @@ def terrain_run (): scene.objects['Run-Hl'].setVisible(False,False) scene.objects['Pause']. restorePhysics() scene.objects['Pause-Hl'].setVisible(True,False) - scene.objects['Cmd_text']['Text']= "Pause (F5)" - scene.objects['Cmd_text'].setVisible(True,False) + scene.objects['Cmd-text']['Text']= "Pause (F5)" + scene.objects['Cmd-text'].setVisible(True,False) # Démarrage de la map if scene.objects['Terrain']['thread_run']==False: @@ -394,7 +396,7 @@ def terrain_stop (): scene.objects['Stop'].setVisible(False,False) scene.objects['Stop'].suspendPhysics() scene.objects['Stop-Hl'].setVisible(False,False) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) # Fin de la map def terrain_end (): @@ -536,8 +538,8 @@ def sound_set (): scene.objects['Sound-cmd']. restorePhysics() scene.objects['Sound-cmd-Hl'].setVisible(True,False) scene.objects['Commands']['sound']=True - scene.objects['Cmd_text']['Text']= "Mute" - scene.objects['Cmd_text'].setVisible(True,False) + scene.objects['Cmd-text']['Text']= "Mute" + scene.objects['Cmd-text'].setVisible(True,False) # Maj du fichier de config (sound : data/config/sound -> [0][1].text) ct_config_tree[0][1].text=str(scene.objects['Commands']['sound']) @@ -552,8 +554,8 @@ def sound_unset (): scene.objects['NoSound-cmd']. restorePhysics() scene.objects['NoSound-cmd-Hl'].setVisible(True,False) scene.objects['Commands']['sound']=False - scene.objects['Cmd_text']['Text']= "Unmute" - scene.objects['Cmd_text'].setVisible(True,False) + scene.objects['Cmd-text']['Text']= "Unmute" + scene.objects['Cmd-text'].setVisible(True,False) # Maj du fichier de config (sound : data/config/sound -> [0][1].text) ct_config_tree[0][1].text=str(scene.objects['Commands']['sound']) @@ -594,10 +596,10 @@ def cmd_init(): audiodev.unlock() # UI : Text, ... - scene.objects['Cmd_text'].setVisible(False,False) - scene.objects['Map_text'].setVisible(False,False) - scene.objects['Text_info-1'].setVisible(False,False) - scene.objects['Text_info-2'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) + scene.objects['Points-Map-text'].setVisible(False,False) + scene.objects['Info-1-text'].setVisible(False,False) + scene.objects['Info-2-text'].setVisible(False,False) scene.objects['Tower_construc_mode'].setVisible(False,False) scene.objects['Terrain']['map_run'] = False @@ -663,43 +665,43 @@ def cmd_hl(cont): text=text_hl[obj.name] if obj.name == "Construc" and scene.objects['Terrain']['construct_mode']==True: # Bascule le construct text="Hide tower position" - scene.objects['Cmd_text']['Text']= text - scene.objects['Cmd_text'].setVisible(True,False) + scene.objects['Cmd-text']['Text']= text + scene.objects['Cmd-text'].setVisible(True,False) # Désactivation if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9): if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd": scene.objects[obj.name+'-Hl'].setVisible(False,True) obj.setVisible(True,True) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) # Run et pause if obj.name=="Pause" or obj.name=="Run": if scene.objects['Terrain']['run'] == True: scene.objects['Pause-Hl'].setVisible(False,False) scene.objects['Pause'].setVisible(True,False) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) else: scene.objects['Run-Hl'].setVisible(False,False) scene.objects['Run'].setVisible(True,False) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) # Stop if obj.name=="Stop": if scene.objects['Terrain']['thread_run']==True: scene.objects['Stop-Hl'].setVisible(False,False) scene.objects['Stop'].setVisible(True,False) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) # Sound if obj.name=="NoSound-cmd" and scene.objects['Commands']['sound']==False: scene.objects['NoSound-cmd-Hl'].setVisible(False,False) scene.objects['NoSound-cmd'].setVisible(True,False) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) if obj.name=="Sound-cmd" and scene.objects['Commands']['sound']==True: scene.objects['Sound-cmd-Hl'].setVisible(False,False) scene.objects['Sound-cmd'].setVisible(True,False) - scene.objects['Cmd_text'].setVisible(False,False) + scene.objects['Cmd-text'].setVisible(False,False) # Click sur les commandes def cmd_click (cont): @@ -826,9 +828,9 @@ def manip_init(cont): scene.objects['Points']['init_lx']=scene.objects['Points'].worldPosition.x scene.objects['Points']['init_ly']=scene.objects['Points'].worldPosition.y scene.objects['Points']['init_lz']=scene.objects['Points'].worldPosition.z - scene.objects['Map_text']['init_relativ_lx']=scene.objects['Map_text'].worldPosition.x-scene.objects['Points'].worldPosition.x - scene.objects['Map_text']['init_relativ_ly']=scene.objects['Map_text'].worldPosition.y-scene.objects['Points'].worldPosition.y - scene.objects['Map_text']['init_relativ_lz']=scene.objects['Map_text'].worldPosition.z-scene.objects['Points'].worldPosition.z + scene.objects['Points-Map-text']['init_relativ_lx']=scene.objects['Points-Map-text'].worldPosition.x-scene.objects['Points'].worldPosition.x + scene.objects['Points-Map-text']['init_relativ_ly']=scene.objects['Points-Map-text'].worldPosition.y-scene.objects['Points'].worldPosition.y + scene.objects['Points-Map-text']['init_relativ_lz']=scene.objects['Points-Map-text'].worldPosition.z-scene.objects['Points'].worldPosition.z # Atteindre une orientation (bas niveau) def applyRotationTo(obj, rx=None, ry=None, rz=None, Local=True): @@ -873,7 +875,7 @@ def manip_reset(): scene.objects['Points'].worldPosition.y = scene.objects['Points']['init_ly'] scene.objects['Points'].worldPosition.z = scene.objects['Points']['init_lz'] applyRotationTo(scene.objects['Terrain'], 0, 0, 0) - scene.objects['Cmd_text']['Text']= "" + scene.objects['Cmd-text']['Text']= "" # Position de départ pour la manipulation de la vue def manip_start(cont): @@ -1113,13 +1115,13 @@ def about_open(): scene.objects['About_title'].color = color_black scene.objects['About_text'].color = color_black scene.objects['About_copyright'].color = color_black - scene.objects['About_link_git'].color= color_link - scene.objects['About_link_gpl'].color= color_link - # scene.objects['About_link_blender'].color= color_link - scene.objects['About_link_upbge'].color= color_link - scene.objects['About_link_kay'].color= color_link - scene.objects['About_link_kenney'].color= color_link - scene.objects['About_ok'].color= color_link + scene.objects['About_link-git'].color= color_link + scene.objects['About_link-gpl'].color= color_link + # scene.objects['About_link-blender'].color= color_link + scene.objects['About_link-upbge'].color= color_link + scene.objects['About_link-kay'].color= color_link + scene.objects['About_link-kenney'].color= color_link + scene.objects['About_close'].color= color_link scene.objects['About'].setVisible(True,True) scene.objects['About'].worldPosition = [0, 1.53623, -1.8] # old [0, 1.53623, -0.892838] scene.objects['About']['timer'] = 0 @@ -1150,7 +1152,7 @@ def about_hl(cont): # dist= scene.objects['Mouse_main'].getDistanceTo(scene.objects['Camera']) # scene.objects['Mouse_main'].worldScale *= (dist/dist_past) *size_scale scene.objects['Aboutbanner'].color = color_white - scene.objects['About_ok'].color = color_white + scene.objects['About_close'].color = color_white scene.objects['About_title'].color = color_white # scene.objects['Mouse_main'].worldScale=[8, 8, 8] # print("about_hl A après", scene.objects['Mouse_main'].worldPosition) @@ -1166,7 +1168,7 @@ def about_hl(cont): # dist= scene.objects['Mouse_main'].getDistanceTo(scene.objects['Camera']) # scene.objects['Mouse_main'].worldScale /= (dist_past/dist) *size_scale scene.objects['Aboutbanner'].color = color_endbanner_bluelight - scene.objects['About_ok'].color = color_link + scene.objects['About_close'].color = color_link scene.objects['About_title'].color = color_black # scene.objects['Mouse_main'].worldScale=[30, 30, 30] # print("about_hl R après", scene.objects['Mouse_main'].worldPosition) @@ -1191,12 +1193,12 @@ def about_link(cont): obj = cont.owner name=obj.name[:-7] link={ - 'About_link_git' : 'https://gitlab.com/phroy/codetower', - 'About_link_gpl' : 'https://www.gnu.org/licenses/gpl-3.0.html', - 'About_link_blender': 'https://www.blender.org', - 'About_link_upbge' : 'https://www.upbge.org', - 'About_link_kay' : 'https://www.kaylousberg.com', - 'About_link_kenney' : 'https://www.kenney.nl'} + 'About_link-git' : 'https://gitlab.com/phroy/codetower', + 'About_link-gpl' : 'https://www.gnu.org/licenses/gpl-3.0.html', + 'About_link-blender': 'https://www.blender.org', + 'About_link-upbge' : 'https://www.upbge.org', + 'About_link-kay' : 'https://www.kaylousberg.com', + 'About_link-kenney' : 'https://www.kenney.nl'} webbrowser.open(link [name]) # FIXME: souris graphique trop compliqué diff --git a/ct_config.xml b/ct_config.xml index d6a9fea..cd730e0 100644 --- a/ct_config.xml +++ b/ct_config.xml @@ -1,6 +1,6 @@ - 2.0 - False + 4.0 + True \ No newline at end of file diff --git a/ct_lib.py b/ct_lib.py index 7c11c31..7434e83 100644 --- a/ct_lib.py +++ b/ct_lib.py @@ -173,7 +173,7 @@ def sound_play (sound): ############################################################################### # Minion caracteristics : category (class), level, hp, speed, armor, bounty, lifes_damage -# Minion 3d object : body (male,female,old, ...), variante (A,B,C,D, ...), level +# Minion 3d body : body (male,female,old, ...), variante (A,B,C,D, ...), level # Création d'un minion def ct_minion_create(x,y,cat,level): @@ -299,17 +299,17 @@ def scn_minion_affect(cont): # Tower caracteristics : category (class), damage, speed, range # Création d'une tour -def ct_build(x,y, cat='Archer tower', tower_name="Tower", color=tower_purple, tower_3d="square-A"): +def ct_build(x,y, cat='Archer tower', tower_name="Tower", color=tower_purple, building="square-A"): tower_minion_3d= scene.objects['Terrain']['tower_minion_3d'] if cat=='Archer tower': # Archer category="Archer-lv1" if cat=='Mage tower': # Mage category="Mage-lv1" body = random.choice(tower_minion_3d[category][0])+"_"+random.choice(tower_minion_3d[category][1])+"_"+random.choice(tower_minion_3d[category][2]) - ct_build_details(x,y, cat, tower_name, color, tower_3d, body) + return (ct_build_details(x,y, cat, tower_name, color, building, body)) # Création d'une tour détaillée -def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_purple, tower_3d="square-A", body="Archer_m_A_common"): +def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_purple, building="square-A", body="Archer_m_A_common"): # Vérification de la place if [x,y] in scene.objects['Terrain']['scene_tile_noncontruct'] or [x,y] in scene.objects['Terrain']['scene_tile_tower']: @@ -329,11 +329,12 @@ def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_pu # Objets 3D time.sleep(0.02) - tour= scene.addObject('Tower-'+tower_3d, scene.objects['Terrain']) + tour= scene.addObject('Tower-'+building, scene.objects['Terrain']) time.sleep(0.02) tour.color = color tour.worldPosition=[x,y,0.2] tour.worldScale=[1,1,1] + 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 @@ -341,6 +342,23 @@ def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_pu tower_minion.worldPosition=[x,y,1] tower_minion.worldScale=[0.25,0.25,0.25] + # Draw3d + if cat=='Archer tower': + bullet1= scene.addObject("Bullet", scene.objects['Terrain']) + bullet1.name="tower("+str(x)+','+str(y)+")-bullet1" # Tower bullet 1 (tb) + bullet1.mass=0.001 + bullet1.worldPosition=[x,y,1.5] + bullet1.worldScale=[0.75,0.75,0.75] + bullet1.suspendPhysics (True) + bullet1.setVisible(False) + bullet2= scene.addObject("Bullet", scene.objects['Terrain']) + bullet2.name="tower("+str(x)+','+str(y)+")-bullet2" # Tower bullet 2 (tb) + bullet2.mass=0.001 + bullet2.worldPosition=[x,y,1.5] + bullet2.worldScale=[0.75,0.75,0.75] + bullet2.suspendPhysics (True) + bullet2.setVisible(False) + # Sounds sound_play(sndbuff_build) @@ -435,7 +453,6 @@ def scn_tower_near(cont): # for obj_i in sensor.hitObjectList: # obj['target_past'].append([obj_i.name, obj.getDistanceTo(obj_i)]) - # Orientation du tower minion towerminion="tm("+str(round(obj.worldPosition.x))+','+str(round(obj.worldPosition.y))+")" angle =math.atan((target.worldPosition.y-obj.worldPosition.y)/(target.worldPosition.x-obj.worldPosition.x)) @@ -471,19 +488,21 @@ def scn_tower_near(cont): # Archer (tir de flêche) if obj['cat']=="Archer tower": if target.name in scene.objects: - scene.objects['Terrain']['draw_process']=True - scene.objects['Terrain']['draw_list'].append([5, "arrow", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8],target.name, angle3, ray_black, 5]) + # scene.objects['Terrain']['draw2d_process']=True + # scene.objects['Terrain']['draw2d_list'].append([5, "arrow", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8],target.name, angle3, ray_black, 5]) + scene.objects['Terrain']['draw3d_process']=True + scene.objects['Terrain']['draw3d_list'].append([5, "arrow", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8], obj.name, target.name, angle3, ray_black, 5]) # Cast zone if obj['cat']=="Mage tower": # Mage (cast) - scene.objects['Terrain']['draw_process']=True - scene.objects['Terrain']['draw_list'].append([30, "cast", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8],ray_blue,30]) + scene.objects['Terrain']['draw2d_process']=True + scene.objects['Terrain']['draw2d_list'].append([30, "cast", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8],ray_blue,30]) # Rayon if obj['cat']=="Test": if target.name in scene.objects: - scene.objects['Terrain']['draw_process']=True - scene.objects['Terrain']['draw_list'].append([5, "ray", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8], target.name, angle3, ray_yellow,5]) # Suivi du minion + scene.objects['Terrain']['draw2d_process']=True + scene.objects['Terrain']['draw2d_list'].append([5, "ray", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8], target.name, angle3, ray_yellow,5]) # Suivi du minion # Dégats target['hp'] = target['hp'] - obj['damage'] @@ -501,16 +520,16 @@ def scn_tower_near(cont): # Texte de carte def ct_map_text_wave(wave): - scene.objects['Map_text']['Text']=("Wave " + str(wave)) - scene.objects['Map_text'].setVisible(True,False) - scene.objects['Map_text'].color = color_text_yellow - scene.objects['Map_text']['timer']=0 - scene.objects['Map_text']['anim']=True + scene.objects['Points-Map-text']['Text']=("Wave " + str(wave)) + scene.objects['Points-Map-text'].setVisible(True,False) + scene.objects['Points-Map-text'].color = color_text_yellow + scene.objects['Points-Map-text']['timer']=0 + scene.objects['Points-Map-text']['anim']=True # Texte de carte def ct_map_text(text): - scene.objects['Map_text']['Text']=text - scene.objects['Map_text'].setVisible(True,False) + scene.objects['Points-Map-text']['Text']=text + scene.objects['Points-Map-text'].setVisible(True,False) # Fin def ct_map_end(x,y): @@ -602,19 +621,93 @@ def ct_sleep (duration): def ct_print (text): # text_info (texte) if text=="": - scene.objects['Text_info-1'].setVisible(False,False) - scene.objects['Text_info-2'].setVisible(False,False) + scene.objects['Info-1-text'].setVisible(False,False) + scene.objects['Info-2-text'].setVisible(False,False) else: lines_txt=text.split("\n", 6) for i in range (len(lines_txt),6): lines_txt.append("") - scene.objects['Text_info-1'].setVisible(True,False) - scene.objects['Text_info-2'].setVisible(True,False) - scene.objects['Text_info-1']['Text']=lines_txt[0]+"\n"+lines_txt[1]+"\n"+lines_txt[2] - scene.objects['Text_info-2']['Text']=lines_txt[3]+"\n"+lines_txt[4]+"\n"+lines_txt[5] + scene.objects['Info-1-text'].setVisible(True,False) + scene.objects['Info-2-text'].setVisible(True,False) + scene.objects['Info-1-text']['Text']=lines_txt[0]+"\n"+lines_txt[1]+"\n"+lines_txt[2] + scene.objects['Info-2-text']['Text']=lines_txt[3]+"\n"+lines_txt[4]+"\n"+lines_txt[5] ############################################################################### -# Dessin bas niveau (bge.render.drawLine) +# Dessin 3d +############################################################################### + +# scene.objects['Terrain']['draw3d_list'].append([5, "arrow", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8], obj.name, target.name, angle3, ray_black, 5]) + +def scn_draw3d(cont): + obj = cont.owner + if obj.sensors['Draw3d'].positive==False: + return + if len(scene.objects['Terrain']['draw3d_list'])==0: + scene.objects['Terrain']['draw3d_process']=False + return + + # Dépilage des draws à executer + for draw_cmd in scene.objects['Terrain']['draw3d_list']: + + # Archer (tir de flêche) + if draw_cmd[1]=="arrow": + if draw_cmd[3] in scene.objects: + bullet1.name=draw_cmd[3]+"-bullet1" + if scene.objects['Terrain']['speed']<1: + draw_cmd[0] = draw_cmd[0]-scene.objects['Terrain']['speed'] + else: + draw_cmd[0] = draw_cmd[0]-1 + + + bullet1.name="tower("+str(x)+','+str(y)+")-bullet1" # Tower bullet 1 (tb) + + # bullet= scene.addObject("Bullet", scene.objects['Terrain']) + # bullet.mass=0.001 # bullet.applyForce=((0,0,9.81),True) + # bullet.worldPosition=[obj.worldPosition.x,obj.worldPosition.y,1.5] + # bullet.worldScale=[0.75,0.75,0.75] + # # bullet.worldScale=[0.5,0.5,0.5] + # bullet.worldLinearVelocity.x = (target.worldPosition.x-bullet.worldPosition.x)*bullet['velocity'] + # bullet.worldLinearVelocity.y= (target.worldPosition.y-bullet.worldPosition.y)*bullet['velocity'] + # bullet.worldLinearVelocity.z = (target.worldPosition.z+0.1-bullet.worldPosition.z)*bullet['velocity'] + + # # x0 = draw_cmd[2][0]+0.25*(math.cos(draw_cmd[4])) + # # y0 = draw_cmd[2][1]+0.25*(math.sin(draw_cmd[4])) + # x0 = draw_cmd[2][0] + # y0 = draw_cmd[2][1] + # z0 = draw_cmd[2][2] + # x1 = scene.objects[draw_cmd[3]].worldPosition.x + # y1 = scene.objects[draw_cmd[3]].worldPosition.y + # z1 = scene.objects[draw_cmd[3]].worldPosition.z-0.1 # ajustement -0.1 + # distance = math.sqrt((x1-x0)**2+(y1-y0)**2+(z1-z0)**2) + # distance_xy = math.sqrt((x1-x0)**2+(y1-y0)**2) + # distance_z = z1-z0 + # angle_z =math.atan((z1-z0)/(distance_xy)) + # angle_xy =math.atan((y1-y0)/(x1-x0)) + # step=distance_xy/(2+draw_cmd[6]) + # step_z=distance_z/(2+draw_cmd[6]) + # if x1>x0: + # angle2=angle_xy + # else: + # angle2=math.pi+angle_xy + # x2=x0+(((6-draw_cmd[0])*step)*(math.cos(angle2))) + # y2=y0+(((6-draw_cmd[0])*step)*(math.sin(angle2))) + # z2=z0-(((6-draw_cmd[0])*step_z)*(math.sin(angle_z))) + # x3=x0+(((6-draw_cmd[0])*step+step)*(math.cos(angle2))) + # y3=y0+(((6-draw_cmd[0])*step+step)*(math.sin(angle2))) + # z3=z0-(((6-draw_cmd[0])*step_z+step_z)*(math.sin(angle_z))) + # bge.render.drawLine([x2,y2, z2], [x3,y3,z3], draw_cmd[5]) + # draw_cmd[0] = draw_cmd[0]-scene.objects['Terrain']['speed'] + # # if scene.objects['Terrain']['speed']<1: + # # draw_cmd[0] = draw_cmd[0]-scene.objects['Terrain']['speed'] + # # else: + # # draw_cmd[0] = draw_cmd[0]-1 + # # bge.render.drawLine([draw_cmd[2][0]+((6-draw_cmd[0])*0.25)*(math.cos(draw_cmd[4])), draw_cmd[2][1]+((6-draw_cmd[0])*0.25)*(math.sin(draw_cmd[4])),draw_cmd[2][2]], + # # [draw_cmd[2][0]+((6-draw_cmd[0])*0.25+0.25)*(math.cos(draw_cmd[4])), draw_cmd[2][1]+((6-draw_cmd[0])*0.25+0.25)*(math.sin(draw_cmd[4])),draw_cmd[2][2]], + # # draw_cmd[5]) + + +############################################################################### +# Dessin 2d (bge.render.drawLine) ############################################################################### def circle (center, radius, color): @@ -629,23 +722,23 @@ def circle (center, radius, color): bge.render.drawLine([x0,y0,center[2]],[x1,y1,center[2]],color) ang += ang_step -# Affiche les draws en cours +# Affiche les draws 2d en cours # -# Type de draw : +# Type de draw 2d: # arrow : [5, "arrow", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8],target.name, angle3, ray_yellow,5] # cast : [30, "cast", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8], ray_blue,30] # ray : [5, "ray", [obj.worldPosition.x, obj.worldPosition.y, obj.worldPosition.z+0.8],[target.worldPosition.x, target.worldPosition.y, target.worldPosition.z], angle3, ray_yellow,5] # -def scn_draw(cont): +def scn_draw2d(cont): obj = cont.owner - if obj.sensors['Draw'].positive==False: + if obj.sensors['Draw2d'].positive==False: return - if len(scene.objects['Terrain']['draw_list'])==0: - scene.objects['Terrain']['draw_process']=False + if len(scene.objects['Terrain']['draw2d_list'])==0: + scene.objects['Terrain']['draw2d_process']=False return # Dépilage des draws à executer - for draw_cmd in scene.objects['Terrain']['draw_list']: + for draw_cmd in scene.objects['Terrain']['draw2d_list']: # Archer (tir de flêche) if draw_cmd[1]=="arrow": @@ -715,10 +808,10 @@ def scn_draw(cont): # Suppression des draws finis i=0 - for draw_cmd in scene.objects['Terrain']['draw_list']: + for draw_cmd in scene.objects['Terrain']['draw2d_list']: if draw_cmd[0]<=0: - scene.objects['Terrain']['draw_list'].pop(i) + scene.objects['Terrain']['draw2d_list'].pop(i) else: i=i+1 - if len(scene.objects['Terrain']['draw_list'])==0: - scene.objects['Terrain']['draw_process']=False + if len(scene.objects['Terrain']['draw2d_list'])==0: + scene.objects['Terrain']['draw2d_process']=False diff --git a/ct_map1.py b/ct_map1.py index fa50d6c..565ef86 100644 --- a/ct_map1.py +++ b/ct_map1.py @@ -129,8 +129,6 @@ 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") 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]) @@ -143,7 +141,6 @@ def wave2(): wave_minion_name=[] for i in range (20): 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) @@ -155,8 +152,6 @@ def wave3(): wave_minion_name=[] for i in range (30): 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) @@ -168,7 +163,6 @@ def wave4(): wave_minion_name_group1=[] wave_minion_name_group2=[] for i in range (20): - # ct_minion(14,3,"Orc",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)): @@ -225,7 +219,7 @@ def map_init(): directory=os.path.join(file_path, inner_path), filename=object_name) - # Ajout des sorties + # Exit scene.objects['Terrain']['endtile'] = "tile_straight.036" ct_map_end(1,-10) ct_map_endflag(0.5,-10) diff --git a/doc/UML-class.png b/doc/UML-class.png index 9e6da0e..dfb58a1 100644 Binary files a/doc/UML-class.png and b/doc/UML-class.png differ