当前位置: 首页>>代码示例>>Python>>正文


Python effect.Effect类代码示例

本文整理汇总了Python中effect.Effect的典型用法代码示例。如果您正苦于以下问题:Python Effect类的具体用法?Python Effect怎么用?Python Effect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Effect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: touch

    def touch(self, e):
        if self.imortal == 0:
            self.g.hurt.play()
            self.imortal = 10
            self.health -= e.get_damage()
            ef = Effect(self.g, "health", (self.rect.x, self.rect.y))
            ef.healthchange = -e.get_damage()
            # drop some skyberries
            if "weapon" in self.g.saveData:
                if self.g.saveData["weapon"] >= 1:
                    wpnstr = "shot" + str(self.g.saveData["weapon"]) + "_lvl"
                    if self.g.saveData[wpnstr] > 1:
                        self.g.saveData[wpnstr] -= 1
                        if self.g.saveData[wpnstr] == 9:
                            Effect(self.g, "msg", (self.rect.x, self.rect.y), "Level Down")
                        if self.g.saveData[wpnstr] == 19:
                            Effect(self.g, "msg", (self.rect.x, self.rect.y), "Level Down")
                        sb = Inventory(self.g, "skyberry", (self.rect.x, self.rect.y))
                        sb.canget = 0
                        sb = Inventory(self.g, "skyberry", (self.rect.x, self.rect.y))
                        sb.canget = 0
                        sb = Inventory(self.g, "skyberry", (self.rect.x, self.rect.y))
                        sb.canget = 0

            self.g.player.gravity = 15
            self.g.player.jumping = 1
            if self.g.saveData["weapon"] != 0:
                shotType = "shot" + str(self.g.saveData["weapon"])
                self.g.saveData[shotType] -= 1
            self.g.saveData["health"] = self.health
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:30,代码来源:player.py

示例2: addHealth

 def addHealth(self, n):
     self.health += n
     ef = Effect(self.g, "health", (self.rect.x, self.rect.y - 10))
     ef.healthchange = n
     if self.health > self.healthmax:
         self.health = self.healthmax
     self.g.saveData["health"] = self.health
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:7,代码来源:player.py

示例3: tick

 def tick(self):
     self.host.game.do_damage(self.host, d(3), D_FIRE, self.owner)
     if self.host == self.host.game.player:
         self.host.game.shout('You are getting burned!')
     else:
         self.host.game.shout('%s is getting burned!' % (self.host.name))
     Effect.tick(self)
开发者ID:Wildcard12,项目名称:python-dungeon-crawler,代码行数:7,代码来源:dv_effects.py

示例4: tick

 def tick(self):
     self.host.game.do_damage(self.host, d(3), D_GENERIC, self.owner)
     if self.host == self.host.game.player:
         self.host.game.shout('You are bleeding')
     else:
         self.host.game.shout('%s bleeds' % (self.host.name))
     Effect.tick(self)
开发者ID:Wildcard12,项目名称:python-dungeon-crawler,代码行数:7,代码来源:av_effects.py

示例5: __init__

 def __init__(self, host, owner):
     dur = 1
     Effect.__init__(self, dur, host, owner)
     actors = owner.game.get_all_srd_actors(owner.pos())
     for act in actors:
         Effect.__init__(self, dur, act, owner)
     weaponinfotext = 'Splatters the enemy'
开发者ID:Wildcard12,项目名称:python-dungeon-crawler,代码行数:7,代码来源:dv_effects.py

示例6: backup_attack_loop

    def backup_attack_loop(self):
        g = self.g
        self.image = self.orginalImage.subsurface((160, 0, 32, 32))

        speed = self.walktimer
        self.walktimer += 1
        if self.walktimer > 6:
            self.walktimer = 6


        self.timer += 1
        timergate = self.timer % 100
        if timergate >= 80:
            if timergate == 80:
                self.face_the_player()
            if timergate == 85:
                Shot(g, self.direction, (self.rect.x + 16, self.rect.y + 8), 'shot8', 'enemy')
            self.walking = 0
        else:
            self.walking = 1
        if timergate % 100 == 0:
            self.face_the_player()

        dx = self.rect.x - g.player.rect.x
        if dx <40 and dx > -40:
            if self.dy == 10.0:
                self.dy = -10.0

        if self.walking:
            self.rect.x += (1 - (self.direction * 2)) * speed
            framen = self.timer / 2  % 3
            self.image = self.orginalImage.subsurface((32 + framen * 32, 0, 32, 32))
        else:
            self.walktimer = 0

        self.dy += .5
        if self.dy > 10.0:
            self.dy = 10.0
        self.rect.y += self.dy

        if self.rect.x < 416:
            self.direction = 0

        
        self.image = pygame.transform.flip(self.image, self.direction, 0)
        # hitting the bullets and player
        s = Rect(self.rect)
        if s.colliderect (g.player.rect):
            g.player.touch(self)
        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if s.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    self.image = g.make_image_white(self.image)
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:58,代码来源:character.py

