예제 #1
0
파일: items.py 프로젝트: fabr1z10/glib3
 def __init__(
         self,
         font: str,
         item_id: str,
         qty: int,
         color_inactive,
         color_active,
         align: entity.TextAlignment = entity.TextAlignment.bottom_left,
         script: callable = None,
         tag=None,
         pos=[0, 0, 0]):
     if item_id not in data.items:
         raise BaseException('Hey! unknown item: ' + item_id)
     item = data.items[item_id]
     text = ''
     if qty == 1:
         text = monkey.engine.read(item['text'])
     else:
         text = str(qty) + ' ' + monkey.engine.read(item['plural'])
     print('init with ' + text)
     print(color_inactive)
     super().__init__(font, 8, text, color_inactive, align, tag, pos)
     self.add_component(
         compo.HotSpot(
             shape=None,
             onenter=func.hover_on_inventory_button(
                 item_id),  # change_color(colorActive),
             onleave=func.hover_off_inventory_button(item_id),
             onclick=func.prova()))
예제 #2
0
파일: items.py 프로젝트: fabr1z10/glib3
 def f(*args):
     key = args[0]
     desc = args[1]
     cio = desc.get('create_if_owned', False)
     if (not cio) and key in vars.inventory:
         # item is in inventory. don't create it
         return None
     pos = desc.get('pos')
     model = desc.get('model', None)
     #text = monkey.engine.read(desc.get('text'))
     s = None
     if model:
         anim = monkey.engine.read(desc.get('anim', None))
         s = entity.Sprite(model=model, pos=pos, anim=anim)
     else:
         s = entity.Entity(pos=pos)
     #s.tag = desc.get('tag', None)
     s.tag = key
     # if a size is provided, add a hotspot
     size = desc.get('size', None)
     if size:
         print('size is ' + str(size))
         s.add_component(
             compo.HotSpot(shape=shapes.Rect(width=size[0], height=size[1]),
                           onenter=func.hover_on(key),
                           onleave=func.hover_off(key),
                           onclick=func.prova()))
     return s
예제 #3
0
파일: items.py 프로젝트: fabr1z10/glib3
 def f(*args):
     key = args[0]
     is_player = key == data.current_player
     desc = args[1]
     model = desc.get('model', None)
     text_color = monkey.engine.read(
         desc.get('text_color', [255, 255, 255, 255]))
     #text_color =
     text_offset = desc.get('text_offset', [0, 60])
     pos = monkey.engine.read(desc.get('pos'))
     tag = desc.get('tag', key)
     speed = desc.get('speed', 100)
     print(tag + " pos is " + str(pos))
     s = None
     dir = desc.get('dir', 's')
     if model:
         s = entity.Sprite(model=model,
                           pos=pos,
                           tag='player' if is_player else tag)
         s.add_component(
             compo.Collider(debug=True,
                            flag=data.Collision.Flags.player,
                            mask=data.Collision.Flags.other,
                            tag=data.Collision.Tags.player,
                            shape=shapes.Rect(width=8,
                                              height=2,
                                              offset=[-4, 0])))
         if is_player:
             s.add_component(compo.Follow())
     else:
         s = entity.Entity(pos=pos, tag='player' if is_player else tag)
     s.add_component(
         scumm.components.CharacterController(dir=dir,
                                              speed=speed,
                                              text_color=text_color,
                                              text_offset=text_offset))
     # if a size is provided, add a hotspot
     size = desc.get('size', None)
     if size:
         print('size is ' + str(size))
         s.add_component(
             compo.HotSpot(shape=shapes.Rect(width=size[0],
                                             height=size[1],
                                             offset=[-0.5 * size[0], 0]),
                           onenter=func.hover_on(key),
                           onleave=func.hover_off(key),
                           onclick=func.prova()))
     return s