마름모 배치 공간 추가
This commit is contained in:
parent
00e2489036
commit
7ad0f770af
8
Assets/03.Images/Ui/Tycoon/Tile.meta
Normal file
8
Assets/03.Images/Ui/Tycoon/Tile.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7925bf4ddbff8564e90c78e31d29629b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/03.Images/Ui/Tycoon/Tile/White Box Rounded.png
Normal file
BIN
Assets/03.Images/Ui/Tycoon/Tile/White Box Rounded.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
130
Assets/03.Images/Ui/Tycoon/Tile/White Box Rounded.png.meta
Normal file
130
Assets/03.Images/Ui/Tycoon/Tile/White Box Rounded.png.meta
Normal file
@ -0,0 +1,130 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f7e2890dfe9e6748b793ed18a7db18e
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
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
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 2
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 256
|
||||
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
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 256
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 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
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 239234
|
||||
packageName: Easy Grid Builder Pro
|
||||
packageVersion: 1.1.1
|
||||
assetPath: Assets/EasyGridBuilder Pro/Prefabs/Canvas Grid Samples/White Box Rounded.png
|
||||
uploadId: 666238
|
68
Assets/Scirpts/CellManager.cs
Normal file
68
Assets/Scirpts/CellManager.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CellManager : MonoBehaviour
|
||||
{
|
||||
public RectTransform cellCanvas;
|
||||
public RectTransform cell;
|
||||
|
||||
// 0 == 비어있음, 1 == 차있음, 2 == 잠김
|
||||
private const int mapSize = 30;
|
||||
private int[] tiles;
|
||||
private RectTransform[] tileUIs;
|
||||
|
||||
void Start()
|
||||
{
|
||||
tiles = new int [mapSize * mapSize];
|
||||
|
||||
// TODO: 데이터 입력
|
||||
for (int i = 0; i < mapSize * mapSize; i++)
|
||||
{
|
||||
tiles[i] = 0;
|
||||
}
|
||||
|
||||
cell.SetParent(null);
|
||||
cell.gameObject.SetActive(false);
|
||||
|
||||
tileUIs = new RectTransform[mapSize * mapSize];
|
||||
for (int i = 0; i < mapSize * mapSize; i++)
|
||||
{
|
||||
var newCell = Instantiate(cell, cellCanvas);
|
||||
newCell.gameObject.SetActive(true);
|
||||
tileUIs[i] = newCell.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
UpdateCells();
|
||||
}
|
||||
|
||||
Vector3 CellToWorld(Vector2Int cellPos)
|
||||
{
|
||||
var worldX = (cellPos.x - cellPos.y) * 0.5f * 1.414f;
|
||||
var worldZ = -(cellPos.x + cellPos.y) * 0.5f * 1.414f;
|
||||
return new Vector3(worldX, 0f, worldZ);
|
||||
}
|
||||
|
||||
Vector2Int WorldToCell(Vector3 worldPos)
|
||||
{
|
||||
var cellX = Mathf.RoundToInt((worldPos.x - worldPos.z)/ 1.414f);
|
||||
var cellY = Mathf.RoundToInt((-worldPos.z - worldPos.x) / 1.414f);
|
||||
return new Vector2Int(cellX, cellY);
|
||||
}
|
||||
|
||||
int GetCellID(Vector2Int cellPos)
|
||||
{
|
||||
return cellPos.x + cellPos.y * mapSize;
|
||||
}
|
||||
|
||||
Vector3 GetCellWorldPos(int cellPos)
|
||||
{
|
||||
return CellToWorld(new Vector2Int(cellPos / mapSize, cellPos % mapSize));
|
||||
}
|
||||
|
||||
public void UpdateCells()
|
||||
{
|
||||
for (int i = 0; i < mapSize * mapSize; i++)
|
||||
{
|
||||
tileUIs[i].anchoredPosition3D = GetCellWorldPos(i);
|
||||
}
|
||||
}
|
||||
}
|
2
Assets/Scirpts/CellManager.cs.meta
Normal file
2
Assets/Scirpts/CellManager.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cf09e2bb72956a419b94848ab48c404
|
Loading…
Reference in New Issue
Block a user