435 lines
15 KiB
C#
435 lines
15 KiB
C#
using Games.GlobeDefine;
|
|
using Games.Item;
|
|
using GCGame.Table;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AdvanceAttrPanel : MonoBehaviour
|
|
{
|
|
|
|
#region
|
|
public GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self;
|
|
public UIImgText combatValueText; // 当前战力
|
|
// public Text combatValueText; // 当前战力
|
|
public Slider injectionSpiritualSlider; // 注灵
|
|
public Text spiritualValueText; // 注灵数值
|
|
public Slider injectionSoulSlder; // 注魂
|
|
public Text soulValueDesc; // 注魂数值
|
|
|
|
public GameObject _VipAttrPanel; //坐骑独有属性增长面板
|
|
public GameObject _ActiveVipBtn; //激活VIP
|
|
public Text vipAttrDescText; // VIP属性加成描述
|
|
public Text _MoveDesc;
|
|
public Text curincPerText; // 当前提升百分比
|
|
|
|
public Image souDanIcon;
|
|
public Image spiritDanIcon;
|
|
|
|
public Image soulDanRedIcon; // 红点状态
|
|
public Image spiritDanRedIcon; // 红点状态
|
|
|
|
public List<AdvanceAttrItem> attrItemList; // 属性列表
|
|
|
|
private AdvanceBase.AdvanceType advanceType; // 当前面板的类型
|
|
#endregion
|
|
|
|
public int soulDanItemId = 1;
|
|
public int spiritualDanItemId = -1;
|
|
public int soulDanLimitCount = -1;
|
|
public int spiritualDanLimitCount = -1;
|
|
public int soulDanHasUsedCount = -1;
|
|
public int spiritualDanHasUsedCount = -1;
|
|
|
|
// 表索引ID
|
|
private int baseId = -1;
|
|
|
|
//是查看界面吗?
|
|
public bool isChaKan;
|
|
|
|
public Tab_AdvanceBase advanceBase = null;
|
|
AdvanceInfo m_AdvanceInfo = null;
|
|
public void InitAttrInfo(AdvanceInfo info, GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self)
|
|
{
|
|
this.showType = showType;
|
|
m_AdvanceInfo = info;
|
|
baseId = info.baseId;
|
|
advanceType = (AdvanceBase.AdvanceType)info.type;
|
|
advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
|
if (advanceBase == null)
|
|
{
|
|
return;
|
|
}
|
|
//初始化相关信息描述
|
|
combatValueText.text = (info.combatValue >= 0 ? info.combatValue : 0).ToString();
|
|
|
|
//获取注魂注灵配置信息
|
|
GetInjectionItemId();
|
|
|
|
//设置注灵注魂的Slider和上面的描述
|
|
SetAllInjectionInfo();
|
|
|
|
//是否显示移动速度加成并且初始化
|
|
SetMoveSpeedIncDesc();
|
|
|
|
|
|
//显示拥有的属性
|
|
ShowOwnAttrInfo(); //累加VIP属性
|
|
|
|
|
|
//设置丹药Icon
|
|
SetDanItemIcon();
|
|
}
|
|
|
|
private float _CurAttrIncPercent = 0.0f;
|
|
public void SetMoveSpeedIncDesc()
|
|
{
|
|
// 增加对他人信息的进阶数据面板支持
|
|
bool isRide = false;
|
|
if (AdvanceMountPanelCtr.Instance != null
|
|
&& AdvanceMountPanelCtr.Instance.gameObject.activeSelf
|
|
&& AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Ride)
|
|
{
|
|
isRide = true;
|
|
}
|
|
else if (OtherPlayerAdvancePanelCtr.Instance != null
|
|
&& OtherPlayerAdvancePanelCtr.Instance.gameObject.activeSelf
|
|
&& OtherPlayerAdvancePanelCtr.Instance.advanceType == AdvanceBase.AdvanceType.Ride)
|
|
{
|
|
isRide = true;
|
|
}
|
|
|
|
if (_MoveDesc != null)
|
|
_MoveDesc.gameObject.SetActive(isRide);
|
|
_VipAttrPanel.SetActive(true);
|
|
|
|
Tab_MountBase mountBase = TableManager.GetMountBaseByID(advanceBase.ModelId, 0);
|
|
if (mountBase != null)
|
|
{
|
|
if (_MoveDesc != null)
|
|
_MoveDesc.text = StrDictionary.GetClientDictionaryString("#{3243}", mountBase.Speed - 100);
|
|
}
|
|
else
|
|
_MoveDesc.gameObject.SetActive(false);
|
|
|
|
Tab_PrivilegeFunction functionTab = null;
|
|
foreach (var tab in TableManager.GetPrivilegeFunction())
|
|
{
|
|
if (tab.Value.PrivilegeId == 12)
|
|
{
|
|
functionTab = tab.Value;
|
|
break;
|
|
}
|
|
}
|
|
if (functionTab != null)
|
|
{
|
|
|
|
if (isChaKan == false)
|
|
{
|
|
_ActiveVipBtn.SetActive(GameManager.gameManager.PlayerDataPool.VipCost < functionTab.getVipCount());
|
|
curincPerText.text = functionTab.GetVipbyIndex(GameManager.gameManager.PlayerDataPool.VipCost) + "%";
|
|
}
|
|
else
|
|
{
|
|
_ActiveVipBtn.SetActive(GameManager.gameManager.OtherPlayerData.VipLvl < functionTab.getVipCount());
|
|
curincPerText.text = functionTab.GetVipbyIndex(GameManager.gameManager.OtherPlayerData.VipLvl) + "%";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
curincPerText.text = "0%";
|
|
}
|
|
|
|
//if (GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic.ContainsKey((int)PrivilegeVipRoot.PRIVILEGE_VIP_TYPE.Diamond)
|
|
// && GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic[(int)PrivilegeVipRoot.PRIVILEGE_VIP_TYPE.Diamond]
|
|
// && (OtherPlayerAdvancePanelCtr.Instance == null || !OtherPlayerAdvancePanelCtr.Instance.gameObject.activeSelf))
|
|
//{
|
|
// _ActiveVipBtn.SetActive(false);
|
|
// //判断当前增加的属性比
|
|
// var curVipLevel = GameManager.gameManager.PlayerDataPool.VipCost;
|
|
// foreach (var tab in TableManager.GetPrivilegeFunction().Values)
|
|
// {
|
|
// if (tab.PrivilegeId == 12)
|
|
// {
|
|
// _CurAttrIncPercent = float.Parse(tab.GetVipbyIndex(curVipLevel)) / 100;
|
|
// curincPerText.text = tab.GetVipbyIndex(curVipLevel) + "%";
|
|
// break;
|
|
// }
|
|
// }
|
|
//}
|
|
//else if(OtherPlayerAdvancePanelCtr.Instance != null && OtherPlayerAdvancePanelCtr.Instance.gameObject.activeSelf && GameManager.gameManager.OtherPlayerData.Privilegeviplvl == (int)PrivilegeVipRoot.PRIVILEGE_VIP_TYPE.Diamond)
|
|
//{
|
|
// var curVipLevel = GameManager.gameManager.OtherPlayerData.VipLvl;
|
|
// foreach (var tab in TableManager.GetPrivilegeFunction().Values)
|
|
// {
|
|
// if (tab.PrivilegeId == 12)
|
|
// {
|
|
// curincPerText.text = tab.GetVipbyIndex(curVipLevel) + "%";
|
|
// break;
|
|
// }
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// if(_ActiveVipBtn != null)
|
|
// {
|
|
// _ActiveVipBtn.SetActive(true);
|
|
// }
|
|
//}
|
|
|
|
}
|
|
|
|
public void SetDanItemIcon()
|
|
{
|
|
// 增加对他人信息的进阶数据面板支持
|
|
AdvanceBase.AdvanceType adType = AdvanceBase.AdvanceType.Invalid;
|
|
if (AdvanceMountPanelCtr.Instance != null && AdvanceMountPanelCtr.Instance.gameObject.activeSelf)
|
|
{
|
|
adType = AdvanceMountPanelCtr.Instance.m_AdvanceType;
|
|
}
|
|
else if (OtherPlayerAdvancePanelCtr.Instance != null && OtherPlayerAdvancePanelCtr.Instance.gameObject.activeSelf)
|
|
{
|
|
adType = OtherPlayerAdvancePanelCtr.Instance.advanceType;
|
|
}
|
|
|
|
Tab_AdvanceOther other = TableManager.GetAdvanceOtherByID((int)adType, 0);
|
|
if (other == null)
|
|
{
|
|
return;
|
|
}
|
|
LoadAssetBundle.Instance.SetImageSprite(spiritDanIcon, other.SpiritItemIcon);
|
|
LoadAssetBundle.Instance.SetImageSprite(souDanIcon, other.SoulItemIcon);
|
|
}
|
|
|
|
public void GetInjectionItemId()
|
|
{
|
|
Tab_AdvanceOther other = TableManager.GetAdvanceOtherByID((int)advanceType, 0);
|
|
if (other == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 消耗的进阶之灵和进阶回魂物品id
|
|
soulDanItemId = other.SoulItemId;
|
|
spiritualDanItemId = other.SpiritItemId;
|
|
|
|
soulDanLimitCount = advanceBase.SoulDanLimit;
|
|
spiritualDanLimitCount = advanceBase.SpiritDanLimit;
|
|
|
|
soulDanHasUsedCount = m_AdvanceInfo.SoulDan;
|
|
spiritualDanHasUsedCount = m_AdvanceInfo.SpiritDan;
|
|
}
|
|
|
|
// 显示属性
|
|
public void ShowOwnAttrInfo()
|
|
{
|
|
for (int index = 0; index < advanceBase.getAttrIdCount(); index++)
|
|
{
|
|
if (advanceBase.GetAttrIdbyIndex(index) != -1)
|
|
{
|
|
attrItemList[index].InitAttrInfo(advanceBase.GetAttrIdbyIndex(index), (int)(advanceBase.GetAttrValuebyIndex(index) * (1 + _CurAttrIncPercent)));
|
|
attrItemList[index].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
HideAllAttr();
|
|
}
|
|
|
|
void HideAllAttr()
|
|
{
|
|
for (int index = 0; index < attrItemList.Count; index++)
|
|
{
|
|
attrItemList[index].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
// 设置注灵相关的信息
|
|
public void SetAllInjectionInfo()
|
|
{
|
|
SetInjectSpiritualInfo();
|
|
SetInjectSoulInfo();
|
|
}
|
|
|
|
// 设置注灵的相关信息
|
|
public void SetInjectSpiritualInfo()
|
|
{
|
|
Tab_AdvanceOther advanceOther = TableManager.GetAdvanceOtherByID((int)advanceType, 0);
|
|
if (advanceOther == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (advanceOther.SpiritOpenGrade > advanceBase.Grade)
|
|
{
|
|
// 在XX等阶开启
|
|
spiritualValueText.text = StrDictionary.GetClientDictionaryString("#{42673}", advanceOther.SpiritOpenGrade);
|
|
injectionSpiritualSlider.value = 0;
|
|
}
|
|
else
|
|
{
|
|
spiritualValueText.text = spiritualDanHasUsedCount + "/" + advanceBase.SpiritDanLimit;
|
|
injectionSpiritualSlider.value = m_AdvanceInfo.SpiritDan / (float)advanceBase.SpiritDanLimit;
|
|
}
|
|
}
|
|
|
|
public void SetInjectSoulInfo()
|
|
{
|
|
Tab_AdvanceOther advanceOther = TableManager.GetAdvanceOtherByID((int)advanceType, 0);
|
|
if (advanceOther == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (advanceOther.SoulOpenGrade > advanceBase.Grade)
|
|
{
|
|
soulValueDesc.text = StrDictionary.GetClientDictionaryString("#{42673}", advanceOther.SoulOpenGrade);
|
|
injectionSoulSlder.value = 0;
|
|
}
|
|
else
|
|
{
|
|
soulValueDesc.text = soulDanHasUsedCount + "/" + advanceBase.SoulDanLimit;
|
|
injectionSoulSlder.value = m_AdvanceInfo.SoulDan / (float)advanceBase.SoulDanLimit;
|
|
}
|
|
}
|
|
|
|
private enum InjectionType
|
|
{
|
|
Soul = 0, //注魂
|
|
Spiritual = 1, //注灵
|
|
}
|
|
|
|
public void OnInjectionBtnClick(int type)
|
|
{
|
|
GameItemContainer bagPack = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_BACKPACK);
|
|
if (bagPack == null)
|
|
return;
|
|
|
|
Tab_AdvanceOther advanceOther = TableManager.GetAdvanceOtherByID((int)advanceType, 0);
|
|
if (advanceOther == null)
|
|
{
|
|
return;
|
|
}
|
|
//判断1.身上有没有足够的物品 2.是否已达到最大使用值
|
|
switch (type)
|
|
{
|
|
case (int)InjectionType.Soul:
|
|
{
|
|
if (advanceBase.Grade < advanceOther.SoulOpenGrade)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{43030}"));
|
|
return;
|
|
}
|
|
|
|
if (soulDanHasUsedCount >= soulDanLimitCount)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42700}"));
|
|
return;
|
|
}
|
|
|
|
if (bagPack.GetItemCountByDataId(soulDanItemId) < 1)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42701}"));
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case (int)InjectionType.Spiritual:
|
|
{
|
|
if (advanceBase.Grade < advanceOther.SpiritOpenGrade)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{43030}"));
|
|
return;
|
|
}
|
|
|
|
if (spiritualDanHasUsedCount >= spiritualDanLimitCount)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42700}"));
|
|
return;
|
|
}
|
|
if (bagPack.GetItemCountByDataId(spiritualDanItemId) < 1)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42701}"));
|
|
return;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
CG_REQ_ADVANCE req = (CG_REQ_ADVANCE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ADVANCE);
|
|
req.SetOptionType((int)AdvanceBase.ReqType.USE_DAN);
|
|
req.SetType((int)advanceType);
|
|
switch (type)
|
|
{
|
|
case (int)InjectionType.Spiritual:
|
|
req.SetParam1((int)InjectionType.Spiritual);
|
|
break;
|
|
case (int)InjectionType.Soul:
|
|
req.SetParam1((int)InjectionType.Soul);
|
|
break;
|
|
}
|
|
req.SetParam2(0);
|
|
req.SendPacket();
|
|
}
|
|
|
|
public void OnVipBtnClick()
|
|
{
|
|
UIManager.ShowUI(UIInfo.YuanBaoShop, delegate (bool bSucess, object param)
|
|
{
|
|
if (bSucess)
|
|
{
|
|
YuanBaoShopLogic.Instance()._TagPanel.ShowPage(3);
|
|
//if (VipInfo.Instance)
|
|
//{
|
|
// VipInfo.Instance.Click_OpenVIPRoot();
|
|
//}
|
|
}
|
|
});
|
|
}
|
|
|
|
// 0.灵 2.魂
|
|
public void OnInjectItemClick(int danType)
|
|
{
|
|
Tab_AdvanceOther advanceOther = TableManager.GetAdvanceOtherByID((int)advanceType, 0);
|
|
if (advanceOther == null)
|
|
{
|
|
return;
|
|
}
|
|
if (danType == 0)
|
|
{
|
|
if (advanceOther.SpiritOpenGrade > advanceBase.Grade)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42673}", advanceOther.SpiritOpenGrade));
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (advanceOther.SoulOpenGrade > advanceBase.Grade)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42673}", advanceOther.SoulOpenGrade));
|
|
return;
|
|
}
|
|
}
|
|
|
|
UIManager.ShowUI(UIInfo.AdvanceSoulAndSoiritDescPanel, delegate (bool bSucess, object param)
|
|
{
|
|
if (bSucess)
|
|
{
|
|
if (danType == 0)
|
|
{
|
|
AdvanceSoulAndSoiritDescPanelCtr.Instance.InitInfo(baseId, (int)advanceType, danType, spiritualDanHasUsedCount, spiritDanIcon.transform.position);
|
|
}
|
|
else
|
|
{
|
|
AdvanceSoulAndSoiritDescPanelCtr.Instance.InitInfo(baseId, (int)advanceType, danType, soulDanHasUsedCount, souDanIcon.transform.position);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|