示例7: concretize_service_request

def concretize_service_request(
        authenticator, log, service_configs, throttler,
        tenant_id,
        service_request):
    """
    Translate a high-level :obj:`ServiceRequest` into a low-level :obj:`Effect`
    of :obj:`pure_http.Request`. This doesn't directly conform to the Intent
    performer interface, but it's intended to be used by a performer.

    :param ICachingAuthenticator authenticator: the caching authenticator
    :param BoundLog log: info about requests will be logged to this.
    :param dict service_configs: As returned by
        :func:`otter.constants.get_service_configs`.
    :param callable throttler: A function of ServiceType, HTTP method ->
        Deferred bracketer or None, used to throttle requests. See
        :obj:`_Throttle`.
    :param tenant_id: tenant ID.
    """
    auth_eff = Effect(Authenticate(authenticator, tenant_id, log))
    invalidate_eff = Effect(InvalidateToken(authenticator, tenant_id))
    if service_request.log is not None:
        log = service_request.log

    service_config = service_configs[service_request.service_type]
    region = service_config['region']
    service_name = service_config['name']

    def got_auth((token, catalog)):
        request_ = add_headers(otter_headers(token), request)
        request_ = add_effect_on_response(
            invalidate_eff, service_request.reauth_codes, request_)
        request_ = add_json_request_data(request_)
        if 'url' in service_config:
            request_ = add_bind_root(service_config['url'], request_)
        else:
            request_ = add_bind_service(
                catalog, service_name, region, log, request_)
        request_ = add_error_handling(
            service_request.success_pred, request_)
        if service_request.json_response:
            request_ = add_json_response(request_)

        return request_(
            service_request.method,
            service_request.url,
            headers=service_request.headers,
            data=service_request.data,
            params=service_request.params,
            log=log)

    eff = auth_eff.on(got_auth)
    bracket = throttler(service_request.service_type,
                        service_request.method.lower(),
                        tenant_id)
    if bracket is not None:
        return Effect(_Throttle(bracket=bracket, effect=eff))
    else:
        return eff
开发者ID:dragorosson,项目名称:otter,代码行数:58,代码来源:__init__.py

示例8: mushroom_attack_loop

    def mushroom_attack_loop(self):
        g = self.g
        if self.health <= 0:
            if self.feeling != 'dead':
                self.feeling = 'dead'
                self.timer = 0
                
        if self.feeling == 'dead':
            if self.timer > 70:
                self.image = pygame.Surface((1, 1), SRCALPHA)
                self.dead = 1
                return
            if self.timer % 10 == 0:
                self.exp2.play()
            if self.timer % 3 == 0:
                # flash on and off
                self.image = pygame.Surface((1, 1), SRCALPHA)
            else:
                x = random.randint(0, 256)
                y = random.randint(0, 256)
                e = Effect(self.g, 'explosion', (self.rect.x + x, self.rect.y + y))
            return


        if self.timer % 20 == 1:
            if self.timer % 200 < 100:
                c = random.randint(0, 20)
                s = Shot(self.g, self.direction, (self.rect.x + 128, self.rect.y + 128 + c), 'shot5', 'enemy')
                s.callback = self.create_slime_monster
                self.squirt2.play()

        s = Rect(self.rect)
        s.x += 80
        s.width -= 100
        s.y += 100
        s.height -= 180
        if s.colliderect (g.player.rect):
            g.player.touch(self)

        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if s.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    tmp = pygame.Surface((256, 256), SRCALPHA)
                    tmp.blit(self.image, (0,0))
                    tmp.blit(self.secondImage, (0,0))
                    self.image = tmp
                    self.hitme.play()
                    
        speed = 2
        self.rect.x += (1 - (self.direction * 2)) * speed
        self.draw_health_meter()
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:56,代码来源:character.py

