666 lines
20 KiB
C#
666 lines
20 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Games.Events;
|
||
using Games.GlobeDefine;
|
||
using Games.ImpactModle;
|
||
using GCGame;
|
||
using GCGame.Table;
|
||
using UnityEngine;
|
||
using UnityEngine.EventSystems;
|
||
using UnityEngine.UI;
|
||
|
||
public class PlayerFrameLogic : MonoBehaviour, IPointerClickHandler
|
||
{
|
||
private static PlayerFrameLogic m_Instance;
|
||
|
||
public Text m_PlayerLevel;
|
||
public UIImgText m_VipLevel;
|
||
public Slider m_HpProcess;
|
||
public Slider m_HpProcess2;
|
||
public Slider m_MpProcess;
|
||
public Slider m_ButtryLeave;
|
||
public Slider m_ButtryLowLeave;
|
||
|
||
// public Text m_PlayerMPText;
|
||
public Text m_PlayerHPText;
|
||
public Image m_PlayerHeadSprite;
|
||
public Text m_PlayerNameLabel;
|
||
public GameObject m_PlayerFrameInfo;
|
||
public Text m_CombatValue;
|
||
public GameObject[] _WifiState;
|
||
public Image[] m_BuffShowIcon;
|
||
|
||
public Image m_PKMode;
|
||
|
||
//public Text pkDesc;
|
||
public Text CurTime;
|
||
public GameObject vipRedIcon;
|
||
|
||
public Image _HeadBG;
|
||
|
||
public GameObject _lackAuoItemIcon;
|
||
|
||
private int m_WifiStatie = -1;
|
||
|
||
private void Awake()
|
||
{
|
||
m_Instance = this;
|
||
}
|
||
|
||
// Use this for initialization
|
||
private void Start()
|
||
{
|
||
m_PlayerLevel.text = "0";
|
||
m_PlayerHPText.text = "0/0";
|
||
m_HpProcess.value = 0;
|
||
m_MpProcess.value = 0;
|
||
for (var i = 0; i < (int) BUFFICON.MAX_BUFFICONUM; i++) m_BuffShowIcon[i].gameObject.SetActive(false);
|
||
UpdateData();
|
||
|
||
UpdateBuffIcon();
|
||
|
||
UpdateCombatValue();
|
||
|
||
UpdatePKInfo();
|
||
|
||
ChangeVip(GameManager.gameManager.PlayerDataPool.VipCost);
|
||
|
||
RefreshPrivilegeVipInfo();
|
||
|
||
RefreshHeadBG(
|
||
GameManager.gameManager.PlayerDataPool.PlayerOrnamentStateInfo.GetCurOrnamentEquipedId(
|
||
(int) OrnamentPanel.OrnamentType.Head));
|
||
|
||
L_Start();
|
||
}
|
||
|
||
private void OnEnable()
|
||
{
|
||
StartCoroutine(CountCurTime());
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
m_Instance = null;
|
||
}
|
||
|
||
public static PlayerFrameLogic Instance()
|
||
{
|
||
return m_Instance;
|
||
}
|
||
|
||
private IEnumerator CountCurTime()
|
||
{
|
||
while (true)
|
||
{
|
||
var dataTime = Utils.GetServerDateTime();
|
||
CurTime.text = StrDictionary.GetClientDictionaryString("#{2124}", dataTime.Hour,
|
||
dataTime.Minute.ToString().PadLeft(2, '0'));
|
||
UpdateBattery();
|
||
yield return new WaitForSeconds(1.0f);
|
||
}
|
||
}
|
||
|
||
public void ChangeHP(long nCurHp, long nMaxHp, long curHPMax)
|
||
{
|
||
m_PlayerHPText.text = Utils.ConvertLargeNumToString(nCurHp) + "/" + Utils.ConvertLargeNumToString(nMaxHp);
|
||
if (nMaxHp != 0)
|
||
{
|
||
m_HpProcess.value = nCurHp * 1.0f / nMaxHp;
|
||
m_HpProcess2.value = nMaxHp * 1.0f / curHPMax;
|
||
}
|
||
else
|
||
{
|
||
m_HpProcess.value = 0;
|
||
}
|
||
}
|
||
|
||
public void ChangeMP(int nCurMp, int nMaxMp)
|
||
{
|
||
//if(m_PlayerMPText == null)
|
||
//{
|
||
// return;
|
||
//}
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer)
|
||
{
|
||
if (nMaxMp != 0)
|
||
//m_PlayerMPText.text = Utils.ConvertLargeNumToString(nCurMp) + "/" + Utils.ConvertLargeNumToString(nMaxMp);
|
||
m_MpProcess.value = nCurMp / (float) nMaxMp;
|
||
else
|
||
//m_PlayerMPText.text = "0/0";
|
||
m_MpProcess.value = 0;
|
||
}
|
||
else
|
||
{
|
||
//m_PlayerMPText.text = "0/0";
|
||
m_MpProcess.value = 0;
|
||
}
|
||
}
|
||
|
||
public void ChangeLev(int nLev)
|
||
{
|
||
m_PlayerLevel.text = nLev.ToString();
|
||
}
|
||
|
||
public void ChangeVip(int vip)
|
||
{
|
||
vip = vip >= 0 ? vip : 0;
|
||
m_VipLevel.text = vip.ToString();
|
||
}
|
||
|
||
public void ChangeHeadPic(string strPic)
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PlayerHeadSprite, strPic);
|
||
}
|
||
|
||
public void ChangeName(string strName)
|
||
{
|
||
if (m_PlayerNameLabel != null)
|
||
m_PlayerNameLabel.text = strName;
|
||
}
|
||
|
||
public void UpdateData()
|
||
{
|
||
if (null == Singleton<ObjManager>.GetInstance().MainPlayer)
|
||
{
|
||
var curRoleData = LoginData.GetPlayerRoleData(PlayerPreferenceData.LastRoleGUID);
|
||
if (null != curRoleData)
|
||
{
|
||
ChangeName(curRoleData.name);
|
||
ChangeHeadPic(null);
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
var nPlayerHP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.HP;
|
||
var nPlayerMaxHP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MaxHP;
|
||
var nPlayerMP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MP;
|
||
var nPlayerMaxMP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MaxMP;
|
||
var nPlayerXP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.XP;
|
||
var nPlayerMaxXP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MaxXP;
|
||
var nPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
var strPlayerHeadPic = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.HeadPic;
|
||
var strPlayerName = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName;
|
||
|
||
ChangeHP(nPlayerHP, nPlayerMaxHP, GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.CurMaxHP);
|
||
ChangeMP(nPlayerMP, nPlayerMaxMP);
|
||
ChangeLev(nPlayerLevel);
|
||
ChangeHeadPic(strPlayerHeadPic);
|
||
ChangeName(strPlayerName);
|
||
}
|
||
|
||
public void OnLackIconClick()
|
||
{
|
||
MessageHelpLogic.ShowHelpMessage(45);
|
||
}
|
||
|
||
public void OnClick_BuffIcon()
|
||
{
|
||
UIManager.ShowUI(UIInfo.ImpactInfoWnd, OnOpenSuccess);
|
||
}
|
||
|
||
public void OnClick_Vip()
|
||
{
|
||
UIManager.ShowUI(UIInfo.YuanBaoShop, delegate(bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
YuanBaoShopLogic.Instance()._TagPanel.ShowPage(3);
|
||
if (VipInfo.Instance) VipInfo.Instance.Click_OpenVIPRoot();
|
||
}
|
||
});
|
||
}
|
||
|
||
public void OnOpenSuccess(bool success, object param)
|
||
{
|
||
var hash = new Hashtable();
|
||
hash.Add("targetId", Singleton<ObjManager>.Instance.MainPlayer.ServerID);
|
||
EventDispatcher.Instance.SendMessage(EventId.OpenImpactInfoWndSuccess, hash);
|
||
}
|
||
|
||
//更新头像的BUFF位
|
||
public void UpdateBuffIcon()
|
||
{
|
||
var nBuffShowIndex = 0;
|
||
if (Singleton<ObjManager>.Instance == null || Singleton<ObjManager>.Instance.MainPlayer == null ||
|
||
Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos == null)
|
||
return;
|
||
for (var i = 0; i < Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos.Count; ++i)
|
||
{
|
||
if (m_BuffShowIcon.Length <= nBuffShowIndex)
|
||
break;
|
||
m_BuffShowIcon[nBuffShowIndex].gameObject.SetActive(false);
|
||
if (Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos[i].IsVaild())
|
||
{
|
||
var _tabImpact =
|
||
TableManager.GetImpactByID(Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos[i].ImpactId);
|
||
if (_tabImpact != null)
|
||
if (_tabImpact.BuffIcon != "-1" && _tabImpact.IsNeedNoticeClient == 1)
|
||
{
|
||
if (nBuffShowIndex >= 0 && nBuffShowIndex < (int) BUFFICON.MAX_BUFFICONUM)
|
||
{
|
||
m_BuffShowIcon[nBuffShowIndex].gameObject.SetActive(true);
|
||
LoadAssetBundle.Instance.SetImageSprite(m_BuffShowIcon[nBuffShowIndex],
|
||
_tabImpact.BuffIcon);
|
||
nBuffShowIndex++;
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
for (var i = nBuffShowIndex; i < (int) BUFFICON.MAX_BUFFICONUM; i++)
|
||
m_BuffShowIcon[i].gameObject.SetActive(false);
|
||
}
|
||
|
||
/*
|
||
* 玩家进入经验副本(副本id=6300,对应的场景ID = 650)时,判断玩家身上是否有经验加成buff(ID=99998) 有:不做处理 无:判断玩家背包是否有经验加成丹(ID=919)
|
||
* 无:不做处理 有:弹出使用界面
|
||
* */
|
||
public void L_ExperienceDoubleBuff()
|
||
{
|
||
// 遍历携带的BUFF
|
||
for (var i = 0; i < Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos.Count; ++i)
|
||
{
|
||
var _ImpactId = Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos[i].ImpactId;
|
||
// 判断玩家身上是否有buff(ID=99998,Id == 99995)
|
||
for (var buffId = 99995; buffId <= 99998; buffId++)
|
||
if (_ImpactId == buffId)
|
||
return;
|
||
//玩家进入经验副本(副本id=6300,对应的场景ID = 650)
|
||
if (GameManager.gameManager.m_RunningScene == 650) DailyCopyInfoItemsPanelCtr.Show(6300);
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获取当前网络状态信息,并进行相关设置
|
||
/// </summary>
|
||
public void GetWifiInfo(float tagSpeed)
|
||
{
|
||
//if (Singleton<ObjManager>.Instance.MainPlayer == null) return;
|
||
|
||
var tag = -1;
|
||
|
||
////检查当前网络是否可用
|
||
//if (NetWorkLogic.GetMe().GetConnectStautus() == NetWorkLogic.ConnectStatus.DISCONNECTED)
|
||
//{
|
||
// Singleton<ObjManager>.Instance.MainPlayer.NetSpeed = -1;
|
||
//}
|
||
|
||
//float tagSpeed = Singleton<ObjManager>.Instance.MainPlayer.NetSpeed
|
||
|
||
if (tagSpeed >= 0 && tagSpeed <= 250)
|
||
tag = 3;
|
||
else if (tagSpeed > 250 && tagSpeed <= 500)
|
||
tag = 2;
|
||
else if (tagSpeed > 500) tag = 1;
|
||
|
||
SetWifiStatic(tag);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 设置当前网络状态
|
||
/// </summary>
|
||
/// <param name="wifiStatic"></param>
|
||
private void SetWifiStatic(int wifiStatic = 1)
|
||
{
|
||
if (_WifiState.Length != 3) return;
|
||
if (wifiStatic == m_WifiStatie) return;
|
||
m_WifiStatie = wifiStatic;
|
||
|
||
for (var i = 0; i < _WifiState.Length; ++i)
|
||
if (i < m_WifiStatie)
|
||
_WifiState[i].SetActive(true);
|
||
else
|
||
_WifiState[i].SetActive(false);
|
||
}
|
||
|
||
//更新战斗力
|
||
public void UpdateCombatValue()
|
||
{
|
||
m_CombatValue.text = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.CombatValue.ToString();
|
||
}
|
||
|
||
public void ShowLackAutoMedicItemBuff(bool isShow)
|
||
{
|
||
if (isShow)
|
||
{
|
||
if (!_lackAuoItemIcon.gameObject.activeInHierarchy)
|
||
_lackAuoItemIcon.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
if (_lackAuoItemIcon.gameObject.activeInHierarchy)
|
||
_lackAuoItemIcon.SetActive(false);
|
||
}
|
||
}
|
||
|
||
#region headBG
|
||
|
||
public void RefreshHeadBG(int id)
|
||
{
|
||
if (id == -1)
|
||
{
|
||
_HeadBG.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
_HeadBG.gameObject.SetActive(true);
|
||
var ornamentTab = TableManager.GetOrnamentByID(id);
|
||
if (ornamentTab == null)
|
||
{
|
||
Debug.LogError("ornamentTab is null : " + id);
|
||
return;
|
||
}
|
||
|
||
LoadAssetBundle.Instance.SetImageSprite(_HeadBG, ornamentTab.ShowIconName);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
private void L_Update()
|
||
{
|
||
if (AdditionData.onePointFiveExpDisableTime - Time.realtimeSinceStartup <= 0 &&
|
||
AdditionData.doubleExpDisableTime - Time.realtimeSinceStartup <= 0)
|
||
if (Singleton<ObjManager>.Instance.MainPlayer != null)
|
||
Hide();
|
||
}
|
||
|
||
private void L_Start()
|
||
{
|
||
InvokeRepeating("L_Update", 0f, 1.0f);
|
||
}
|
||
|
||
private void Hide()
|
||
{
|
||
for (var i = 0; i < Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos.Count; ++i)
|
||
{
|
||
var _ImpactId = Singleton<ObjManager>.Instance.MainPlayer.ClientImpactInfos[i].ImpactId;
|
||
if (_ImpactId == 99998) Singleton<ObjManager>.Instance.MainPlayer.UpdateImpact(99998, 1, 1, 0);
|
||
if (_ImpactId == 99995) Singleton<ObjManager>.Instance.MainPlayer.UpdateImpact(99995, 1, 1, 0);
|
||
}
|
||
}
|
||
|
||
#region PKMode
|
||
|
||
private int m_nPKModle = -1;
|
||
|
||
public int PKModle
|
||
{
|
||
get { return m_nPKModle; }
|
||
set { m_nPKModle = value; }
|
||
}
|
||
|
||
private int m_nPKCDTime = -1;
|
||
|
||
public int PKCDTime
|
||
{
|
||
get { return m_nPKCDTime; }
|
||
set { m_nPKCDTime = value; }
|
||
}
|
||
|
||
public int PKValue { get; set; }
|
||
|
||
public void OnPKClick()
|
||
{
|
||
var sceneClass = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
|
||
if (sceneClass == null)
|
||
return;
|
||
|
||
if (sceneClass.CanChangePK == 0)
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{35009}"));
|
||
return;
|
||
}
|
||
|
||
if (Singleton<ObjManager>.Instance.MainPlayer != null &&
|
||
GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < 30)
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1111}"));
|
||
return;
|
||
}
|
||
|
||
UIManager.ShowUI(UIInfo.PKSetInfo);
|
||
//PopMenuLogic.ShowMenu("PKModePopMenu", m_PKMode.gameObject);
|
||
}
|
||
|
||
public void SendNewPKModle(int pkModle)
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer == null) return;
|
||
if (_mainPlayer.PkModle == pkModle) return;
|
||
var pkChange = (CG_CHANGE_PKMODLE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_CHANGE_PKMODLE);
|
||
pkChange.SetObjId(_mainPlayer.ServerID);
|
||
pkChange.SetPKModle(pkModle);
|
||
pkChange.SendPacket();
|
||
}
|
||
|
||
public void OnKillModleClick()
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer == null) return;
|
||
if (_mainPlayer.PkModle == (int) CharacterDefine.PKMODLE.KILL && m_nPKCDTime < 0)
|
||
{
|
||
_mainPlayer.SendNoticMsg(false, "#{1107}");
|
||
return;
|
||
}
|
||
|
||
//弹出确认框
|
||
var _strNotice = StrDictionary.GetClientDictionaryString("#{1106}");
|
||
MessageBoxLogic.OpenOKCancelBox(_strNotice, "", SwitchKillModeOnOk, SwitchKillModeOnCancle);
|
||
}
|
||
|
||
public void ShowPKDesc()
|
||
{
|
||
UIManager.ShowUI(UIInfo.PKSetInfo);
|
||
}
|
||
|
||
public void SwitchKillModeOnOk()
|
||
{
|
||
if (m_nPKModle != (int) CharacterDefine.PKMODLE.KILL || m_nPKCDTime > 0)
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer)
|
||
{
|
||
//发包请求切换
|
||
var pkChange = (CG_CHANGE_PKMODLE) PacketDistributed.CreatePacket(MessageID.PACKET_CG_CHANGE_PKMODLE);
|
||
pkChange.SetObjId(_mainPlayer.ServerID);
|
||
pkChange.SetPKModle((int) CharacterDefine.PKMODLE.KILL);
|
||
pkChange.SendPacket();
|
||
}
|
||
}
|
||
}
|
||
|
||
public void SwitchKillModeOnCancle()
|
||
{
|
||
}
|
||
|
||
public void ChangePKText()
|
||
{
|
||
//m_PKMode
|
||
if (Singleton<ObjManager>.GetInstance().MainPlayer != null)
|
||
{
|
||
if (GameManager.gameManager.RunningScene == GlobeVar.CROSSSERVERSCENEID)
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "crossserver");
|
||
return;
|
||
}
|
||
|
||
if (GameManager.gameManager.RunningScene == (int) GameDefine_Globe.SCENE_DEFINE.SCENE_GUANNING)
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "pkmodecamp");
|
||
//pkDesc.text = StrDictionary.GetClientDictionaryString("#{42628}");
|
||
}
|
||
else
|
||
{
|
||
if (Singleton<ObjManager>.GetInstance().MainPlayer.PkModle == (int) CharacterDefine.PKMODLE.KILL)
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "pkmodeall");
|
||
// pkDesc.text = StrDictionary.GetClientDictionaryString("#{42627}");
|
||
else if (Singleton<ObjManager>.GetInstance().MainPlayer.PkModle == (int) CharacterDefine.PKMODLE.Camp)
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "pkmodecamp");
|
||
//pkDesc.text = StrDictionary.GetClientDictionaryString("#{42628}");
|
||
else if (Singleton<ObjManager>.GetInstance().MainPlayer.PkModle == (int) CharacterDefine.PKMODLE.Evil)
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "pkmodeevil");
|
||
//pkDesc.text = StrDictionary.GetClientDictionaryString("#{42629}");
|
||
else if (Singleton<ObjManager>.GetInstance().MainPlayer.PkModle == (int) CharacterDefine.PKMODLE.NORMAL)
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "pkmodepeace");
|
||
//pkDesc.text = StrDictionary.GetClientDictionaryString("#{42630}");
|
||
}
|
||
}
|
||
}
|
||
|
||
public void ForcePKCamp()
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(m_PKMode, "pkmodecamp");
|
||
//pkDesc.text = StrDictionary.GetClientDictionaryString("#{42628}");
|
||
}
|
||
|
||
public void UpdatePKInfo()
|
||
{
|
||
ChangePKText();
|
||
}
|
||
|
||
public void OnHeadClick()
|
||
{
|
||
UIManager.ShowUI(UIInfo.RoleView);
|
||
}
|
||
|
||
public void ShowVipRedIcon(bool isShow)
|
||
{
|
||
vipRedIcon.SetActive(isShow);
|
||
}
|
||
|
||
public void OnPointerClick(PointerEventData eventData)
|
||
{
|
||
var serverID = Singleton<ObjManager>.GetInstance().MainPlayer.ServerID;
|
||
var selPacket = (CG_ASK_SELOBJ_INFO) PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_SELOBJ_INFO);
|
||
selPacket.SetObjId(serverID);
|
||
selPacket.SetSeleobjId(serverID);
|
||
selPacket.SendPacket();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region PrivilegeVIP
|
||
|
||
public List<GameObject> _activeIconList;
|
||
|
||
public void RefreshPrivilegeVipInfo()
|
||
{
|
||
//for(int index = 0; index < _activeIconList.Count; index++)
|
||
//{
|
||
// //1.白银 2.钻石 3.黄金
|
||
// if(GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic.ContainsKey(index + 1)
|
||
// && GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic[index + 1])
|
||
// {
|
||
// _activeIconList[index].SetActive(true);
|
||
// }else
|
||
// {
|
||
// _activeIconList[index].SetActive(false);
|
||
// }
|
||
//}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 电池电量
|
||
|
||
private float _lastAskTime;
|
||
|
||
public PlayerFrameLogic()
|
||
{
|
||
PKValue = 0;
|
||
}
|
||
|
||
private const float _askInterval = 20.0f; //20秒更新一次电量
|
||
|
||
private void UpdateBattery()
|
||
{
|
||
if (Time.time - _lastAskTime > _askInterval)
|
||
{
|
||
_lastAskTime = Time.time;
|
||
var level = SystemInfo.batteryLevel;
|
||
var low = level < 0.1f;
|
||
m_ButtryLeave.gameObject.SetActive(!low);
|
||
m_ButtryLowLeave.gameObject.SetActive(low);
|
||
if (low)
|
||
m_ButtryLowLeave.value = level;
|
||
else
|
||
m_ButtryLeave.value = level;
|
||
}
|
||
}
|
||
|
||
// public void SetButtryInfo(float leave)
|
||
// {
|
||
// //m_ButtryLeave.gameObject.SetActive(leave > 0.1f);
|
||
// //m_ButtryLowLeave.gameObject.SetActive(leave <= 0.1f);
|
||
// //m_ButtryLowLeave.value = leave;
|
||
// //m_ButtryLeave.value = leave;
|
||
// }
|
||
//
|
||
// public void SetButtryInfoV2(float leave)
|
||
// {
|
||
//
|
||
// }
|
||
|
||
#endregion
|
||
}
|
||
|
||
|
||
//public class RefreshImpactInfoItem : UIItemBase
|
||
//{
|
||
// ClientImpactInfo m_ImpactInfo = null;
|
||
// IEnumerator UpdateOnePre()
|
||
// {
|
||
// while (true)
|
||
// {
|
||
// Debug.LogError("m_ImpactInfo.ImpactId == " + m_ImpactInfo.ImpactId);
|
||
// yield return new WaitForSeconds(1);
|
||
// if (m_ImpactInfo == null)
|
||
// yield break;
|
||
// if (m_ImpactInfo.RemainTime - Time.realtimeSinceStartup < 0)
|
||
// {
|
||
// RefreshBuffShow();
|
||
// break;
|
||
// }
|
||
|
||
// }
|
||
// }
|
||
|
||
// public override void Show(Hashtable hash)
|
||
// {
|
||
// base.Show();
|
||
// m_ImpactInfo = (ClientImpactInfo)hash["InitObj"];
|
||
// ShowItem(m_ImpactInfo);
|
||
// }
|
||
|
||
// public void ShowItem(ClientImpactInfo impactInfo)
|
||
// {
|
||
// Tab_Impact _tabImpact = TableManager.GetImpactByID(impactInfo.ImpactId, 0);
|
||
// if (_tabImpact == null)
|
||
// {
|
||
// RefreshBuffShow();
|
||
// return;
|
||
// }
|
||
// StopCoroutine(UpdateOnePre());
|
||
// if (_tabImpact.IsForever != 1 || impactInfo.IsForever == false)
|
||
// {
|
||
// StartCoroutine(UpdateOnePre());
|
||
// }
|
||
// }
|
||
|
||
|
||
// private void RefreshBuffShow()
|
||
// {
|
||
// Singleton<ObjManager>.Instance.MainPlayer.UpdateImpact(m_ImpactInfo.ImpactId, 1, 1, 0);
|
||
// }
|
||
//} |