Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,217 changes: 2,217 additions & 0 deletions Fantasy-Grower/Assets/Scenes/SynthesisTest.unity

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Fantasy-Grower/Assets/Scenes/SynthesisTest.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Fantasy-Grower/Assets/ScriptableObject/WeaponSO/testWeaponA.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf84d2193e2760c4c9f107ed9dfb64cb, type: 3}
m_Name: testWeaponA
m_EditorClassIdentifier:
WeaponIcon: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
weaponName: A
weaponInfo: AA
weaponCount: 100
Damage: 0
isUnlock: 1
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf84d2193e2760c4c9f107ed9dfb64cb, type: 3}
m_Name: SO_Equipment
m_Name: testWeaponB
m_EditorClassIdentifier:
weaponName:
weaponInfo:
WeaponIcon: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
weaponName: B
weaponInfo: BB
weaponCount: 0
Damage: 0
currentLevel: 0
isUnlock: 1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Fantasy-Grower/Assets/ScriptableObject/WeaponSO/testWeaponC.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf84d2193e2760c4c9f107ed9dfb64cb, type: 3}
m_Name: testWeaponC
m_EditorClassIdentifier:
WeaponIcon: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0}
weaponName: C
weaponInfo: CC
weaponCount: 0
Damage: 0
isUnlock: 1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions Fantasy-Grower/Assets/Scripts/Equipment/EquipmentManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using UnityEngine;
using UnityEngine.UI;

[System.Serializable]
public struct WeaponTable
{
public SO_Weapon[] weapons;
}

