def attack(self, pos, gap, orientation,team): if self.nextAttackTimer != 0.0 or self.knivesAvailable == 0: #print 'cooldown: ', self.nextAttackTimer, self.knivesAvailable return False self.knivesAvailable -= 1 self.nextAttackTimer += self.attackCooldown #create a knife just outside the spawn location knifeShape = Rect.createAtOrigin(10,10) #TODO: how to handle diagonal movement and firing? # spawn outside rect, or inside? knifePos = pos + orientation.getNormalized()*gap #print orientation.getNormalized() * gap #proj = BasicProjectile(knifePos,knifeShape,team,orientation) proj = MagicKnife(knifePos,knifeShape,self.owner,orientation) proj.owner = self.owner #Set owner so it can return and keep track of unit self.knives.append(proj) glad.world.objectList.append(proj) #play sound effect proj.sound.play(self.owner.pos) return True
def attack(self, pos, gap, orientation,team): if self.nextAttackTimer != 0.0: return False self.nextAttackTimer += self.attackCooldown #create a knife just outside the spawn location projectileShape = Rect.createAtOrigin(self.size[0], self.size[1]) #TODO: how to handle diagonal movement and firing? # spawn outside rect, or inside? projectilePos = pos + orientation.getNormalized()*gap proj = SlimeBall(projectilePos,projectileShape,self.owner,orientation,self.hue) #proj = Rock(projectilePos,projectileShape,team,orientation) glad.world.objectList.append(proj) #play sound effect proj.sound.play(self.owner.pos) return True
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(64, 64) AbstractObject.__init__(self, pos, shape, **kwargs) self.collisionType = 'UNIT' self.orientation = Vector(1,0)
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(26, 28) BasicUnit.__init__(self, pos, shape, name='GHOST', **kwargs) self.rangedWeapon = KnifeThrower(self) self.alwaysMove = True
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(16, 16) BasicUnit.__init__(self, pos, shape, name='FAERIE', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'sparkle') self.alwaysMove = True
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(64, 64) BasicUnit.__init__(self, pos, shape, name='BIG_SLIME', slime=True, **kwargs) self.rangedWeapon = SlimeAttack(self) self.alwaysMove = True
def __init__(self, pos, owner, **kwargs): shape = Rect.createAtOrigin(32, 32) AbstractObject.__init__(self, pos, shape, **kwargs) self.owner = self #keep a copy of who the corpse belongs to self.collisionType = 'OBJ' #should add collision type for corpses, keys, and other stuff you can walk over self.currentAnimation = 'ANIM_BLOOD_'+str(random.randint(0,3)) self.animationPlayer = animation.AnimationPlayer(glad.resource.resourceDict[self.currentAnimation], 0.2, True)
def __init__(self, pos, **kwargs): #For now, just use BasicUnit Defaults #default soldier size shape = Rect.createAtOrigin(32, 32) BasicUnit.__init__(self, pos, shape, name='SOLDIER', **kwargs) #self.rangedWeapon = BasicRangedAttack('knife',size=(12,12)) self.rangedWeapon = KnifeThrower(self)
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 32) BasicUnit.__init__(self, pos, shape, name='FIRE_ELEM', **kwargs) #self.rangedWeapon = KnifeThrower() self.rangedWeapon = BasicRangedAttack(self, 'meteor') self.alwaysMove = True self.animationPlayer.timer = 0.1
def __init__(self, pos, shape = Rect.createAtOrigin(32, 32), hue=180, name='SOLDIER', slime=False, **kwargs): AbstractObject.__init__(self, pos, shape, **kwargs) self.collisionType = 'UNIT' #Default statistics self.strength = 10 self.dexterity = 10 self.constitution = 10 self.intelligence = 10 self.armor = 10 self.level = 1 self.life = 100 self.mana = 100 self.rangedWeapon = None self.meleeWeapon = None self.rangedDamage = 10 self.meleeDamage = 10 self.range = 400 #range for ranged weapon (in pixels) self.moveSpeed = 200 #By default, have units face 'right' self.orientation = Vector(1,0) self.directionString = self.orientationToString() #may not be needed #self.name = "SOLDIER" #might as well be soldier by default, name used to load animations with current name format self.name=name self.slime=slime if self.slime: self.currentAnimation = 'ANIM_' + self.name + '_TEAM_' + str(self.team) +'_MOVE' else: self.currentAnimation = 'ANIM_' + self.name + '_TEAM_' + str(self.team) +'_MOVE' + self.orientationToString() self.animationTime = 0.2 self.animationPlayer = animation.AnimationPlayer(glad.resource.resourceDict[self.currentAnimation], self.animationTime , True) self.alwaysMove = False #turning self.turnTime = 0.08 #Attacking self.attacking = False #attack animation self.attackTime = 0.1 #time attack frame is up self.attackTimer = 0 self.animateAttack = False self.hue = hue #I thnk this is from my old method of team coloring - can probably be removed
def attack(self, pos, gap, orientation,team): if self.nextAttackTimer != 0.0: return False self.nextAttackTimer += self.attackCooldown #create a knife just outside the spawn location projectileShape = Rect.createAtOrigin(self.size[0], self.size[1]) #TODO: how to handle diagonal movement and firing? # spawn outside rect, or inside? projectilePos = pos + orientation.getNormalized()*gap dict = {'rock': Rock(projectilePos,projectileShape,self.owner,orientation), 'arrow': Arrow(projectilePos,projectileShape,self.owner,orientation), 'firearrow': FireArrow(projectilePos,projectileShape,self.owner,orientation), 'fireball': Fireball(projectilePos,projectileShape,self.owner,orientation), 'hammer': Hammer(projectilePos,projectileShape,self.owner,orientation), 'lightning': Lightning(projectilePos,projectileShape,self.owner,orientation), 'meteor': Meteor(projectilePos,projectileShape,self.owner,orientation), 'bone' : Bone(projectilePos,projectileShape,self.owner,orientation), 'knife' : Knife(projectilePos,projectileShape,self.owner,orientation), 'sparkle' : Sparkle(projectilePos,projectileShape,self.owner,orientation), 'boulder' : Boulder(projectilePos,projectileShape,self.owner,orientation)} proj = dict[self.type] proj.owner = self.owner #play sound - if I do this when the projectile is created, it plays it for each entry in the above dict #need to play sound for each attack, right now just this, knifeThrower, and slimeAttack proj.sound.play(self.owner.pos) #if self.type == "arrow": # glad.resource.resourceDict['twang'].play(self.owner.pos) #elif self.type == "sparkle": # glad.resource.resourceDict['faerie1'].play(self.owner.pos) #elif self.type == "lightning": # glad.resource.resourceDict['bolt1'].play(self.owner.pos) #elif self.type == "meteor": # glad.resource.resourceDict['blast1'].play(self.owner.pos) #else: # glad.resource.resourceDict['fwip'].play(self.owner.pos) #Just testing sound, should be for only stuff on screen or nearby, #proj = BasicProjectile(projectilePos, projectileShape, team, orientation) #basic projectile should be default #proj = Fireball(projectilePos,projectileShape,team,orientation) ##proj = Knife(projectilePos,projectileShape,team,orientation) glad.world.objectList.append(proj) return True
def __init__(self, pos, tileNum, type = None, shape=Rect.createAtOrigin(32,32), **kwargs): AbstractObject.__init__(self, pos, shape, team=None, moveDir=None, **kwargs) self.collisionType = 'LAND' if tileNum in Tile.water: self.collisionType = 'WATER' elif tileNum in Tile.tree: self.collisionType = 'TREE' elif tileNum in Tile.wall: self.collisionType = 'WALL' elif tileNum in Tile.barrier: self.CollisionType = 'BARRIER' #set appropriate tile to be drawn self.tileNum = tileNum tileName = Tile.tileDict[self.tileNum] anim = [glad.resource.get(tileName)] self.currentAnimation = animation.Animation(anim) self.animationPlayer = animation.AnimationPlayer(self.currentAnimation, 0.2, True)
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 26) BasicUnit.__init__(self, pos, shape, name='THIEF', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'knife', size=(12,12))
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(30, 26) BasicUnit.__init__(self, pos, shape, name='SKELETON', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'bone', size=(14,14))
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 32) BasicUnit.__init__(self, pos, shape, name='ORC', **kwargs) self.rangedWeapon = KnifeThrower(self)
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 28) BasicUnit.__init__(self, pos, shape, name='MAGE', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'fireball')
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(96, 72) BasicUnit.__init__(self, pos, shape, name='GOLEM', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'boulder', size=(26,26))
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(20, 20) BasicUnit.__init__(self, pos, shape, name='ELF', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'rock',size=(12,12))
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 22) BasicUnit.__init__(self, pos, shape, name='DRUID', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'lightning')
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 28) BasicUnit.__init__(self, pos, shape, name='BARBARIAN', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'hammer', size=(12,12))
def __init__(self, pos, **kwargs): shape = Rect.createAtOrigin(32, 32) BasicUnit.__init__(self, pos, shape, name='ARCHER', **kwargs) self.rangedWeapon = BasicRangedAttack(self, 'arrow', size=(14,14))