152 lines
3.6 KiB
C#
152 lines
3.6 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.Events;
|
|||
|
using Games.LogicObj;
|
|||
|
using Games.ChatHistory;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame;
|
|||
|
|
|||
|
public class Obj_NPCHeadUI : Obj_HeadUI
|
|||
|
{
|
|||
|
public static UIPathData pathData
|
|||
|
{
|
|||
|
get { return UIInfo.NPCHeadInfo; }
|
|||
|
}
|
|||
|
|
|||
|
public override UIPathData uiPathData
|
|||
|
{
|
|||
|
get { return pathData; }
|
|||
|
}
|
|||
|
|
|||
|
protected override bool HideByOption
|
|||
|
{
|
|||
|
get { return true; }
|
|||
|
}
|
|||
|
|
|||
|
public Slider HpSlider;
|
|||
|
public GameObject beLongObj;
|
|||
|
public GameObject boardObj;
|
|||
|
public GameObject BackImage;
|
|||
|
public ChatBubbleLogic m_ChatBubbleLogic;
|
|||
|
//public GameObject _SpecialCounTimeObj;
|
|||
|
//public Text _SpecialCountTime;
|
|||
|
|
|||
|
protected override void OnEnable()
|
|||
|
{
|
|||
|
base.OnEnable();
|
|||
|
if (m_ChatBubbleLogic != null)
|
|||
|
m_ChatBubbleLogic.gameObject.SetActive(false);
|
|||
|
_healthAsShield = false;
|
|||
|
}
|
|||
|
|
|||
|
public void HideBackImage(bool state)
|
|||
|
{
|
|||
|
BackImage.SetActive(state);
|
|||
|
}
|
|||
|
|
|||
|
public void HideHp(bool state)
|
|||
|
{
|
|||
|
if(HpSlider!=null)
|
|||
|
HpSlider.gameObject.SetActive(state);
|
|||
|
}
|
|||
|
|
|||
|
public void ChangeBoardState(bool state)
|
|||
|
{
|
|||
|
if (boardObj != null)
|
|||
|
boardObj.SetActive(state);
|
|||
|
}
|
|||
|
|
|||
|
public void ChangeBelong(bool state)
|
|||
|
{
|
|||
|
//if(beLongObj!=null)
|
|||
|
{
|
|||
|
beLongObj.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
public override void ShowChatBubble(ChatHistoryItem text)
|
|||
|
{
|
|||
|
if (null != m_ChatBubbleLogic)
|
|||
|
{
|
|||
|
m_ChatBubbleLogic.Show(text);
|
|||
|
}
|
|||
|
}
|
|||
|
public override void HideChatBubble(bool state)
|
|||
|
{
|
|||
|
if (null != m_ChatBubbleLogic)
|
|||
|
{
|
|||
|
m_ChatBubbleLogic.gameObject.SetActive(state);
|
|||
|
}
|
|||
|
}
|
|||
|
#region 护盾处理方式
|
|||
|
private Color _baseHealthColor;
|
|||
|
|
|||
|
private float _healthRatio;
|
|||
|
private string _npcName;
|
|||
|
private bool _healthAsShield;
|
|||
|
private Image _healthBar;
|
|||
|
|
|||
|
public void CreateShield()
|
|||
|
{
|
|||
|
if (!_healthAsShield)
|
|||
|
{
|
|||
|
_healthAsShield = true;
|
|||
|
if (HpSlider != null)
|
|||
|
{
|
|||
|
if (_healthBar == null)
|
|||
|
_healthBar = HpSlider.fillRect.GetComponent<Image>();
|
|||
|
if (_healthBar != null)
|
|||
|
{
|
|||
|
_baseHealthColor = _healthBar.color;
|
|||
|
_healthBar.color =
|
|||
|
Utils.GetColorByString(StrDictionary.GetClientDictionaryString(GlobeVar.shieldColorKey));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
base.SetName(StrDictionary.GetClientDictionaryString(GlobeVar.shieldNameKey));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateShield(float ratio)
|
|||
|
{
|
|||
|
if (_healthAsShield && HpSlider != null)
|
|||
|
HpSlider.value = ratio;
|
|||
|
}
|
|||
|
|
|||
|
public void RemoveShield()
|
|||
|
{
|
|||
|
if (_healthAsShield)
|
|||
|
{
|
|||
|
_healthAsShield = false;
|
|||
|
HpSlider.value = _healthRatio;
|
|||
|
if (_healthBar != null)
|
|||
|
_healthBar.color = _baseHealthColor;
|
|||
|
base.SetName(_npcName);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void SetName(string myName)
|
|||
|
{
|
|||
|
_npcName = myName;
|
|||
|
if (!_healthAsShield)
|
|||
|
base.SetName(myName);
|
|||
|
}
|
|||
|
|
|||
|
public void SetLevelName(int level, string name)
|
|||
|
{
|
|||
|
string lvName = "LV" + level.ToString() + " " + name;
|
|||
|
base.SetName(lvName);
|
|||
|
}
|
|||
|
|
|||
|
public void SetNewHp(float rate)
|
|||
|
{
|
|||
|
// 如果当前显示护盾效果,则不处理生命值改变
|
|||
|
_healthRatio = rate;
|
|||
|
if (!_healthAsShield)
|
|||
|
HpSlider.value = _healthRatio;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|