182 lines
6.3 KiB
C#
182 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class SkillCard : CardCoolTimeBase, IDropHandler
|
|
{
|
|
public static Dictionary<int, Func<bool>> dic_button = new Dictionary<int, Func<bool>>();
|
|
|
|
public Image[] images; // 0 1 아이콘, 2 버튼, 3 상태bg
|
|
public TextMeshProUGUI[] texts; // 0 상태
|
|
public GameObject[] gos_type; // 0 전투, 1 ui
|
|
public GameObject[] gos; // 0 상태, 1 잠김, 2 +
|
|
|
|
SkillDragItem m_skillDragItem;
|
|
SkillListTableData m_Data;
|
|
int m_Slot, m_PetId, m_Petlv;
|
|
|
|
public override void Set<T>(T _base)
|
|
{
|
|
base.Set(_base);
|
|
m_Data = _base as SkillListTableData;
|
|
|
|
CoolTime_Off();
|
|
|
|
if (!DSUtil.CheckNull(m_Data))
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
images[0].enabled = true;
|
|
images[0].sprite = images[1].sprite = m_Data.Get_Icon();
|
|
var lv = sdata.Get_SkillLv(eRole.PC, m_Data.n_SkillID);
|
|
gos[0].SetActive(true);
|
|
gos[1].SetActive(lv == 0);
|
|
gos[2].SetActive(false);
|
|
|
|
if (sdata.IsEquipSkill(m_Data.n_SkillID, sdata.Equip.Preset))
|
|
{
|
|
texts[0].text = table_localtext.Ins.Get_Text(207);
|
|
images[3].sprite = UIAtlasMgr.Ins.Get_Sprite("label 5");
|
|
}
|
|
else if (lv > 0)
|
|
{
|
|
texts[0].text = table_localtext.Ins.Get_Text(402);
|
|
images[3].sprite = UIAtlasMgr.Ins.Get_Sprite("label 3");
|
|
}
|
|
else
|
|
{
|
|
texts[0].text = table_localtext.Ins.Get_Text(208);
|
|
images[3].sprite = UIAtlasMgr.Ins.Get_Sprite("label 3 black");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DSUtil.ActivateGameObjects(gos, 0);
|
|
images[0].enabled = false;
|
|
}
|
|
}
|
|
public override void Set(int _val)
|
|
{
|
|
m_Slot = _val;
|
|
}
|
|
|
|
public void Set_PetSkill(int skillid, int petid, int lv)
|
|
{
|
|
CoolTime_Off();
|
|
m_PetId = petid;
|
|
m_Petlv = lv;
|
|
m_Data = table_skilllist.Ins.Get_Data_orNull(skillid);
|
|
DSUtil.InActivateGameObjects(gos);
|
|
images[0].sprite = m_Data.Get_Icon();
|
|
}
|
|
|
|
public override void Set_CardType(eUICardType _type)
|
|
{
|
|
base.Set_CardType(_type);
|
|
var et = images[2].GetComponent<EventTrigger>();
|
|
switch (CardType)
|
|
{
|
|
case eUICardType.UI:
|
|
DSUtil.InActivateGameObjects(gos_type, 1);
|
|
et.enabled = false;
|
|
images[1].raycastTarget = true;
|
|
images[2].GetComponent<Button>().onClick.AddListener(OnClick_SkillUI);
|
|
if (DSUtil.CheckNull(m_skillDragItem))
|
|
m_skillDragItem = images[1].gameObject.AddComponent<SkillDragItem>();
|
|
m_skillDragItem.m_skillID = m_Data.n_SkillID;
|
|
break;
|
|
case eUICardType.Use:
|
|
DSUtil.InActivateGameObjects(gos_type, 0);
|
|
et.enabled = true;
|
|
images[0].raycastTarget = false;
|
|
gos[0].SetActive(false);
|
|
break;
|
|
case eUICardType.UIEquip:
|
|
DSUtil.InActivateGameObjects(gos_type, 0);
|
|
break;
|
|
case eUICardType.SkillTest:
|
|
DSUtil.InActivateGameObjects(gos_type, 0);
|
|
et.enabled = false;
|
|
images[0].raycastTarget = false;
|
|
DSUtil.InActivateGameObjects(gos);
|
|
GetComponentInChildren<Button>(true).onClick.AddListener(() =>
|
|
{
|
|
if (dic_button.ContainsKey(m_Data.n_SkillID))
|
|
{
|
|
if (dic_button[m_Data.n_SkillID]())
|
|
dic_button.Remove(m_Data.n_SkillID);
|
|
}
|
|
else
|
|
MyValue.MyPC.Use_Skill(m_Data, false, m_Index, true);
|
|
});
|
|
break;
|
|
case eUICardType.UIPetSkill:
|
|
images[0].raycastTarget = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void OnDrop(PointerEventData eventData)
|
|
{
|
|
if (CardType == eUICardType.UIEquip)
|
|
{
|
|
var draggedSkill = eventData.pointerDrag.GetComponent<SkillDragItem>();
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
if (!DSUtil.CheckNull(draggedSkill) && sdata.IsObtainItem(draggedSkill.m_skillID))
|
|
{
|
|
int unequipid = 0;
|
|
if (!DSUtil.CheckNull(m_Data))
|
|
unequipid = m_Data.n_SkillID;
|
|
sdata.Equip.Set_Equip(eItem.Skill, draggedSkill.m_skillID, m_Slot, unequipid);
|
|
NewGameUI.Ins.m_SkillUI.EquipSkill(m_Slot, draggedSkill.m_skillID);
|
|
NewGameUI.Ins.m_SkillUI.Set_UI();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnClick_SkillUI()
|
|
{ // UI 스킬 카드
|
|
NewGameUI.Ins.m_SkillUI.m_SkillUI_SkillInfo.Set(m_Data);
|
|
}
|
|
|
|
public void OnClick_Skill()
|
|
{ // 실제 스킬 사용
|
|
if (CardType == eUICardType.UIEquip)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
if (!DSUtil.CheckNull(m_Data))
|
|
{
|
|
switch (CardType)
|
|
{
|
|
case eUICardType.Use:
|
|
if (dic_button.ContainsKey(m_Data.n_SkillID))
|
|
{
|
|
if (dic_button[m_Data.n_SkillID]())
|
|
dic_button.Remove(m_Data.n_SkillID);
|
|
}
|
|
else if (m_CoolTime <= 0f)
|
|
{
|
|
if (MyValue.MyPC.Use_Skill(m_Data, false, m_Index))
|
|
m_CoolTime = m_Data.Get_CoolTime(MyValue.MyPC.Get_StatInfo().Get_Stat(eStat.COOLTIME_Multiplier));
|
|
}
|
|
else
|
|
MessageInfo.Ins.Add_Log(166);
|
|
break;
|
|
case eUICardType.UIPetSkill:
|
|
NewGameUI.Ins.m_PetUI.m_PetSkillDetailUI.Set(m_Data.n_SkillID, m_PetId, m_Petlv);
|
|
break;
|
|
default:
|
|
//ItemDescUI.Ins.Set(m_ItemData);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override TableDataBase Get_Data() { return m_Data; }
|
|
} |