def SetHP(self, hpPercentage, iMinHP, iMaxHP):
            if not self.hpGauge.IsShow():
                if app.ENABLE_VIEW_TARGET_PLAYER_HP:
                    showingButtonCount = len(self.showingButtonList)
                    if showingButtonCount > 0:
                        if chr.GetInstanceType(
                                self.vid) == chr.INSTANCE_TYPE_PLAYER:
                            self.SetSize(
                                max(150 + 75 * 3, showingButtonCount * 75),
                                self.GetHeight())
                        else:
                            self.SetSize(200 + 7 * self.nameLength,
                                         self.GetHeight())
                    else:
                        self.SetSize(200 + 7 * self.nameLength,
                                     self.GetHeight())
                else:
                    self.SetSize(200 + 7 * self.nameLength, self.GetHeight())

                if localeInfo.IsARABIC():
                    self.name.SetPosition(self.GetWidth() - 23, 13)
                else:
                    self.name.SetPosition(23, 13)

                self.name.SetWindowHorizontalAlignLeft()
                self.name.SetHorizontalAlignLeft()
                self.hpGauge.Show()
                self.UpdatePosition()

            self.hpGauge.SetPercentage(hpPercentage, 100)
            if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
                iMinHPText = '.'.join([
                    i - 3 < 0 and str(iMinHP)[:i] or str(iMinHP)[i - 3:i]
                    for i in range(
                        len(str(iMinHP)) % 3,
                        len(str(iMinHP)) + 1, 3) if i
                ])
                iMaxHPText = '.'.join([
                    i - 3 < 0 and str(iMaxHP)[:i] or str(iMaxHP)[i - 3:i]
                    for i in range(
                        len(str(iMaxHP)) % 3,
                        len(str(iMaxHP)) + 1, 3) if i
                ])
                self.hpDecimal.SetText(str(iMinHPText) + "/" + str(iMaxHPText))
                (textWidth, textHeight) = self.hpDecimal.GetTextSize()
                if localeInfo.IsARABIC():
                    self.hpDecimal.SetPosition(120 / 2 + textWidth / 2, -13)
                else:
                    self.hpDecimal.SetPosition(130 / 2 - textWidth / 2, -13)

                self.hpDecimal.Show()
Esempio n. 2
0
def isPlayerCloseToInstance(vid_target):
    """
	Check if an instance is close to another instance.

	Args:
		vid_target ([type]): [description]

	Returns:
		[type]: [description]
	"""
    my_vid = net.GetMainActorVID()
    target_x, target_y, zz = chr.GetPixelPosition(vid_target)
    for vid in net_packet.InstancesList:
        if not chr.HasInstance(vid):
            continue
        if chr.GetInstanceType(vid) == PLAYER_TYPE and vid != my_vid:
            curr_x, curr_y, z = chr.GetPixelPosition(vid)
            distance = dist(target_x, target_y, curr_x, curr_y)
            if (distance < 300):
                return True

    return False
    def OnUpdate(self):
        if not self.vid:
            return
        if systemSetting.IsShowSalesText():

            if chr.GetInstanceType(self.vid) not in [
                    chr.INSTANCE_TYPE_PLAYER, chr.INSTANCE_TYPE_NPC
            ]:
                self.Hide()
            if GetShopNamesRange() == 1.000:
                self.Show()
                (x, y) = chr.GetProjectPosition(self.vid, 220)
                self.SetPosition(x - self.GetWidth() / 2,
                                 y - self.GetHeight() / 2)
            else:
                LIMIT_RANGE = abs(constInfo.SHOPNAMES_RANGE *
                                  GetShopNamesRange())
                (to_x, to_y, to_z) = chr.GetPixelPosition(self.vid)
                (my_x, my_y, my_z) = player.GetMainCharacterPosition()
                if abs(my_x - to_x) <= LIMIT_RANGE and abs(
                        my_y - to_y) <= LIMIT_RANGE:
                    (x, y) = chr.GetProjectPosition(self.vid, 220)
                    self.SetPosition(x - self.GetWidth() / 2,
                                     y - self.GetHeight() / 2)
                    self.Show()
                else:
                    self.Hide()
                    self.SetPosition(-10000, 0)
        else:
            for key in g_privateShopAdvertisementBoardDict.keys():
                if player.GetMainCharacterIndex() == key:
                    g_privateShopAdvertisementBoardDict[key].Show()
                    x, y = chr.GetProjectPosition(
                        player.GetMainCharacterIndex(), 220)
                    g_privateShopAdvertisementBoardDict[key].SetPosition(
                        x - self.GetWidth() / 2, y - self.GetHeight() / 2)
                else:
                    g_privateShopAdvertisementBoardDict[key].Hide()
