Files
JJBB/Assets/Project/Script/GUI/Advance/AdvanceSkillTips.cs
2024-08-23 15:49:34 +08:00

252 lines
10 KiB
C#

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
using GCGame.Table;
using Games.Item;
using Games.GlobeDefine;
public class AdvanceSkillTips : MonoBehaviour {
public static AdvanceSkillTips Instance;
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
Instance = null;
}
#region
public GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self;
public Image skillIcon;
public Text skillName;
public Text isMainOrNotText; //是否是主动技能 是否已解锁
public GameObject isSkillActiveOrot;
public Text curEffectDesc; //当前效果
public Text nextEffectDesc; //下一级效果,满级隐藏
public Image itemQuality;
public Image itemIcon;
public Text upLevelNeedGrade;
public Text itemName;
public Text needItemCount;
public Text ownItemCount;
public GameObject _GainBtn;
public GameObject learnPanel; //满级隐藏学习按钮
public GameObject itemDescPanel; //满级的话隐藏
#endregion
private int levelUpNeedItemId;
private int levelUpNeedItemCount;
private int levelUpNeedGrade;
private int curAdvanceGrade;
private int curOwnItemCount; //当前拥有的物品数量
private int curAdvanceType; //当前进阶类型
private int nextSkillId; //下个技能iD
public Transform objPos;
GameItemContainer bagPack = null;
private Tab_AdvanceSkill nextAdvanceSkill = null;
public void InitSkillTip(int skillId, int baseId, Vector2 pos, GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self)
{
this.showType = showType;
objPos.position = pos;
Tab_AdvanceSkill advanceSkill = TableManager.GetAdvanceSkillByID(skillId, 0);
if(advanceSkill == null)
{
return;
}
Tab_SkillEx skillEx = TableManager.GetSkillExByID(skillId, 0);
if(skillEx == null)
{
return;
}
Tab_SkillBase skillBase = TableManager.GetSkillBaseByID(skillEx.BaseId, 0);
if(skillBase == null)
{
return;
}
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
if(advanceBase == null)
{
return;
}
//设置SkillIcon name
LoadAssetBundle.Instance.SetImageSprite(skillIcon, skillBase.Icon);
skillName.text = skillBase.Name + "\u00A0\u00A0\u00A0" + StrDictionary.GetClientDictionaryString("#{2673}", advanceSkill.SkillLevel);
nextSkillId = advanceSkill.NextSkillExId;
curAdvanceGrade = advanceBase.Grade;
curAdvanceType = (advanceBase.Id - advanceBase.Level) / 1000 - 1;
curEffectDesc.text = StrDictionary.GetClientDictionaryString("#{42694}", skillEx.SkillDesc);
//主动 被动 是否激活
isMainOrNotText.text = (skillBase.SkillClass & 1) != 0 ? StrDictionary.GetClientDictionaryString("#{42698}") : StrDictionary.GetClientDictionaryString("#{42699}");
isSkillActiveOrot.SetActive(advanceSkill.SkillLevel != 0 ? false : true);
if (advanceSkill.NextSkillExId != -1) //技能等级未达到满级
{
// 当处于他人显示状态,不显示学习面板
if(showType == GameDefine_Globe.ShowType.Other)
{
learnPanel.gameObject.SetActive(false);
}
else
{
learnPanel.gameObject.SetActive(true);
}
nextEffectDesc.gameObject.SetActive(true);
itemDescPanel.gameObject.SetActive(true);
Tab_SkillEx nextSkillex = TableManager.GetSkillExByID(advanceSkill.NextSkillExId, 0);
if(nextEffectDesc != null)
{
nextEffectDesc.text = StrDictionary.GetClientDictionaryString("#{42695}", nextSkillex.SkillDesc);
}
nextAdvanceSkill = TableManager.GetAdvanceSkillByID(advanceSkill.NextSkillExId, 0);
if(nextAdvanceSkill == null)
{
return;
}
levelUpNeedItemId = nextAdvanceSkill.CostItemId;
levelUpNeedItemCount = nextAdvanceSkill.CostItemNum;
levelUpNeedGrade = nextAdvanceSkill.NeedAdvanceLevel;
bagPack = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_BACKPACK);
if (bagPack == null)
return;
curOwnItemCount = bagPack.GetItemCountByDataId(levelUpNeedItemId);
//设置升级物品跟描述
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(nextAdvanceSkill.CostItemId, 0);
if (commonItem == null)
{
return;
}
LoadAssetBundle.Instance.SetImageSprite(itemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
LoadAssetBundle.Instance.SetImageSprite(itemIcon, commonItem.Icon);
if (commonItem.QualityEffect > 0)
{
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, itemIcon.transform);
}
else
{
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, itemIcon.transform);
}
upLevelNeedGrade.text = advanceBase.Grade >= nextAdvanceSkill.NeedAdvanceLevel ?
StrDictionary.GetClientDictionaryString("#{44004}", nextAdvanceSkill.NeedAdvanceLevel) : StrDictionary.GetClientDictionaryString("#{44005}", nextAdvanceSkill.NeedAdvanceLevel); //nextAdvanceSkill.NeedAdvanceLevel.ToString();
itemName.text = commonItem.Name;
GameItemContainer backPack = GameManager.gameManager.PlayerDataPool.BackPack;
if(backPack != null)
{
// 当处于显示他人界面时,不显示当前拥有数目
if(showType == GameDefine_Globe.ShowType.Self)
{
ownItemCount.transform.parent.gameObject.SetActive(true);
ownItemCount.text = backPack.GetItemCountByDataId(levelUpNeedItemId) >= nextAdvanceSkill.CostItemNum ?
StrDictionary.GetClientDictionaryString("#{44004}", backPack.GetItemCountByDataId(levelUpNeedItemId)) : StrDictionary.GetClientDictionaryString("#{44005}", backPack.GetItemCountByDataId(levelUpNeedItemId));//nextAdvanceSkill.CostItemNum.ToString();
_GainBtn.SetActive(backPack.GetItemCountByDataId(levelUpNeedItemId) < nextAdvanceSkill.CostItemNum);
}
else
{
ownItemCount.transform.parent.gameObject.SetActive(false);
}
}
needItemCount.text = nextAdvanceSkill.CostItemNum.ToString();
}
else
{
learnPanel.gameObject.SetActive(false);
nextEffectDesc.gameObject.SetActive(false);
itemDescPanel.gameObject.SetActive(false);
}
}
public void OnGainBtnClick()
{
ItemTooltipsLogic.ShowItemTooltip(levelUpNeedItemId, ItemTooltipsLogic.ShowType.GetPath, _GainBtn.transform.position,
() =>
{
UIManager.CloseUI(UIInfo.AdvanceSkillInfoTip);
});
}
public void OnLearnBtnClick()
{
if(curOwnItemCount < levelUpNeedItemCount)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42696}"));
return;
}
if(curAdvanceGrade < levelUpNeedGrade)
{
switch (curAdvanceType)
{
case (int)AdvanceBase.AdvanceType.Ride:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42667}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
case (int)AdvanceBase.AdvanceType.Wing:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42669}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
case (int)AdvanceBase.AdvanceType.Piano:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42668}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
case (int)AdvanceBase.AdvanceType.Qilinbi:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42670}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
case (int)AdvanceBase.AdvanceType.Mask:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44035}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
case (int)AdvanceBase.AdvanceType.Soul:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44034}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
case (int)AdvanceBase.AdvanceType.Huopao:
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42711}") + StrDictionary.GetClientDictionaryString("#{42697}"));
break;
}
return;
}
//发送申请升级的协议
if(nextSkillId != -1)
{
CG_REQ_ADVANCE req = (CG_REQ_ADVANCE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ADVANCE);
req.SetOptionType((int)AdvanceBase.ReqType.SKILL_OPTION);
req.SetType(curAdvanceType);
req.SetParam1(nextSkillId);
req.SetParam2(-1);
req.SendPacket();
}
// OnBackClick();
}
public void OnBackClick()
{
UIManager.CloseUI(UIInfo.AdvanceSkillInfoTip);
}
public void RefreshOwnItemCount()
{
GameItemContainer backPack = GameManager.gameManager.PlayerDataPool.BackPack;
if (backPack == null)
return;
ownItemCount.text = backPack.GetItemCountByDataId(levelUpNeedItemId) >= nextAdvanceSkill.CostItemNum ?
StrDictionary.GetClientDictionaryString("#{44004}", backPack.GetItemCountByDataId(levelUpNeedItemId)) : StrDictionary.GetClientDictionaryString("#{44005}", backPack.GetItemCountByDataId(levelUpNeedItemId));//nextAdvanceSkill.CostItemNum.ToString();
_GainBtn.SetActive(backPack.GetItemCountByDataId(levelUpNeedItemId) < nextAdvanceSkill.CostItemNum);
}
}