Exemplo n.º 1
0
    public void SetGuildName(long dbid, string guildName)
    {
        if (string.IsNullOrEmpty(guildName))
        {
            Debug.LogError("guildName is null");
            return;
        }
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        headBarStruct.textGuildName.gameObject.SetActive(true);
        headBarStruct.textGuildName.text = guildName;

        RefreshLayout(dbid);
    }
Exemplo n.º 2
0
    public void SetTaskImg(long dbid, Sprite taskSpt)
    {
        if (taskSpt == null)
        {
            Debug.LogError("taskSpt is null");
            return;
        }
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        headBarStruct.imageTask.gameObject.SetActive(true);
        headBarStruct.imageTask.sprite = taskSpt;

        RefreshLayout(dbid);
    }
Exemplo n.º 3
0
    public void SetTitle(long dbid, string titlename)
    {
        if (string.IsNullOrEmpty(titlename))
        {
            Debug.LogError("title is null");
            return;
        }
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        headBarStruct.textTitle.gameObject.SetActive(true);
        headBarStruct.textTitle.text = titlename;

        RefreshLayout(dbid);
    }
Exemplo n.º 4
0
    public void SetPlayerTypeProgressBar(long dbid, float fillamount, bool isTeam = false)
    {
        if (isTeam)
        {
            //TODO change image sprite
        }
        else
        {
            //TODO change image sprite
        }
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        headBarStruct.progressbar.SetActive(true);
        headBarStruct.progressbar.transform.Find("Image").GetComponent <Image>().fillAmount = fillamount;
        RefreshLayout(dbid);
    }
Exemplo n.º 5
0
    public void SetChengHao(long dbid, Sprite chenghao)
    {
        if (chenghao == null)
        {
            Debug.LogError("chenghao is null");
            return;
        }
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        headBarStruct.imageChengHao.sprite = chenghao;
        headBarStruct.textChengHao.gameObject.SetActive(true);

        if (headBarStruct.textChengHao.isActiveAndEnabled)
        {
            headBarStruct.textChengHao.gameObject.SetActive(false);
        }
        RefreshLayout(dbid);
    }
Exemplo n.º 6
0
    public void SetChengHao(long dbid, string chenghao)
    {
        if (string.IsNullOrEmpty(chenghao))
        {
            Debug.LogError("chenghao is null");
            return;
        }
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        headBarStruct.textChengHao.text = chenghao;
        headBarStruct.textChengHao.gameObject.SetActive(true);

        if (headBarStruct.imageChengHao.isActiveAndEnabled)
        {
            headBarStruct.imageChengHao.gameObject.SetActive(false);
        }
        RefreshLayout(dbid);
    }
