Exemplo n.º 1
0
 def activate(self,xy,obj):
     if obj.weaponID != self.ID:
         obj.weaponID = self.ID
         pic = obj.world.weaponPics[self.weaponID]
         obj.changeWeapon(BodyPart.weapon(pic,obj.world,self.damage,self.attackStyle))
         if obj.faceRight == False:
             obj.weapon.reflectY()
     obj.attack()
Exemplo n.º 2
0
    def __init__(
        self,
        world,
        name,
        arm,
        helm,
        leg,
        body,
        team='Green',
        AI=None,
        health=100,
        player=False
    ):  #construct requires name, arm pic, helm pic, leg pic, body pic, with options team, AI function, health and wheter or its a player
        self.over = world.over
        self.world = world

        self.body = BodyPart.bodyPart(body,
                                      world)  #creates the necessary limbs
        self.armLeft = BodyPart.bodyPart(arm, world)
        self.armRight = BodyPart.bodyPart(arm, world)
        self.helm = BodyPart.bodyPart(helm, world)
        self.legLeft = BodyPart.bodyPart(leg, world)
        self.legRight = BodyPart.bodyPart(leg, world)

        self.body.x = self.helm.x  #sets the body parts to the proper co-ordinates
        self.body.y = self.helm.y + self.helm.size[1]
        self.armLeft.x = self.body.x - (self.body.size[0] // 2)
        self.armLeft.y = self.body.y
        self.legLeft.x = self.body.x
        self.legLeft.y = self.body.y + self.body.size[1]
        self.legRight.x = self.legLeft.x + (self.legLeft.size[0] // 2)
        self.legRight.y = self.legLeft.y
        self.armRight.x = self.armLeft.x + self.body.size[0]
        self.armRight.y = self.armLeft.y

        self.name = name
        self.xVel = 0  #x and y velocity
        self.yVel = 0
        self.x = self.armLeft.x  #initializes x to the left arm x
        self.y = self.helm.y  # and y to the helm's y co ordinate

        self.size = (
            (self.armLeft.size[0] // 2) + self.body.size[0] +
            (self.armRight.size[0] // 2),
            self.helm.size[1] + self.body.size[1] + self.legLeft.size[1]
        )  # calculates the size of the character

        self.level = 1  # initializes the character's level to one

        self.speedLimit = 5  #maximum speedlimit
        self.faceRight = True  #facing right
        self.isJump = False  #jumping
        self.jumpSpeed = self.size[
            1] // 3  #jump speed is a third of the objects's size
        self.attackSpeed = 5  #rotation factor for attacks
        self.health = health  #sets the health
        self.maxHealth = health
        self.weapon = None  #stores a weapon object
        self.attacking = False  #bool for attacking
        self.team = team
        self.invincible = False  #used for after taking damage
        self.flashDelay = 0  #amount of flashes after taking damage
        self.flashAmount = 0
        self.damage = 5  #initializes damage to 5
        self.baseDamage = 5  #damage without level modifiers
        self.damage = self.damage + (
            self.damage * (self.level / 10)
        )  #modifies damage to be based on the characters level
        self.player = player
        self.headingToPoint = False  #boolean for if the character is heading to a point in the world
        self.goal = (0, 0)  #the goal they are trying to get to
        self.activeSpell = False  #if they have a spell flying/doing whatever in the game
        self.spellDelay = 0  #delay for shooting spells, dependant on the spell type, Spells.py
        self.faceTile = False  #if the character is walking into a tile
        self.dead = False  #self explanitory, but if the player is dead
        self.exp = 0  #current experience, influences when the character goes up a level
        self.expToLevel = 50  #the experience to the next level

        self.moveRight = True  #wheter or not the character can move right, unused probably
        self.moveLeft = True
        self.target = False  #unused also i think
        self.row = self.x // 32  #current row in the game world
        self.column = self.y // 32
        self.fleeing = False  #if they are fleeing(AI.villager)
        self.money = 0  #current money

        self.spell = None  #current spell function
        self.AI = AI  #current AI function
        self.control = True  #if the character can be controlled(only used fo the player)

        self.ID = genID()  #calculates the character specific ID
        self.AIGoal = None  #the goal for the AI, used by AI.py
        self.inv = Inventory.objectInventory(self.world.itemList)
        self.selectedSlot = 0
        self.weaponID = None
        self.tileHitTime = time.time()
        self.tileHitDelay = 0.4
        self.baseTileHitPower = 5
        self.damagedTile = (0, 0, 0)
        self.drawCrack = None
        self.hitRad = (3, 5)
        self.openInv = False
        self.skills = []
        self.mining = Mining.mining(self, self.over)
        self.woodcutting = Woodcutting.woodcutting(self, self.over)
        self.skills.append(self.mining)
        self.skills.append(self.woodcutting)
        self.AIPlaceGoals = []
        self.villageRole = None
        self.mustBuild = None
        self.placeDelay = 0.3
        self.placeTime = time.time()

        self.crafting = Crafting.crafting(self.inv, self.world.itemList)
        self.craftable = []

        self.toCraft = (None, None)
        self.lastCraft = None
        self.toGive = None
        self.toTake = (None, None)
        self.currentBuildingProject = None
        self.requiredResources = []
Exemplo n.º 3
0
    def __init__(self,world, name, arm, helm, leg, body, team='Green', AI=None, health=100, player=False):#construct requires name, arm pic, helm pic, leg pic, body pic, with options team, AI function, health and wheter or its a player
        self.over = world.over
        self.world = world

        self.body = BodyPart.bodyPart(body,world)#creates the necessary limbs
        self.armLeft = BodyPart.bodyPart(arm,world)
        self.armRight = BodyPart.bodyPart(arm,world)
        self.helm = BodyPart.bodyPart(helm,world)
        self.legLeft = BodyPart.bodyPart(leg,world)
        self.legRight = BodyPart.bodyPart(leg,world)

        self.body.x = self.helm.x#sets the body parts to the proper co-ordinates
        self.body.y = self.helm.y + self.helm.size[1]
        self.armLeft.x = self.body.x - (self.body.size[0]//2)
        self.armLeft.y=self.body.y
        self.legLeft.x = self.body.x
        self.legLeft.y = self.body.y + self.body.size[1]
        self.legRight.x = self.legLeft.x + (self.legLeft.size[0] // 2)
        self.legRight.y = self.legLeft.y
        self.armRight.x = self.armLeft.x + self.body.size[0]
        self.armRight.y = self.armLeft.y
        
        self.name = name
        self.xVel = 0#x and y velocity
        self.yVel = 0
        self.x = self.armLeft.x#initializes x to the left arm x
        self.y = self.helm.y# and y to the helm's y co ordinate

        self.size = ((self.armLeft.size[0]//2) + self.body.size[0] + (self.armRight.size[0]//2), self.helm.size[1] + self.body.size[1] + self.legLeft.size[1])# calculates the size of the character

        self.level = 1# initializes the character's level to one

        self.speedLimit = 5#maximum speedlimit
        self.faceRight = True#facing right
        self.isJump = False#jumping
        self.jumpSpeed = self.size[1]//3#jump speed is a third of the objects's size
        self.attackSpeed = 5#rotation factor for attacks
        self.health = health#sets the health
        self.maxHealth = health
        self.weapon = None#stores a weapon object
        self.attacking = False#bool for attacking
        self.team = team
        self.invincible = False#used for after taking damage
        self.flashDelay = 0#amount of flashes after taking damage
        self.flashAmount = 0
        self.damage = 5#initializes damage to 5
        self.baseDamage = 5#damage without level modifiers
        self.damage = self.damage + (self.damage * (self.level / 10))#modifies damage to be based on the characters level
        self.player = player
        self.headingToPoint = False#boolean for if the character is heading to a point in the world
        self.goal = (0,0)#the goal they are trying to get to
        self.activeSpell = False#if they have a spell flying/doing whatever in the game
        self.spellDelay = 0#delay for shooting spells, dependant on the spell type, Spells.py
        self.faceTile = False#if the character is walking into a tile
        self.dead = False#self explanitory, but if the player is dead
        self.exp = 0#current experience, influences when the character goes up a level
        self.expToLevel = 50#the experience to the next level

        self.moveRight = True#wheter or not the character can move right, unused probably
        self.moveLeft = True
        self.target = False#unused also i think
        self.row = self.x//32#current row in the game world
        self.column = self.y//32
        self.fleeing = False#if they are fleeing(AI.villager)
        self.money = 0#current money

        self.spell = None#current spell function
        self.AI = AI#current AI function
        self.control = True#if the character can be controlled(only used fo the player)

        self.ID = genID()#calculates the character specific ID
        self.AIGoal = None#the goal for the AI, used by AI.py
        self.inv = Inventory.objectInventory(self.world.itemList)
        self.selectedSlot = 0
        self.weaponID = None
        self.tileHitTime = time.time()
        self.tileHitDelay = 0.4
        self.baseTileHitPower = 5
        self.damagedTile = (0,0,0)
        self.drawCrack = None
        self.hitRad = (3,5)
        self.openInv = False
        self.skills = []
        self.mining = Mining.mining(self,self.over)
        self.woodcutting = Woodcutting.woodcutting(self,self.over)
        self.skills.append(self.mining)
        self.skills.append(self.woodcutting)
        self.AIPlaceGoals = []
        self.villageRole = None
        self.mustBuild = None
        self.placeDelay = 0.3
        self.placeTime = time.time()

        self.crafting = Crafting.crafting(self.inv,self.world.itemList)
        self.craftable = []

        self.toCraft = (None,None)
        self.lastCraft = None
        self.toGive = None
        self.toTake = (None,None)
        self.currentBuildingProject =None
        self.requiredResources = []