本文整理汇总了Python中GameState.get_player方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.get_player方法的具体用法?Python GameState.get_player怎么用?Python GameState.get_player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameState
的用法示例。
在下文中一共展示了GameState.get_player方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: objects
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def objects():
# libtcod.console_clear(consoles['entity_console'])
Utils.clear_layer(layers['entity_console'])
for object in Map.get_all_objects():
if object != GameState.get_player():
object.draw()
GameState.get_player().draw()
示例2: take_turn
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def take_turn(self):
# a basic monster takes its turn. If you can see it, it can see you
monster = self.owner
player = GameState.get_player()
if GameState.current_level.is_visible(obj=monster):
self.active = True
GameState.continue_walking = False
# move towards player if far away
if self.active:
dist = monster.distance_to(player)
if dist > self.attack_range:
# monster.move_astar(player)
self.reload -= 1
# close enough, attack! (if the player is still alive.)
elif player.fighter.hp > 0 and self.reload <= 0 and GameState.current_level.is_visible(obj=monster):
""" DISABLE """
#Animate.follow_line(self.owner, player)
self.play_animation('Shot', self.owner, player.x, player.y )
monster.fighter.attack(player)
self.reload = 3
else:
# Move away?
self.reload -= 1
return Constants.TURN_COST
示例3: drop
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def drop(self):
# add to the map and remove from the player's inventory. also, place it at the player's coordinates
GameState.current_level.get_all_objects().append(self.owner)
GameState.inventory.remove(self.owner)
player = GameState.get_player()
self.owner.x = player.x
self.owner.y = player.y
# special case: if the object has the Equipment component, dequip it before dropping
if self.owner.equipment:
self.owner.equipment.dequip()
Utils.message('You dropped a ' + self.owner.name + '.', libtcod.yellow)
示例4: take_damage
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def take_damage(self, damage):
# apply damage if possible
player = GameState.get_player()
if damage > 0:
self.hp -= damage
# check for death. if there's a death function, call it
if self.hp <= 0:
function = self.death_function
if self.owner != player: # yield experience to the player
player.fighter.xp += self.xp
if function is not None:
function(self.owner)
示例5: render_stat_bars
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def render_stat_bars():
pos = Pos(Constants.MAP_CONSOLE_WIDTH + 4, 35)
# SHOW PLAYER STAT BARS
Render.draw_box_bar(pos.x, pos.y, 14, '', GameState.get_player().fighter.hp, GameState.get_player().fighter.base_max_hp,
Color("178,0,45"),
Color("64,0,16"), layers['side_panel_console'])
Render.draw_box_bar(pos.x, pos.y + 1, 14, '', GameState.get_player().fighter.sp, GameState.get_player().fighter.base_max_sp,
Color("0,30,255"),
Color("0,10,64"), layers['side_panel_console'])
Render.draw_box_bar(pos.x, pos.y + 2, 14, '', GameState.get_player().fighter.xp, 1000, # TODO: will be NEXT_LVL_XP
Color("255,255,0"),
Color("65,65,0"), layers['side_panel_console'])
# RENDER MONSTER HEALTH BARS
temp_y = 3
for object in GameState.current_level.get_visible_objects():
if object.fighter and object.base_speed != 0 and (object is not GameState.get_player()): # and Fov.is_visible(obj=object)
if temp_y < 17: # TODO: Make constant to scale UI
Render.draw_box_bar(Constants.MAP_CONSOLE_WIDTH + 1, temp_y, 17, object.name, object.fighter.hp, object.fighter.max_hp,
Color("0,255,0"),
Color("0,64,0"),
layers['side_panel_console'])
temp_y += 2
示例6: render_stat_bars
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def render_stat_bars():
pos = Pos(Constants.MAP_CONSOLE_WIDTH + 4, 35)
# SHOW PLAYER STAT BARS
render_box_bar(pos.x, pos.y, 14, '', GameState.get_player().fighter.hp, GameState.get_player().fighter.base_max_hp,
libtcod.Color(178, 0, 45),
libtcod.Color(64, 0, 16), layers['side_panel_console'])
render_box_bar(pos.x, pos.y + 1, 14, '', GameState.get_player().fighter.sp, GameState.get_player().fighter.base_max_sp,
libtcod.Color(0, 30, 255),
libtcod.Color(0, 10, 64), layers['side_panel_console'])
render_box_bar(pos.x, pos.y + 2, 14, '', GameState.get_player().fighter.xp, 1000, # TODO: will be NEXT_LVL_XP
libtcod.Color(255, 255, 0),
libtcod.Color(65, 65, 0), layers['side_panel_console'])
# RENDER MONSTER HEALTH BARS
temp_y = 3
for object in Map.get_visible_objects():
if object.fighter and (object is not GameState.get_player()): # and Fov.is_visible(obj=object)
if temp_y < 17: # TODO: Make constant to scale UI
render_box_bar(Constants.MAP_CONSOLE_WIDTH + 1, temp_y, 17, object.name, object.fighter.hp, object.fighter.max_hp,
libtcod.Color(0, 255, 0),
libtcod.Color(0, 64, 0),
layers['side_panel_console'])
temp_y += 2
示例7: initialize
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def initialize():
global fov_recompute, fov_map, player
# unexplored areas start black (which is the default background color)
# from Render import clear_map
# clear_map()
map = Map.current_map()
player = GameState.get_player()
require_recompute()
fov_map = libtcod.map_new(Constants.MAP_WIDTH, Constants.MAP_HEIGHT)
for y in range(Constants.MAP_HEIGHT):
for x in range(Constants.MAP_WIDTH):
fov_change(x, y, map[x][y].block_sight, map[x][y].blocked)
示例8: render_common
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def render_common():
import Input
pos = Pos(Constants.MAP_CONSOLE_WIDTH, 0)
set_foreground(layers['side_panel_console'], libtcod.Color(0, 70, 140))
""" LEVEL NUMBER """
print_rect(layers['side_panel_console'], pos.x + 1, pos.y + 1, 17, 1, "Level 1".center(17, ' '))
""" MOUSE X / Y """
print_rect(layers['side_panel_console'], pos.x + 9, pos.y + 18, 17, 2,
"X: " + str(Input.mouse.cx) + " \nY: " + str(Input.mouse.cy) + " ")
""" STATS """
set_foreground(layers['panel_console'], libtcod.Color(175, 175, 255))
player = GameState.get_player()
print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 18, str(player.fighter.base_str).rjust(3))
print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 19, str(player.fighter.base_def).rjust(3))
print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 20, str(player.fighter.base_agl).rjust(3))
print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 21, str(player.fighter.base_stm).rjust(3))
print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 22, str(player.fighter.base_skl).rjust(3))
print_line(layers['side_panel_console'], Constants.MAP_CONSOLE_WIDTH + 5, 23, str(player.fighter.base_int).rjust(3))
""" CONTROLS """
print_line(layers['side_panel_console'], 59, 39, "Move: NUMPAD")
print_line(layers['side_panel_console'], 59, 40, "Fire: F")
print_line(layers['side_panel_console'], 59, 41, "Pickup: G")
print_line(layers['side_panel_console'], 59, 42, "Pop-Up Test: B")
print_line(layers['side_panel_console'], 59, 43, "Decend: <")
print_line(layers['side_panel_console'], 59, 44, "DEBUG: X")
""" DUNGEON NAME """
pos = Pos(0, Constants.MAP_CONSOLE_HEIGHT)
print_rect(layers['panel_console'], pos.x + 1, pos.y + 1, Constants.SCREEN_WIDTH - 19, 1,
GameState.dungeon_name.center(57, ' '))
示例9: defense
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def defense(self): # return actual defense, by summing up the bonuses from all equipped items
bonus = sum(equipment.defense_bonus for equipment in GameState.get_all_equipped(self.owner))
if self.owner is GameState.get_player():
bonus -= max(0, (GameState.current_level.number_of_adjacent_objects(GameState.get_player()) - 2))
return self.base_defense + bonus
示例10: target_mode
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def target_mode(source, target=None, ranged_componenet=None):
""" Reset Params """
targets = []
target_x = 0
target_y = 0
if source is None:
source = GameState.get_player()
""" If no target supplied, Enter Targeting mode """
if target is None:
tile_effected = set([])
# Utils.message('Choose Target. Left Click/Space to execute. Right Click/ESC to cancel.', libtcod.gold)
''' Get list of visible enemies to cycle through '''
target_list = GameState.current_level.closest_monsters(ranged_componenet.max_range)
if target_list:
target_list = cycle(target_list)
target = next(target_list)[0]
''' Used to detect mouse movement '''
mouse = Input.mouse
mouse_last_x, mouse_last_y = mouse.cx, mouse.cy
mouse_moved = False
while True:
''' Clear Screen '''
Render.clear_layer(layers['overlay_console'])
"""
Render.draw_rect(layers['overlay_console'], 0, 0,
Constants.MAP_CONSOLE_WIDTH,
Constants.MAP_CONSOLE_HEIGHT,
frame=True,
f_color=terminal.color_from_argb(255, 255, 100, 100),
bk_color=terminal.color_from_name('transparent'),
title="Targeting Mode - Right Click/ESC to Cancel")
# """
''' Get Inputs '''
Input.update()
key = Input.key
''' determine if mouse moved, otherwise use auto-target '''
if mouse.cx != mouse_last_x or mouse.cy != mouse_last_y:
mouse_moved = True
moues_last_x, mouse_last_y = mouse.cx, mouse.cy
if mouse_moved:
target_x, target_y = Utils.to_map_coordinates(mouse.cx, mouse.cy)
elif target:
target_x, target_y = target.x, target.y
else:
target_x, target_y = source.x, source.y
''' determine line of fire (You may not be able to hit every enemy you see) '''
line = Utils.get_line((source.x, source.y),
(target_x, target_y),
walkable=True,
ignore_mobs=True,
max_length=ranged_componenet.max_range)
for point in line:
if point == (None, None):
break
point = Utils.to_camera_coordinates(point[0], point[1])
#libtcod.console_set_char_background(0, point[0], point[1], libtcod.lighter_blue, libtcod.BKGND_SET)
Render.draw_char(layers['overlay_console'], point[0], point[1], 0x2588, terminal.color_from_argb(128, 64, 64, 255))
if len(line) > 0:
index = Utils.find_element_in_list((None, None), line)
if index is None:
point = line[-1]
else:
point = line[index - 1]
circle = Utils.get_circle_points(point[0], point[1], ranged_componenet.aoe)
if circle:
tile_effected = set(circle)
for points in circle:
points = Utils.to_camera_coordinates(points[0], points[1])
Render.draw_char(layers['overlay_console'], points[0], points[1], 0x2588, terminal.color_from_argb(128, 200, 32, 32))
Render.draw_char(layers['overlay_console'], points[0], points[1], 0xE000, terminal.color_from_argb(128, 255, 0, 0))
if mouse.lbutton_pressed or key == terminal.TK_SPACE:
# target_tile = (target_x, target_y)
# print tile_effected
for target in tile_effected:
# target = Map.to_map_coordinates(target[0], target[1])
monster = GameState.current_level.get_monster_at((target[0], target[1]))
if monster is not None:
print "Monster: " + str(monster) + " at " + str(target)
targets.append(monster)
break
if mouse.rbutton_pressed or key == terminal.TK_ESCAPE:
break
#.........这里部分代码省略.........
示例11: reset
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def reset(self):
self.time_travelers = [GameState.get_player()]
示例12: full_map
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import get_player [as 别名]
def full_map():
if Fov.recompute():
Utils.clear_layer(0)
map = Map.current_map()
player = GameState.get_player()
Map.move_camera(player.x, player.y)
camera_x, camera_y = Map.get_camera()
# Map.d_map[player.x][player.y] = 0
for y in range(Constants.MAP_CONSOLE_HEIGHT):
for x in range(Constants.MAP_CONSOLE_WIDTH):
map_x, map_y = (camera_x + x, camera_y + y)
tile = map[map_x][map_y]
visible = Fov.is_visible(pos=(map_x, map_y))
# dist = Utils.distance_between(player.x, player.y, map_x, map_y)
# Map.d_map[map_x][map_y] = int(dist)
if Constants.DEBUG:
if Map.is_blocked(map_x, map_y):
draw_char(layers['map_console'], x, y, '*',
tile.f_color, libtcod.BKGND_SET)
#else:
if True:
dist = Map.current_map()[map_x][map_y].distance_to_player
char = chr(min(dist + 48, 200)) # chr(min(Map.d_map[map_x][map_y] + 48, 200))
if dist == -1:
char = ' '
c_value = max(dist, 0) # max(Map.d_map[map_x][map_y] , 0)
# char = hm_values[min(c_value, len(hm_values) - 1)]
db_color = hm_colors[min(c_value, len(hm_colors) - 1)]
draw_char(layers['map_console'], x, y, char,
db_color, libtcod.BKGND_SET)
else:
if not visible:
if tile.explored:
if tile.blocked:
char = tile.char
f_color = libtcod.Color(50, 50, 50)
b_color = libtcod.Color(10, 10, 10)
else:
char = '.'
f_color = libtcod.Color(50, 50, 50)
b_color = libtcod.Color(0, 0, 0)
draw_char(layers['map_console'], x, y, char,
f_color, libtcod.BKGND_SET)
draw_background(layers['map_console'], x, y,
b_color, flag=libtcod.BKGND_SET)
#libtcod.console_put_char_ex(consoles['map_console'], x, y, char,
# Themes.OUT_OF_FOV_COLOR, libtcod.BKGND_SET)
else:
offset_color = get_offset_color(map_x, map_y)
draw_char(layers['map_console'], x, y, tile.char,
tile.f_color - offset_color, libtcod.BKGND_SET)
draw_background(layers['map_console'], x, y,
tile.b_color - offset_color, flag=libtcod.BKGND_SET)
tile.explored = True