네임스페이스 수정

This commit is contained in:
NTG_Lenovo 2025-07-02 17:09:53 +09:00
parent 86af2ec92a
commit 355f05a4dd
8 changed files with 158 additions and 154 deletions

View File

@ -1,4 +1,3 @@
using System.Linq;
#if UNITY_EDITOR
using UnityEditor.AddressableAssets;

View File

@ -1,7 +1,7 @@
using UnityEditor;
using UnityEngine;
namespace DDD.Editor
namespace DDD
{
public class AssetPostProcessor : AssetPostprocessor
{

View File

@ -1,13 +1,12 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Superlazy;
using UnityEditor;
using UnityEditor.U2D;
using UnityEngine;
using UnityEngine.U2D;
namespace DDD.Editor
namespace DDD
{
public static class AssetPostprocessorSprite
{

View File

@ -1,18 +1,20 @@
using UnityEngine;
public class BillBoardVisual : MonoBehaviour
namespace DDD
{
private Camera cam;
void Start()
public class BillBoardVisual : MonoBehaviour
{
cam = Camera.main;
}
private Camera cam;
// Update is called once per frame
void LateUpdate()
{
transform.localRotation = cam.transform.localRotation;
void Start()
{
cam = Camera.main;
}
// Update is called once per frame
void LateUpdate()
{
transform.localRotation = cam.transform.localRotation;
}
}
}
}

View File

@ -1,21 +1,23 @@
using DDD;
using TMPro;
using UnityEngine;
public class ItemUI : MonoBehaviour
namespace DDD
{
public TextMeshProUGUI nameText;
private Item _item;
public void SetUpItem(Item item)
public class ItemUI : MonoBehaviour
{
_item = item;
UpdateItem();
}
public TextMeshProUGUI nameText;
private void UpdateItem()
{
nameText.text = _item.Name;
private Item _item;
public void SetUpItem(Item item)
{
_item = item;
UpdateItem();
}
private void UpdateItem()
{
nameText.text = _item.Name;
}
}
}

View File

@ -1,104 +1,106 @@
using System.Diagnostics;
using UnityEngine;
public class CellManager : MonoBehaviour
namespace DDD
{
public RectTransform cellCanvas;
public CellUI cell;
public int minX = -20;
public int maxX = 20;
public int minZ = -20;
public int maxZ = 20;
// 0 == 비어있음, 1 == 차있음, 2 == 잠김
public const int offsetZ = 40;
private const int mapSize = 80;
private int[] tiles;
private CellUI[] tileUIs;
void Start()
public class CellManager : MonoBehaviour
{
tiles = new int [mapSize * mapSize];
public RectTransform cellCanvas;
public CellUI cell;
// TODO: 데이터 입력
for (int i = 0; i < mapSize * mapSize; i++)
public int minX = -20;
public int maxX = 20;
public int minZ = -20;
public int maxZ = 20;
// 0 == 비어있음, 1 == 차있음, 2 == 잠김
public const int offsetZ = 40;
private const int mapSize = 80;
private int[] tiles;
private CellUI[] tileUIs;
void Start()
{
tiles[i] = 0;
}
tiles = new int [mapSize * mapSize];
cell.transform.SetParent(null);
cell.gameObject.SetActive(false);
tileUIs = new CellUI[mapSize * mapSize];
for (int i = 0; i < mapSize * mapSize; i++)
{
var newCell = Instantiate(cell, cellCanvas);
newCell.gameObject.SetActive(true);
tileUIs[i] = newCell.GetComponent<CellUI>();
}
UpdateCells();
}
public static Vector3 CellToWorld(Vector2Int cellPos)
{
var worldX = (cellPos.x - cellPos.y) * 0.5f * 1.414f; // sqrt(2)
var worldZ = -(cellPos.x + cellPos.y) * 0.5f * 1.414f + offsetZ;
return new Vector3(worldX, 0f, worldZ);
}
public static Vector2Int WorldToCell(Vector3 worldPos)
{
var cellX = Mathf.RoundToInt((worldPos.x - (worldPos.z - offsetZ)) / 1.414f);
var cellY = Mathf.RoundToInt((-(worldPos.z - offsetZ) - worldPos.x) / 1.414f);
return new Vector2Int(cellX, cellY);
}
public static int GetCellID(Vector2Int cellPos)
{
return cellPos.x + cellPos.y * mapSize;
}
public static Vector3 GetCellWorldPos(int cellPos)
{
int x = cellPos % mapSize; // x는 열 (가로)
int y = cellPos / mapSize; // y는 행 (세로)
return CellToWorld(new Vector2Int(x, y));
}
private void Update()
{
//UpdateCells();
}
public void UpdateCells()
{
for (int i = 0; i < mapSize * mapSize; i++)
{
var worldPos = GetCellWorldPos(i);
// 바운더리체크 함수로 빼기
if (minX > worldPos.x || worldPos.x > maxX)
// TODO: 데이터 입력
for (int i = 0; i < mapSize * mapSize; i++)
{
tileUIs[i].gameObject.SetActive(false);
continue;
tiles[i] = 0;
}
if (minZ > worldPos.z || worldPos.z > maxZ)
cell.transform.SetParent(null);
cell.gameObject.SetActive(false);
tileUIs = new CellUI[mapSize * mapSize];
for (int i = 0; i < mapSize * mapSize; i++)
{
tileUIs[i].gameObject.SetActive(false);
continue;
var newCell = Instantiate(cell, cellCanvas);
newCell.gameObject.SetActive(true);
tileUIs[i] = newCell.GetComponent<CellUI>();
}
tileUIs[i].SetTile(tiles[i]);
tileUIs[i].gameObject.SetActive(true);
tileUIs[i].transform.position = GetCellWorldPos(i);
UpdateCells();
}
}
public void SetupCell(Vector3 position)
{
tiles[GetCellID(WorldToCell(position))] = 1;
public static Vector3 CellToWorld(Vector2Int cellPos)
{
var worldX = (cellPos.x - cellPos.y) * 0.5f * 1.414f; // sqrt(2)
var worldZ = -(cellPos.x + cellPos.y) * 0.5f * 1.414f + offsetZ;
return new Vector3(worldX, 0f, worldZ);
}
public static Vector2Int WorldToCell(Vector3 worldPos)
{
var cellX = Mathf.RoundToInt((worldPos.x - (worldPos.z - offsetZ)) / 1.414f);
var cellY = Mathf.RoundToInt((-(worldPos.z - offsetZ) - worldPos.x) / 1.414f);
return new Vector2Int(cellX, cellY);
}
public static int GetCellID(Vector2Int cellPos)
{
return cellPos.x + cellPos.y * mapSize;
}
public static Vector3 GetCellWorldPos(int cellPos)
{
int x = cellPos % mapSize; // x는 열 (가로)
int y = cellPos / mapSize; // y는 행 (세로)
return CellToWorld(new Vector2Int(x, y));
}
private void Update()
{
//UpdateCells();
}
public void UpdateCells()
{
for (int i = 0; i < mapSize * mapSize; i++)
{
var worldPos = GetCellWorldPos(i);
// 바운더리체크 함수로 빼기
if (minX > worldPos.x || worldPos.x > maxX)
{
tileUIs[i].gameObject.SetActive(false);
continue;
}
if (minZ > worldPos.z || worldPos.z > maxZ)
{
tileUIs[i].gameObject.SetActive(false);
continue;
}
tileUIs[i].SetTile(tiles[i]);
tileUIs[i].gameObject.SetActive(true);
tileUIs[i].transform.position = GetCellWorldPos(i);
}
}
public void SetupCell(Vector3 position)
{
tiles[GetCellID(WorldToCell(position))] = 1;
}
}
}

View File

@ -1,46 +1,48 @@
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
public class CellUI : MonoBehaviour
namespace DDD
{
public Color emptyColor = Color.white;
public Color selectedColor = Color.white;
public Color batchedColor = Color.white;
public Color lockedColor = Color.white;
private Image image;
private void OnEnable()
public class CellUI : MonoBehaviour
{
image = GetComponent<Image>();
}
public Color emptyColor = Color.white;
public Color selectedColor = Color.white;
public Color batchedColor = Color.white;
public Color lockedColor = Color.white;
public void SetTile(int tile)
{
// 0 == 비어있음, 1 == 차있음, 2 == 잠김
switch (tile)
private Image image;
private void OnEnable()
{
case 0:
image.color = emptyColor;
break;
case 1:
image.color = batchedColor;
break;
case 2:
image.color = lockedColor;
break;
image = GetComponent<Image>();
}
public void SetTile(int tile)
{
// 0 == 비어있음, 1 == 차있음, 2 == 잠김
switch (tile)
{
case 0:
image.color = emptyColor;
break;
case 1:
image.color = batchedColor;
break;
case 2:
image.color = lockedColor;
break;
}
}
private void OnDrawGizmos()
{
// 기즈모 위치 예시
Vector3 pos = transform.position;
// 텍스트 표시
Handles.color = Color.black;
Handles.Label(pos, CellManager.WorldToCell(transform.position).ToString());
}
}
private void OnDrawGizmos()
{
// 기즈모 위치 예시
Vector3 pos = transform.position;
// 텍스트 표시
Handles.color = Color.black;
Handles.Label(pos, CellManager.WorldToCell(transform.position).ToString());
}
}
}

View File

@ -1,9 +1,7 @@
using System;
using System.Collections;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
namespace DDD
{