mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Bugfix du store.
This commit is contained in:
parent
706c874fd1
commit
39d2183fd3
BIN
ropy-20.blend
Normal file
BIN
ropy-20.blend
Normal file
Binary file not shown.
199
rp.py
199
rp.py
@ -13,6 +13,7 @@ import runpy
|
||||
|
||||
import rp_map1 as rp_map # Map definition
|
||||
import rp_doc # Documentation
|
||||
import rp_store # Store
|
||||
# import ct_cmd # user script (commands)
|
||||
|
||||
###############################################################################
|
||||
@ -100,7 +101,7 @@ def points_maj (cont):
|
||||
if scene.objects['Points-Nbligne-text']['Text']!=str(scene.objects['Points']['nbligne']):
|
||||
scene.objects['Points-Nbligne-text']['Text']=str(scene.objects['Points']['nbligne'])
|
||||
|
||||
# Position du rover
|
||||
# Position du Rover
|
||||
obj=scene.objects['Rover']
|
||||
obj['position']=str(obj.worldPosition.x)+","+str(obj.worldPosition.y)+","+str(obj.worldPosition.z)
|
||||
|
||||
@ -144,8 +145,7 @@ def terrain_init ():
|
||||
|
||||
# Création des balises
|
||||
scene.objects['Terrain']['map_tile_beacon']= []
|
||||
# for i in range (500):
|
||||
for i in range (100):
|
||||
for i in range (200):
|
||||
beacon= scene.addObject("Beacon", scene.objects['Terrain'])
|
||||
beacon.worldPosition=[29,1+i,0.2]
|
||||
beacon.setVisible(False,True)
|
||||
@ -157,6 +157,7 @@ def terrain_init ():
|
||||
# Read config (mission actuelle : data/mission/current -> [1][0].text)
|
||||
scene.objects['Points']['mission']=int(rp_config_tree[1][0].text)
|
||||
rp_map.map_init()
|
||||
scene.objects['Terrain']['thread_cmd']=False
|
||||
rp_map.map_reset()
|
||||
|
||||
# Récupération de la position de la caméra
|
||||
@ -188,8 +189,8 @@ def terrain_run ():
|
||||
scene.objects['Run'].setVisible(False,False)
|
||||
scene.objects['Run'].suspendPhysics()
|
||||
scene.objects['Run-Hl'].setVisible(False,False)
|
||||
scene.objects['Pause']. restorePhysics()
|
||||
scene.objects['Pause'].setVisible(True,False)
|
||||
# scene.objects['Pause']. restorePhysics() # FIXME pause pas implémenté
|
||||
# scene.objects['Pause'].setVisible(True,False) # FIXME pause pas implémenté
|
||||
|
||||
# Démarrage de la map
|
||||
if scene.objects['Terrain']['thread_cmd']==False:
|
||||
@ -273,22 +274,21 @@ def terrain_grid ():
|
||||
bpy.data.materials["Grid-Yellow"].node_tree.nodes["Shader de mélange"].inputs[0].default_value = 0
|
||||
bpy.data.materials["Grid-Green"].node_tree.nodes["Shader de mélange"].inputs[0].default_value = 0
|
||||
bpy.data.materials["Grid-Holo"].node_tree.nodes["Émission"].inputs[1].default_value = 0
|
||||
# bpy.data.materials["Grid-Holo-Yellow"].node_tree.nodes["Émission"].inputs[1].default_value = 5
|
||||
# bpy.data.materials["Grid"].node_tree.nodes["Emission"].inputs[1].default_value =scene.objects['Grid-u']['timer']
|
||||
bpy.data.materials["Grid-Holo-Yellow"].node_tree.nodes["Émission.003"].inputs[1].default_value = 0
|
||||
bpy.data.materials["Grid-Holo-Green"].node_tree.nodes["Émission"].inputs[1].default_value = 0
|
||||
scene.objects['Grid-u'].setVisible(True,True)
|
||||
scene.objects['Grid-v'].setVisible(True,True)
|
||||
scene.objects['Grid-u']['anim'] = True
|
||||
|
||||
def terrain_grid_anim ():
|
||||
rp_map.aim_show()
|
||||
bpy.data.materials["Grid"].node_tree.nodes["Shader de mélange"].inputs[0].default_value=scene.objects['Grid-u']['timer']
|
||||
bpy.data.materials["Grid-Yellow"].node_tree.nodes["Shader de mélange"].inputs[0].default_value=scene.objects['Grid-u']['timer']
|
||||
bpy.data.materials["Grid-Green"].node_tree.nodes["Shader de mélange"].inputs[0].default_value=scene.objects['Grid-u']['timer']
|
||||
bpy.data.materials["Grid-Holo"].node_tree.nodes["Émission"].inputs[1].default_value =scene.objects['Grid-u']['timer']*5
|
||||
# bpy.data.materials["Grid-Holo-Yellow"].node_tree.nodes["Émission"].inputs[1].default_value =scene.objects['Grid-u']['timer']*5
|
||||
# bpy.data.materials["Grid"].node_tree.nodes["Emission"].inputs[1].default_value =scene.objects['Grid-u']['timer']
|
||||
bpy.data.materials["Grid-Holo-Yellow"].node_tree.nodes["Émission.003"].inputs[1].default_value =scene.objects['Grid-u']['timer']*5
|
||||
bpy.data.materials["Grid-Holo-Green"].node_tree.nodes["Émission"].inputs[1].default_value =scene.objects['Grid-u']['timer']*5
|
||||
scene.objects['Grid-u']['timer']+=0.01
|
||||
if scene.objects['Grid-u']['timer']>= 0.05 and scene.objects['Grid-u'].visible :
|
||||
rp_map.aim_show()
|
||||
if scene.objects['Grid-u']['timer']>= 1:
|
||||
scene.objects['Grid-u']['anim'] = False
|
||||
|
||||
@ -359,6 +359,8 @@ def cmd_init():
|
||||
scene.objects['Store-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['ResetView-Hl'].setVisible(False,False)
|
||||
scene.objects['About-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['Speed_up-Hl'].setVisible(False,False)
|
||||
scene.objects['Speed_down-Hl'].setVisible(False,False)
|
||||
|
||||
# UI : Sounds
|
||||
# Read config (sound : data/config/sound -> [0][1].text)
|
||||
@ -397,7 +399,10 @@ def cmd_init():
|
||||
# Read config (game speed : data/config/speed -> [0][0].text)
|
||||
speed_mode=[0.25, 0.5, 1,2,4,10]
|
||||
speed_mode_txt=["1/4", "1/2", "1", "2","4","10"]
|
||||
scene.objects['Commands']['speed']=float(rp_config_tree[0][0].text)
|
||||
if scene.objects['Points']['upgrade_speed'] :
|
||||
scene.objects['Commands']['speed']=float(rp_config_tree[0][0].text)
|
||||
else:
|
||||
scene.objects['Commands']['speed']=1.00
|
||||
i=speed_mode.index(scene.objects['Commands']['speed'])
|
||||
scene.objects['Text_speed']['Text']=speed_mode_txt[i]
|
||||
|
||||
@ -411,12 +416,15 @@ def cmd_init():
|
||||
scene.objects['Book_mission']['Text'] = "Mission en cours : "+str(scene.objects['Points']['mission'])
|
||||
scene.objects['Book_level']['Text'] = "Niveau actuel : "+str(scene.objects['Points']['level'])
|
||||
|
||||
# Upgrade
|
||||
upgrade_maj()
|
||||
|
||||
# Windows
|
||||
windows=("Doc", "Doc_chap-general", "Doc_chap-missions", "Doc_chap-rover", "Doc_chap-python", "About")
|
||||
for window in windows:
|
||||
scene.objects[window].setVisible(False,True)
|
||||
rp_doc.init()
|
||||
|
||||
rp_store.init()
|
||||
|
||||
##
|
||||
# Highlight des commandes
|
||||
@ -434,8 +442,9 @@ def cmd_hl(cont):
|
||||
# Run et pause
|
||||
if obj.name=="Pause" or obj.name=="Run":
|
||||
if scene.objects['Terrain']['run'] == True:
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
scene.objects['Pause-Hl'].setVisible(True,False)
|
||||
pass
|
||||
# scene.objects['Pause'].setVisible(False,False) FIXME pause pas implémenté
|
||||
# scene.objects['Pause-Hl'].setVisible(True,False) FIXME pause pas implémenté
|
||||
else:
|
||||
scene.objects['Run'].setVisible(False,False)
|
||||
scene.objects['Run-Hl'].setVisible(True,False)
|
||||
@ -483,8 +492,9 @@ def cmd_hl(cont):
|
||||
# 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)
|
||||
pass
|
||||
# scene.objects['Pause-Hl'].setVisible(False,False) FIXME pause pas implémenté
|
||||
# scene.objects['Pause'].setVisible(True,False) FIXME pause pas implémenté
|
||||
else:
|
||||
scene.objects['Run-Hl'].setVisible(False,False)
|
||||
scene.objects['Run'].setVisible(True,False)
|
||||
@ -541,9 +551,9 @@ def cmd_click (cont):
|
||||
if obj.name=="About-cmd":
|
||||
sound_play (snd_open)
|
||||
about_open ()
|
||||
# if obj.name=="Store-cmd":
|
||||
# sound_play (snd_open)
|
||||
# print ("Store")
|
||||
if obj.name=="Store-cmd":
|
||||
sound_play (snd_open)
|
||||
store_open ()
|
||||
|
||||
|
||||
###############################################################################
|
||||
@ -632,9 +642,11 @@ def mode(cont):
|
||||
|
||||
# Touche +/- du pad -> Vitesse + ou /
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.PADPLUSKEY].queue:
|
||||
terrain_speed (scene.objects['Speed_up'])
|
||||
if scene.objects['Points']['upgrade_speed'] :
|
||||
terrain_speed (scene.objects['Speed_up'])
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.PADMINUS].queue:
|
||||
terrain_speed (scene.objects['Speed_down'])
|
||||
if scene.objects['Points']['upgrade_speed'] :
|
||||
terrain_speed (scene.objects['Speed_down'])
|
||||
|
||||
###############################################################################
|
||||
# Manipulation 3D de la scène
|
||||
@ -873,6 +885,8 @@ def mouse_down():
|
||||
##
|
||||
|
||||
def tablet_open ():
|
||||
|
||||
# Fenêtre
|
||||
scene.objects['Terrain']['manip_mode']=8 # Fenêtre modale Aide
|
||||
scene.objects['Camera']['current_lx'] = scene.objects['Camera'].worldPosition.x
|
||||
scene.objects['Camera']['current_ly'] = scene.objects['Camera'].worldPosition.y
|
||||
@ -894,12 +908,10 @@ def tablet_open ():
|
||||
rp_doc.open()
|
||||
|
||||
##
|
||||
# Enteindre la tablette
|
||||
# Fermeture de la tablette
|
||||
##
|
||||
|
||||
def tablet_close ():
|
||||
|
||||
# Fermeture de la tablette
|
||||
rp_doc.close()
|
||||
scene.objects['Terrain']['manip_mode']=0 # Enlever la fenêtre modale
|
||||
|
||||
@ -928,14 +940,8 @@ def tablet_close ():
|
||||
scene.objects['Doc-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['ResetView-Hl'].setVisible(False,False)
|
||||
scene.objects['About-cmd-Hl'].setVisible(False,False)
|
||||
|
||||
# UI : Sounds
|
||||
# Read config (sound : data/config/sound -> [0][1].text)
|
||||
if rp_config_tree[0][1].text == "True":
|
||||
sound_set ()
|
||||
else:
|
||||
sound_unset ()
|
||||
# audiodev.unlock()
|
||||
scene.objects['Speed_up-Hl'].setVisible(False,False)
|
||||
scene.objects['Speed_down-Hl'].setVisible(False,False)
|
||||
scene.objects['Cmd-text'].setVisible(False,False)
|
||||
|
||||
# Camera
|
||||
@ -959,6 +965,132 @@ def tablet_close_click(cont):
|
||||
sound_play (snd_close)
|
||||
tablet_close()
|
||||
|
||||
###############################################################################
|
||||
# Store
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Prendre en compte les upgrades
|
||||
##
|
||||
|
||||
def upgrade_maj():
|
||||
|
||||
# Read config (upgrades choisis : data/upgrade/ -> [2][i].text)
|
||||
upgrade_card=("battery", "beacon", "paint", "speed")
|
||||
scene.objects['Points']['upgrade_nb'] =0
|
||||
for i in range(len(upgrade_card)):
|
||||
if rp_config_tree[2][i].text == "True":
|
||||
scene.objects['Points']['upgrade_'+upgrade_card[i]]=True
|
||||
scene.objects['Points']['upgrade_nb'] +=1
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] = True
|
||||
scene.objects['Points']['upgrade_credit']= scene.objects['Points']['level']- 1 - scene.objects['Points']['upgrade_nb']
|
||||
|
||||
# Batterie
|
||||
# FIXME : autonomie non gérée
|
||||
if scene.objects['Points']['upgrade_battery'] :
|
||||
scene.objects['Panels_upgrade'].setVisible(True,True)
|
||||
else:
|
||||
scene.objects['Panels_upgrade'].setVisible(False,True)
|
||||
|
||||
# Balise, voir rp_marquer ()
|
||||
if scene.objects['Points']['upgrade_beacon'] :
|
||||
scene.objects['Cubes_upgrade'].setVisible(True,True)
|
||||
else:
|
||||
scene.objects['Cubes_upgrade'].setVisible(False,True)
|
||||
|
||||
# Peinture
|
||||
# FIXME : pas de fontion de peinture
|
||||
|
||||
# Vitesse
|
||||
if scene.objects['Points']['upgrade_speed'] :
|
||||
scene.objects['Text_speed'].setVisible(True,True)
|
||||
scene.objects['Text_speed_label-fr'].setVisible(True,True)
|
||||
scene.objects['Speed_down'].setVisible(True,True)
|
||||
scene.objects['Speed_down']. restorePhysics()
|
||||
scene.objects['Speed_up'].setVisible(True,True)
|
||||
scene.objects['Speed_up']. restorePhysics()
|
||||
else:
|
||||
scene.objects['Text_speed'].setVisible(False,True)
|
||||
scene.objects['Text_speed_label-fr'].setVisible(False,True)
|
||||
scene.objects['Speed_down'].setVisible(False,True)
|
||||
scene.objects['Speed_down'].suspendPhysics()
|
||||
scene.objects['Speed_up'].setVisible(False,True)
|
||||
scene.objects['Speed_up'].suspendPhysics()
|
||||
|
||||
##
|
||||
# Ouvrir le store
|
||||
##
|
||||
|
||||
def store_open ():
|
||||
upgrade_maj()
|
||||
if scene.objects['Grid-u'].visible:
|
||||
scene.objects['Store']['Grid_visible'] = True
|
||||
terrain_grid()
|
||||
else:
|
||||
scene.objects['Store']['Grid_visible'] = False
|
||||
|
||||
|
||||
rp_store.open()
|
||||
|
||||
##
|
||||
# Fermer le store
|
||||
##
|
||||
|
||||
def store_close():
|
||||
rp_store.close()
|
||||
scene.objects['Terrain']['manip_mode']=0 # Enlever la fenêtre modale
|
||||
|
||||
# Maj du fichier de config (upgrade : data/upgrade/i -> [2][i].text)
|
||||
upgrade_card=("battery", "beacon", "paint", "speed")
|
||||
for i in range(len(upgrade_card)):
|
||||
if scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] == True:
|
||||
rp_config_tree[2][i].text="True"
|
||||
else:
|
||||
rp_config_tree[2][i].text="False"
|
||||
buffer_xml = ET.tostring(rp_config_tree)
|
||||
with open("rp_config.xml", "wb") as f:
|
||||
f.write(buffer_xml)
|
||||
|
||||
# Overlay
|
||||
scene.objects['Points'].setVisible(True,True)
|
||||
scene.objects['Commands'].setVisible(True,True)
|
||||
scene.objects['Camera'].setVisible(True,True)
|
||||
scene.active_camera = scene.objects["Camera"]
|
||||
scene.addOverlayCollection(scene.cameras['Camera-Hud'], bpy.data.collections['Hud'])
|
||||
|
||||
# UI : Commands
|
||||
scene.objects['Run-Hl'].setVisible(False,False)
|
||||
scene.objects['Pause'].setVisible(False,False)
|
||||
scene.objects['Pause'].suspendPhysics()
|
||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
||||
# scene.objects['Stop'].setVisible(False,False)
|
||||
# scene.objects['Stop'].suspendPhysics()
|
||||
scene.objects['Stop-Hl'].setVisible(False,False)
|
||||
scene.objects['Aim-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['Doc-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['ResetView-Hl'].setVisible(False,False)
|
||||
scene.objects['About-cmd-Hl'].setVisible(False,False)
|
||||
scene.objects['Speed_up-Hl'].setVisible(False,False)
|
||||
scene.objects['Speed_down-Hl'].setVisible(False,False)
|
||||
scene.objects['Cmd-text'].setVisible(False,False)
|
||||
|
||||
# Maj de l'interface
|
||||
upgrade_maj()
|
||||
|
||||
# Affichage de la grille + mission
|
||||
if scene.objects['Store']['Grid_visible']:
|
||||
terrain_grid()
|
||||
|
||||
|
||||
##
|
||||
# Clic pour fermer le store
|
||||
##
|
||||
|
||||
def store_close_click(cont):
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
sound_play (snd_close)
|
||||
store_close()
|
||||
|
||||
###############################################################################
|
||||
# About
|
||||
###############################################################################
|
||||
@ -1034,7 +1166,6 @@ def about_close():
|
||||
scene.objects['Terrain']['manip_mode']=0
|
||||
scene.objects['About'].setVisible(False,True)
|
||||
scene.objects['About'].worldPosition = [42, -2, 3]
|
||||
scene.objects['About']['timer']= 0
|
||||
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['current_lx']
|
||||
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['current_ly']
|
||||
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['current_lz']
|
||||
|
15
rp_cmd.py
15
rp_cmd.py
@ -40,15 +40,18 @@ def mrp_avancer_mur():
|
||||
|
||||
def commandes():
|
||||
|
||||
print("Go !!")
|
||||
rp_marquer()
|
||||
rp_gauche()
|
||||
mrp_avancer_mur()
|
||||
rp_droite()
|
||||
# rp_marquer()
|
||||
# rp_gauche()
|
||||
# mrp_avancer_mur()
|
||||
# rp_gauche()
|
||||
|
||||
# mrp_avancer()
|
||||
# rp_gauche()
|
||||
# mrp_avancer()
|
||||
|
||||
mrp_avancer_mur()
|
||||
rp_gauche()
|
||||
mrp_avancer_mur()
|
||||
print ("fin")
|
||||
|
||||
rp_fin()
|
||||
|
||||
|
@ -3,13 +3,19 @@
|
||||
<speed>4.0</speed>
|
||||
<sound>False</sound>
|
||||
<cam>
|
||||
<worldPosition.x>-5.090217113494873</worldPosition.x>
|
||||
<worldPosition.y>-16.436044692993164</worldPosition.y>
|
||||
<worldPosition.z>11.98914909362793</worldPosition.z>
|
||||
<worldPosition.x>-1.3732191324234009</worldPosition.x>
|
||||
<worldPosition.y>-44.52867889404297</worldPosition.y>
|
||||
<worldPosition.z>36.26533126831055</worldPosition.z>
|
||||
</cam>
|
||||
</config>
|
||||
<mission>
|
||||
<current>4</current>
|
||||
<current>6</current>
|
||||
<level>6</level>
|
||||
</mission>
|
||||
<upgrade>
|
||||
<battery>True</battery>
|
||||
<beacon>True</beacon>
|
||||
<paint>False</paint>
|
||||
<speed>True</speed>
|
||||
</upgrade>
|
||||
</data>
|
89
rp_lib.py
89
rp_lib.py
@ -28,6 +28,7 @@ import rp_map1 as rp_map # Map definition
|
||||
###############################################################################
|
||||
|
||||
scene = bge.logic.getCurrentScene()
|
||||
debug_mvt = scene.objects['Terrain']['debug_mvt']
|
||||
|
||||
# Sounds
|
||||
audiodev = aud.Device()
|
||||
@ -35,6 +36,7 @@ snd_click = aud.Sound('asset/sounds/rp_click.ogg')
|
||||
|
||||
# Threads
|
||||
threads_cmd=[]
|
||||
threads_gostore=[]
|
||||
debug_thread = scene.objects['Terrain']['debug_thread']
|
||||
|
||||
# UPBGE constants
|
||||
@ -123,6 +125,12 @@ def thread_cmd_start(fct):
|
||||
def thread_cmd_stop():
|
||||
thread_stop(threads_cmd, "commands")
|
||||
|
||||
def thread_gostore_start(fct):
|
||||
thread_start(threads_gostore, "go store", fct)
|
||||
|
||||
def thread_gostore_stop():
|
||||
thread_stop(threads_gostore, "go store")
|
||||
|
||||
def rp_end():
|
||||
if (debug_thread):
|
||||
print ("Thread commands is arrived.")
|
||||
@ -188,12 +196,13 @@ def rp_avancer ():
|
||||
if obj['stop']:
|
||||
return False
|
||||
|
||||
# Points et console
|
||||
print ("rp_avancer()")
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_avancer()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
|
||||
# Animation rapide
|
||||
if scene.objects['Commands']['speed'] == 10:
|
||||
if scene.objects['Commands']['speed'] == 10 and scene.objects['Points']['step']> 2: # A tendance à planter sur les premiers mouvements en rapide + balisage
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
z0 = obj.worldPosition.z
|
||||
@ -274,8 +283,9 @@ def rp_gauche ():
|
||||
if obj['stop']:
|
||||
return False
|
||||
|
||||
# Points et console
|
||||
print ("rp_gauche()")
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_gauche()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
step=math.pi/2 # Pas angulaire
|
||||
|
||||
@ -319,8 +329,9 @@ def rp_droite ():
|
||||
if obj['stop']:
|
||||
return False
|
||||
|
||||
# Points et console
|
||||
print ("rp_droite()")
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_droite()")
|
||||
scene.objects['Points']['step'] +=1
|
||||
step=math.pi/2 # Pas angulaire
|
||||
|
||||
@ -364,8 +375,9 @@ def rp_marquer ():
|
||||
if obj['stop']:
|
||||
return False
|
||||
|
||||
# Points et console
|
||||
print ("rp_marquer() -> balise #"+ str(len(scene.objects['Terrain']['map_tile_beacon'])))
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_marquer() -> balise #"+ str(len(scene.objects['Terrain']['map_tile_beacon'])))
|
||||
rp_tempo (0.1)
|
||||
x = obj.worldPosition.x
|
||||
y = obj.worldPosition.y
|
||||
@ -376,7 +388,12 @@ def rp_marquer ():
|
||||
print ("Case déjà marquée !")
|
||||
return False
|
||||
|
||||
for i in range (150):
|
||||
# Posage
|
||||
if scene.objects['Points']['upgrade_beacon']:
|
||||
beacon_max= 200
|
||||
else:
|
||||
beacon_max= 20
|
||||
for i in range (beacon_max):
|
||||
beacon = scene.objects["Beacon-"+str(i)]
|
||||
if beacon['activated']==False:
|
||||
beacon.worldPosition=[x,y,0.2]
|
||||
@ -384,10 +401,8 @@ def rp_marquer ():
|
||||
beacon.setVisible(True, True)
|
||||
scene.objects['Terrain']['map_tile_beacon'].append([x,y])
|
||||
break
|
||||
if i ==149 :
|
||||
if i ==beacon_max-1 :
|
||||
print ("Plus de balise disponible !")
|
||||
# beacon= scene.addObject("Beacon", scene.objects['Terrain'])
|
||||
# beacon.worldPosition=[x,y,0.2]
|
||||
rp_tempo (0.1)
|
||||
return True
|
||||
|
||||
@ -402,8 +417,9 @@ def rp_detect ():
|
||||
if obj['stop']:
|
||||
return True
|
||||
|
||||
# Points et console
|
||||
print ("rp_detect")
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_detect")
|
||||
|
||||
# Détection
|
||||
x0 = obj.worldPosition.x
|
||||
@ -422,19 +438,22 @@ def rp_detect ():
|
||||
x1 = x0-1
|
||||
y1 = y0
|
||||
if [x1,y1] in scene.objects['Terrain']['map_tile_montain']:
|
||||
print ("Présence de montage devant !")
|
||||
if (debug_mvt):
|
||||
print ("Présence de montage devant !")
|
||||
if scene.objects['Points']['mission']==3: # Contrôle objectif mission 3
|
||||
rover_goal ()
|
||||
return True
|
||||
|
||||
if [x1,y1] in scene.objects['Terrain']['map_tile_station']:
|
||||
print ("Présence de la station devant !")
|
||||
if (debug_mvt):
|
||||
print ("Présence de la station devant !")
|
||||
if scene.objects['Points']['mission']==3: # Contrôle objectif mission 3
|
||||
rover_goal ()
|
||||
return True
|
||||
|
||||
if [x1,y1] in scene.objects['Terrain']['map_tile_station']:
|
||||
print ("Sortie de carte devant !")
|
||||
if (debug_mvt):
|
||||
print ("Sortie de carte devant !")
|
||||
if scene.objects['Points']['mission']==3: # Contrôle objectif mission 3
|
||||
rover_goal ()
|
||||
return True
|
||||
@ -451,8 +470,9 @@ def rp_prendre ():
|
||||
if obj['stop']:
|
||||
return False
|
||||
|
||||
# Points et console
|
||||
print ("rp_prendre")
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_prendre")
|
||||
# FIXME
|
||||
|
||||
##
|
||||
@ -466,8 +486,9 @@ def rp_radar ():
|
||||
if obj['stop']:
|
||||
return False
|
||||
|
||||
# Points et console
|
||||
print ("rp_radar")
|
||||
# Points et console
|
||||
if (debug_mvt):
|
||||
print ("rp_radar")
|
||||
# FIXME
|
||||
|
||||
|
||||
@ -555,7 +576,8 @@ def rover_colision_station ():
|
||||
|
||||
def rover_goal ():
|
||||
obj=scene.objects['Rover']
|
||||
print ("Goal !!")
|
||||
if (debug_mvt):
|
||||
print ("Goal !!")
|
||||
obj['stop'] = True
|
||||
|
||||
# Animation
|
||||
@ -577,9 +599,9 @@ def rover_goal ():
|
||||
rp_gauche()
|
||||
|
||||
speed = scene.objects['Commands']['speed']
|
||||
scene.objects['Rover'].playAction('Rover-Obj1', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Mast'].playAction('Mast-Obj1', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Mast-cap'].playAction('Mast-cap-Obj1', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Rover'].playAction('Rover-Aim1', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Mast'].playAction('Mast-Aim1', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Mast-cap'].playAction('Mast-cap-Aim1', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
|
||||
scene.objects['Wheel-right-front'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Wheel-right-mid'].playAction('Wheel-Avancer', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
@ -592,19 +614,18 @@ def rover_goal ():
|
||||
scene.objects['Sun'].applyMovement((0, 0, 0), True)
|
||||
rp_tempo (0.1)
|
||||
|
||||
# Revenir à une position propre
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
obj.worldPosition.x = round(x0)
|
||||
obj.worldPosition.y = round(y0)
|
||||
# print ("Position actuelle :", x0, y0, obj.worldPosition.x, obj.worldPosition.y)
|
||||
|
||||
# Level
|
||||
# print ("scene.objects['Points']['mission'] :", scene.objects['Points']['mission'])
|
||||
# print ("scene.objects['Points']['level'] :", scene.objects['Points']['level'])
|
||||
if scene.objects['Points']['mission']==scene.objects['Points']['level']:
|
||||
scene.objects['Points']['level']+=1
|
||||
|
||||
def map_aim_near (cont):
|
||||
pass
|
||||
# obj = cont.owner
|
||||
# sensor = obj.sensors['Near']
|
||||
# if sensor.positive :
|
||||
# print ("Goall !!")
|
||||
# rover_goal()
|
||||
|
||||
###############################################################################
|
||||
# Temporisation
|
||||
|
208
rp_store.py
208
rp_store.py
@ -20,7 +20,7 @@ scene = bge.logic.getCurrentScene()
|
||||
color_store_fct = (0, 1, 0.857,1) # Turquoise
|
||||
color_store_hl = (0.799, 0.617, 0.021, 1) # Jaune
|
||||
color_store_activate = (0.936, 0.033, 1, 1) # Rose
|
||||
color_store_inventory = (1, 0.192, 0.03, 1) # Orange
|
||||
color_store_upgraded = (1, 0.192, 0.03, 1) # Orange
|
||||
|
||||
# UPBGE constants
|
||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
||||
@ -35,56 +35,68 @@ ACTIVATE = bge.logic.KX_INPUT_ACTIVE
|
||||
# Cards description pour le magasin
|
||||
storecard_description ={}
|
||||
|
||||
# Vitesse
|
||||
sc_vitesse_title="Vitesse"
|
||||
sc_vitesse_text="Permet de modifier\nla vitesse des \ndéplacements."
|
||||
storecard_description.update({"Store-vitesse-card" : [sc_vitesse_title, sc_vitesse_text]})
|
||||
# Speed - Vitesse
|
||||
sc_speed_title="Vitesse"
|
||||
sc_speed_text="Permet de modifier\nla vitesse des \ndéplacements."
|
||||
storecard_description.update({"Store-speed-card" : [sc_speed_title, sc_speed_text]})
|
||||
|
||||
# Peinture
|
||||
sc_peinture_title="Peinture"
|
||||
sc_peinture_text="Permet de changer la \ncouleur des objets."
|
||||
storecard_description.update({"Store-peinture-card" : [sc_peinture_title, sc_peinture_text]})
|
||||
# Paint - Peinture
|
||||
sc_paint_title="Peinture"
|
||||
sc_paint_text="Permet de changer la \ncouleur des objets."
|
||||
storecard_description.update({"Store-paint-card" : [sc_paint_title, sc_paint_text]})
|
||||
|
||||
# Batterie +
|
||||
sc_batterie_title="Batterie +"
|
||||
sc_batterie_text="Augmente la capacité \nde la batterie à 200 \nmouvements (contre \n50)."
|
||||
storecard_description.update({"Store-batterie-card" : [sc_batterie_title, sc_batterie_text]})
|
||||
# Battery + - Batterie +
|
||||
sc_battery_title="Batterie +"
|
||||
sc_battery_text="Augmente la capacité \nde la batterie à 200 \nmouvements (contre \n50)."
|
||||
storecard_description.update({"Store-battery-card" : [sc_battery_title, sc_battery_text]})
|
||||
|
||||
# Balise +
|
||||
sc_balise_title="Balise +"
|
||||
sc_balise_text="Porte le nombre de \nbasiles transportées\nà 200 (contre 50)."
|
||||
storecard_description.update({"Store-balise-card" : [sc_balise_title, sc_balise_text]})
|
||||
# Beacon + - Balise +
|
||||
sc_beacon_title="Balise +"
|
||||
sc_beacon_text="Porte le nombre de \nbalises transportées\nà 200 (contre 20)."
|
||||
storecard_description.update({"Store-beacon-card" : [sc_beacon_title, sc_beacon_text]})
|
||||
|
||||
################################################################################
|
||||
# Init, open et close
|
||||
################################################################################
|
||||
|
||||
def init (cont):
|
||||
##
|
||||
# Initialisation de la tablette
|
||||
##
|
||||
|
||||
def init():
|
||||
|
||||
# Mémorisation de la position de la tablette du store
|
||||
scene.objects["Store"]['init_lx']=scene.objects["Store"].worldPosition.x
|
||||
scene.objects["Store"]['init_ly']=scene.objects["Store"].worldPosition.y
|
||||
scene.objects["Store"]['init_lz']=scene.objects["Store"].worldPosition.z
|
||||
|
||||
# Placement de la position de la tablette du store
|
||||
scene.objects['Store'].worldScale = [0.01, 0.01, 0.01]
|
||||
# applyRotationTo(scene.objects['Store'], None, (-0.2*math.pi)/180, (115*math.pi)/180, False)
|
||||
applyRotationTo(scene.objects['Store'], None, (-2.38*math.pi)/180, (100*math.pi)/180, False)
|
||||
# scene.objects['Store'].applyRotation((math.pi/2+(0.59189*math.pi)/180, 0, 0), True)
|
||||
# scene.objects['Store'].applyRotation((math.pi/2+(3*math.pi)/180, 0, 0), True)
|
||||
scene.objects['Store'].applyRotation((math.pi/4+(2*math.pi)/180, 0, 0), True)
|
||||
|
||||
##
|
||||
# Ouverture du store
|
||||
##
|
||||
|
||||
def open ():
|
||||
scene.objects['Rover']['store-anim_end']=False
|
||||
scene.objects['Rover']['stop']=False
|
||||
thread_gostore_start(rover_go_store) # Aller au store
|
||||
|
||||
##
|
||||
# Arrivée au store
|
||||
##
|
||||
|
||||
def open2 (cont):
|
||||
obj=scene.objects['Rover']
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Terrain']['manip_mode']==0:
|
||||
sound_play (snd_click)
|
||||
thread_cmd_start(open)
|
||||
thread_gostore_stop()
|
||||
obj['store-anim_end']=False
|
||||
|
||||
##
|
||||
# Fermeture
|
||||
##
|
||||
|
||||
def close (cont):
|
||||
pass
|
||||
# obj=scene.objects['Rover']
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Terrain']['manip_mode']==0:
|
||||
# sound_play (snd_click)
|
||||
# thread_cmd_start(store)
|
||||
|
||||
##
|
||||
# Ouverture
|
||||
##
|
||||
|
||||
def open():
|
||||
obj=scene.objects['Rover']
|
||||
|
||||
# Pathfinder pour le store
|
||||
rover_go_store()
|
||||
# Affinage de la position
|
||||
obj.worldPosition.x = -9.75
|
||||
obj.worldPosition.y = -4
|
||||
obj.worldPosition.z = 0.19
|
||||
@ -108,31 +120,39 @@ def open():
|
||||
ipoFlags = 0
|
||||
# speed = scene.objects['Commands']['speed']*4
|
||||
speed = 0.5
|
||||
scene.objects['Bubble-1'].playAction('Bubble-1-ShaderAction', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Bubble-1'].setVisible(True,True)
|
||||
# scene.objects['Bubble-1-line'].playAction('Bubble-1-line-ShaderAction', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
# scene.objects['Bubble-1-text'].setVisible(True,True)
|
||||
scene.objects['Bubble-1-text'].playAction('Bubble-1-text-ShaderAction', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
|
||||
# Mise en couleurs
|
||||
scene.objects['Store_close'].color= color_store_fct
|
||||
scene.objects['Store_button'].color= color_store_fct
|
||||
function_card=("balise", "batterie", "peinture", "vitesse")
|
||||
for i in range(len(function_card)):
|
||||
scene.objects["Store-"+function_card[i]+"-card"].color = color_store_fct
|
||||
scene.objects["Store-"+function_card[i]+"-card-icon"].color = color_store_fct
|
||||
scene.objects["Store-"+function_card[i]+"-card-text"].color = color_store_fct
|
||||
scene.objects['Store_upgrade'].color= color_store_fct
|
||||
scene.objects['Store_upgrade'].setVisible(False, True)
|
||||
scene.objects['Store_upgrade-colbox'].suspendPhysics (True)
|
||||
upgrade_card=("battery", "beacon", "paint", "speed")
|
||||
for i in range(len(upgrade_card)):
|
||||
if scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] == True:
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card"].color = color_store_upgraded
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card-icon"].color = color_store_upgraded
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card-text"].color = color_store_upgraded
|
||||
else:
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card"].color = color_store_fct
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card-icon"].color = color_store_fct
|
||||
scene.objects["Store-"+upgrade_card[i]+"-card-text"].color = color_store_fct
|
||||
scene.objects['Store']['page_fct'] =""
|
||||
scene.objects['Store_text']['Text'] = " "
|
||||
scene.objects['Store_text'].setVisible(False,True)
|
||||
|
||||
scene.objects['Store_credits']['Text'] = "Crédits : "+str(scene.objects['Points']['upgrade_credit'])
|
||||
|
||||
# Animation de la tablette
|
||||
scene.objects['Store'].setVisible(True,True)
|
||||
scene.objects['Store'].worldPosition = [-12.25, -2.7, 0.4]
|
||||
scene.objects['Store'].worldScale = [0.01, 0.01, 0.01]
|
||||
# applyRotationTo(scene.objects['Store'], None, (-0.2*math.pi)/180, (115*math.pi)/180, False)
|
||||
applyRotationTo(scene.objects['Store'], None, (-2.38*math.pi)/180, (100*math.pi)/180, False)
|
||||
# scene.objects['Store'].applyRotation((math.pi/2+(0.59189*math.pi)/180, 0, 0), True)
|
||||
scene.objects['Store'].applyRotation((math.pi/2+(3*math.pi)/180, 0, 0), True)
|
||||
scene.objects['Store']['timer'] = 0
|
||||
scene.objects['Store']['anim'] = True
|
||||
scene.objects['Store_upgrade'].setVisible(False, True)
|
||||
scene.objects['Store_upgrade-colbox'].suspendPhysics (True)
|
||||
scene.objects['Store_text'].setVisible(False,True)
|
||||
|
||||
|
||||
##
|
||||
# Animation du store
|
||||
@ -160,6 +180,18 @@ def open_anim():
|
||||
if scene.objects['Store']['timer']== resol:
|
||||
scene.objects['Store']['anim'] = False
|
||||
|
||||
##
|
||||
# Fermeture
|
||||
##
|
||||
|
||||
def close ():
|
||||
scene.objects["Store"].worldPosition.x=scene.objects["Store"]['init_lx']
|
||||
scene.objects["Store"].worldPosition.y=scene.objects["Store"]['init_ly']
|
||||
scene.objects["Store"].worldPosition.z=scene.objects["Store"]['init_lz']
|
||||
scene.objects['Store'].setVisible(False,True)
|
||||
scene.objects['Bubble-1'].setVisible(False,True)
|
||||
# scene.objects['Bubble-1-text'].setVisible(False,True)
|
||||
|
||||
###############################################################################
|
||||
# Interface
|
||||
###############################################################################
|
||||
@ -174,13 +206,12 @@ def hl (cont):
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED :
|
||||
obj = cont.owner
|
||||
name=obj.name[:-7]
|
||||
print(name)
|
||||
name_text=name+"-text"
|
||||
name_icon=name+"-icon"
|
||||
scene.objects[name].color = color_store_hl
|
||||
|
||||
# Close et button
|
||||
if name == "Store_close" or name == "Store_button":
|
||||
if name == "Store_close" or name == "Store_upgrade":
|
||||
scene.objects[name].color = color_store_hl
|
||||
else:
|
||||
scene.objects[name].color = color_store_hl
|
||||
@ -195,7 +226,7 @@ def hl (cont):
|
||||
name_icon=obj.name[:-7]+"-icon"
|
||||
|
||||
# Close et button
|
||||
if name == "Store_close" or name == "Store_button":
|
||||
if name == "Store_close" or name == "Store_upgrade":
|
||||
scene.objects[name].color = color_store_fct
|
||||
else:
|
||||
if name == scene.objects['Store']['page_fct'] :
|
||||
@ -203,9 +234,14 @@ def hl (cont):
|
||||
scene.objects[name_text].color = color_store_activate
|
||||
scene.objects[name_icon].color = color_store_activate
|
||||
else:
|
||||
scene.objects[name].color = color_store_fct
|
||||
scene.objects[name_text].color = color_store_fct
|
||||
scene.objects[name_icon].color = color_store_fct
|
||||
if scene.objects[name]['upgraded'] == True:
|
||||
scene.objects[name].color = color_store_upgraded
|
||||
scene.objects[name_text].color = color_store_upgraded
|
||||
scene.objects[name_icon].color = color_store_upgraded
|
||||
else:
|
||||
scene.objects[name].color = color_store_fct
|
||||
scene.objects[name_text].color = color_store_fct
|
||||
scene.objects[name_icon].color = color_store_fct
|
||||
|
||||
##
|
||||
# Afficher les details de la fonction à partir d'une carte
|
||||
@ -219,9 +255,14 @@ def card (cont):
|
||||
|
||||
# Enlever l'ancienne carte
|
||||
if scene.objects['Store']['page_fct'] !="":
|
||||
scene.objects[scene.objects['Store']['page_fct']].color = color_store_fct
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-text'].color = color_store_fct
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-icon'].color = color_store_fct
|
||||
if scene.objects[scene.objects['Store']['page_fct']]['upgraded'] == True:
|
||||
scene.objects[scene.objects['Store']['page_fct']].color = color_store_upgraded
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-text'].color = color_store_upgraded
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-icon'].color = color_store_upgraded
|
||||
else:
|
||||
scene.objects[scene.objects['Store']['page_fct']].color = color_store_fct
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-text'].color = color_store_fct
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-icon'].color = color_store_fct
|
||||
|
||||
# Afficher le texte de la carte
|
||||
scene.objects['Store']['page_fct'] = name_fct
|
||||
@ -231,6 +272,34 @@ def card (cont):
|
||||
scene.objects['Store_text']['Text'] = storecard_description[name_fct][1]
|
||||
scene.objects['Store_text'].setVisible(True, False)
|
||||
|
||||
# Upgrade
|
||||
if scene.objects[name_fct]['upgraded'] == True or scene.objects['Points']['upgrade_credit'] ==0:
|
||||
scene.objects['Store_upgrade'].setVisible(False, False)
|
||||
scene.objects['Store_upgrade-colbox'].suspendPhysics (True)
|
||||
else:
|
||||
scene.objects['Store_upgrade'].setVisible(True, False)
|
||||
scene.objects['Store_upgrade-colbox']. restorePhysics()
|
||||
|
||||
##
|
||||
# Selectionner l'upgrade
|
||||
##
|
||||
|
||||
def upgrade (cont):
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
# sound_play (sndbuff_book_flip)
|
||||
obj = cont.owner
|
||||
name_fct = scene.objects['Store']['page_fct']
|
||||
if name_fct !="":
|
||||
scene.objects[name_fct]['upgraded'] = True
|
||||
scene.objects[scene.objects['Store']['page_fct']].color = color_store_upgraded
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-text'].color = color_store_upgraded
|
||||
scene.objects[scene.objects['Store']['page_fct']+'-icon'].color = color_store_upgraded
|
||||
scene.objects['Points']['upgrade_nb'] +=1
|
||||
scene.objects['Points']['upgrade_credit']= scene.objects['Points']['level']- 1 - scene.objects['Points']['upgrade_nb']
|
||||
scene.objects['Store_credits']['Text'] = "Crédits : "+str(scene.objects['Points']['upgrade_credit'])
|
||||
scene.objects['Store_upgrade'].setVisible(False, False)
|
||||
scene.objects['Store_upgrade'].suspendPhysics (True)
|
||||
|
||||
###############################################################################
|
||||
# Rover
|
||||
###############################################################################
|
||||
@ -311,16 +380,16 @@ def rover_dir_nbpas(direction, pas):
|
||||
|
||||
def rover_go_store():
|
||||
obj=scene.objects['Rover']
|
||||
# print("Go store !!")
|
||||
scene.objects['Points']['step'] =0
|
||||
|
||||
# Pathfinder : debug
|
||||
obj.worldPosition.x=-13
|
||||
obj.worldPosition.y=-8
|
||||
# Position de départ pour le debug
|
||||
# obj.worldPosition.x=12
|
||||
# obj.worldPosition.y=9
|
||||
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
z0 = obj.worldPosition.z
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
print ("Position actuelle :", x0, y0)
|
||||
|
||||
# Pathfinder : zone 1
|
||||
if x0<=-10 and (y0==2 or y0==3):
|
||||
@ -393,3 +462,4 @@ def rover_go_store():
|
||||
# print ("Position actuelle :", x0, y0)
|
||||
|
||||
rover_dir ("o")
|
||||
obj['store-anim_end']=True
|
||||
|
Loading…
Reference in New Issue
Block a user