Esempio n. 4
0
    def RefreshButton(self):

        self.HideAllButton()

        if chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
            #self.__ShowButton(locale.TARGET_BUTTON_BUILDING_DESTROY)
            #self.__ArrangeButtonPosition()
            return

        if player.IsPVPInstance(self.vid) or player.IsObserverMode():
            # PVP_INFO_SIZE_BUG_FIX
            self.SetSize(200 + 7 * self.nameLength, 40)
            self.UpdatePosition()
            # END_OF_PVP_INFO_SIZE_BUG_FIX
            return

        self.ShowDefaultButton()

        if guild.MainPlayerHasAuthority(guild.AUTH_ADD_MEMBER):
            if not guild.IsMemberByName(self.nameString):
                if 0 == chr.GetGuildID(self.vid):
                    self.__ShowButton(locale.TARGET_BUTTON_INVITE_GUILD)

        if not messenger.IsFriendByName(self.nameString):
            self.__ShowButton(locale.TARGET_BUTTON_FRIEND)

        if player.IsPartyMember(self.vid):

            self.__HideButton(locale.TARGET_BUTTON_FIGHT)

            if player.IsPartyLeader(self.vid):
                self.__ShowButton(locale.TARGET_BUTTON_LEAVE_PARTY)
            elif player.IsPartyLeader(player.GetMainCharacterIndex()):
                self.__ShowButton(locale.TARGET_BUTTON_EXCLUDE)

        else:
            if player.IsPartyMember(player.GetMainCharacterIndex()):
                if player.IsPartyLeader(player.GetMainCharacterIndex()):
                    self.__ShowButton(locale.TARGET_BUTTON_INVITE_PARTY)
            else:
                if chr.IsPartyMember(self.vid):
                    self.__ShowButton(locale.TARGET_BUTTON_REQUEST_ENTER_PARTY)
                else:
                    self.__ShowButton(locale.TARGET_BUTTON_INVITE_PARTY)

            if player.IsRevengeInstance(self.vid):
                self.__HideButton(locale.TARGET_BUTTON_FIGHT)
                self.__ShowButton(locale.TARGET_BUTTON_AVENGE)
            elif player.IsChallengeInstance(self.vid):
                self.__HideButton(locale.TARGET_BUTTON_FIGHT)
                self.__ShowButton(locale.TARGET_BUTTON_ACCEPT_FIGHT)
            elif player.IsCantFightInstance(self.vid):
                self.__HideButton(locale.TARGET_BUTTON_FIGHT)

            if not player.IsSameEmpire(self.vid):
                self.__HideButton(locale.TARGET_BUTTON_INVITE_PARTY)
                self.__HideButton(locale.TARGET_BUTTON_FRIEND)
                self.__HideButton(locale.TARGET_BUTTON_FIGHT)

        distance = player.GetCharacterDistance(self.vid)
        if distance > self.EXCHANGE_LIMIT_RANGE:
            self.__HideButton(locale.TARGET_BUTTON_EXCHANGE)
            self.__ArrangeButtonPosition()

        self.__ArrangeButtonPosition()