feat: 스킬 편집 UI 내의 스킬 슬롯, 스킬 정보 클릭 액션 적용

This commit is contained in:
aube.lee
2025-02-11 16:34:06 +09:00
parent f03359ec4a
commit 4f7d0616ce
24 changed files with 2053 additions and 1495 deletions

View File

@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: d38d0eab2a70b9245868a06c5d63f4ba
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,27 +1,28 @@
[
{
"items": [
{
"id": "K0001",
"name": "FireBall",
"mpConsumption": 10,
"damage": 1.2,
"damage": 1.2000000476837159,
"coolDown": 5,
"slotNumber": 1,
"slotNumber": 0,
"requiredLevel": 1
},
{
"id": "K0002",
"name": "IceBall",
"mpConsumption": 12,
"damage": 1.3,
"damage": 1.2999999523162842,
"coolDown": 6,
"slotNumber": 2,
"slotNumber": 1,
"requiredLevel": 3
},
{
"id": "K0003",
"name": "Leaf Shuriken",
"mpConsumption": 7,
"damage": 1.15,
"damage": 1.149999976158142,
"coolDown": 3,
"slotNumber": 0,
"requiredLevel": 5
@@ -30,7 +31,7 @@
"id": "K0004",
"name": "Earth Smash",
"mpConsumption": 20,
"damage": 1.8,
"damage": 1.7999999523162842,
"coolDown": 15,
"slotNumber": 0,
"requiredLevel": 7
@@ -39,7 +40,7 @@
"id": "K0005",
"name": "Bubble POP",
"mpConsumption": 5,
"damage": 1.15,
"damage": 1.149999976158142,
"coolDown": 2,
"slotNumber": 0,
"requiredLevel": 9
@@ -48,7 +49,7 @@
"id": "K0006",
"name": "Leaf Cutter",
"mpConsumption": 14,
"damage": 1.4,
"damage": 1.399999976158142,
"coolDown": 5,
"slotNumber": 0,
"requiredLevel": 11
@@ -57,7 +58,7 @@
"id": "K0007",
"name": "DarknessBall",
"mpConsumption": 30,
"damage": 2.4,
"damage": 2.4000000953674318,
"coolDown": 12,
"slotNumber": 0,
"requiredLevel": 13
@@ -66,9 +67,10 @@
"id": "K0008",
"name": "Elemental burst",
"mpConsumption": 60,
"damage": 8,
"damage": 8.0,
"coolDown": 40,
"slotNumber": 0,
"requiredLevel": 15
}
]
]
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3994df9e50c49d64782998dd7a9706a3
guid: a5c573092f412bf47b101f0d7f7c809f
TextScriptImporter:
externalObjects: {}
userData:

View File

@@ -92,13 +92,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -263,13 +263,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -317,6 +317,7 @@ GameObject:
- component: {fileID: 7711391530007573910}
- component: {fileID: 894771521184045827}
- component: {fileID: 3064740509906673288}
- component: {fileID: 1927401673230932622}
m_Layer: 5
m_Name: Skill Information Item
m_TagString: Untagged
@@ -397,16 +398,72 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ed9616c40d2f25049a1cd91f744b3eff, type: 3}
m_Name:
m_EditorClassIdentifier:
imageSprites:
keys: []
values: []
skillImage: {fileID: 8663022219627117037}
skillName: {fileID: 8742526129269004090}
skillDamage: {fileID: 6604346907373336785}
skillCooltime: {fileID: 5644015466645616352}
skillReqMp: {fileID: 2735593499604854753}
skillReqLvTitle: {fileID: 5702090017575127642}
skillReqLv: {fileID: 8218594638945546518}
locker: {fileID: 8836474559121583485}
selectedState: {fileID: 6064772624787250806}
skillId:
--- !u!114 &1927401673230932622
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 979625317529729593}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 1, g: 1, b: 1, a: 1}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 894771521184045827}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4246042669031692282, guid: 69c387b76a1d6fe48a70aa3e0eb1c0ac, type: 3}
m_TargetAssemblyTypeName: TON.SkillSettingUI, Assembly-CSharp
m_MethodName: OnClickSkillInfo
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &1100155134931810629
GameObject:
m_ObjectHideFlags: 0
@@ -546,7 +603,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 2aa08635294c7f4439316a676e949dc8, type: 3}
m_Sprite: {fileID: 21300000, guid: d38d0eab2a70b9245868a06c5d63f4ba, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
@@ -648,13 +705,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -936,7 +993,7 @@ MonoBehaviour:
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -1064,13 +1121,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -1198,13 +1255,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -1332,13 +1389,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -1541,13 +1598,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
@@ -1748,13 +1805,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontSize: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535

View File

@@ -162,6 +162,7 @@ GameObject:
- component: {fileID: 7221054774098027555}
- component: {fileID: 8618505599359909844}
- component: {fileID: 8968069870202076509}
- component: {fileID: 5331091819972320112}
m_Layer: 5
m_Name: Skill Slot
m_TagString: Untagged
@@ -244,6 +245,62 @@ MonoBehaviour:
skillImage: {fileID: 6834027631568802153}
lockerImage: {fileID: 5863612593878900192}
selectedState: {fileID: 2050701555096933595}
--- !u!114 &5331091819972320112
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6583065413429247215}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.9607844, g: 0.9607844, b: 0.9607844, a: 1}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 8618505599359909844}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4246042669031692282, guid: 69c387b76a1d6fe48a70aa3e0eb1c0ac, type: 3}
m_TargetAssemblyTypeName: TON.SkillSettingUI, Assembly-CSharp
m_MethodName: OnClickSkillSlot
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &6834027631568802153
GameObject:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 69c387b76a1d6fe48a70aa3e0eb1c0ac
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}

View File

@@ -99,12 +99,11 @@ namespace TON
// 일반 객체는 그대로 JSON 변환
json = JsonUtility.ToJson(data, true);
}
Debug.Log("SaveToFile ::: " + json);
File.WriteAllText(path, json);
Debug.Log($"파일 저장 성공 ::: {fileName}.json");
}
}
}

View File

@@ -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");
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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();
}
}
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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;
// 스킬 이미지 세팅하기
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()