Exemplo n.º 7
0
    public void CreateHeadBar(long dbid, string name, string titlename, string guildname, Sprite taskSpt = null, ShowType showType = ShowType.ePlayerNormal)
    {
        _ShowType = showType;
        HeadBarStruct headBarStruct;

        if (!m_headBarDic.ContainsKey(dbid))
        {
            headBarStruct           = new HeadBarStruct();
            headBarStruct.textTitle = CreateTxt();
            headBarStruct.textTitle.transform.SetParent(m_titleParent.transform);
            headBarStruct.textTitle.transform.localScale    = Vector3.one;
            headBarStruct.textTitle.transform.localRotation = Quaternion.identity;
            headBarStruct.textTitle.transform.localPosition = Vector3.zero;
            if (string.IsNullOrEmpty(titlename))
            {
                headBarStruct.textTitle.gameObject.SetActive(false);
            }
            else
            {
                headBarStruct.textTitle.gameObject.SetActive(true);
                headBarStruct.textTitle.text = titlename;
            }

            headBarStruct.textGuildName = CreateTxt();
            headBarStruct.textGuildName.transform.SetParent(m_txtParent.transform);
            headBarStruct.textGuildName.transform.localScale    = Vector3.one;
            headBarStruct.textGuildName.transform.localRotation = Quaternion.identity;
            headBarStruct.textGuildName.transform.localPosition = Vector3.zero;
            headBarStruct.textGuildName.alignment = TextAnchor.MiddleCenter;
            if (string.IsNullOrEmpty(guildname))
            {
                headBarStruct.textGuildName.gameObject.SetActive(false);
            }
            else
            {
                headBarStruct.textGuildName.gameObject.SetActive(true);
                headBarStruct.textGuildName.text = guildname;
            }

            headBarStruct.textName = CreateTxt();
            headBarStruct.textName.transform.SetParent(m_txtParent.transform);
            headBarStruct.textName.transform.localScale    = Vector3.one;
            headBarStruct.textName.transform.localRotation = Quaternion.identity;
            headBarStruct.textName.transform.localPosition = Vector3.zero;
            if (string.IsNullOrEmpty(name))
            {
                headBarStruct.textName.gameObject.SetActive(false);
            }
            else
            {
                headBarStruct.textName.gameObject.SetActive(true);
                headBarStruct.textName.text = name;
            }

            headBarStruct.imageTask = CreateImage();
            headBarStruct.imageTask.transform.SetParent(m_imgParent.transform);
            headBarStruct.imageTask.transform.localScale    = Vector3.one;
            headBarStruct.imageTask.transform.localRotation = Quaternion.identity;
            headBarStruct.imageTask.transform.localPosition = Vector3.zero;
            if (taskSpt == null)
            {
                headBarStruct.imageTask.gameObject.SetActive(false);
            }
            else
            {
                headBarStruct.imageTask.gameObject.SetActive(true);
                headBarStruct.imageTask.sprite = taskSpt;
                headBarStruct.imageTask.SetNativeSize();
            }

            headBarStruct.imageChengHao = CreateImage();
            headBarStruct.imageChengHao.transform.SetParent(m_imgParent.transform);
            headBarStruct.imageChengHao.transform.localScale    = Vector3.one;
            headBarStruct.imageChengHao.transform.localRotation = Quaternion.identity;
            headBarStruct.imageChengHao.transform.localPosition = Vector3.zero;
            headBarStruct.imageChengHao.gameObject.SetActive(false);

            headBarStruct.textChengHao = CreateTxt();
            headBarStruct.textChengHao.transform.SetParent(m_txtParent.transform);
            headBarStruct.textChengHao.transform.localScale    = Vector3.one;
            headBarStruct.textChengHao.transform.localRotation = Quaternion.identity;
            headBarStruct.textChengHao.transform.localPosition = Vector3.zero;
            headBarStruct.textChengHao.alignment = TextAnchor.MiddleCenter;
            headBarStruct.textChengHao.gameObject.SetActive(false);


            headBarStruct.progressbar = CreateProgressBar();
            headBarStruct.progressbar.transform.SetParent(m_imgParent.transform);
            headBarStruct.progressbar.transform.localScale    = Vector3.one;
            headBarStruct.progressbar.transform.localRotation = Quaternion.identity;
            headBarStruct.progressbar.transform.localPosition = Vector3.zero;
            headBarStruct.progressbar.SetActive(false);

            m_headBarDic.Add(dbid, headBarStruct);
        }
        else
        {
            headBarStruct = m_headBarDic[dbid];
        }
        RefreshLayout(dbid);
    }
