codetower/ct_doc.py

462 lines
22 KiB
Python
Raw Normal View History

2022-04-22 02:04:48 +02:00
import bge # Bibliothèque Blender Game Engine (UPBGE)
2022-04-22 16:54:49 +02:00
import aud # Sounds
2022-04-22 02:04:48 +02:00
###############################################################################
# ct_doc.py
# @title: Documentation
# @project: CodeTower
# @lang: fr,en
# @authors: Philippe Roy <phroy@phroy.org>
# @copyright: Copyright (C) 2022 Philippe Roy
# @license: GNU GPL
#
# This game is a tower defense coding game. The towers are driven by Python code.
# The file is the the map and waves definition.
#
###############################################################################
scene = bge.logic.getCurrentScene()
# Colors
color_doc_chap = (0.153, 0.116, 0.105, 1) # WoodDark
color_doc_fct = (0.326, 0.101, 0.0592, 1) # BrownDark
# color_doc_fct = (0.577, 0.233, 0.115, 1) # Brown
# color_doc_hl = (0.799, 0.617, 0.021, 1) # Yellow
color_doc_hl = (0.13, 0.254, 0.407, 1) # BlueDark
color_doc_activate = (1.0, 0.025, 0.116, 1) # Red
2022-04-22 16:54:49 +02:00
# Sounds
audiodev = aud.Device()
2022-07-22 17:48:41 +02:00
snd_book_open = aud.Sound('asset/sounds/book_open.ogg')
sndbuff_book_open = aud.Sound.cache(snd_book_open)
snd_book_close = aud.Sound('asset/sounds/book_close.ogg')
sndbuff_book_close = aud.Sound.cache(snd_book_close)
2022-04-22 16:54:49 +02:00
snd_book_flip = aud.Sound('asset/sounds/book_flip.ogg')
sndbuff_book_flip = aud.Sound.cache(snd_book_flip)
2022-04-22 02:04:48 +02:00
# UPBGE constants
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
ACTIVATE = bge.logic.KX_INPUT_ACTIVE
# JUST_DEACTIVATED = bge.logic.KX_SENSOR_JUST_DEACTIVATED
2022-07-29 03:51:06 +02:00
# Functions description
fct_description ={}
2022-04-22 02:04:48 +02:00
###############################################################################
# Map
###############################################################################
2022-07-29 03:51:06 +02:00
map_card=["Level-card", "Sleep-card"]
2022-04-22 02:04:48 +02:00
2022-04-22 16:54:49 +02:00
# ct_level ()
2022-07-31 04:10:28 +02:00
ct_level_title = "\n Get your level"
ct_level_text = "\n \n ct_level ()\n \v - Return your level (integer)\n \n"
ct_level_text = ct_level_text + " For each new tower, new upgrade, \n new tech or new spell, you spend one \n level-point.\n"
2022-07-29 03:51:06 +02:00
fct_description.update({"Level-card" : [ct_level_title, ct_level_text]})
2022-04-22 02:04:48 +02:00
2022-04-22 16:54:49 +02:00
# ct_sleep (delay)
2022-07-31 04:10:28 +02:00
ct_sleep_title="\n Time management"
ct_sleep_text="\n \n ct_sleep (delay)\n \v - delay : duration in seconds (float)"
2022-07-29 03:51:06 +02:00
fct_description.update({"Sleep-card" : [ct_sleep_title, ct_sleep_text]})
2022-04-22 02:04:48 +02:00
###############################################################################
# Tower
###############################################################################
2022-07-29 03:51:06 +02:00
tower_card=["Build-card", "Remove-card", "Upgrade-card", "Activate-card", "Tune-card", "Targets-card"]
2022-04-22 02:04:48 +02:00
2022-04-22 16:54:49 +02:00
# ct_build (x, y, category, name, color, style)
2022-04-22 02:04:48 +02:00
ct_build_title="Build a tower"
2022-07-31 04:10:28 +02:00
ct_build_text="ct_build (x,y, category, name, color, style)\n \v- x tower location (integer)\n \v- y tower location (integer)\n"
2022-04-22 02:04:48 +02:00
ct_build_text = ct_build_text +" \v- category (string) : \n \v \v- \"Archer tower\" (default value)\n \v \v- \"Mage tower\"\n"
ct_build_text = ct_build_text +" \v- name (string)\n \v- color (RGB tuple, default=purple)\n"
ct_build_text = ct_build_text +" \v- style (string) : \n \v \v- \"square\" (default value) or \"round\"\n \v \v- version : A (default value), B or C\n \v \v- exemple : 'round-B' \n"
ct_build_text = ct_build_text +" \v- Return boolean flag (builded -> True)\n\n"
2022-04-22 16:54:49 +02:00
ct_build_text = ct_build_text +"Predefined colors : blue, green, magenta,\n orange, purple, red, turquoise, yellow.\n\n"
2022-04-22 02:04:48 +02:00
ct_build_text = ct_build_text +"Exemple : ct_build (1, 1, \"Archer tower\", \n \"Tower #1\", yellow, \"round-A\")\n"
2022-07-29 03:51:06 +02:00
fct_description.update({"Build-card" : [ct_build_title, ct_build_text]})
2022-04-22 02:04:48 +02:00
2022-04-22 16:54:49 +02:00
# ct_remove (x, y)
2022-07-31 04:10:28 +02:00
ct_remove_title="\n Remove a tower"
ct_remove_text="\n \n ct_remove (x, y) \n \v - x tower location (integer)\n \v - y tower location (integer)\n \n"
ct_remove_text = ct_remove_text + " When you destroy a tower you regain \n the level-points spent by the tower."
2022-07-29 03:51:06 +02:00
fct_description.update({"Remove-card" : [ct_remove_title, ct_remove_text]})
# ct_upgrade (x, y)
2022-07-31 04:10:28 +02:00
ct_upgrade_title="\n Upgrade / downgrade a tower"
ct_upgrade_text="\n \n ct_upgrade (x, y, value) \n \v - x tower location (integer)\n \v - y tower location (integer)\n \v - value (integer)\n \n"
ct_upgrade_text = ct_upgrade_text + " You change the tower level by adding \n the value. \n \n"
ct_upgrade_text = ct_upgrade_text + " For downgrading, the value have to \n be negative."
2022-07-29 03:51:06 +02:00
fct_description.update({"Upgrade-card" : [ct_upgrade_title, ct_upgrade_text]})
# ct_activate (x, y)
2022-07-31 04:10:28 +02:00
ct_activate_title="\n Activate/desactivate a tower"
ct_activate_text="\n \n ct_activate (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_activate_text = ct_activate_text +" \v - state (bool) : \n \v \v - True (default value) : set \n \v \v - False : unset\n \n"
ct_activate_text = ct_activate_text + " When you desactivate a tower you \n regain the level-points spent by the \n tower.\n \n"
ct_activate_text = ct_activate_text + " When you reactivate a tower, you must \n to have the amount of level-points \n spent by the tower."
2022-07-29 03:51:06 +02:00
fct_description.update({"Activate-card" : [ct_activate_title, ct_activate_text]})
# ct_tune (x, y)
ct_tune_title="Tune a tower"
2022-07-31 04:10:28 +02:00
ct_tune_text=" ct_tune (x, y, damage, speed, range) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_tune_text = ct_tune_text + " \v - damage (float)\n \v - speed (float)\n \v - range (float)\n \n"
ct_tune_text = ct_tune_text + " You change the tower characteristics. \n"
ct_tune_text = ct_tune_text +" The base value for each characteristic \n is 1."
ct_tune_text = ct_tune_text +" The tower power is the sum : \n damage + speed + range. \n \n"
ct_tune_text = ct_tune_text +" The power depend on the level : \n"
ct_tune_text = ct_tune_text +" \v - level = 2^(power-3)\n"
ct_tune_text = ct_tune_text +" \v - power = ln(level)/ln(2) + 3\n \n"
ct_tune_text = ct_tune_text +" Power : 3 | 4 | 5 | 6 | 7 | 8 | ... \n"
ct_tune_text = ct_tune_text +" Level : 1 | 2 | 4 | 8 | 16 | 32 | ... \n"
2022-07-29 03:51:06 +02:00
fct_description.update({"Tune-card" : [ct_tune_title, ct_tune_text]})
# ct_targets (x, y)
2022-07-31 04:10:28 +02:00
ct_targets_title = "\n Get the targets list"
ct_targets_text=" \n \n ct_targets (x, y) \n \v - x tower location (integer)\n \v - y tower location (integer)\n "
ct_targets_text = ct_targets_text +" \v- Return the list of minions within \n range of the tower (list of \n targets) \n \n"
ct_targets_text = ct_targets_text +" Target (list) : [ name (string), class \n (string), level (integer), distance \n travelled (float),"
ct_targets_text = ct_targets_text +" hp (integer), speed \n (float), armor (float),"
ct_targets_text = ct_targets_text +" bounty (integer), \n lifes_damage (integer) ]"
2022-07-29 03:51:06 +02:00
fct_description.update({"Targets-card" : [ct_targets_title, ct_targets_text]})
2022-04-22 02:04:48 +02:00
###############################################################################
# Tech
###############################################################################
2022-07-29 03:51:06 +02:00
tech_card=["Accurate-card", "Volley-card", "Slow_tech-card", "Fire-card", "Bolt-card", "Ice-card", "Acid-card"]
# ct_accurate
2022-07-31 04:10:28 +02:00
ct_accurate_title="\n Accurate"
ct_accurate_text="\n \n ct_accurate (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_accurate_text = ct_accurate_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_accurate_text = ct_accurate_text +" Increases attack damage by 4. \n \n"
ct_accurate_text = ct_accurate_text +" It can't be combined with \'volley\' \n or \'slow\'."
# ct_accurate_text = ct_accurate_text +" With the accurate mode, the damage \n is multiplied by 4 but the tower speed \n is divided by 2."
2022-07-29 03:51:06 +02:00
fct_description.update({"Accurate-card" : [ct_accurate_title, ct_accurate_text]})
# ct_volley
2022-07-31 04:10:28 +02:00
ct_volley_title="\n Volley of arrows "
ct_volley_text="\n \n ct_volley (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_volley_text = ct_volley_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_volley_text = ct_volley_text +" Fires an volley of 4 arrows.\n \n"
ct_volley_text = ct_volley_text +" It can't be combined with \'accurate\' \n or \'slow\'."
# ct_volley_text = ct_volley_text +" With the volley mode, the tower fires \n volley of arrows (4 arrows), but the \n damage is divided by 2."
2022-07-29 03:51:06 +02:00
fct_description.update({"Volley-card" : [ct_volley_title, ct_volley_text]})
# ct_slow_tech
2022-07-31 04:10:28 +02:00
ct_slow_tech_title="\n Slow down the target"
ct_slow_tech_text="\n \n ct_slow (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_slow_tech_text = ct_slow_tech_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_slow_tech_text = ct_slow_tech_text +" Finds the vulnerability for slow down \n the target"
ct_slow_tech_text = ct_slow_tech_text +" (speed divided by 4).\n \n"
ct_slow_tech_text = ct_slow_tech_text +" It can't be combined with \'accurate\' \n or \'volley\'."
# ct_slow_tech_text = ct_slow_tech_text +" (minion speed divided by 2)."
2022-07-29 03:51:06 +02:00
fct_description.update({"Slow_tech-card" : [ct_slow_tech_title, ct_slow_tech_text]})
# ct_fire
2022-07-31 04:10:28 +02:00
ct_fire_title="\n Flaming arrow"
ct_fire_text="\n \n ct_fire (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_fire_text = ct_fire_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_fire_text = ct_fire_text +" Deals fire damage.\n \n"
ct_fire_text = ct_fire_text +" The tower can't cumulate two arrow \n types (fire, bolt, ice, acid) at once."
2022-07-29 03:51:06 +02:00
fct_description.update({"Fire-card" : [ct_fire_title, ct_fire_text]})
# ct_bolt
2022-07-31 04:10:28 +02:00
ct_bolt_title="\n Charged arrow"
ct_bolt_text="\n \n ct_bolt (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_bolt_text = ct_bolt_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_bolt_text = ct_bolt_text +" Deals lighting damage.\n \n"
ct_bolt_text = ct_bolt_text +" The tower can't cumulate two arrow \n types (fire, bolt, ice, acid) at once."
2022-07-29 03:51:06 +02:00
fct_description.update({"Bolt-card" : [ct_bolt_title, ct_bolt_text]})
# ct_ice
2022-07-31 04:10:28 +02:00
ct_ice_title="\n Ice arrow"
ct_ice_text="\n \n ct_ice (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_ice_text = ct_ice_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_ice_text = ct_ice_text +" Deals ice damage.\n \n"
ct_ice_text = ct_ice_text +" The tower can't cumulate two arrow \n types (fire, bolt, ice, acid) at once."
2022-07-29 03:51:06 +02:00
fct_description.update({"Ice-card" : [ct_ice_title, ct_ice_text]})
# ct_acid
2022-07-31 04:10:28 +02:00
ct_acid_title="\n Acid arrow"
ct_acid_text="\n \n ct_acid (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_acid_text = ct_acid_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_acid_text = ct_acid_text +" Deals acid damage.\n \n"
ct_acid_text = ct_acid_text +" The tower can't cumulate two arrow \n types (fire, bolt, ice, acid) at once."
2022-07-29 03:51:06 +02:00
fct_description.update({"Acid-card" : [ct_acid_title, ct_acid_text]})
2022-04-22 02:04:48 +02:00
###############################################################################
# Spell
###############################################################################
2022-07-29 03:51:06 +02:00
spell_card=["Slow_spell-card", "Detect-card", "Fear-card", "Aura-card"]
2022-04-22 02:04:48 +02:00
2022-08-18 16:47:39 +02:00
# ct_slow_tech
ct_slow_tech_title="\n Slow down the target"
ct_slow_tech_text="\n \n ct_slow (x, y, state) \n \v - x tower location (integer)\n \v - y tower location (integer)\n"
ct_slow_tech_text = ct_slow_tech_text +" \v - state (bool) : \n \v \v - True : set \n \v \v - False : unset\n \n"
ct_slow_tech_text = ct_slow_tech_text +" Finds the vulnerability for slow down \n the target"
ct_slow_tech_text = ct_slow_tech_text +" (speed divided by 4).\n \n"
ct_slow_tech_text = ct_slow_tech_text +" It can't be combined with \'accurate\' \n or \'volley\'."
# ct_slow_tech_text = ct_slow_tech_text +" (minion speed divided by 2)."
fct_description.update({"Slow_tech-card" : [ct_slow_tech_title, ct_slow_tech_text]})
2022-07-29 03:51:06 +02:00
# ct_slow_spell
ct_slow_spell_title="FIXME"
ct_slow_spell_text="FIXME\n"
fct_description.update({"Slow_spell-card" : [ct_slow_spell_title, ct_slow_spell_text]})
# ct_detect
ct_detect_title="FIXME"
ct_detect_text="FIXME\n"
fct_description.update({"Detect-card" : [ct_detect_title, ct_detect_text]})
# ct_fear
ct_fear_title="FIXME"
ct_fear_text="FIXME\n"
fct_description.update({"Fear-card" : [ct_fear_title, ct_fear_text]})
# ct_aura
ct_aura_title="FIXME"
ct_aura_text="FIXME\n"
fct_description.update({"Aura-card" : [ct_aura_title, ct_aura_text]})
2022-04-22 02:04:48 +02:00
2022-04-22 16:54:49 +02:00
###############################################################################
# Interface
###############################################################################
2022-07-22 17:48:41 +02:00
##
# Initialisation du livre
##
def init():
2022-07-29 03:51:06 +02:00
# Mettre les pages avec la couleurs par defaut
2022-07-22 17:48:41 +02:00
scene.objects['Book_close'].color = color_doc_chap
scene.objects['Book_chap-screen'].color = color_doc_chap
scene.objects['Book_chap-map'].color = color_doc_chap
scene.objects['Book_chap-tower'].color = color_doc_chap
scene.objects['Book_chap-tech'].color = color_doc_chap
scene.objects['Book_chap-spell'].color = color_doc_chap
scene.objects['Book_close'].color = color_doc_chap
2022-07-29 03:51:06 +02:00
# Mettre les cartes avec la couleurs par defaut
for i in range(len(map_card)):
scene.objects[map_card[i]].color = color_doc_fct
scene.objects[map_card[i]+"-colbox"].suspendPhysics()
for i in range(len(tower_card)):
scene.objects[tower_card[i]].color = color_doc_fct
scene.objects[tower_card[i]+"-colbox"].suspendPhysics()
for i in range(len(tech_card)):
scene.objects[tech_card[i]].color = color_doc_fct
scene.objects[tech_card[i]+"-colbox"].suspendPhysics()
for i in range(len(spell_card)):
scene.objects[spell_card[i]].color = color_doc_fct
scene.objects[spell_card[i]+"-colbox"].suspendPhysics()
2022-07-31 04:10:28 +02:00
##
# Ouverture du livre
##
def open():
# Afficher le livre
scene.objects['Book'].worldPosition = [0, -22, 16.5]
# scene.objects['Book_close'].color = color_doc_chap
# scene.objects['Book_chap-screen'].color = color_doc_chap
# scene.objects['Book_chap-map'].color = color_doc_chap
# scene.objects['Book_chap-tower'].color = color_doc_chap
# scene.objects['Book_chap-tech'].color = color_doc_chap
# scene.objects['Book_chap-spell'].color = color_doc_chap
# scene.objects['Book_close'].color = color_doc_chap
scene.objects['Book'].setVisible(True,True)
scene.objects['Book_text_title'].setVisible(False,True)
scene.objects['Book_text'].setVisible(False,True)
sound_play (sndbuff_book_open)
# Activer la page screen (page par defaut)
scene.objects['Book']['page_chap'] = "Book_chap-screen"
scene.objects['Book']['page_fct'] = ""
scene.objects['Book_chap-screen'].color = color_doc_activate
scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_screen'].setVisible(True,True)
# # Mettre les cartes avec la couleurs par defaut
# for i in range(len(map_card)):
# scene.objects[map_card[i]].color = color_doc_fct
# scene.objects[map_card[i]+"-colbox"].suspendPhysics()
# for i in range(len(tower_card)):
# scene.objects[tower_card[i]].color = color_doc_fct
# scene.objects[tower_card[i]+"-colbox"].suspendPhysics()
# for i in range(len(tech_card)):
# scene.objects[tech_card[i]].color = color_doc_fct
# scene.objects[tech_card[i]+"-colbox"].suspendPhysics()
# for i in range(len(spell_card)):
# scene.objects[spell_card[i]].color = color_doc_fct
# scene.objects[spell_card[i]+"-colbox"].suspendPhysics()
2022-07-22 17:48:41 +02:00
##
# Fermeture du livre
##
def close():
sound_play (sndbuff_book_close)
2022-07-31 04:10:28 +02:00
# Cacher les cartes de fonction
2022-07-29 03:51:06 +02:00
scene.objects['Book_page_screen'].setVisible(False,True)
scene.objects['Book_page_map'].setVisible(False,True)
scene.objects['Book_page_tower'].setVisible(False,True)
scene.objects['Book_page_tech'].setVisible(False,True)
scene.objects['Book_page_spell'].setVisible(False,True)
2022-07-31 04:10:28 +02:00
# Mettre les cartes avec la couleurs par defaut
for i in range(len(map_card)):
scene.objects[map_card[i]+"-colbox"].suspendPhysics()
for i in range(len(tower_card)):
scene.objects[tower_card[i]+"-colbox"].suspendPhysics()
for i in range(len(tech_card)):
scene.objects[tech_card[i]+"-colbox"].suspendPhysics()
for i in range(len(spell_card)):
scene.objects[spell_card[i]+"-colbox"].suspendPhysics()
# Cacher le livre
2022-07-22 17:48:41 +02:00
scene.objects['Book_page_screen'].setVisible(False,True)
scene.objects['Book'].setVisible(False,True)
# scene.objects['Book'].worldPosition = [28, 0.84549, 1.53626] # Position dans Blender [28, 0.84549, 1.53626]
scene.objects['Book'].worldPosition = [28, 15, 14] # Position dans Blender [28, 0.84549, 1.53626]
scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition
##
# Highlight du livre
##
def hl (cont):
if cont.sensors['MO'].status == JUST_ACTIVATED :
obj = cont.owner
name=obj.name[:-7]
scene.objects[name].color = color_doc_hl
if name == scene.objects['Book']['page_chap'] or name == scene.objects['Book']['page_fct'] :
scene.objects[name].color = color_doc_activate
else:
scene.objects[name].color = color_doc_hl
if cont.sensors['MO'].status == JUST_RELEASED :
obj = cont.owner
name=obj.name[:-7]
if name == scene.objects['Book']['page_chap'] or name == scene.objects['Book']['page_fct'] :
scene.objects[name].color = color_doc_activate
else:
2022-07-31 04:10:28 +02:00
if name[5:10]=="chap-":
2022-07-22 17:48:41 +02:00
scene.objects[name].color = color_doc_chap
else:
scene.objects[name].color = color_doc_fct
##
# Afficher le chapitre
##
2022-04-22 16:54:49 +02:00
2022-04-22 02:04:48 +02:00
def chapter(cont):
2022-04-22 16:54:49 +02:00
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and cont.sensors['Click'].positive:
sound_play (sndbuff_book_flip)
2022-04-22 02:04:48 +02:00
obj = cont.owner
2022-07-29 03:51:06 +02:00
last_name_chap= scene.objects['Book']['page_chap']
name_chap= obj.name[:-7]
scene.objects[last_name_chap].color = color_doc_chap
2022-04-22 02:04:48 +02:00
scene.objects[name_chap].color = color_doc_activate
2022-07-29 03:51:06 +02:00
scene.objects['Book']['page_chap'] = name_chap
last_name_fct= scene.objects['Book']['page_fct']
if last_name_fct != "":
scene.objects[last_name_fct].color = color_doc_fct
scene.objects['Book']['page_fct'] = ""
2022-04-22 02:04:48 +02:00
scene.objects['Book_text_title'].setVisible(False,True)
scene.objects['Book_text'].setVisible(False,True)
2022-07-29 03:51:06 +02:00
# Effacer les fonctions cartes
2022-07-22 17:48:41 +02:00
scene.objects['Book_page_screen'].setVisible(False,True)
scene.objects['Book_page_map'].setVisible(False,True)
2022-07-29 03:51:06 +02:00
scene.objects['Book_page_tower'].setVisible(False,True)
scene.objects['Book_page_tech'].setVisible(False,True)
scene.objects['Book_page_spell'].setVisible(False,True)
# Désactiver les cartes
for i in range(len(map_card)):
scene.objects[map_card[i]+"-colbox"].suspendPhysics()
for i in range(len(tower_card)):
scene.objects[tower_card[i]+"-colbox"].suspendPhysics()
for i in range(len(tech_card)):
scene.objects[tech_card[i]+"-colbox"].suspendPhysics()
for i in range(len(spell_card)):
scene.objects[spell_card[i]+"-colbox"].suspendPhysics()
# Afficher la page Screen
2022-04-22 02:04:48 +02:00
if name_chap == "Book_chap-screen":
scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_screen'].setVisible(True,True)
2022-07-29 03:51:06 +02:00
# Afficher la page Map
if name_chap == "Book_chap-map":
scene.objects['Book_page_map'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_map'].setVisible(True,True)
for i in range(len(map_card)):
scene.objects[map_card[i]+"-colbox"].restorePhysics()
2022-07-22 17:48:41 +02:00
2022-07-29 03:51:06 +02:00
# Afficher la page Tower
if name_chap == "Book_chap-tower":
scene.objects['Book_page_tower'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_tower'].setVisible(True,True)
for i in range(len(tower_card)):
scene.objects[tower_card[i]+"-colbox"].restorePhysics()
2022-07-22 17:48:41 +02:00
2022-07-29 03:51:06 +02:00
# Afficher la page Tech
if name_chap == "Book_chap-tech":
scene.objects['Book_page_tech'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_tech'].setVisible(True,True)
for i in range(len(tech_card)):
scene.objects[tech_card[i]+"-colbox"].restorePhysics()
2022-07-22 17:48:41 +02:00
2022-07-29 03:51:06 +02:00
# Afficher la page Speel
if name_chap == "Book_chap-spell":
scene.objects['Book_page_spell'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_spell'].setVisible(True,True)
for i in range(len(spell_card)):
scene.objects[spell_card[i]+"-colbox"].restorePhysics()
2022-07-22 17:48:41 +02:00
##
# Afficher les details de la fonction à partir d'une carte
##
def card (cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
sound_play (sndbuff_book_flip)
obj = cont.owner
2022-07-29 03:51:06 +02:00
# Highlight des cartes
last_name_fct= scene.objects['Book']['page_fct']
name_fct= obj.name[:-7]
if last_name_fct != "":
scene.objects[last_name_fct].color = color_doc_fct
scene.objects['Book']['page_fct'] = name_fct
scene.objects[name_fct].color = color_doc_activate
2022-07-22 17:48:41 +02:00
# Afficher le texte de la fonction
2022-07-31 04:10:28 +02:00
# print ("name_fct : ", name_fct)
# print ("fct_description : ", fct_description)
2022-07-29 03:51:06 +02:00
scene.objects['Book_text_title']['Text'] = fct_description[name_fct][0]
scene.objects['Book_text']['Text'] = fct_description[name_fct][1]
scene.objects['Book_text_title'].setVisible(True, False)
scene.objects['Book_text'].setVisible(True, False)
2022-07-22 17:48:41 +02:00
##
# Sounds
##
def sound_play (sound):
if scene.objects['Commands']['sound']:
audiodev.play(sound)