Example #1
0
 def draw(self, surf, gameStateObj=None, blend=None):
     if self.on and self.frameCount >= 0 and Engine.get_time() > self.start_time:
         # The animation is too far to the right. Must move left. (" - 32")
         image = self.image
         x, y = self.position
         if self.ignore_map:
             topleft = x, y
         else:
             topleft = (x-gameStateObj.cameraOffset.x-1)*GC.TILEWIDTH, (y-gameStateObj.cameraOffset.y)*GC.TILEHEIGHT
         if blend:
             image = Image_Modification.change_image_color(image, blend)
         if self.tint:
             Engine.blit(surf, image, topleft, image.get_rect(), Engine.BLEND_RGB_ADD)
         else:
             surf.blit(image, topleft)
    def draw(self, surf, gameStateObj):
        """Assumes image has already been developed."""
        image = self.create_image(self.image_state)
        x, y = self.unit.position
        left = x * GC.TILEWIDTH + self.spriteOffset[0]
        top = y * GC.TILEHEIGHT + self.spriteOffset[1]

        # Active Skill Icon
        if not self.unit.isDying and 'ActiveSkillCharged' in self.unit.tags:
            active_icon = GC.ICONDICT["ActiveSkill"]
            active_icon = Engine.subsurface(
                active_icon, (GC.PASSIVESPRITECOUNTER.count * 32, 0, 32, 32))
            topleft = (left - max(0, (active_icon.get_width() - 16) // 2),
                       top - max(0, (active_icon.get_height() - 16) // 2))
            surf.blit(active_icon, topleft)

        if self.transition_state in WARP_OUT_SET:
            if self.unit.deathCounter:
                image = Image_Modification.flickerImageWhiteColorKey(
                    image, 255)
                image = Image_Modification.flickerImageTranslucentColorKey(
                    image, int(100 * self.unit.deathCounter // 27))
            else:
                self.transition_counter -= Engine.get_delta()
                if self.transition_counter < 0:
                    self.transition_counter = 0
                image = Image_Modification.flickerImageTranslucentColorKey(
                    image, 100 - self.transition_counter //
                    (self.transition_time // 100))
                if self.transition_counter <= 0:
                    if self.transition_state == 'fade_out':
                        self.transition_state = 'normal'
                        if self.state == 'fake_transition_out':
                            self.change_state('normal', gameStateObj)
                        self.unit.die(gameStateObj)
                    elif self.transition_state == 'fade_out_event':
                        self.transition_state = 'normal'
                        if self.state == 'fake_transition_out':
                            self.change_state('normal', gameStateObj)
                        self.unit.die(gameStateObj, event=True)
                    elif self.transition_state == 'warp_out':
                        gameStateObj.map.initiate_warp_flowers(
                            self.unit.position)
                        self.unit.die(gameStateObj, event=True)
                        self.transition_state = 'normal'
                        if self.state == 'fake_transition_out':
                            self.change_state('normal', gameStateObj)
                    elif self.transition_state in ('fade_move', 'warp_move'):
                        # gameStateObj.map.initiate_warp_flowers(self.unit.position)
                        self.unit.leave(gameStateObj)
                        self.unit.position = self.next_position
                        self.unit.previous_position = self.next_position
                        self.unit.arrive(gameStateObj)
                        gameStateObj.cursor.setPosition(
                            self.unit.position, gameStateObj)
                        # gameStateObj.stateMachine.changeState('move_camera')
                        self.next_position = None
                        gameStateObj.map.initiate_warp_flowers(
                            self.unit.position)
                        if self.transition_state == 'fade_move':
                            self.set_transition('fade_in')
                        elif self.transition_state == 'warp_move':
                            self.set_transition('warp_in')
        elif self.transition_state == 'warp_in' or self.transition_state == 'fade_in':
            self.transition_counter -= Engine.get_delta()
            if self.transition_counter < 0:
                self.transition_counter = 0
            image = Image_Modification.flickerImageTranslucentColorKey(
                image,
                self.transition_counter // (self.transition_time // 100))
            if self.transition_counter <= 0:
                self.transition_state = 'normal'
                if self.state == 'fake_transition_in':
                    self.change_state('normal', gameStateObj)

        if self.unit.flicker:
            color = self.unit.flicker[2]
            total_time = self.unit.flicker[1]
            starting_time = self.unit.flicker[0]
            time_passed = Engine.get_time() - starting_time
            if time_passed >= total_time:
                self.unit.end_flicker()
            else:
                color = ((total_time - time_passed) * float(c) // total_time
                         for c in color)
                #  image = Image_Modification.flicker_image(image.convert_alpha(), color)
                image = Image_Modification.change_image_color(
                    image.convert_alpha(), color)
        elif self.unit.flickerRed and gameStateObj.boundary_manager.draw_flag:
            image = Image_Modification.flickerImageRed(image.convert_alpha(),
                                                       80)
        # if any(status.unit_translucent for status in self.unit.status_effects):
        if 'unit_translucent' in self.unit.status_bundle:
            image = Image_Modification.flickerImageTranslucentColorKey(
                image, 50)

        if 'unit_tint' in self.unit.status_bundle:
            for status in self.unit.status_effects:
                if status.unit_tint:
                    color = status.unit_tint.color
                    time = Engine.get_time()
                    diff = Utility.determine_perc(time,
                                                  status.unit_tint.period,
                                                  status.unit_tint.width)
                    diff = Utility.clamp(
                        255. * diff * status.unit_tint.max_alpha, 0, 255)
                    color = (color[0], color[1], color[2], diff)
                    image = Image_Modification.color_tint(
                        image.convert_alpha(), color)

        # Active Skill Indicator -- this flashes the unit yellow when a skill is charged
        # if not self.unit.isDying and 'ActiveSkillCharged' in self.unit.tags:
        #     time = Engine.get_time()
        #     length = 500
        #     if not (time//1000)%3 and not (time//length)%(1000//length):
        #         diff = time%length
        #         if diff > length//2:
        #             diff = length - diff
        #         diff = Utility.clamp(255. * diff / length * 2, 0, 255)
        #         color = (248, 248, -248, diff)
        #         image = Image_Modification.color_tint(image.convert_alpha(), color)
        # What is this line even doing? - Something majorly important though
        # Each image has (self.image.get_width() - 32)/2 buffers on the left and right of it, to handle any off tile spriting
        # Without self.image.get_width() - 32)//2, we would output the left buffer along with the unit,
        # and the unit would end up +left buffer width to the right of where it should be
        topleft = left - max(0, (image.get_width() - 16) // 2), top - 24
        surf.blit(image, topleft)

        # =======
        # Status Aura Icon
        if not self.unit.isDying and 'aura' in self.unit.status_bundle:
            aura_icon_name = self.unit.team + 'AuraIcon'
            aura_icon = GC.IMAGESDICT[
                aura_icon_name] if aura_icon_name in GC.IMAGESDICT else GC.IMAGESDICT[
                    'AuraIcon']
            aura_icon = Engine.subsurface(
                aura_icon, (0, GC.PASSIVESPRITECOUNTER.count * 10, 32, 10))
            topleft = (left - max(0, (aura_icon.get_width() - 16) // 2),
                       top - max(0, (aura_icon.get_height() - 16) // 2) + 8)
            surf.blit(aura_icon, topleft)
        # Status always animationss
        for status in self.unit.status_effects:
            if status.always_animation:
                x, y = self.unit.position
                topleft = (x - 1) * GC.TILEWIDTH + self.spriteOffset[0], (
                    y - 1) * GC.TILEHEIGHT + self.spriteOffset[1]
                surf.blit(status.always_animation.image, topleft)

        if self.transition_state.startswith('warp'):
            num_frames = 12
            fps = self.transition_time // num_frames
            frame = (self.transition_time - self.transition_counter) // fps
            if frame >= 0 and frame < num_frames:
                warp_anim = Engine.subsurface(GC.IMAGESDICT['Warp'],
                                              (frame * 32, 0, 32, 48))
                topleft = (left - max(0, (warp_anim.get_width() - 16) // 2),
                           top - max(0,
                                     (warp_anim.get_height() - 16) // 2) - 4)
                surf.blit(warp_anim, topleft)

        # Talk, Warning and Danger icons
        if gameStateObj.cursor.currentSelectedUnit:
            cur_unit = gameStateObj.cursor.currentSelectedUnit
            if (cur_unit, self.unit.name) in gameStateObj.talk_options:
                frame = (Engine.get_time() // 100) % 8
                topleft = (left - 1, top - 12)
                if frame in (0, 1, 2):
                    offset = 0
                elif frame in (3, 7):
                    offset = 1
                else:
                    offset = 2
                surf.blit(GC.IMAGESDICT['TalkMarker'],
                          (topleft[0], topleft[1] + offset))
            if self.unit.checkIfEnemy(cur_unit):
                self.draw_warning_marker(surf, left, top, cur_unit)
Example #3
0
    def draw(self, surf, gameStateObj):
        currentTime = Engine.get_time()
        # if should be displaying exp bar OR should be displaying level Up screen
        if self.state.getState() in [
                'exp_wait', 'exp_leave', 'exp0', 'exp100', 'init',
                'prepare_promote'
        ]:
            if self.exp_bar:
                self.exp_bar.draw(surf)

        elif self.state.getState() == 'levelUp':
            self.levelUpAnimation.draw(surf, gameStateObj)
            """
            marker1 = self.animationMarker[0]
            marker2 = self.animationMarker[1]
            LvlSurf = Engine.subsurface(self.levelUpAnimation, (marker2*78, marker1*16, 78, 16))
            x, y = self.unit.position
            topleft = (x-gameStateObj.cameraOffset.x-2)*GC.TILEWIDTH, (y-gameStateObj.cameraOffset.y-1)*GC.TILEHEIGHT
            surf.blit(LvlSurf, topleft)
            """

        elif self.state.getState() == 'levelScreen':
            # Highlight underline -- yellow, blue
            new_color = Image_Modification.color_transition2((88, 16, -40),
                                                             (-80, -32, 40))
            # Scroll out
            if currentTime - self.state_time > self.LEVELUPWAIT + (
                    self.get_num_sparks() + 1) * self.SPARKTIME + 300:
                self.unit_scroll_offset += 10
                self.screen_scroll_offset += 20
                self.animations = []
            else:  # scroll in
                if self.unit_scroll_offset:
                    self.lastSparkUpdate = currentTime - 300  # add 300 extra milliseconds of waiting at beginning
                self.unit_scroll_offset -= 10
                self.unit_scroll_offset = max(0, self.unit_scroll_offset)
                self.screen_scroll_offset -= 20
                self.screen_scroll_offset = max(0, self.screen_scroll_offset)

            DisplayWidth = self.levelUpScreen.get_width()
            DisplayHeight = self.levelUpScreen.get_height()
            # Level up screen
            LevelUpSurface = Engine.create_surface(
                (DisplayWidth, DisplayHeight), transparent=True, convert=True)
            # Create background
            LevelSurf = self.levelUpScreen
            LevelUpSurface.blit(LevelSurf, (0, 0))

            # Render top banner text
            long_name = gameStateObj.metaDataObj['class_dict'][
                self.unit.klass]['long_name']
            GC.FONT['text_white'].blit(long_name, LevelUpSurface, (12, 3))
            GC.FONT['text_yellow'].blit(
                cf.WORDS['Lv'], LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 12, 3))
            if self.first_spark_flag or self.force_level:
                level = str(self.unit.level)
            elif self.unit.level == 1:
                level = str(self.prev_level)
            else:
                level = str(self.unit.level - 1)
            GC.FONT['text_blue'].blit(level, LevelUpSurface,
                                      (LevelUpSurface.get_width() / 2 + 50 -
                                       GC.FONT['text_blue'].size(level)[0], 3))

            # Blit first spark
            if self.force_level and not self.first_spark_flag:
                self.first_spark_flag = True
                self.lastSparkUpdate = currentTime
            elif self.screen_scroll_offset == 0 and not self.first_spark_flag and currentTime - self.lastSparkUpdate > self.SPARKTIME + 500:
                position = (87, 27)
                spark_animation = CustomObjects.Animation(self.statupanimation,
                                                          position, (11, 1),
                                                          animation_speed=32,
                                                          ignore_map=True)
                self.animations.append(spark_animation)
                self.first_spark_flag = True
                self.lastSparkUpdate = currentTime
                # Sound
                GC.SOUNDDICT['Level_Up_Level'].play()

            # Add sparks to animation list one at a time
            if self.first_spark_flag and currentTime - self.lastSparkUpdate > self.SPARKTIME:
                self.sparkCounter += 1
                self.sparkUp = True  # Whether the sparkCounter was actually incremented or not
                if self.sparkCounter > 7:
                    self.sparkCounter = 7
                    self.sparkUp = False
                else:
                    while self.levelup_list[self.sparkCounter] == 0:
                        self.sparkCounter += 1
                        self.sparkUp = True
                        if self.sparkCounter > 7:
                            self.sparkCounter = 7
                            self.sparkUp = False
                            break

                if self.sparkUp:
                    self.underline_offset = 36  # for underline growing
                    # Add animations and Sound
                    # Animations
                    if self.sparkCounter >= 4:
                        position = (88,
                                    (self.sparkCounter - 4) * GC.TILEHEIGHT +
                                    61)
                    else:
                        position = (24, self.sparkCounter * GC.TILEHEIGHT + 61)
                    arrow_animation = CustomObjects.Animation(
                        self.uparrow, (position[0] + 31, position[1] - 37),
                        (10, 1),
                        animation_speed=32,
                        ignore_map=True,
                        hold=True)
                    self.arrow_animations.append(arrow_animation)
                    spark_animation = CustomObjects.Animation(
                        self.statupanimation,
                        position, (11, 1),
                        animation_speed=32,
                        ignore_map=True)
                    self.animations.append(spark_animation)
                    # Only 1-7 are supported increases for a levelup right now
                    # assert 8 > self.levelup_list[self.sparkCounter] > 0, "%s %s"%(self.levelup_list, self.levelup_list[self.sparkCounter])
                    if 1 <= self.levelup_list[self.sparkCounter] <= 4:
                        row = Engine.subsurface(
                            self.numbers,
                            (0,
                             (self.levelup_list[self.sparkCounter] - 1) * 24,
                             10 * 28, 24))
                        number_animation = CustomObjects.Animation(
                            row, (position[0] + 29, position[1] + 23), (10, 1),
                            animation_speed=32,
                            ignore_map=True,
                            hold=True)
                    else:
                        row = Engine.subsurface(
                            self.numbers, (0, (Utility.clamp(
                                self.levelup_list[self.sparkCounter], 1, 7) -
                                               1) * 24, 2 * 28, 24))
                        number_animation = CustomObjects.Animation(
                            row, (position[0] + 29, position[1] + 23), (2, 1),
                            animation_speed=32,
                            ignore_map=True,
                            hold=True)
                    number_animation.frameCount = -5  # delay this animation for 5 frames
                    self.animations.append(number_animation)
                    # Sound
                    GC.SOUNDDICT['Stat Up'].play()

                self.lastSparkUpdate = currentTime  # Reset the last update time.

            # HP, Str, Mag, Skl, Spd, Luck, Def, Res
            new_underline_surf = Image_Modification.change_image_color(
                self.statunderline, new_color)
            for num in range(len(self.levelup_list[0:self.sparkCounter + 1])):
                if self.levelup_list[
                        num] > 0:  # IE it should be updated, since it leveled up
                    if num == self.sparkCounter:
                        rect = (self.underline_offset, 0,
                                new_underline_surf.get_width() -
                                self.underline_offset, 3)
                        new_underline_surf = Engine.subsurface(
                            new_underline_surf, rect)
                        self.underline_offset -= 6
                        self.underline_offset = max(0, self.underline_offset)
                        if num >= 4:
                            topleft = (76 + self.underline_offset // 2,
                                       45 + GC.TILEHEIGHT * (num - 4))
                        else:
                            topleft = (12 + self.underline_offset // 2,
                                       45 + GC.TILEHEIGHT * (num))
                    else:
                        if num >= 4:
                            topleft = (76, 45 + GC.TILEHEIGHT * (num - 4))
                        else:
                            topleft = (12, 45 + GC.TILEHEIGHT * (num))
                    LevelUpSurface.blit(new_underline_surf, topleft)

            # Update and draw arrow animations
            self.arrow_animations = [
                animation for animation in self.arrow_animations
                if not animation.update(gameStateObj)
            ]
            for animation in self.arrow_animations:
                animation.draw(LevelUpSurface, gameStateObj, blend=new_color)
            # Update and draw number animations
            self.number_animations = [
                animation for animation in self.number_animations
                if not animation.update(gameStateObj)
            ]
            for animation in self.number_animations:
                animation.draw(LevelUpSurface, gameStateObj, blend=new_color)

            GC.FONT['text_yellow'].blit('HP', LevelUpSurface, (10, 35))
            GC.FONT['text_yellow'].blit(cf.WORDS['STR'], LevelUpSurface,
                                        (10, GC.TILEHEIGHT + 35))
            GC.FONT['text_yellow'].blit(cf.WORDS['MAG'], LevelUpSurface,
                                        (10, GC.TILEHEIGHT * 2 + 35))
            GC.FONT['text_yellow'].blit(cf.WORDS['SKL'], LevelUpSurface,
                                        (10, GC.TILEHEIGHT * 3 + 35))
            GC.FONT['text_yellow'].blit(
                cf.WORDS['SPD'], LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 8, 35))
            GC.FONT['text_yellow'].blit(
                cf.WORDS['LCK'], LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 8, GC.TILEHEIGHT + 35))
            GC.FONT['text_yellow'].blit(
                cf.WORDS['DEF'], LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 8, GC.TILEHEIGHT * 2 + 35))
            GC.FONT['text_yellow'].blit(
                cf.WORDS['RES'], LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 8, GC.TILEHEIGHT * 3 + 35))

            hp_text = self.unit.stats['HP'].base_stat - (
                self.levelup_list[0] if self.sparkCounter < 0 else 0)
            str_text = self.unit.stats['STR'].base_stat - (
                self.levelup_list[1] if self.sparkCounter < 1 else 0)
            mag_text = self.unit.stats['MAG'].base_stat - (
                self.levelup_list[2] if self.sparkCounter < 2 else 0)
            skl_text = self.unit.stats['SKL'].base_stat - (
                self.levelup_list[3] if self.sparkCounter < 3 else 0)
            spd_text = self.unit.stats['SPD'].base_stat - (
                self.levelup_list[4] if self.sparkCounter < 4 else 0)
            lck_text = self.unit.stats['LCK'].base_stat - (
                self.levelup_list[5] if self.sparkCounter < 5 else 0)
            def_text = self.unit.stats['DEF'].base_stat - (
                self.levelup_list[6] if self.sparkCounter < 6 else 0)
            res_text = self.unit.stats['RES'].base_stat - (
                self.levelup_list[7] if self.sparkCounter < 7 else 0)

            GC.FONT['text_blue'].blit(
                str(hp_text), LevelUpSurface,
                (50 - GC.FONT['text_blue'].size(str(hp_text))[0], 35))
            GC.FONT['text_blue'].blit(
                str(str_text), LevelUpSurface,
                (50 - GC.FONT['text_blue'].size(str(str_text))[0],
                 GC.TILEHEIGHT + 35))
            GC.FONT['text_blue'].blit(
                str(mag_text), LevelUpSurface,
                (50 - GC.FONT['text_blue'].size(str(mag_text))[0],
                 GC.TILEHEIGHT * 2 + 35))
            GC.FONT['text_blue'].blit(
                str(skl_text), LevelUpSurface,
                (50 - GC.FONT['text_blue'].size(str(skl_text))[0],
                 GC.TILEHEIGHT * 3 + 35))
            GC.FONT['text_blue'].blit(
                str(spd_text), LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 48 -
                 GC.FONT['text_blue'].size(str(spd_text))[0], 35))
            GC.FONT['text_blue'].blit(
                str(lck_text), LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 48 -
                 GC.FONT['text_blue'].size(str(lck_text))[0],
                 GC.TILEHEIGHT + 35))
            GC.FONT['text_blue'].blit(
                str(def_text), LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 48 -
                 GC.FONT['text_blue'].size(str(def_text))[0],
                 GC.TILEHEIGHT * 2 + 35))
            GC.FONT['text_blue'].blit(
                str(res_text), LevelUpSurface,
                (LevelUpSurface.get_width() / 2 + 48 -
                 GC.FONT['text_blue'].size(str(res_text))[0],
                 GC.TILEHEIGHT * 3 + 35))
            """
            # HP, Str, Mag, Skl, Spd, Luck, Def, Res
            for num in range(len(self.levelup_list[0:self.sparkCounter])):
                if self.levelup_list[num] != 0: # IE it should be updated, since it leveled up
                    # Blit number
                    if num >= 4:
                        topleft = (LevelUpSurface.get_width()/2+50, GC.TILEHEIGHT * (num - 4) + 33)
                    else:
                        topleft = (52, GC.TILEHEIGHT * num + 33)
                    change = str(self.levelup_list[num])
                    if self.levelup_list[num] > 0:
                        change = '+' + change
                    GC.FONT['stat_white'].blit(change, LevelUpSurface, topleft)
            """
            pos = (6 - self.screen_scroll_offset,
                   GC.WINHEIGHT - 8 - LevelUpSurface.get_height())
            surf.blit(LevelUpSurface, pos)

            # Blit unit's pic
            BigPortraitSurf = self.unit.bigportrait
            pos = (GC.WINWIDTH - BigPortraitSurf.get_width() - 4,
                   GC.WINHEIGHT + self.unit_scroll_offset -
                   BigPortraitSurf.get_height())
            surf.blit(BigPortraitSurf, pos)

        # Update and draw animations
        self.animations = [
            animation for animation in self.animations
            if not animation.update(gameStateObj)
        ]
        for animation in self.animations:
            animation.draw(surf, gameStateObj)
Example #4
0
    def draw(self, surf, gameStateObj):
        """Assumes image has already been developed."""
        image = self.create_image(self.image_state)
        x, y = self.unit.position
        left = x * GC.TILEWIDTH + self.spriteOffset[0]
        top = y * GC.TILEHEIGHT + self.spriteOffset[1]

        # Active Skill Icon
        if not self.unit.isDying:
            for status in self.unit.status_effects:
                if (status.combat_art and status.combat_art.check_charged()
                   and status.combat_art.get_max() > 0 and status.combat_art.is_activated()) \
                   or (status.activated_item and status.activated_item.check_charged()
                   and status.activated_item.get_max() > 0):
                    active_icon = GC.ICONDICT["ActiveSkill"]
                    active_icon = Engine.subsurface(active_icon, (GC.PASSIVESPRITECOUNTER.count*32, 0, 32, 32))
                    topleft = (left - max(0, (active_icon.get_width() - 16)//2), top - max(0, (active_icon.get_height() - 16)//2))
                    surf.blit(active_icon, topleft)
                    break

        if self.transition_state in WARP_OUT_SET:
            if self.unit.deathCounter:
                image = Image_Modification.flickerImageWhiteColorKey(image, 255)
                image = Image_Modification.flickerImageTranslucentColorKey(image, int(100*self.unit.deathCounter//27))
            else:
                image = Image_Modification.flickerImageTranslucentColorKey(image, 100 - self.transition_counter//(self.transition_time//100))
        elif self.transition_state == 'warp_in' or self.transition_state == 'fade_in':
            image = Image_Modification.flickerImageTranslucentColorKey(image, self.transition_counter//(self.transition_time//100))
        
        if self.unit.flicker:
            color = self.unit.flicker[2]
            total_time = self.unit.flicker[1]
            starting_time = self.unit.flicker[0]
            time_passed = Engine.get_time() - starting_time
            if time_passed >= total_time:
                self.unit.end_flicker()
            else:
                color = ((total_time - time_passed)*float(c)//total_time for c in color)
                #  image = Image_Modification.flicker_image(image.convert_alpha(), color)
                image = Image_Modification.change_image_color(image.convert_alpha(), color)
        elif self.unit.flickerRed and gameStateObj.boundary_manager.draw_flag:
            image = Image_Modification.flickerImageRed(image.convert_alpha(), 80)
        # if any(status.unit_translucent for status in self.unit.status_effects):
        if 'unit_translucent' in self.unit.status_bundle:
            image = Image_Modification.flickerImageTranslucentColorKey(image, 50)

        if 'unit_tint' in self.unit.status_bundle:
            for status in self.unit.status_effects:
                if status.unit_tint:
                    color = status.unit_tint.color
                    time = Engine.get_time()
                    diff = Utility.determine_perc(time, status.unit_tint.period, status.unit_tint.width)
                    diff = Utility.clamp(255. * diff * status.unit_tint.max_alpha, 0, 255)
                    color = (color[0], color[1], color[2], diff)
                    image = Image_Modification.color_tint(image.convert_alpha(), color)            

        # Active Skill Indicator -- this flashes the unit yellow when a skill is charged
        # if not self.unit.isDying and 'ActiveSkillCharged' in self.unit.tags:
        #     time = Engine.get_time()
        #     length = 500
        #     if not (time//1000)%3 and not (time//length)%(1000//length):
        #         diff = time%length
        #         if diff > length//2:
        #             diff = length - diff
        #         diff = Utility.clamp(255. * diff / length * 2, 0, 255)
        #         color = (248, 248, -248, diff)
        #         image = Image_Modification.color_tint(image.convert_alpha(), color)

        # Turnwheel indicator -- this flashes the unit green
        if self.turnwheel_indicator:
            time = Engine.get_time()
            length = 200
            if not (time//200)%2 and not (time//length)%(200//length):
                diff = time%length
                if diff > length//2:
                    diff = length - diff
                diff = Utility.clamp(255. * diff / length * 2, 0, 255)
                color = (-120, 120, -120, diff)
                image = Image_Modification.color_tint(image.convert_alpha(), color)

        # What is this line even doing? - Something majorly important though
        # Each image has (self.image.get_width() - 32)/2 buffers on the left and right of it, to handle any off tile spriting
        # Without self.image.get_width() - 32)//2, we would output the left buffer along with the unit, 
        # and the unit would end up +left buffer width to the right of where it should be
        topleft = left - max(0, (image.get_width() - 16)//2), top - 24
        surf.blit(image, topleft)

        # =======
        # Status Aura Icon
        if not self.unit.isDying and 'aura' in self.unit.status_bundle:
            aura_icon_name = self.unit.team + 'AuraIcon'
            aura_icon = GC.IMAGESDICT[aura_icon_name] if aura_icon_name in GC.IMAGESDICT else GC.IMAGESDICT['AuraIcon']
            aura_icon = Engine.subsurface(aura_icon, (0, GC.PASSIVESPRITECOUNTER.count*10, 32, 10))
            topleft = (left - max(0, (aura_icon.get_width() - 16)//2), top - max(0, (aura_icon.get_height() - 16)//2) + 8)
            surf.blit(aura_icon, topleft)
        # Status always animationss
        for status in self.unit.status_effects:
            if status.always_animation:
                x, y = self.unit.position
                topleft = (x-1) * GC.TILEWIDTH + self.spriteOffset[0], (y-1) * GC.TILEHEIGHT + self.spriteOffset[1]
                surf.blit(status.always_animation.image, topleft)

        if self.transition_state.startswith('warp'):
            num_frames = 12
            fps = self.transition_time//num_frames
            frame = (self.transition_time - self.transition_counter)//fps
            if frame >= 0 and frame < num_frames:
                warp_anim = Engine.subsurface(GC.IMAGESDICT['Warp'], (frame*32, 0, 32, 48))
                topleft = (left - max(0, (warp_anim.get_width() - 16)//2), top - max(0, (warp_anim.get_height() - 16)//2) - 4)
                surf.blit(warp_anim, topleft)

        # Talk, Warning and Danger icons
        if gameStateObj.cursor.currentSelectedUnit:
            cur_unit = gameStateObj.cursor.currentSelectedUnit
            if (cur_unit.id, self.unit.id) in gameStateObj.talk_options:
                frame = (Engine.get_time()//100)%8
                topleft = (left - 1, top - 12)
                if frame in (0, 1, 2):
                    offset = 0
                elif frame in (3, 7):
                    offset = 1
                else:
                    offset = 2
                surf.blit(GC.IMAGESDICT['TalkMarker'], (topleft[0], topleft[1] + offset))
            elif self.unit.checkIfEnemy(cur_unit) and cur_unit.team == 'player':
                self.draw_warning_marker(surf, left, top, cur_unit)
            elif gameStateObj.support and gameStateObj.support.get_edge(cur_unit.id, self.unit.id):
                level = gameStateObj.support.get_edge(cur_unit.id, self.unit.id).get_support_level()
                if level > 0:
                    level = min(level, 3)
                    icon = Engine.subsurface(GC.IMAGESDICT['MapSupportIcons65'], ((level-1)*8, 0, 8, 11))
                    frame = (Engine.get_time()//100)%8
                    topleft = (left + 4, top - 11)
                    if frame in (0, 1, 2):
                        offset = 0
                    elif frame in (3, 7):
                        offset = 1
                    else:
                        offset = 2
                    # diff = Utility.determine_perc(Engine.get_time(), 2000, 2000)
                    # print(diff)
                    # diff = Utility.clamp(255. * diff, 0, 255)
                    # tint = (0, -64, 128, diff)
                    # icon = Image_Modification.color_tint(icon.copy(), tint)
                    surf.blit(icon, (topleft[0], topleft[1] + offset))
    def draw(self, surf, gameStateObj):
        """Assumes image has already been developed."""
        image = self.create_image(self.image_state)
        x, y = self.unit.position
        left = x * GC.TILEWIDTH + self.spriteOffset[0]
        top = y * GC.TILEHEIGHT + self.spriteOffset[1]

        # Active Skill Icon
        if not self.unit.isDying and 'ActiveSkillCharged' in self.unit.tags:
            active_icon = GC.ICONDICT["ActiveSkill"]
            active_icon = Engine.subsurface(
                active_icon, (GC.PASSIVESPRITECOUNTER.count * 32, 0, 32, 32))
            topleft = (left - max(0, (active_icon.get_width() - 16) / 2),
                       top - max(0, (active_icon.get_height() - 16) / 2))
            surf.blit(active_icon, topleft)

        if self.transition_state in WARP_OUT_SET:
            if self.unit.deathCounter:
                image = Image_Modification.flickerImageWhiteColorKey(
                    image, 255)
                image = Image_Modification.flickerImageTranslucentColorKey(
                    image, int(100 * self.unit.deathCounter / 27))
            else:
                self.transition_counter -= Engine.get_delta()
                if self.transition_counter < 0:
                    self.transition_counter = 0
                image = Image_Modification.flickerImageTranslucentColorKey(
                    image, 100 - self.transition_counter /
                    (self.transition_time / 100))
                if self.transition_counter <= 0:
                    if self.transition_state == 'fade_out':
                        self.transition_state = 'normal'
                        if self.state == 'fake_transition_out':
                            self.change_state('normal', gameStateObj)
                        self.unit.die(gameStateObj, event=True)
                    elif self.transition_state == 'warp_out':
                        gameStateObj.map.initiate_warp_flowers(
                            self.unit.position)
                        self.unit.die(gameStateObj, event=True)
                        self.transition_state = 'normal'
                        if self.state == 'fake_transition_out':
                            self.change_state('normal', gameStateObj)
                    elif self.transition_state in ('fade_move', 'warp_move'):
                        gameStateObj.map.initiate_warp_flowers(
                            self.unit.position)
                        self.unit.leave(gameStateObj)
                        self.unit.position = self.next_position
                        self.unit.arrive(gameStateObj)
                        self.next_position = None
                        gameStateObj.map.initiate_warp_flowers(
                            self.unit.position)
                        if self.transition_state == 'fade_move':
                            self.set_transition('fade_in')
                        elif self.transition_state == 'warp_move':
                            self.set_transition('warp_in')
        elif self.transition_state == 'warp_in' or self.transition_state == 'fade_in':
            self.transition_counter -= Engine.get_delta()
            if self.transition_counter < 0:
                self.transition_counter = 0
            image = Image_Modification.flickerImageTranslucentColorKey(
                image, self.transition_counter / (self.transition_time / 100))
            if self.transition_counter <= 0:
                self.transition_state = 'normal'
                if self.state == 'fake_transition_in':
                    self.change_state('normal', gameStateObj)
        elif self.unit.flicker:
            color = self.unit.flicker[2]
            total_time = self.unit.flicker[1]
            starting_time = self.unit.flicker[0]
            time_passed = Engine.get_time() - starting_time
            if time_passed >= total_time:
                self.unit.end_flicker()
            else:
                color = ((total_time - time_passed) * float(c) / total_time
                         for c in color)
                #  image = Image_Modification.flicker_image(image.convert_alpha(), color)
                image = Image_Modification.change_image_color(
                    image.convert_alpha(), color)
        elif self.unit.flickerRed and gameStateObj.boundary_manager.draw_flag:
            image = Image_Modification.flickerImageRed(image.convert_alpha(),
                                                       80)
        # if any(status.unit_translucent for status in self.unit.status_effects):
        if 'unit_translucent' in self.unit.status_bundle:
            image = Image_Modification.flickerImageTranslucentColorKey(
                image, 50)
        # What is this line even doing? - Something majorly important though
        # Each image has (self.image.get_width() - 32)/2 buffers on the left and right of it, to handle any off tile spriting
        # Without self.image.get_width() - 32)/2, we would output the left buffer along with the unit,
        # and the unit would end up +left buffer width to the right of where it should be
        topleft = left - max(0, (image.get_width() - 16) / 2), top - 24
        surf.blit(image, topleft)

        # =======
        # Status Aura Icon
        if not self.unit.isDying and 'aura' in self.unit.status_bundle:
            aura_icon_name = self.unit.team + 'AuraIcon'
            aura_icon = GC.IMAGESDICT[
                aura_icon_name] if aura_icon_name in GC.IMAGESDICT else GC.IMAGESDICT[
                    'AuraIcon']
            aura_icon = Engine.subsurface(
                aura_icon, (0, GC.PASSIVESPRITECOUNTER.count * 10, 32, 10))
            topleft = (left - max(0, (aura_icon.get_width() - 16) / 2),
                       top - max(0, (aura_icon.get_height() - 16) / 2) + 8)
            surf.blit(aura_icon, topleft)
        # Status always animationss
        for status in self.unit.status_effects:
            if status.always_animation:
                x, y = self.unit.position
                topleft = (x - 1) * GC.TILEWIDTH + self.spriteOffset[0], (
                    y - 1) * GC.TILEHEIGHT + self.spriteOffset[1]
                surf.blit(status.always_animation.image, topleft)

        if self.transition_state.startswith('warp'):
            num_frames = 12
            fps = self.transition_time / num_frames
            frame = (self.transition_time - self.transition_counter) / fps
            if frame >= 0 and frame < num_frames:
                warp_anim = Engine.subsurface(GC.IMAGESDICT['Warp'],
                                              (frame * 32, 0, 32, 48))
                topleft = (left - max(0, (warp_anim.get_width() - 16) / 2),
                           top - max(0, (warp_anim.get_height() - 16) / 2) - 4)
                surf.blit(warp_anim, topleft)

        if gameStateObj.cursor.currentSelectedUnit and (
                gameStateObj.cursor.currentSelectedUnit.name,
                self.unit.name) in gameStateObj.talk_options:
            frame = (Engine.get_time() / 100) % 8
            topleft = (left + 6, top - 12)
            surf.blit(
                Engine.subsurface(GC.IMAGESDICT['TalkMarker'],
                                  (frame * 8, 0, 8, 16)), topleft)