using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
public class TestMain : MonoBehaviour
{
[SerializeField]
private GameObject wallPrefab;
[SerializeField]
private GameObject blockPrefab;
[SerializeField]
private Transform boardTr;
private TestBlock testBlock;
private int[,] str =
{
{0, 0, 4, 2, 4, 0, 0},
{0, 0, 5, 1, 2, 0, 0},
{0, 0, 5, 4, 3, 0, 0},
{0, 0, 1, 2, 3, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
};
// Start is called before the first frame update
void Start()
{
this.testBlock = new TestBlock();
for(int row = 0; row < 7; row++)
{
for(int col = 0; col < 7; col++)
{
switch (str[row, col])
{
case 0:
testBlock.Move(row, col);
testBlock.InstantiateObj(this.wallPrefab, this.boardTr, TestBlock.eBlockType.WALL);
break;
case 1:
testBlock.Move(row, col);
testBlock.InstantiateObj(this.blockPrefab, this.boardTr, TestBlock.eBlockType.RED);
break;
case 2:
testBlock.Move(row, col);
testBlock.InstantiateObj(this.blockPrefab, this.boardTr, TestBlock.eBlockType.BLUE);
break;
case 3:
testBlock.Move(row, col);
testBlock.InstantiateObj(this.blockPrefab, this.boardTr, TestBlock.eBlockType.GREEN);
break;
case 4:
testBlock.Move(row, col);
testBlock.InstantiateObj(this.blockPrefab, this.boardTr, TestBlock.eBlockType.YELLOW);
break;
case 5:
testBlock.Move(row, col);
testBlock.InstantiateObj(this.wallPrefab, this.boardTr, TestBlock.eBlockType.PURPLE);
break;
}
}
}
}
private void Update()
{
Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Ray2D ray = new Ray2D(pos, Vector2.zero);
RaycastHit2D hit;
if(Physics2D.Raycast(ray.origin, ray.direction))
{
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestBlock : MonoBehaviour
{
private int nRow;
private int nCol;
public enum eBlockType
{
WALL = 0,
RED = 1,
BLUE = 2,
GREEN = 3,
YELLOW = 4,
PURPLE = 5,
}
public void InstantiateObj(GameObject objPrefab, Transform boardTr, eBlockType type)
{
GameObject obj = Instantiate(objPrefab, boardTr);
obj.transform.position = boardTr.position + new Vector3(nCol, nRow);
SpriteRenderer objSp = obj.GetComponent<SpriteRenderer>();
objSp.sprite = Resources.Load<Sprite>($"Test/{type}");
}
public void Move(int row, int col)
{
this.nRow = row;
this.nCol = col;
}
}
'워리어 콤보 모작 개발일지' 카테고리의 다른 글
워리어콤보 개발일지 - Block 인식하기 (0) | 2023.09.16 |
---|---|
워리어콤보 개발일지 - 좌표찍기 (0) | 2023.09.16 |
워리어콤보 개발일지 - 2차원 배열 출력 (0) | 2023.09.14 |
워리어콤보 모작 개발일지 - 04 [StageInfo, StageReader][연습] (0) | 2023.09.14 |
워리어콤보 모작 개발일지 - 03 [Block][연습] (0) | 2023.09.14 |