當前位置: 首頁>>代碼示例>>Python>>正文


Python ComponentManager.check_Component方法代碼示例

本文整理匯總了Python中ComponentManager.ComponentManager.check_Component方法的典型用法代碼示例。如果您正苦於以下問題:Python ComponentManager.check_Component方法的具體用法?Python ComponentManager.check_Component怎麽用?Python ComponentManager.check_Component使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ComponentManager.ComponentManager的用法示例。


在下文中一共展示了ComponentManager.check_Component方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Walk_Direction

# 需要導入模塊: from ComponentManager import ComponentManager [as 別名]
# 或者: from ComponentManager.ComponentManager import check_Component [as 別名]
def Walk_Direction(creatureid, direction):
    cCoord = CM.get_Component('Coord', creatureid)
    newCoord = Coord(cCoord.X + direction.X, cCoord.Y + direction.Y)
    Coords = CM.dict_of('Coord')
    walkable = True
    for key, value in Coords.iteritems():
        if value == newCoord:
            if CM.check_Component('Tile', key):
                tile = CM.get_Component('Tile', key)
                if not tile.Passable:
                    walkable = False
    if walkable:
        cCoord.X = newCoord.X
        cCoord.Y = newCoord.Y
        return True
    else:
        return False
開發者ID:Akhier,項目名稱:12Down,代碼行數:19,代碼來源:S_MoveCreature.py

示例2: Teleport_Random

# 需要導入模塊: from ComponentManager import ComponentManager [as 別名]
# 或者: from ComponentManager.ComponentManager import check_Component [as 別名]
def Teleport_Random(creatureid):
    cCoord = CM.get_Component('Coord', creatureid)
    x = randint(1, config.playscreen_width - 1)
    y = randint(1, config.playscreen_height - 1)
    newCoord = Coord(x, y)
    Coords = CM.dict_of('Coord')
    walkable = True
    for key, value in Coords.iteritems():
        if value == newCoord:
            if CM.check_Component('Tile', key):
                tile = CM.get_Component('Tile', key)
                if not tile.Passable:
                    walkable = False
    if walkable:
        cCoord.X = newCoord.X
        cCoord.Y = newCoord.Y
    else:
        Teleport_Random(creatureid)
開發者ID:Akhier,項目名稱:12Down,代碼行數:20,代碼來源:S_MoveCreature.py

示例3: Blink_Random_Failable

# 需要導入模塊: from ComponentManager import ComponentManager [as 別名]
# 或者: from ComponentManager.ComponentManager import check_Component [as 別名]
def Blink_Random_Failable(creatureid, mindist=4, maxdist=10):
    cCoord = CM.get_Component('Coord', creatureid)
    x = randint(mindist, maxdist) * choice([-1, 1])
    y = randint(mindist, maxdist) * choice([-1, 1])
    newCoord = Coord(cCoord.X + x, cCoord.Y + y)
    while newCoord.X < 1 or newCoord.X > config.playscreen_width - 3 or \
            newCoord.Y < 1 or newCoord.Y > config.playscreen_height - 3:
        x = randint(mindist, maxdist) * choice([-1, 1])
        y = randint(mindist, maxdist) * choice([-1, 1])
        newCoord = Coord(cCoord.X + x, cCoord.Y + y)
    Coords = CM.dict_of('Coord')
    walkable = True
    for key, value in Coords.iteritems():
        if value == newCoord:
            if CM.check_Component('Tile', key):
                tile = CM.get_Component('Tile', key)
                if not tile.Passable:
                    walkable = False
    if walkable:
        cCoord.X = newCoord.X
        cCoord.Y = newCoord.Y
開發者ID:Akhier,項目名稱:12Down,代碼行數:23,代碼來源:S_MoveCreature.py


注:本文中的ComponentManager.ComponentManager.check_Component方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。