コード例 #1
0
class MultiArrowBlock(ArrowBlock):
    imgs = imgstrip4f("ArrowBlockAttached", 16)
    img = imgs[0]
    dimgs = [colcopy(i, (0, 255, 255), (0, 100, 100)) for i in imgs]
    eup = False
    init = False

    def __init__(self, x, y, d=0):
        self.place(x, y)
        self.dir = D.get_dir(d)
        self.d = d

    def update(self, world, events):
        if not self.init:
            tx, ty = self.x, self.y
            self.blockchain = []
            while True:
                tx, ty = D.offsetdxy(D.rotdir(self.dir, 1), tx, ty)
                if not world.in_world(tx, ty):
                    break
                o = world.get_o(tx, ty)
                if not o or o.name == "Fixed":
                    break
                self.blockchain.append(o)
            self.init = True
        dx, dy = self.dir if world.button else D.anti(self.dir)
        if not self.moving and self.can_move(dx, dy, world):
            if all([o.can_move(dx, dy, world) for o in self.blockchain]):
                self.ex_move(dx, dy, world)
                for o in self.blockchain:
                    o.ex_move(dx, dy, world)

    def get_img(self, world):
        return self.imgs[self.d] if world.button else self.dimgs[self.d]
コード例 #2
0
class ArrowHob(Hob):
    imgs = imgstrip4f("ArrowCooker", 16)
    img = imgs[0]
    updates = True

    def __init__(self, x, y, d=0):
        self.place(x, y)
        self.dir = D.get_dir(d)
        self.d = d

    def update(self, world, events):
        if self.contents:
            self.contents.heat()
            if self.contents.contents:
                self.warn = self.contents.contents.warn
                self.progress = self.contents.contents.progress
            else:
                self.warn = False
                self.progress = None
        if not self.moving:
            dx, dy = self.dir if world.button else D.anti(self.dir)
            if self.move(dx, dy, world):
                self.locked = True
            else:
                self.locked = False

    def get_img(self, world):
        return self.imgs[self.d]
コード例 #3
0
class ComboExit(Object):
    img = imgstrip4f("ComboExit", 16)[1]
    o3d = 4
    updates = True
    nexit = None

    def update(self, world, events):
        if not self.nexit:
            self.nexit = world.get_o(self.x, self.y - 1)
            assert self.nexit and self.nexit.name == "Exit", "NO EXIT FOUND"
            self.nexit.combo = self
        self.fx = self.nexit.fx if self.contents else 0
コード例 #4
0
class Flipper(Counter):
    imgs = imgstrip4f("Flipper", 16)
    img = imgs[0]
    tick = 1
    updates = True

    def update(self, world, events):
        self.tick += 1
        if self.tick == 600:
            world.p_button()
            self.tick = 1
        self.progress = self.tick * 14 // 600

    def get_img(self, world):
        return self.imgs[world.button]
コード例 #5
0
class Fryer(Hob):
    img = img4("Fryer")
    cookingimgs = imgstrip4f("FryerCooking", 16)
    render_contents = False

    def can_place(self, item):
        return item.name == "Basket"

    def update(self, world, events):
        if self.contents:
            self.contents.heat()
            if self.contents.contents:
                self.warn = self.contents.contents.warn
                self.progress = self.contents.contents.progress

    def get_img(self, world):
        return self.cookingimgs[world.anitick // 4 %
                                4] if self.contents else self.img
コード例 #6
0
class ArrowBlock(Object):
    imgs = imgstrip4f("ArrowBlock", 16)
    img = imgs[0]
    dimgs = [colcopy(i, (0, 255, 255), (0, 100, 100)) for i in imgs]
    name = "ArrowBlock"
    o3d = 4
    updates = True
    eup = False

    def __init__(self, x, y, d=0):
        self.place(x, y)
        self.dir = D.get_dir(d)
        self.d = d

    def update(self, world, events):
        if not self.moving:
            dx, dy = self.dir if world.button else D.anti(self.dir)
            self.move(dx, dy, world)

    def get_img(self, world):
        return self.imgs[self.d] if world.button else self.dimgs[self.d]
コード例 #7
0
class FoodExit(Object):
    img = img4("Exit")
    cimg = imgstrip4f("ComboExit", 16)[0]
    o3d = 4
    reverse = False
    combo = False
    name = "Exit"

    def on_place(self, world):
        for o in world.orders:
            if o.double:
                if self.combo and self.contents == o.os[
                        0].plate and self.combo.contents and self.combo.contents == o.os[
                            1].plate:
                    self.fx = 1
                    self.locked = True
                    self.order = o
                    break
            elif o.plate == self.contents:
                self.fx = 1
                self.locked = True
                self.order = o
                break
        else:
            self.fx = 0
        world.reg_updates(self)

    def update(self, world, events):
        if self.fx:
            if self.reverse:
                self.fx -= 1
                if not self.fx:
                    self.reverse = False
            else:
                self.fx += 1
                if self.fx == 64:
                    if self.order in world.orders:
                        world.remove_order(self.order)
                        self.contents = None
                        if self.order.double:
                            self.combo.contents = None
                            plate = Food.Plate()
                            plate.dirty = world.washing
                            world.returned.append([plate, 360])
                        world.del_updates(self)
                        money.play()
                        self.locked = False
                        plate = Food.Plate()
                        plate.dirty = world.washing
                        world.returned.append([plate, 360])
                    else:
                        self.reverse = True
                        self.order = None
        elif self.contents:
            for o in world.orders:
                if o.double:
                    if self.combo and self.contents == o.os[
                            0].plate and self.combo.contents and self.combo.contents == o.os[
                                1].plate:
                        self.fx = 1
                        self.locked = True
                        self.order = o
                elif o.plate == self.contents:
                    self.fx = 1
                    self.locked = True
                    self.order = o
            else:
                self.locked = False
        else:
            self.locked = False
            world.del_updates(self)

    def get_img(self, world):
        return self.cimg if self.combo else self.img