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

171 lines
6.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GCGame.Table;
using UnityEngine.UI;
using Games.GlobeDefine;
using Module.Log;
// 进阶技能显示面板
// 增加对他人信息查看支持
public class AdvanceSkillPanel : MonoBehaviour {
public List<AdvanceSkillItem> skillItemList;
public Text skillNameDesc;
public GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self;
private Dictionary<int, int> ownSkillIndexAndIdDic = new Dictionary<int, int>();
// 增加对他人信息查看界面支持
public void InitSkillPanel(AdvanceInfo info, GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self)
{
//获取全部的技能分类
GetAllAdvanceSkillDic(info.type);
this.showType = showType;
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(info.baseId, 0);
if (advanceBase == null)
{
return;
}
ownSkillIndexAndIdDic.Clear();
// 整理info中的技能信息存为 Dic<槽位索引技能ID>形式
for (int index = 0; index < info.skillId.Count; index++)
{
Tab_AdvanceSkill advanceSkill = TableManager.GetAdvanceSkillByID(info.skillId[index], 0);
if (advanceSkill != null)
{
if (ownSkillIndexAndIdDic.ContainsKey(advanceSkill.Index))
{
ownSkillIndexAndIdDic[advanceSkill.Index] = advanceSkill.Id;
} else
{
ownSkillIndexAndIdDic.Add(advanceSkill.Index, advanceSkill.Id);
}
}
}
// 检测技能数量,并进行显示
for (int index = 0; index < skillItemList.Count; index++)
{
skillItemList[index].gameObject.SetActive(index < curTypeSkillDic.Count ? true : false);
if (skillItemList[index].gameObject.activeInHierarchy)
{
if (!curTypeSkillDic.ContainsKey(index))
{
LogModule.ErrorLog("Index : " + index + " hasn't set origin skill");
return;
}
skillItemList[index].gameObject.GetComponent<AdvanceSkillItem>().InitSkillItem(
ownSkillIndexAndIdDic.ContainsKey(index) ? ownSkillIndexAndIdDic[index] : curTypeSkillDic[index],
advanceBase.Id,
showType);
}
}
// 显示当前进阶类型的面板名称
InitSkillDesc(info.type);
}
public void InitSkillDesc(int type)
{
switch (type)
{
case (int)AdvanceBase.AdvanceType.Ride:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{42667}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
case (int)AdvanceBase.AdvanceType.Wing:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{42669}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
case (int)AdvanceBase.AdvanceType.Piano:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{42668}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
case (int)AdvanceBase.AdvanceType.Qilinbi:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{42670}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
case (int)AdvanceBase.AdvanceType.Mask:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{44035}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
case (int)AdvanceBase.AdvanceType.Soul:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{44034}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
case (int)AdvanceBase.AdvanceType.Huopao:
skillNameDesc.text = StrDictionary.GetClientDictionaryString("#{42711}") + StrDictionary.GetClientDictionaryString("#{44033}");
break;
}
}
// curTypeSkillDic<技能所在技能槽的index, 技能id>
private Dictionary<int, int> curTypeSkillDic = new Dictionary<int, int>();
/// <summary>
/// 获得type类型的所有初始化的技能
/// </summary>
/// <param name="type">进阶类型</param>
public void GetAllAdvanceSkillDic(int type)
{
curTypeSkillDic.Clear();
foreach (var skillInfo in TableManager.GetAdvanceSkill().Values)
{
if (skillInfo.Type == type)
{
if (curTypeSkillDic.ContainsKey(skillInfo.Index)
&& skillInfo.SkillLevel == 0
&& skillInfo.NeedCareer == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession)
{
curTypeSkillDic[skillInfo.Index] = skillInfo.Id;
}
else
{
if (skillInfo.SkillLevel == 0
&& skillInfo.NeedCareer == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession)
{
if (curTypeSkillDic.ContainsKey(skillInfo.Index))
{
curTypeSkillDic[skillInfo.Index] = skillInfo.Id;
}
else
{
curTypeSkillDic.Add(skillInfo.Index, skillInfo.Id);
}
}
}
}
}
}
public void RefreshSkillPanel(int oldId, int newId, int baseId)
{
Tab_AdvanceSkill advanceSkill = TableManager.GetAdvanceSkillByID(newId, 0);
if (advanceSkill == null)
{
return;
}
if (advanceSkill.Index < skillItemList.Count)
{
skillItemList[advanceSkill.Index].gameObject.GetComponent<AdvanceSkillItem>().InitSkillItem(newId, baseId, showType);
}
}
public void RefreshSkillItemRedIconState()
{
for(int index = 0; index < skillItemList.Count; index++)
{
skillItemList[index].GetComponent<AdvanceSkillItem>().RefreshRedIconState();
}
}
public bool IsHaveSkillCanLevelUp()
{
for(int index = 0; index < skillItemList.Count; index++)
{
if (skillItemList[index].CanAdvanceSkillItemLevelUp())
return true;
}
return false;
}
}