public class EquipmentManager : MonoBehaviour
{
private static EquipmentManager _instance;
public static EquipmentManager Instance
{
get
{
_instance = FindAnyObjectByType<EquipmentManager>();
if (Instance == null)
{
Debug.LogError("씬에 스크립트를 참조한 오브젝트가 없습니다");
}
return _instance;
}
}
public static Color[] weaponLevelColor =
{
Color.green,
Color.cyan,
Color.magenta,
Color.yellow,
};

[Header("합성&강화 공통 변수")]
public GameObject ItemInfoPanel;

private int weaponTypeValue;
private int weaponLevelValue;

[Header("합성")]
public Image[] WeaponBackgroundImage;
public Image[] WeaponSlotImage;
public Text[] WeaponCountText;
public Text SynthesisCountText;

private Color[] SynthesisColor = { Color.red, Color.cyan };
private int synthesisCount = 1;

[Header("강화")]
[Header("인벤토리")]
public WeaponTable[] WeaponArray; // 2중 배열로 무기 종류와 등급에 따른 무기 분류
public Slot[] Invens;

private void Awake()
{
if (_instance == null)
{
_instance = this;
DontDestroyOnLoad(gameObject);
}
else
Destroy(gameObject);
}

public void OpenItemInfoPage(Slot inven)
{
weaponTypeValue = (int)inven._WeaponType;
weaponLevelValue = (int)inven._WeaponLevel;
ItemInfoPanel.SetActive(true);
RefreshSynthesis();
}

public void RefreshSlot()
{
for (int i = 0; i < Invens.Length; i++)
{
Invens[i].RefreshIcon();
}
}

private void RefreshSynthesis()
{
if (WeaponArray[weaponTypeValue].weapons.Length < weaponLevelValue + 1)
return;
for (int i = 0; i < 2; i++)
{
WeaponBackgroundImage[i].color = weaponLevelColor[weaponLevelValue + i];
WeaponSlotImage[i].sprite = WeaponArray[weaponTypeValue]
.weapons[weaponLevelValue + i]
.WeaponIcon;
string hexColor = "#" + ColorUtility.ToHtmlStringRGB(SynthesisColor[i]);
int weaponValue = synthesisCount * (i == 0 ? 5 : 1);
WeaponCountText[i].text =
$"{WeaponArray[weaponTypeValue].weapons[weaponLevelValue + i].weaponCount}(<color={hexColor}>{(weaponValue >= 0 ? "+" : "-")}{weaponValue}</color>)";
SynthesisCountText.text = synthesisCount.ToString("0");
}
}

public SO_Weapon GetWeapon(WeaponType type, WeaponLevel level) =>
WeaponArray[(int)type].weapons[(int)level];

public void UpCount()
{
if (
(synthesisCount + 1) * 5
<= WeaponArray[weaponTypeValue].weapons[weaponLevelValue].weaponCount
)
{
synthesisCount++;
RefreshSynthesis();
}
}

public void DownCount()
{
if (synthesisCount - 1 > 0)
{
synthesisCount--;
RefreshSynthesis();
}
}

public void Synthesis()
{
if (WeaponArray[weaponTypeValue].weapons.Length < weaponLevelValue + 1)
return;
if (
synthesisCount * 5
<= WeaponArray[weaponTypeValue].weapons[weaponLevelValue].weaponCount
)
{
WeaponArray[weaponTypeValue].weapons[weaponLevelValue].weaponCount -=
(uint)synthesisCount * 5;
GetItem(weaponTypeValue, weaponLevelValue + 1, (uint)synthesisCount);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

무기가 이미 최고 등급인 상태에서 Synthesis가 호출되면 weaponLevelValue + 1 인덱스 접근 시 에러가 발생합니다. 합성이 가능한 최대 등급인지 확인하는 방어 코드가 필요합니다.

synthesisCount = 1;
RefreshSynthesis();
}
}

public void GetItem(int weaponType, int weaponLevel, uint amount)
{
WeaponArray[weaponType].weapons[weaponLevel].weaponCount += amount;
RefreshSlot();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Fantasy-Grower/Assets/Scripts/Equipment/SO_Weapon.cs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WeaponLevel enum에서 C가 D보다 높게 쓰여있는 이유가 있을까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 지적입니다 수정하도록 하겠습니다

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public enum WeaponType
public class SO_Weapon : ScriptableObject
{
Copy link
Copy Markdown
Contributor

@suti1110 suti1110 Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SO_Weapon클래스에서 WeaponId라는 속성을 추가로 넣는 것을 권장 드립니다

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WeaponID 부분과 같은 것들은 장비 탭을 만들 때 넣을 예정입니다

//필요한 기능에 따라 변수 및 함수가 추가될 수 있음
[Header("필요 변수"), SerializeField]
public Sprite WeaponImage { get; private set; }
[Header("필요 변수")]
[SerializeField]
private Sprite _weaponIcon;
public Sprite WeaponIcon => WeaponIcon;

[Header("무기 정보")]
public string weaponName;
public string weaponInfo;
public uint weaponCount;
public int Damage;
public WeaponType Type;
public WeaponLevel currentLevel;
public bool isUnlock;
}
8 changes: 8 additions & 0 deletions Fantasy-Grower/Assets/Scripts/Equipment/UI.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions Fantasy-Grower/Assets/Scripts/Equipment/UI/Slot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.UI;

public enum SlotType
{
Inventory,
Synthesis,
Enchent,
}

public class Slot : MonoBehaviour
{
[Header("아이템 속성")]
public WeaponType _WeaponType;
public WeaponLevel _WeaponLevel;

[Header("UI속성")]
public SlotType _SlotType;
public GameObject WeaponIconWall;
public Image WeaponIcon;
public Text WeaponCountText;

protected void Start()
{
RefreshIcon();
if (TryGetComponent<Button>(out Button button))
{
button.onClick.AddListener(OnButtonClick);
}
}

protected void OnButtonClick()
{
EquipmentManager.Instance.OpenItemInfoPage(this);
}

public void GetItem() =>
EquipmentManager.Instance.GetWeapon(_WeaponType, _WeaponLevel).weaponCount++;

public void RefreshIcon()
{
GetComponent<Image>().color = EquipmentManager.weaponLevelColor[(int)_WeaponLevel];
WeaponIcon.sprite = EquipmentManager
.Instance.GetWeapon(_WeaponType, _WeaponLevel)
.WeaponIcon;
if (EquipmentManager.Instance.GetWeapon(_WeaponType, _WeaponLevel).isUnlock)
{
WeaponIconWall.SetActive(false);
WeaponIcon.color = Color.white;
// 무기 개수 text 필요
}
else
{
WeaponIconWall.SetActive(true);
}
}
}
2 changes: 2 additions & 0 deletions Fantasy-Grower/Assets/Scripts/Equipment/UI/Slot.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading