def Update(self, frameTime): if self.HaSidoResuelto(frameTime): return True if self.ERROR: return False if self.moving: if self.termino_instruction: if self.playingStepByStep and self.stepDone: return stack = self.scenario.GetStack(self.currentPos) self.direction = self.SiguienteInstruccion() if stack != None and self.direction != None: if stack.IsFull() and self.direction == "INS_DOWN" and self.attachedBox != None: window = Application.getActiveWindow() window.SetMessage(self.BuildErrorMessage()) self.ERROR = True else: if self.direction == "INS_DOWN": if self.movingDown: if self.attachedBox == None: limit = 595 else: limit = 590 - len(self.scenario.GetStack(self.currentPos).stack)*self.scenario.GetBoxSize() if self.holder.GetPosition()[1] >= limit: if self.attachedBox == None: #llego al fondo sin caja! self.movingDown = False self.catching = True self.movingUp = False else: #llego al lugar donde poner la caja que carga! self.scenario.GetStack(self.currentPos).InsertOnTop(self.attachedBox) self.attachedBox = None self.movingDown = False self.movingUp = False self.catching = True self.catching2 = True else: # aun no ha llego lo mas bajo que puede llegar desp_x = frameTime*self.velocity self.MoverVertical(desp_x) if self.attachedBox != None: posy = self.holder.GetPosition()[1] + self.base_holder_size[1] self.attachedBox.SetPositionY(posy) elif self.movingUp: if int(self.holder.GetPosition()[1]) <= self.base_cable_size[1] + self.cable.GetPosition()[1]: self.movingDown = False self.catching = False self.movingUp = False self.function_set.UnsetHighlightInstruction(self.function_id, self.instruction_id) self.termino_instruction = True self.StopStepByStep() else: desp_x = -frameTime*self.velocity self.MoverVertical(desp_x) if self.attachedBox != None: posy = self.holder.GetPosition()[1] + self.base_holder_size[1] self.attachedBox.SetPositionY(posy) elif self.catching or self.catching2: self.MoverVertical(frameTime*self.velocity) elif self.direction == "PROG_1": self.CambiarAProg(0) elif self.direction == "PROG_2": self.CambiarAProg(1) elif self.direction == "PROG_3": self.CambiarAProg(2) elif self.direction == "PROG_4": self.CambiarAProg(3) elif self.direction == "INS_RIGHT": stack = self.scenario.GetStack(self.currentPos + 1) if stack == None: self.ERROR = True window = Application.getActiveWindow() window.SetMessage(self.BuildErrorMessage()) return if self.left_pin.GetPosition()[0] >= self.GetStackPosition(self.currentPos + 1): x = self.left_pin.GetSize()[0]/2; self.base_left_pin_pos = (self.GetStackPosition(self.currentPos + 1) + x, self.left_pin.GetPosition()[1]) self.currentPos += 1 self.function_set.UnsetHighlightInstruction(self.function_id, self.instruction_id) self.termino_instruction = True self.StopStepByStep() else: desp_x = frameTime*self.velocity self.MoverHorizontal(desp_x) elif self.direction == "INS_LEFT": stack = self.scenario.GetStack(self.currentPos - 1) if stack == None: self.ERROR = True window = Application.getActiveWindow() window.SetMessage(self.BuildErrorMessage()) return if self.left_pin.GetPosition()[0] <= self.GetStackPosition(self.currentPos - 1): self.base_left_pin_pos = (self.GetStackPosition(self.currentPos - 1) + self.left_pin.GetSize()[0]/2, self.left_pin.GetPosition()[1]) self.currentPos -= 1 self.function_set.UnsetHighlightInstruction(self.function_id, self.instruction_id) self.termino_instruction = True self.StopStepByStep() else: desp_x = -frameTime*self.velocity self.MoverHorizontal(desp_x) elif self.direction == None: self.termino_instruction = True self.StopStepByStep()