Exemplo n.º 8
0
    //layout
    private void RefreshLayout(long dbid)
    {
        float         y             = 0;
        HeadBarStruct headBarStruct = m_headBarDic[dbid];

        switch (_ShowType)
        {
        case ShowType.ePlayerNormal:
        {
            if (headBarStruct.textTitle.isActiveAndEnabled)
            {
                headBarStruct.textTitle.alignment = TextAnchor.MiddleRight;
                headBarStruct.textName.alignment  = TextAnchor.MiddleLeft;

                float mus = headBarStruct.textTitle.preferredWidth - headBarStruct.textName.preferredWidth;
                headBarStruct.textTitle.transform.localPosition = new Vector3(-headBarStruct.textTitle.rectTransform.sizeDelta.x / 2 + mus / 2, y, 0);
                headBarStruct.textName.transform.localPosition  = new Vector3(headBarStruct.textName.rectTransform.sizeDelta.x / 2 + mus / 2, y, 0);
            }
            else
            {
                headBarStruct.textName.alignment = TextAnchor.MiddleCenter;
                headBarStruct.textName.transform.localPosition = Vector3.zero;
            }
            y += headBarStruct.textName.preferredHeight / 2;

            if (headBarStruct.textGuildName.isActiveAndEnabled)
            {
                y += headBarStruct.textGuildName.preferredHeight / 2;
                headBarStruct.textGuildName.transform.localPosition = new Vector3(0, y, 0);
            }
            if (headBarStruct.textChengHao.isActiveAndEnabled)
            {
                y += headBarStruct.textChengHao.preferredHeight / 2;
                headBarStruct.textChengHao.transform.localPosition = new Vector3(0, y, 0);
            }
            if (headBarStruct.imageChengHao.isActiveAndEnabled)
            {
                y += headBarStruct.imageChengHao.preferredHeight / 2;
                headBarStruct.imageChengHao.transform.localPosition = new Vector3(0, y, 0);
            }

            if (headBarStruct.imageTask.isActiveAndEnabled)
            {
                y += headBarStruct.imageTask.preferredHeight / 2;
                headBarStruct.imageTask.transform.localPosition = new Vector3(0, y, 0);
            }
            break;
        }

        case ShowType.ePlayerPvp:
        {
            headBarStruct.textGuildName.gameObject.SetActive(false);
            headBarStruct.textChengHao.gameObject.SetActive(false);
            headBarStruct.imageChengHao.gameObject.SetActive(false);
            headBarStruct.imageTask.gameObject.SetActive(false);
            headBarStruct.progressbar.gameObject.SetActive(true);

            headBarStruct.progressbar.transform.localPosition = new Vector3(0, 0, 0);
            y += headBarStruct.progressbar.GetComponent <Image>().preferredHeight / 2;
            if (headBarStruct.textTitle.isActiveAndEnabled)
            {
                headBarStruct.textTitle.alignment = TextAnchor.MiddleRight;
                headBarStruct.textName.alignment  = TextAnchor.MiddleLeft;
                float mus = headBarStruct.textTitle.preferredWidth - headBarStruct.textName.preferredWidth;
                headBarStruct.textTitle.transform.localPosition = new Vector3(-headBarStruct.textTitle.rectTransform.sizeDelta.x / 2 + mus / 2, y, 0);
                headBarStruct.textName.transform.localPosition  = new Vector3(headBarStruct.textName.rectTransform.sizeDelta.x / 2 + mus / 2, y, 0);
            }
            else
            {
                headBarStruct.textName.alignment = TextAnchor.MiddleCenter;
                headBarStruct.textName.transform.localPosition = new Vector3(0, y, 0);
            }
            break;
        }

        case ShowType.eMonsterNormal:
        {
            headBarStruct.textGuildName.gameObject.SetActive(false);
            headBarStruct.textChengHao.gameObject.SetActive(false);
            headBarStruct.textTitle.gameObject.SetActive(false);
            headBarStruct.imageChengHao.gameObject.SetActive(false);
            headBarStruct.textName.gameObject.SetActive(false);
            headBarStruct.progressbar.gameObject.SetActive(true);

            if (headBarStruct.textName.isActiveAndEnabled)
            {
                headBarStruct.textName.alignment = TextAnchor.MiddleCenter;
                headBarStruct.progressbar.transform.localPosition = new Vector3(0, 0, 0);
                y += headBarStruct.progressbar.GetComponent <Image>().preferredHeight / 2;
                headBarStruct.textName.transform.localPosition = new Vector3(0, y, 0);
            }

            if (headBarStruct.imageTask.isActiveAndEnabled)
            {
                y += headBarStruct.imageTask.preferredHeight / 2;
                headBarStruct.imageTask.transform.localPosition = new Vector3(0, y, 0);
            }
            break;
        }
        }
        headBarStruct.titleRelativePos       = headBarStruct.textTitle.transform.position;
        headBarStruct.nameRelativePos        = headBarStruct.textName.transform.position;
        headBarStruct.guildNameRelativePos   = headBarStruct.textGuildName.transform.position;
        headBarStruct.taskRelativePos        = headBarStruct.imageTask.transform.position;
        headBarStruct.chengHaoImgRelativePos = headBarStruct.imageChengHao.transform.position;
        headBarStruct.chengHaoTxtRelativePos = headBarStruct.textChengHao.transform.position;
        headBarStruct.progressbarRelativePos = headBarStruct.progressbar.transform.position;
        m_headBarDic[dbid] = headBarStruct;
    }