Exemplo n.º 1
0
    void UpdateTargetStatus(long npcid, uint teamid, uint ownerid, uint clanid, string ownerName)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("IEntitySystem is null--");
            return;
        }
        INPC npc = es.FindEntity(npcid) as INPC;

        if (npc == null)
        {
            Engine.Utility.Log.Error("npc is null--{0}", npcid);
            return;
        }

        if (m_nLastNpcId != 0 && m_nLastNpcId != npcid)
        {
            return;
        }
        bool showPackage = npc.IsBoss();

        m_toggle_packageState.gameObject.SetActive(showPackage);
        string text     = "";
        bool   belongMe = false;



        if (teamid != 0)
        {
            if (DataManager.Manager <TeamDataManager>().TeamId == teamid)
            {
                belongMe = true;
            }
            else
            {
                belongMe = false;
            }
            text = string.Format("{0}的队伍", ownerName);
        }
        else if (clanid != 0)
        {
            DataManager.Manager <ClanManger>().GetClanName(clanid, (namedata) =>
            {
                if (DataManager.Manager <ClanManger>().ClanId == clanid)
                {
                    belongMe = true;
                }
                else
                {
                    belongMe = false;
                }
                text = string.Format("{0}氏族", namedata.ClanName);
            });
        }
        else
        {
            belongMe = MainPlayerHelper.GetPlayerID() == ownerid;
            text     = ownerName;
        }
        //Engine.Utility.Log.Error("ownerid:" + ownerid
        //               + "---text:" + text
        //               + "---teamid:" + teamid
        //               + "---clanid:" + clanid);


        m_label_TeamLeaderName.text = text;
        m_toggle_packageState.value = belongMe;
    }
Exemplo n.º 2
0
    void InitTargetChangeUI()
    {
        IEntity ie = Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget();

        if (ie == null)
        {
            m_trans_target.gameObject.SetActive(false);
        }
        else
        {
            m_trans_target.gameObject.SetActive(true);
            IEntity entity = ie;
            string  name   = entity.GetName();
            string  lvstr  = entity.GetProp((int)CreatureProp.Level).ToString();
            m_label_MonsterLevel_Label.text = lvstr;

            bool showPackage = false;
            //怪
            if (entity.GetEntityType() == EntityType.EntityType_NPC)
            {
                INPC        npc = entity as INPC;
                NpcDataBase ndb = GameTableManager.Instance.GetTableItem <NpcDataBase>((uint)npc.GetProp((int)EntityProp.BaseID));
                if (ndb == null)
                {
                    return;
                }
                showPackage = npc.IsBoss();
                if (ndb.dwMonsterType == 1)
                {
                    InitTargetUIInMonster();
                    m_widget_player.gameObject.SetActive(false);
                    m_widget_monster.gameObject.SetActive(true);
                    m_lableTargetLevel.text = entity.GetProp((int)CreatureProp.Level).ToString();
                }
                else
                {
                    InitTargetUI();
                    string iconName = UIManager.GetIconName(ndb.npcIcon, npc.IsPet());
                    UIManager.GetTextureAsyn(iconName,
                                             ref m_curTargetIconAsynSeed, () =>
                    {
                        if (null != m_spriteTargetIcon)
                        {
                            m_spriteTargetIcon.mainTexture = null;
                        }
                    }, m_spriteTargetIcon, false);

                    m_widget_player.gameObject.SetActive(true);
                    m_widget_monster.gameObject.SetActive(false);
                }
            }

            // 玩家
            else
            {
                InitTargetUI();
                m_widget_player.gameObject.SetActive(true);
                m_widget_monster.gameObject.SetActive(false);
                IPlayer player = entity as IPlayer;
                if (player != null)
                {
                    int job = player.GetProp((int)PlayerProp.Job);
                    int sex = player.GetProp((int)PlayerProp.Sex);
                    SelectRoleDataBase sdb = table.SelectRoleDataBase.Where((GameCmd.enumProfession)job, (GameCmd.enmCharSex)sex);
                    if (sdb != null)
                    {
                        UIManager.GetTextureAsyn(sdb.strprofessionIcon,
                                                 ref m_curTargetIconAsynSeed, () =>
                        {
                            if (null != m_spriteTargetIcon)
                            {
                                m_spriteTargetIcon.mainTexture = null;
                            }
                        }, m_spriteTargetIcon, false);
                    }
                    m_transHateList.gameObject.SetActive(false);
                }
            }
            m_toggle_packageState.gameObject.SetActive(showPackage);
            m_lableTargetName.text = name;
            UpdateTargetHp(entity);
        }
    }
