protected void RebuildForEditor() { Transform tf = m_tf; Vector3 vPos = m_vPos; Vector2 vScreenPos = m_vScreenPos; HUDBloodType nBloodType = m_nBloodType; float fPos = HudSetting.Instance.m_fTestBloodPos; HUDTilteLine[] titles = new HUDTilteLine[m_nTitleNumb]; int nNumb = m_nTitleNumb; for (int i = 0; i < m_nTitleNumb; ++i) { titles[i] = new HUDTilteLine(); titles[i].m_szText = m_TitleLine[i].m_szText; titles[i].m_nType = m_TitleLine[i].m_nType; titles[i].m_nColorIndex = m_TitleLine[i].m_nColorIndex; titles[i].m_nLine = m_TitleLine[i].m_nLine; titles[i].m_nSpriteID = m_TitleLine[i].m_nSpriteID; } Clear(); m_tf = tf; m_vPos = vPos; m_vScreenPos = vScreenPos; m_nBloodType = nBloodType; int nOldLine = -1; bool bStartLine = false; for (int i = 0; i < nNumb; ++i) { HUDTilteLine title = titles[i]; if (nOldLine != title.m_nLine) { if (bStartLine) { EndTitle(); } bStartLine = true; BeginTitle(); } if (title.m_nType == HUDTilteType.Blood) { PushBlood(m_nBloodType, fPos); } else if (title.m_nSpriteID != 0) { PushIcon(title.m_nType, title.m_nSpriteID); } else { PushTitle(title.m_szText, title.m_nType, title.m_nColorIndex); } nOldLine = title.m_nLine; } if (bStartLine) { EndTitle(); } }
// 功能:设置血条 // 参数:nType - 血条的类型 // fBloodPos - 血条的进度(百分比) public void PushBlood(HUDBloodType nType, float fBloodPos) { if (m_nTitleNumb >= m_TitleLine.Length) { return; } int nStart = m_aSprite.size; // 添加背景 int nBkWidth = HudSetting.Instance.m_nBloodBkWidth; int nBkHeight = HudSetting.Instance.m_nBloodBkHeight; int nBloodWidth = HudSetting.Instance.m_nBloodWidth; int nHeight = HudSetting.Instance.m_nBloodHeight; m_nBloodSpriteID = 0; if (nType == HUDBloodType.Blood_Green) { m_nBloodSpriteID = HudSetting.Instance.m_nBloodGreen; } else if (nType == HUDBloodType.Blood_Red) { m_nBloodSpriteID = HudSetting.Instance.m_nBloodRed; } else if (nType == HUDBloodType.Blood_Blue) { m_nBloodSpriteID = HudSetting.Instance.m_nBloodBlue; } PushSprite(HudSetting.Instance.m_nBloodBk, nBkWidth, nBkHeight, (nBloodWidth - nBkWidth) * 0.5f, 0);// (nBkHeight - nHeight) * 0.5f); PushSliceTitle(m_nBloodSpriteID, nBloodWidth, nHeight, 0.0f, 0.0f, fBloodPos); if (m_TitleLine[m_nTitleNumb] == null) { m_TitleLine[m_nTitleNumb] = new HUDTilteLine(); } m_TitleLine[m_nTitleNumb].m_nType = HUDTilteType.Blood; m_TitleLine[m_nTitleNumb].m_fWidth = nBloodWidth; m_TitleLine[m_nTitleNumb].m_nHeight = nHeight; m_TitleLine[m_nTitleNumb].m_nStart = nStart; m_TitleLine[m_nTitleNumb].m_nEnd = m_aSprite.size; m_TitleLine[m_nTitleNumb].m_szText = string.Empty; m_TitleLine[m_nTitleNumb].m_nSpriteID = 0; m_nBloodType = nType; m_nBloodIndex = m_nTitleNumb; m_fCurLineWidth = nBloodWidth; m_fCurLineHeight = nHeight; ++m_nTitleNumb; }
public void Clear() { ClearSprite(); m_fLineOffsetY = 0.0f; m_fCurLineHeight = 0; m_fCurLineWidth = 0; m_nStartLineIndex = 0; m_nTitleNumb = 0; m_bInitHUDMesh = false; m_nBloodIndex = 0; m_nBloodSpriteID = 0; m_nBloodType = HUDBloodType.Blood_None; m_nLines = 0; m_nMeridianIndex = 0; m_nMeridianNumb = 0; }
void RefreshTitle() { if (0 == m_nTitleIns) { m_nTitleIns = HUDTitleInfo.HUDTitleRender.Instance.RegisterTitle(transform, 1.8f, m_bMain); } float fOffsetY = GetHeadNameOffsetY(); HUDTitleInfo title = HUDTitleInfo.HUDTitleRender.Instance.GetTitle(m_nTitleIns); title.Clear(); title.SetOffsetY(fOffsetY); title.ShowTitle(true); // 血条 HUDBloodType nBloodType = GetBloodType(); if (nBloodType != HUDBloodType.Blood_None) { title.BeginTitle(); title.PushBlood(nBloodType, curHpBarValue()); title.EndTitle(); } title.BeginTitle(); title.PushTitle(m_szName, HUDTilteType.PlayerName, 0); // 威望 { title.PushTitle("天下无双", HUDTilteType.PlayerPrestige, 1); } // 可反击标识(主角和平模式,并且可以反击) if (!m_bMain) { title.PushIcon(HUDTilteType.PKFlag, HudSetting.Instance.m_nPKFlagPic); } title.EndTitle(); // 帮会名字 string szFamily = "天下第一帮"; if (!string.IsNullOrEmpty(szFamily)) { title.BeginTitle(); title.PushTitle(szFamily, HUDTilteType.PlayerCorp, 0); title.EndTitle(); } // 称号 { { string szDesign = "武林蒙主"; int nFontType = 1; title.BeginTitle(); title.PushTitle(szDesign, HUDTilteType.PlayerDesignation, nFontType); title.EndTitle(); } } // 队长标记 //if (isTeamLeader) { title.BeginTitle(); title.PushIcon(HUDTilteType.HeadIcon, HudSetting.Instance.m_nTeamFlagPic); title.EndTitle(); } }