本文整理汇总了Python中ai.AI.begin_move方法的典型用法代码示例。如果您正苦于以下问题:Python AI.begin_move方法的具体用法?Python AI.begin_move怎么用?Python AI.begin_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ai.AI
的用法示例。
在下文中一共展示了AI.begin_move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import begin_move [as 别名]
#.........这里部分代码省略.........
self.load_objects()
self.load_characters()
def load_objects(self):
self.object_models = {}
for key in self.object_catalog:
house_object = self.object_catalog[key]
object_model = self.loader.loadModel(os.path.join("data","egg", house_object.name))
object_model.reparentTo(self.render)
x_coord, y_coord = house_object.map_coords
object_model.setPos(x_coord+0.5, y_coord+0.5, 0)
self.object_models[key] = object_model
def load_walls(self):
for i in xrange(len(self.wall_data.layout)-1):
for j in xrange(len(self.wall_data.layout[0])-1):
wall = self.wall_data.layout[i][j]
wall_below = self.wall_data.layout[i+1][j]
wall_next = self.wall_data.layout[i][j+1]
if (wall, wall_next) in DRAW_HORIZONTAL:
self.make_horizontal_wall((i,j))
if (wall, wall_below) in DRAW_VERTICAL:
self.make_vertical_wall((i,j))
def load_characters(self):
self.character_models = {}
catalog = self.character_catalog.get_catalog()
for key in catalog:
character_model = Actor(os.path.join("data","egg","placeholder_character"))
x,y = catalog[key].position
character_model.setPos(x-0.5,y-0.5,0)
character_model.reparentTo(self.render)
self.character_models[key] = character_model
def load_3d_gui(self):
self.selector = self.loader.loadModel(os.path.join("data","egg", "selected"))
self.selector.setPos(0,0,3)
self.selector.hide()
self.selector.reparentTo(self.render)
def make_horizontal_wall(self, pos):
x, y = pos
cm = CardMaker("wall")
cm.setFrame(0, 1, 0, 2)
front_card = cm.generate()
front = self.render.attachNewNode(front_card)
front.setH(90)
front.setPos(x,y,0)
back_card = cm.generate()
back = self.render.attachNewNode(back_card)
back.setH(270)
back.setPos(x,y+1,0)
def make_vertical_wall(self, pos):
x, y = pos
cm = CardMaker("wall")
cm.setFrame(0, 1, 0, 2)
front_card = cm.generate()
front = self.render.attachNewNode(front_card)
front.setH(0)
front.setPos(x,y,0)
back_card = cm.generate()
back = self.render.attachNewNode(back_card)
back.setH(180)
back.setPos(x+1,y,0)
def load_floor(self):
cm = CardMaker("floor")
cm.setFrame(0, 1, 0, 1)
card = cm.generate()
grass_texture = self.loader.loadTexture(os.path.join("data", "images", "grass.png"))
wood_texture = self.loader.loadTexture(os.path.join("data", "images", "floor_wood_0.png"))
for x, row in enumerate(self.floor_data.layout):
for y, tile in enumerate(row):
floor = self.render.attachNewNode(cm.generate())
floor.setP(270)
floor.setPos(x,y,0)
if tile == floor_layout.GRASS:
floor.setTexture(grass_texture)
elif tile == floor_layout.WOOD:
floor.setTexture(wood_texture)
def select_character(self, character_id):
self.selector.show()
self.selector.reparentTo(self.character_models[character_id])
def move_character(self, character_id, destination):
self.ai.begin_move(character_id, destination)
def step_character(self, character_id, next_node):
model = self.character_models[character_id]
x, y, z = model.getPos()
step = calculate_step((x,y),next_node)
model.lookAt(next_node[0], next_node[1], 0)
model.setPos(model, 0, 0.1, 0)
#model.setPos(model, step[0], step[1], 0)
model_pos = model.getPos()
self.ai.character_catalog[character_id].update_path(model_pos)