Exemplo n.º 3
0
    //StringBuilder targetName = new StringBuilder(20);
    private void OnTargetChange(object param)
    {
        stTargetChange tc = (stTargetChange)param;

        if (tc.target == null)
        {
            m_trans_target.gameObject.SetActive(false);
        }
        else
        {
            IEntity entity = tc.target;
            string  name   = entity.GetName();
            string  lvstr  = entity.GetProp((int)CreatureProp.Level).ToString();
            m_label_MonsterLevel_Label.text = lvstr;
            bool showPackeage = false;

            if (entity.GetEntityType() == EntityType.EntityType_NPC)
            {
                INPC npc = entity as INPC;
                showPackeage = npc.IsBoss();
                NpcDataBase ndb = GameTableManager.Instance.GetTableItem <NpcDataBase>((uint)npc.GetProp((int)EntityProp.BaseID));
                if (ndb != null)
                {
                    if (ndb.dwMonsterType == 1)
                    {
                        InitTargetUIInMonster();
                        m_widget_player.gameObject.SetActive(false);
                        m_widget_monster.gameObject.SetActive(true);
                        m_lableTargetLevel.text = entity.GetProp((int)CreatureProp.Level).ToString();
                    }
                    else
                    {
                        InitTargetUI();
                        string iconName = UIManager.GetIconName(ndb.npcIcon, npc.IsPet());
                        UIManager.GetTextureAsyn(iconName,
                                                 ref m_curTargetIconAsynSeed, () =>
                        {
                            if (null != m_spriteTargetIcon)
                            {
                                m_spriteTargetIcon.mainTexture = null;
                            }
                        }, m_spriteTargetIcon, false);

                        m_widget_player.gameObject.SetActive(true);
                        m_widget_monster.gameObject.SetActive(false);
                    }
                }
                if (npc.IsMonster() == false)
                {
                    bool bVisit = true;
                    if (npc.IsSummon() || npc.IsPet())
                    {
                        bVisit = false;
                    }

                    CopyTypeTable ct = DataManager.Manager <ComBatCopyDataManager>().GetCurCopyType();
                    if (ct != CopyTypeTable.Arena)
                    {
                        if (bVisit)
                        {
                            Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().VisiteNPC(npc.GetUID());
                        }
                    }
                }
                else
                {
                    //请
                    if (m_nLastNpcId != entity.GetUID())
                    {
                        BShowEnemyList = false;
                        m_transHateList.gameObject.SetActive(false);
                    }
                }
                m_nLastNpcId = entity.GetUID();
                if (m_nLastNpcId != 0)
                {
                    stRefreshNPCBelongParam npcbelongdata = NpcAscription.Instance.GetNpcBelongByNpcID(m_nLastNpcId);
                    UpdateTargetStatus(npcbelongdata.npcid, npcbelongdata.teamid, npcbelongdata.ownerid, npcbelongdata.clanid, npcbelongdata.ownerName);
                }
            }
            else
            {
                InitTargetUI();
                m_widget_player.gameObject.SetActive(true);
                m_widget_monster.gameObject.SetActive(false);
                IPlayer player = entity as IPlayer;
                if (player != null)
                {
                    int job = player.GetProp((int)PlayerProp.Job);
                    int sex = player.GetProp((int)PlayerProp.Sex);
                    SelectRoleDataBase sdb = table.SelectRoleDataBase.Where((GameCmd.enumProfession)job, (GameCmd.enmCharSex)sex);
                    if (sdb != null)
                    {
                        UIManager.GetTextureAsyn(sdb.strprofessionIcon,
                                                 ref m_curTargetIconAsynSeed, () =>
                        {
                            if (null != m_spriteTargetIcon)
                            {
                                m_spriteTargetIcon.mainTexture = null;
                            }
                        }, m_spriteTargetIcon, false);
                    }
                    m_transHateList.gameObject.SetActive(false);

                    //目标选择
                    OnSetSelectTargetGrid(player.GetID());
                }
            }
            m_toggle_packageState.gameObject.SetActive(showPackeage);

            m_lableTargetName.text = name;
            //m_lableTargetLevel.text = entity.GetProp((int)CreatureProp.Level).ToString();

            UpdateTargetHp(entity);

            BuffManager.TargetBuffList.Clear();


            if (entity != null)
            {
                List <Client.stAddBuff> lstBuff;
                IBuffPart part = entity.GetPart(EntityPart.Buff) as IBuffPart;
                if (part != null)
                {
                    part.GetBuffList(out lstBuff);
                    for (int i = 0; i < lstBuff.Count; ++i)
                    {
                        stAddBuff          buff = lstBuff[i];
                        table.BuffDataBase db   = GameTableManager.Instance.GetTableItem <table.BuffDataBase>(buff.buffid);
                        if (db != null)
                        {
                            if (db.dwShield == 1)
                            {//不显示的直接跳过
                                continue;
                            }
                        }
                        BuffManager.TargetBuffList.Add(lstBuff[i]);
                    }
                }
                else
                {
                    Engine.Utility.Log.Error("获取{0}Buff部件失败!", entity.GetName());
                }
            }
            m_trans_target.gameObject.SetActive(true);
            RefreshBuffIcon(m_trans_TargetBUffContainer, BuffManager.TargetBuffList);
        }
    }