맵 대충 해결됐다 싶으니 맵꾸를 다시 해보는즁
건물 두 개를 통째로 하나의 object로 두어 레일 양 옆에 설치되게끔 설정하였다.
똑같은 건물 여러개는 재미없을 수 있으니 색변화도 살짝 주었다.
(예쁘진 않은건 안비밀)
타입도 수정.
코드
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StructureManager : MonoBehaviour
{
private Queue<List<Structure>> qStructures = new Queue<List<Structure>>();
private bool install;
private bool uninstall;
public void InstallStructure(Rail rail)
{
if (!(this.install ^= true)) return;
List<Structure> list = new List<Structure>();
int type = Random.Range((int)Structure.eType.ARCHITECTURE1, (int)Structure.eType.ARCHITECTURE3 + 1);
GameObject go = StructurePoolManager.Instance.EnableStructure(type);
go.transform.position = rail.transform.position;
list.Add(go.GetComponent<Structure>());
int rand = Random.Range(0, 2);
GameObject pole;
if (rand == 0)
{
pole = StructurePoolManager.Instance.EnableStructure((int)Structure.eType.LAMP);
}
else
{
pole = StructurePoolManager.Instance.EnableStructure(((int)Structure.eType.CLOCK));
}
float[] dirx = new float[] { -1, 1 };
pole.transform.position = rail.transform.position + Vector3.left * dirx[Random.Range(0, dirx.Length)] * Random.Range(5f, 7f)+Vector3.back*Random.Range(1f, 15f);
list.Add(pole.GetComponent<Structure>());
qStructures.Enqueue(list);
}
public void UninstallStructure()
{
if (!(this.uninstall^=true) ||qStructures.Count == 0) return;
List<Structure> list = qStructures.Dequeue();
for(int i=0; i < list.Count; i++)
{
StructurePoolManager.Instance.DisableStructure(list[i].gameObject);
}
}
}
architecture 오브젝트의 사이즈가 floor 오브젝트의 사이즈보다 크므로 floor 2번 제거 당 1번 제거로 구현.
(if(!this.install^=true) return, if(!this.uninstall^=true) return 이 부분이 그 부분)
^= : XOR 연산.
install과 uninstall을 true와 XOR 연산을 했을 때 true면 밑의 연산들을 수행.
false ^=true 결과값 : true
true ^=false 결과값 : false
Random.Range로 structure들의 타입 및 위치를 랜덤하게 설정.
생성한 structure들은 list로 묶여 queue로 관리.
결과
'K-digital traning > Final Project' 카테고리의 다른 글
Gazzlers 개발일지 - Enemy 공격 (1) | 2023.12.27 |
---|---|
Gazzlers 개발일지 - Enemy 관리 (0) | 2023.12.21 |
Gazzlers 개발일지 - Map 수정(with CurvedWorld) (0) | 2023.12.19 |
Gazzlers 중간점검 (0) | 2023.12.14 |
Gazzlers 개발일지 - Enemy 장애물 회피 (1) | 2023.12.10 |