Exemple #1
0
    public void UpdateCharacterInfo(bool show_warning)
    {
        for (int i = 0; i < m_MainLayout.m_Characters.Length; i++)
        {
            UICharacterInfo info = null;
            if (m_ListCharacterInfos.Count <= i)
            {
                info = NGUITools.AddChild(m_CharacterInfoIndicator[i], CharacterInfoPrefab).GetComponent <UICharacterInfo>();
                m_ListCharacterInfos.Add(info);
            }
            else
            {
                info = m_MainLayout.m_Characters[i].Info.GetComponentsInChildren <UICharacterInfo>(true)[0];
            }

            if (m_TeamData != null && i < m_TeamData.Creatures.Count)
            {
                bool is_warning = info.IsWarning;
                info.UpdateInfo(m_TeamData.Creatures[i].creature, i);
                if (show_warning == true && is_warning == false && info.IsWarning == true)
                {
                    Tooltip.Instance.ShowMessage(Localization.Get("WarningFront"));
                }
            }
            else
            {
                info.UpdateInfo(null, i);
            }
        }
        CheckSelectCharacter();
        m_TeamPower.text = Localization.Format("PowerValue", m_TeamData.Power);
    }
    /// <summary>
    /// 初始化角色选择界面
    /// </summary>
    /// <param name="init">是否初始化</param>
    public void InitCharacterSelect(bool init)
    {
        m_PanelCreate.SetActive(false);
        m_PanelSelect.SetActive(true);

        if (init)
        {
            foreach (var old in m_UiCharacters)
            {
                Destroy(old);
            }
            m_UiCharacters.Clear();

            for (int i = 0; i < User.Instance.Info.Player.Characters.Count; i++)
            {
                GameObject      obj           = Instantiate(m_UiCharacterInfo, this.m_UiCharacterList);
                UICharacterInfo characterInfo = obj.GetComponent <UICharacterInfo>();
                characterInfo.NCharacterInfo = User.Instance.Info.Player.Characters[i];

                Button button = obj.GetComponent <Button>();
                int    index  = i;
                button.onClick.AddListener(() =>
                {
                    OnSelectCharacter(index);
                });

                m_UiCharacters.Add(obj);
                obj.SetActive(true);
            }
        }
        if (User.Instance.Info.Player.Characters.Count > 0)
        {
            OnSelectCharacter(0);
        }
    }
    /// <summary>
    /// 选择角色
    /// </summary>
    /// <param name="index">角色索引</param>
    public void OnSelectCharacter(int index)
    {
        this.m_CharacterSelectIndex = index;
        var character = User.Instance.Info.Player.Characters[index];

        Debug.LogFormat("Select Character: [{0}]{1}[{2}]", character.Id, character.Name, character.Class);
        User.Instance.CurrentCharacter   = character;
        m_CharacterView.CurrentCharacter = (int)character.Class - 1;

        for (int i = 0; i < User.Instance.Info.Player.Characters.Count; i++)
        {
            UICharacterInfo uICharacterInfo = this.m_UiCharacters[i].GetComponent <UICharacterInfo>();
            uICharacterInfo.Selected = index == i;
        }
    }
Exemple #4
0
    public void UpdateCharacterInfo()
    {
        TeamData team_data = TeamDataManager.Instance.GetTeam(pe_Team.Main); //得到队伍的信息

        for (int i = 0; i < m_MainLayout.m_Characters.Length; i++)
        {
            if (m_ListCharacterInfos.Count <= i)
            {
                UICharacterInfo info = NGUITools.AddChild(m_CharacterInfoIndicator[i], m_CharacterInfoPrefab).GetComponent <UICharacterInfo>(); //添加角色信息的预设体
                m_ListCharacterInfos.Add(info);                                                                                                 //往数组里面添加角色额信息
            }
            if (team_data != null && i < team_data.Creatures.Count)
            {
                m_ListCharacterInfos[i].UpdateInfo(team_data.Creatures[i].creature, 5); //绘制或者更新角色的信息
            }
            else
            {
                m_ListCharacterInfos[i].UpdateInfo(null, 5);
            }
        }
    }