Ejemplo n.º 1
0
 def __init__(self):
     AvatarObject.__init__(self)
     self.rate = 1000
     self.time = 0
     self.pushable = False
     self.dying = False
     self.dead = False
Ejemplo n.º 2
0
 def __init__(self):
     AvatarObject.__init__(self)
     self.rate = 4000
     self.time = 0
     self.warned = False
     self.pushable = True
     self.activated = False
     self.dying = False
Ejemplo n.º 3
0
Archivo: rpg.py Proyecto: bitcraft/mh
    def __init__(self):
        AvatarObject.__init__(self)

        self.defaultSpells = []
        self.isAlive = True
        self.hp = 10
        self.wieght = 10

        # stats
        self.str = 1
        self.int = 1
        self.dex = 1
        self.exp = 0

        self.init()

        self._oldPosition = None

        self.arms = None
        self.leftHand = None
        self.rightHand = None
        self.join = None

        self.reach = 2   # number of pixels that char can reach to grab things
Ejemplo n.º 4
0
 def die(self):
     self.bolt = AvatarObject()
     self.bolt.name = "self.bolt"
     avatar = Avatar()
     ani = Animation("electrify.png", "electrify", 2, 1, 50)
     avatar.add(ani)
     avatar.play("electrify", loop=6, callback=self.die2)
     self.bolt.setAvatar(avatar)
     self.parent.add(self.bolt)
     body0 = self.parent.getBody(self)
     body1 = self.parent.getBody(self.bolt)
     x, y, z, d, w, h = body0.bbox
     self.parent.setBBox(self.bolt, (x, y, z, 1, w, h))
     self.parent.join(body0, body1)
     ani.load()
     self.dying = True
     self.parent.emitSound("powerdown.wav", thing=self)
Ejemplo n.º 5
0

avatar = Avatar()
ani = Animation("magician-male-walk.png", "walk", [0,1,2,1], 4)
avatar.add(ani)
npc = NPC()
npc.setName("Nail")
npc.setAvatar(avatar)
npc.setGUID(6)
uni.add(npc)


avatar = Avatar()
ani = StaticAnimation("16x16-forest-town.png", "barrel", (9,1), (16,16))
avatar.add(ani)
item = AvatarObject()
item.pushable = True
item.setName("Barrel")
item.setAvatar(avatar)
item.setGUID(513)
uni.add(item)

avatar = Avatar()
ani = StaticAnimation("16x16-forest-town.png", "sign", (11,1), (16,16))
avatar.add(ani)
item = AvatarObject()
item.pushable = False
item.setName("Sign")
item.setAvatar(avatar)
item.setGUID(514)
uni.add(item) 
Ejemplo n.º 6
0
 def __init__(self, avatar, builders):
     AvatarObject.__init__(self, avatar)
     self.actionBuilders = builders
Ejemplo n.º 7
0
 def __init__(self):
     AvatarObject.__init__(self)
     self.gravity = True
     self.pushable = True
     self.held = None
     self.hasPassword = False
Ejemplo n.º 8
0
class LaserRobot(AvatarObject):
    sounds = ["ex0.wav", "warn.wav", "select1.wav", "powerdown.wav"]

    def __init__(self):
        AvatarObject.__init__(self)
        self.rate = 4000
        self.time = 0
        self.warned = False
        self.pushable = True
        self.activated = False
        self.dying = False


    def activate(self):
        self.activated = True
        self.parent.emitSound("select1.wav", thing=self)


    def update(self, time):
        #if self.isFalling and self.isAlive and not self.dying:
        #    self.die()

        #if not self.isAlive:
        #    self.destroy()

        if not self.activated: return

        self.time += time
        if self.time >= self.rate:
            self.time -= self.rate
            if self.warned:
                self.warned = False
                self.shoot()
            else:
                self.warned = True
                self.warn()


    def die2():
        body0 = self.parent.getBody(self)
        body1 = self.parent.getBody(self.bolt)
        self.parent.unjoin(body0, body1)
        self.isAlive = False


    def die(self):
        self.bolt = AvatarObject()
        self.bolt.name = "self.bolt"
        avatar = Avatar()
        ani = Animation("electrify.png", "electrify", 2, 1, 50)
        avatar.add(ani)
        avatar.play("electrify", loop=6, callback=self.die2)
        self.bolt.setAvatar(avatar)
        self.parent.add(self.bolt)
        body0 = self.parent.getBody(self)
        body1 = self.parent.getBody(self.bolt)
        x, y, z, d, w, h = body0.bbox
        self.parent.setBBox(self.bolt, (x, y, z, 1, w, h))
        self.parent.join(body0, body1)
        ani.load()
        self.dying = True
        self.parent.emitSound("powerdown.wav", thing=self)


    def warn(self):
        self.avatar.play("warn", loop=4)
        self.parent.emitSound("warn.wav", thing=self)


    def shoot(self):
        boss = [ i for i in self.parent.getChildren() if isinstance(i, Boss) ]
        hero = self.parent.getChildByGUID(1)
        bbox = self.parent.getBody(self).bbox.inflate(0,128,0)

        if boss:
            boss = boss.pop()
            if bbox.collidebbox(self.parent.getBody(boss).bbox):
                boss.hit()

        laser = Laser()
        self.parent.add(laser, bbox.center)
        if bbox.collidebbox(self.parent.getBody(hero).bbox):
            if not hero.avatar.isPlaying("crouch") and hero.isAlive:
                self.parent.emitText(choice(laserFlavour), thing=self)
                hero.die()

        self.parent.emitSound("ex0.wav", thing=self)
        self.avatar.play("shoot", loop=0)