示例9: get_last_info

def get_last_info(fname):
    eff = Effect(ReadFileLines(fname)).on(
        lambda lines: (int(lines[0]),
                       datetime.utcfromtimestamp(float(lines[1]))))

    def log_and_return(e):
        _eff = err(e, "error reading previous number of tenants")
        return _eff.on(lambda _: (None, None))

    return eff.on(error=log_and_return)
开发者ID:glyph,项目名称:otter,代码行数:10,代码来源:metrics.py

示例10: get_org_repos

def get_org_repos(name):
    """
    Fetch the repos that belong to an organization.

    :return: An Effect resulting in a list of strings naming the repositories.
    """
    req = Effect(
        HTTPRequest("get",
                    "https://api.github.com/orgs/{0}/repos".format(name)))
    return req.on(success=lambda x: [repo['name'] for repo in json.loads(x)])
开发者ID:python-effect,项目名称:effect-examples,代码行数:10,代码来源:core.py

示例11: as_effect

    def as_effect(self):
        """Produce a :obj:`Effect` to create a stack."""
        eff = Effect(Func(uuid4))

        def got_uuid(uuid):
            stack_config = append_stack_uuid(self.stack_config, uuid)
            return create_stack(thaw(stack_config)).on(
                _success_reporter('Waiting for stack to create'))

        return eff.on(got_uuid)
开发者ID:meker12,项目名称:otter,代码行数:10,代码来源:steps.py

示例12: tick

 def tick(self):
     a = -d(4)
     if self.host.cur_health - a > self.host.health:
         a = self.host.cur_health - self.host.health
     self.host.game.do_damage(self.host, a, D_ORDER)
     if self.host == self.host.game.player:
         self.host.game.shout('You are regenerating')
     else:
         self.host.game.shout('%s is regenerating' % (self.host.name))
     Effect.tick(self)
开发者ID:Wildcard12,项目名称:python-dungeon-crawler,代码行数:10,代码来源:generic_effects.py

示例13: get_orgs

def get_orgs(name):
    """
    Fetch the organizations a user belongs to.

    :return: An Effect resulting in a list of strings naming the user's
    organizations.
    """
    req = Effect(
        HTTPRequest("get",
                    "https://api.github.com/users/{0}/orgs".format(name)))
    return req.on(success=lambda x: [org['login'] for org in json.loads(x)])
开发者ID:python-effect,项目名称:effect-examples,代码行数:11,代码来源:core.py

示例14: main_effect

def main_effect():
    """
    Request a username from the keyboard, and look up all repos in all of
    that user's organizations.

    :return: an Effect resulting in a list of repositories.
    """
    intent = ReadLine("Enter Github Username> ")
    read_eff = Effect(intent)
    org_repos_eff = read_eff.on(success=get_orgs_repos)
    return org_repos_eff
开发者ID:python-effect,项目名称:effect-examples,代码行数:11,代码来源:core.py

示例15: robot_attack_loop

    def robot_attack_loop(self):
        g = self.g
        self.timer += 1
        speed = 9
        attackphase = self.timer % 70
        self.image = self.orginalImage.subsurface((0, 32, 32, 32))
        if attackphase == 1: # lunge at the player
            self.face_the_player()
            self.attacking = 2 # 2 = lunging
        elif attackphase == 50: # fire a ball of death at the player
            Shot(self.g, self.direction, (self.rect.x + 16, self.rect.y + 20), 'shot8', 'enemy')
        if attackphase >= 50 and attackphase <= 65: # fire a ball of death at the player
            self.image = self.orginalImage.subsurface((64, 32, 32, 32))

        # lunging
        if self.attacking == 2:
            self.image = self.orginalImage.subsurface((32, 32, 32, 32))
            if self.rect.colliderect (self.g.player.rect):
                self.g.player.touch(self)
            self.rect.x += speed
            if self.direction:
                self.rect.x -= speed*2

        # loop through bullets and see if I die
        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if self.rect.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    self.image = g.make_image_white(self.image, (32, 32))
        self.image = pygame.transform.flip(self.image, not self.direction, 0)

        if self.health <= 0:
            self.feeling = 'dead'
            self.attacking = 0
            self.dontwalk = 1
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:39,代码来源:character.py


注:本文中的effect.Effect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。