feat: 스킬 편집 UI 내의 스킬 슬롯, 스킬 정보 클릭 액션 적용
This commit is contained in:
@@ -53,9 +53,10 @@ namespace TON
|
||||
// TODO : Custom Order After System Load
|
||||
// UIManager.Show<IngameUI>(UIList.IngameUI);
|
||||
// UIManager.Show<LobbyUI>(UIList.LobbyUI);
|
||||
UIManager.Show<ControllerUI>(UIList.ControllerUI);
|
||||
ControllerUI.Instance.Initalize();
|
||||
// UIManager.Show<ControllerUI>(UIList.ControllerUI);
|
||||
// ControllerUI.Instance.Initalize();
|
||||
// UIManager.Show<IngameOptionUI>(UIList.IngameOptionUI);
|
||||
UIManager.Show<SkillSettingUI>(UIList.SkillSettingUI);
|
||||
// UIManager.Show<CharaterCreateUI>(UIList.CharaterCreateUI);
|
||||
// UIManager.Show<TitleUI>(UIList.TitleUI);
|
||||
}
|
||||
|
||||
@@ -99,12 +99,11 @@ namespace TON
|
||||
// 일반 객체는 그대로 JSON 변환
|
||||
json = JsonUtility.ToJson(data, true);
|
||||
}
|
||||
Debug.Log("SaveToFile ::: " + json);
|
||||
|
||||
File.WriteAllText(path, json);
|
||||
Debug.Log($"파일 저장 성공 ::: {fileName}.json");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,10 @@ namespace TON
|
||||
|
||||
private List<SkillBase> equippedSkills = new List<SkillBase>();
|
||||
|
||||
|
||||
public void Initalize()
|
||||
{
|
||||
LoadSkillData();
|
||||
SetSkillInstances();
|
||||
// TODO: player skill data 초기화[셋팅]
|
||||
// 예시) 1,4,5번 스킬을 EquippedSkills에 추가
|
||||
GetActiveSkillInstance();
|
||||
}
|
||||
|
||||
@@ -38,7 +35,8 @@ namespace TON
|
||||
skillDatas.Clear();
|
||||
}
|
||||
|
||||
skillDatas = JSONLoader.LoadFromResources<List<SkillData>>("Skill");
|
||||
skillDatas = JSONLoader.LoadFromResources<List<SkillData>>("skill");
|
||||
|
||||
if (skillDatas == null)
|
||||
{
|
||||
skillDatas = new List<SkillData>();
|
||||
@@ -89,10 +87,11 @@ namespace TON
|
||||
{
|
||||
if (skill.slotNumber == 1 || skill.slotNumber == 2 || skill.slotNumber == 3)
|
||||
{
|
||||
Debug.Log("GetActiveSkillInstance() : " + skill.id);
|
||||
// Debug.Log("GetActiveSkillInstance() : " + skill.id);
|
||||
equippedSkills.Add(skillInstances.GetValueOrDefault(skill.id));
|
||||
}
|
||||
}
|
||||
equippedSkills.Sort((a, b) => a.SkillData.slotNumber.CompareTo(b.SkillData.slotNumber));
|
||||
return equippedSkills;
|
||||
}
|
||||
|
||||
@@ -133,14 +132,14 @@ namespace TON
|
||||
// 스킬 생성
|
||||
GameObject effectGameObject = ObjectPoolManager.Instance.GetEffect(skillId);
|
||||
Projectile projectile = effectGameObject.GetComponent<Projectile>();
|
||||
SkillBase targetSkillBase = GetSkillData(skillId);
|
||||
SkillBase targetSkillBase = GetSkillInstance(skillId);
|
||||
targetSkillBase.SetCurrentCoolDown();
|
||||
|
||||
projectile.Init(targetSkillBase.SkillData.damage);
|
||||
|
||||
effectGameObject.transform.SetPositionAndRotation(firePoint.position, firePoint.rotation);
|
||||
|
||||
// 🔥 스킬 방향 반전
|
||||
// 스킬 방향 반전
|
||||
var bulletScale = effectGameObject.transform.localScale;
|
||||
bulletScale.x = Mathf.Abs(bulletScale.x) * lastDirection;
|
||||
effectGameObject.transform.localScale = bulletScale;
|
||||
@@ -152,14 +151,29 @@ namespace TON
|
||||
targetSkillBase.OnSkillExecuted?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SkillBase GetSkillData(string skillId)
|
||||
public SkillBase GetSkillInstance(string skillId)
|
||||
{
|
||||
// 스킬 베이스가 null일때 방어로직 추가
|
||||
SkillBase result = skillInstances.GetValueOrDefault(skillId);
|
||||
Assert.IsNotNull(result, "SkillDataManager.ExecuteSkill() : targetSkillBase is null");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void UpdateSkillData(string skillId, int slotNumber)
|
||||
{
|
||||
foreach (var skill in skillDatas)
|
||||
{
|
||||
if (skill.id == skillId)
|
||||
{
|
||||
skill.slotNumber = slotNumber;
|
||||
}
|
||||
if (skill.slotNumber == slotNumber && skill.id != skillId)
|
||||
{
|
||||
skill.slotNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
JSONLoader.SaveToFile(skillDatas, "skill");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@ namespace TON
|
||||
{
|
||||
public class SkillInformationItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
SerializableDictionary<string, Sprite> imageSprites = new SerializableDictionary<string, Sprite>();
|
||||
|
||||
public GameObject skillImage;
|
||||
public TextMeshProUGUI skillName;
|
||||
public TextMeshProUGUI skillDamage;
|
||||
@@ -21,10 +18,15 @@ namespace TON
|
||||
public TextMeshProUGUI skillReqLv;
|
||||
|
||||
public GameObject locker;
|
||||
public GameObject selectedState;
|
||||
|
||||
public string skillId;
|
||||
|
||||
|
||||
public void Initalize(SkillData skillData, int playerLevel)
|
||||
{
|
||||
skillId = skillData.id;
|
||||
|
||||
skillName.text = skillData.name;
|
||||
skillDamage.text = $"{skillData.damage}";
|
||||
skillCooltime.text = $"{skillData.coolDown}";
|
||||
@@ -46,5 +48,16 @@ namespace TON
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedSkillInfo()
|
||||
{
|
||||
selectedState.SetActive(true);
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void UnselectedSkillInfo()
|
||||
{
|
||||
selectedState.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
@@ -8,13 +9,16 @@ namespace TON
|
||||
public class SkillScrollViewController : MonoBehaviour
|
||||
{
|
||||
public ScrollRect scrollRect;
|
||||
public float space = 10f;
|
||||
|
||||
public GameObject uiPrefab;
|
||||
public SkillInformationItem skillInfoPrefab;
|
||||
public List<RectTransform> uiPrefabList = new List<RectTransform>();
|
||||
public List<SkillInformationItem> createSkillInfo = new List<SkillInformationItem>();
|
||||
|
||||
public int playerLevel;
|
||||
|
||||
private SkillInformationItem selectedSkillInfo;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
scrollRect = GetComponent<ScrollRect>();
|
||||
@@ -31,8 +35,16 @@ namespace TON
|
||||
for (int i = 0; i < skillDatas.Count; i++)
|
||||
{
|
||||
SkillData skillData = skillDatas[i];
|
||||
GameObject skillInfoItem = Instantiate(uiPrefab, scrollRect.content);
|
||||
skillInfoItem.GetComponent<SkillInformationItem>().Initalize(skillData, playerLevel);
|
||||
SkillInformationItem skillInfoItem = Instantiate(skillInfoPrefab, scrollRect.content);
|
||||
|
||||
skillInfoItem.gameObject.SetActive(true);
|
||||
skillInfoItem.Initalize(skillData, playerLevel);
|
||||
createSkillInfo.Add(skillInfoItem);
|
||||
|
||||
if (playerLevel < skillData.requiredLevel)
|
||||
{
|
||||
skillInfoItem.GetComponent<Button>().interactable = false;
|
||||
}
|
||||
|
||||
RectTransform rectTransform = skillInfoItem.GetComponent<RectTransform>();
|
||||
|
||||
@@ -43,5 +55,26 @@ namespace TON
|
||||
|
||||
scrollRect.content.sizeDelta = new Vector2(scrollRect.content.sizeDelta.x, y);
|
||||
}
|
||||
|
||||
public void OnClickSkillInfo()
|
||||
{
|
||||
GameObject selectedSlotGameObject = EventSystem.current.currentSelectedGameObject;
|
||||
selectedSkillInfo = selectedSlotGameObject.GetComponent<SkillInformationItem>();
|
||||
|
||||
string selectSkillId = selectedSkillInfo.SelectedSkillInfo();
|
||||
// SkillSettingUI.Instance.OnClickSkillInfo(selectSkillId);
|
||||
Debug.Log($"OnClickSkillInfo() : {createSkillInfo.Count}");
|
||||
foreach (var skillInfo in createSkillInfo)
|
||||
{
|
||||
Debug.Log($"OnClickSkillInfo() : {selectSkillId} , {skillInfo.skillId}");
|
||||
Debug.Log(skillInfo.skillId != selectSkillId);
|
||||
if (skillInfo.skillId != selectSkillId)
|
||||
{
|
||||
skillInfo.UnselectedSkillInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
@@ -12,10 +15,36 @@ namespace TON
|
||||
public SkillSettingUI_SkillSlot skillSlotPrefab;
|
||||
public List<SkillSettingUI_SkillSlot> createSkillSlots = new List<SkillSettingUI_SkillSlot>();
|
||||
|
||||
public ScrollRect scrollRect;
|
||||
public SkillInformationItem skillInfoPrefab;
|
||||
public List<RectTransform> uiPrefabList = new List<RectTransform>();
|
||||
public List<SkillInformationItem> createSkillInfo = new List<SkillInformationItem>();
|
||||
|
||||
public Button settingButton;
|
||||
|
||||
|
||||
private int selectedSlotIndex = -1;
|
||||
private string selectedSkillId = null;
|
||||
private int playerLevel;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
playerLevel = PlayerDataManager.Singleton.player.level;
|
||||
|
||||
SetSkillSlots();
|
||||
SetSkillInfoItem();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (selectedSlotIndex != -1 && !string.IsNullOrWhiteSpace(selectedSkillId))
|
||||
{
|
||||
settingButton.interactable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingButton.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSkillSlots()
|
||||
@@ -39,15 +68,102 @@ namespace TON
|
||||
|
||||
if (i < activatedSkills.Count) // 해당 인덱스에 활성화된 스킬이 있을 경우
|
||||
{
|
||||
newSkillSlot.Initalize(activatedSkills[i].SkillData.id);
|
||||
newSkillSlot.Initalize(activatedSkills[i].SkillData.id, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 복제 됐을때 기본 상태가 잠금 상태
|
||||
newSkillSlot.GetComponent<Button>().interactable = false;
|
||||
}
|
||||
|
||||
createSkillSlots.Add(newSkillSlot);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSkillInfoItem()
|
||||
{
|
||||
List<SkillData> skillDatas = SkillDataManager.Singleton.skillDatas;
|
||||
|
||||
float y = 0;
|
||||
for (int i = 0; i < skillDatas.Count; i++)
|
||||
{
|
||||
SkillData skillData = skillDatas[i];
|
||||
SkillInformationItem skillInfoItem = Instantiate(skillInfoPrefab, scrollRect.content);
|
||||
|
||||
skillInfoItem.gameObject.SetActive(true);
|
||||
skillInfoItem.Initalize(skillData, playerLevel);
|
||||
createSkillInfo.Add(skillInfoItem);
|
||||
|
||||
if (playerLevel < skillData.requiredLevel)
|
||||
{
|
||||
skillInfoItem.GetComponent<Button>().interactable = false;
|
||||
}
|
||||
|
||||
RectTransform rectTransform = skillInfoItem.GetComponent<RectTransform>();
|
||||
|
||||
uiPrefabList.Add(rectTransform);
|
||||
uiPrefabList[i].anchoredPosition = new Vector2(0f, -y);
|
||||
y += uiPrefabList[i].sizeDelta.y;
|
||||
}
|
||||
|
||||
scrollRect.content.sizeDelta = new Vector2(scrollRect.content.sizeDelta.x, y);
|
||||
}
|
||||
|
||||
public void OnClickSkillSlot()
|
||||
{
|
||||
GameObject selectedSlotGameObject = EventSystem.current.currentSelectedGameObject;
|
||||
SkillSettingUI_SkillSlot selectedSlot = selectedSlotGameObject.GetComponent<SkillSettingUI_SkillSlot>();
|
||||
|
||||
selectedSlotIndex = selectedSlot.SelectedSlot();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (i != selectedSlotIndex)
|
||||
{
|
||||
createSkillSlots[i].UnselectedSlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickSkillInfo()
|
||||
{
|
||||
GameObject selectedSlotGameObject = EventSystem.current.currentSelectedGameObject;
|
||||
SkillInformationItem selectedSkillInfo = selectedSlotGameObject.GetComponent<SkillInformationItem>();
|
||||
|
||||
selectedSkillId = selectedSkillInfo.SelectedSkillInfo();
|
||||
foreach (var skillInfo in createSkillInfo)
|
||||
{
|
||||
if (skillInfo.skillId != selectedSkillId)
|
||||
{
|
||||
skillInfo.UnselectedSkillInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickSettingButton()
|
||||
{
|
||||
Debug.Log($"OnClickSettingButton() : {selectedSkillId} , {selectedSlotIndex}");
|
||||
// 스킬 데이터 업데이트 할때 selectedSlotIndex +1 해서 넘겨줘야함
|
||||
SkillDataManager.Singleton.UpdateSkillData(selectedSkillId, selectedSlotIndex + 1);
|
||||
|
||||
// 스킬 업데이트 후 UI 갱신
|
||||
var unselectedSkill = createSkillInfo.Find(skill => skill.skillId == selectedSkillId);
|
||||
unselectedSkill?.UnselectedSkillInfo();
|
||||
createSkillSlots[selectedSlotIndex].UnselectedSlot();
|
||||
|
||||
selectedSkillId = null;
|
||||
selectedSlotIndex = -1;
|
||||
|
||||
RefreshUI();
|
||||
}
|
||||
|
||||
private void RefreshUI()
|
||||
{
|
||||
SetSkillSlots();
|
||||
SetSkillInfoItem();
|
||||
}
|
||||
|
||||
public void OnClickCloseButton()
|
||||
{
|
||||
UIManager.Hide<SkillSettingUI>(UIList.SkillSettingUI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,26 @@ namespace TON
|
||||
public GameObject lockerImage;
|
||||
public GameObject selectedState;
|
||||
|
||||
public void Initalize(string skillId)
|
||||
private int slotIndex;
|
||||
|
||||
public void Initalize(string skillId, int index)
|
||||
{
|
||||
slotIndex = index;
|
||||
// 스킬 이미지 세팅하기
|
||||
Assert.IsTrue(AssetManager.Singleton.LoadSkillIcon(skillId, out Sprite loadedSkillImage));
|
||||
skillImage.SetActive(true);
|
||||
skillImage.GetComponent<Image>().sprite = loadedSkillImage;
|
||||
if (skillId != null) // 스킬 슬롯에 스킬이 지정된 경우
|
||||
{
|
||||
Assert.IsTrue(AssetManager.Singleton.LoadSkillIcon(skillId, out Sprite loadedSkillImage));
|
||||
skillImage.SetActive(true);
|
||||
skillImage.GetComponent<Image>().sprite = loadedSkillImage;
|
||||
}
|
||||
|
||||
lockerImage.SetActive(false);
|
||||
}
|
||||
|
||||
public void SelectedSlot()
|
||||
public int SelectedSlot()
|
||||
{
|
||||
selectedState.SetActive(true);
|
||||
return slotIndex;
|
||||
}
|
||||
|
||||
public void UnselectedSlot()
|
||||
|
||||
Reference in New Issue
Block a user