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


Python Avatar.setPosition方法代碼示例

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


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

示例1: BotWrapper

# 需要導入模塊: from Avatar import Avatar [as 別名]
# 或者: from Avatar.Avatar import setPosition [as 別名]
class BotWrapper(object):
    """Provides access to user bot methods and keeps meta-data for user bots"""
    
    def __init__(self,plyr,parent=None):
        #Bot __init__ is given starthealth, parent class
        self.bot = __import__(plyr).Bot(parent.STARTHEALTH,self)
        self.name = self.bot.getName()
        self.imagesDict = self.bot.getImages()
        self.parent = parent
        self.VERSION = self.parent.VERSION
        self.botmodifiers = BotModifiers(self.name)
        self.botstats = BotStats(self.name,self.botmodifiers)
        self.__position = [0,0]
        self.__ids = [0,0,0,0,0]
        self.resetStats()
        self.avatar = Avatar(self.name,self.__position,self.imagesDict)
        
    #def addEnemy(self,enemy):
    #    self.bot.addEnemy(enemy)
        
    def addPoints(self,n):
        self.botstats.add("points",n)
    
    #args: Damage object
    #Return: integer health
    def adjustHealth(self,damage):
        return self.bot.adjustHealth(damage)
    
    #args: string command
    #Return: none
    #executes user inputted commands
    def command(self,command):
        print "COMMAND: ",command," , made it to the botwrapper of: ",self.name
        self.bot.command(command)       
    #args integer round number
    #Return: none    
    def endRound(self,roundnumber):
        self.bot.endRound(roundnumber)
        if self.bot.getHealth() <= 0:
            self.__stance = "OUT!!"
    
    #args: none
    #return: none        
    def endGame(self):
        self.botstats.endgame()
        mod = self.botstats.getNextModifier()
        while mod:
            self.botmodifiers.adjustModifier(*mod)
            mod = self.botstats.getNextModifier()
            
    def getAvatar(self):
        self.avatar.stance = self.getStance()
        self.avatar.setPosition(self.__position)
        self.avatar.health = self.getHealth()
        self.avatar.enemies = self.getEnemies()
        self.avatar.modifiers = self.botmodifiers.getModifiers(True)
        try:
            self.avatar.color = self.bot.getColor()
        except AttributeError:
            self.avatar.color = (255,255,255)
        return copy.copy(self.avatar)
    
    #args: none
    #Return: list of enemies' names    
    def getEnemies(self):
        return self.bot.getEnemies()
    
    #args: none
    #Return: integer health    
    def getHealth(self):
        return self.bot.getHealth()
    
    
    def getIds(self):
        return self.__ids
    
    #args: none
    #Return: float angle to look    
    def getLookDirection(self):
        return self.bot.getLookDirection()
 
    
    def getModifier(self,name):
        return self.botmodifiers.getModifier(name)
    
    def getMoveDirection(self):
        return self.bot.getMoveDirection()
    
    #args: none
    #Return: string name
    def getName(self):
        return self.name
    
    def getPosition(self):
        return self.__position

    #args: none
    #Return: Stance object
    def getStance(self):
        if self.__stance:
#.........這裏部分代碼省略.........
開發者ID:lovi9573,項目名稱:BotWars,代碼行數:103,代碼來源:Wrappers.py


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