167 lines
5.0 KiB
C#
167 lines
5.0 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
using Games.Item;
|
|
using Games.GlobeDefine;
|
|
|
|
// 进阶项技能 Icon
|
|
public class AdvanceSkillItem : MonoBehaviour {
|
|
|
|
private GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self;
|
|
public GameObject canLevelUPIcon;
|
|
public Image skillIcon;
|
|
public Text skillLevel;
|
|
|
|
public Material _grayMaterial;
|
|
|
|
private int _CurGrade = -1;
|
|
private int curSkillId = -1;
|
|
private int curBaseId = -1;
|
|
|
|
public void InitSkillItem(int skillId, int baseId, GameDefine_Globe.ShowType showType = GameDefine_Globe.ShowType.Self)
|
|
{
|
|
this.showType = showType;
|
|
|
|
curBaseId = baseId;
|
|
curSkillId = skillId;
|
|
|
|
if (skillId == -1)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Tab_AdvanceSkill advanceSkill = TableManager.GetAdvanceSkillByID(skillId, 0);
|
|
if(advanceSkill == null)
|
|
{
|
|
return;
|
|
}
|
|
skillLevel.text = advanceSkill.SkillLevel.ToString();
|
|
Tab_SkillEx curSkillEx = TableManager.GetSkillExByID(skillId, 0);
|
|
{
|
|
if(curSkillEx == null)
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
}
|
|
if (curSkillEx != null)
|
|
{
|
|
curSkillId = skillId;
|
|
Tab_SkillBase skillBase = TableManager.GetSkillBaseByID(curSkillEx.BaseId, 0);
|
|
if (skillBase != null)
|
|
{
|
|
LoadAssetBundle.Instance.SetImageSprite(skillIcon, skillBase.Icon);
|
|
|
|
skillIcon.material = advanceSkill.SkillLevel > 0 ? skillIcon.defaultMaterial : _grayMaterial;
|
|
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
|
if(advanceBase != null)
|
|
{
|
|
_CurGrade = advanceBase.Grade;
|
|
SetUpIconState(skillId, advanceBase.Grade);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(AdvanceSkillTips.Instance) //刷新技能面板
|
|
{
|
|
AdvanceSkillTips.Instance.InitSkillTip(curSkillId, curBaseId, this.gameObject.transform.position, showType);
|
|
}
|
|
}
|
|
|
|
private bool _IsCanLevelUp = false;
|
|
public bool IsCanLevelIp
|
|
{
|
|
get { return _IsCanLevelUp; }
|
|
set { _IsCanLevelUp = value; }
|
|
}
|
|
|
|
public bool CanAdvanceSkillItemLevelUp()
|
|
{
|
|
return _IsCanLevelUp;
|
|
}
|
|
|
|
public void SetUpIconState(int skillId, int grade)
|
|
{
|
|
if(canLevelUPIcon == null)
|
|
{
|
|
return;
|
|
}
|
|
Tab_AdvanceSkill curAdvanceBaseSkill = TableManager.GetAdvanceSkillByID(skillId, 0);
|
|
if(curAdvanceBaseSkill == null)
|
|
{
|
|
canLevelUPIcon.gameObject.SetActive(false);
|
|
_IsCanLevelUp = false;
|
|
return;
|
|
}
|
|
|
|
skillIcon.material = curAdvanceBaseSkill.SkillLevel > 0 ? skillIcon.defaultMaterial : _grayMaterial;
|
|
Tab_AdvanceSkill nextAdvanceBaseSkill = TableManager.GetAdvanceSkillByID(curAdvanceBaseSkill.NextSkillExId, 0);
|
|
if (nextAdvanceBaseSkill == null)
|
|
{
|
|
canLevelUPIcon.gameObject.SetActive(false);
|
|
_IsCanLevelUp = false;
|
|
return;
|
|
}
|
|
|
|
curSkillId = skillId;
|
|
GameItemContainer bagPack = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_BACKPACK);
|
|
if (bagPack == null)
|
|
return;
|
|
int ownItemCount = bagPack.GetItemCountByDataId(nextAdvanceBaseSkill.CostItemId);
|
|
|
|
if((ownItemCount >= nextAdvanceBaseSkill.CostItemNum) && grade >= nextAdvanceBaseSkill.NeedAdvanceLevel)
|
|
{
|
|
canLevelUPIcon.gameObject.SetActive(true);
|
|
_IsCanLevelUp = true;
|
|
}
|
|
else
|
|
{
|
|
canLevelUPIcon.gameObject.SetActive(false);
|
|
_IsCanLevelUp = false;
|
|
}
|
|
}
|
|
|
|
//物品数量更新的时候要重新判断一次是否可以升级,因为刷新技能的时候物品还未同步
|
|
public void RefreshRedIconState()
|
|
{
|
|
SetUpIconState(curSkillId, _CurGrade);
|
|
}
|
|
|
|
|
|
public void OnSkillItemClick()
|
|
{
|
|
if(curSkillId == -1)
|
|
{
|
|
return;
|
|
}
|
|
if(AdvanceSkillTips.Instance && AdvanceSkillTips.Instance.gameObject.activeInHierarchy)
|
|
{
|
|
AdvanceSkillTips.Instance.InitSkillTip(curSkillId, curBaseId, this.gameObject.transform.position, showType);
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowUI(UIInfo.AdvanceSkillInfoTip, delegate (bool bSucess, object param) {
|
|
if (bSucess)
|
|
{
|
|
AdvanceSkillTips.Instance.InitSkillTip(curSkillId, curBaseId, this.gameObject.transform.position, showType);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public bool IsShowingRedIcon()
|
|
{
|
|
if(canLevelUPIcon != null)
|
|
{
|
|
return canLevelUPIcon.activeSelf;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|