2025-10-08 16:31:53 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class MapVisualizer : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
{
|
2025-10-09 22:33:05 +08:00
|
|
|
[HideInInspector] public HomeMapSO SOHomeMap;
|
|
|
|
|
[HideInInspector] public GameObject startPositionObject;
|
|
|
|
|
[HideInInspector] public GameObject defaultRoomPrefab;
|
|
|
|
|
[HideInInspector] public float cellSize;
|
2025-10-08 20:06:51 +08:00
|
|
|
|
2025-10-08 16:31:53 +08:00
|
|
|
private void Start()
|
|
|
|
|
{
|
2025-10-09 22:33:05 +08:00
|
|
|
this.self_initialize_room_data();
|
2025-10-08 16:31:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-10-09 22:33:05 +08:00
|
|
|
// 初始化房间数据, 创建默认的雕像房间
|
|
|
|
|
private void self_initialize_room_data()
|
2025-10-08 16:31:53 +08:00
|
|
|
{
|
2025-10-09 22:33:05 +08:00
|
|
|
self_create_room(position: new Vector2Int(0, 0),
|
|
|
|
|
room_type: HomeMapSO.RoomType.StatueRoom);
|
2025-10-08 16:31:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建一个房间
|
2025-10-09 22:33:05 +08:00
|
|
|
private void self_create_room(Vector2Int position, HomeMapSO.RoomType room_type)
|
2025-10-08 16:31:53 +08:00
|
|
|
{
|
2025-10-09 22:33:05 +08:00
|
|
|
SOHomeMap.m_create_room(position, room_type);
|
|
|
|
|
GameObject _room = Instantiate<GameObject>(
|
2025-10-08 16:31:53 +08:00
|
|
|
defaultRoomPrefab,
|
2025-10-08 20:06:51 +08:00
|
|
|
position: startPositionObject.transform.position +
|
|
|
|
|
new Vector3(position.x * cellSize, position.y * cellSize, 0),
|
2025-10-08 16:31:53 +08:00
|
|
|
rotation: Quaternion.identity);
|
2025-10-09 22:33:05 +08:00
|
|
|
_room.transform.SetParent(startPositionObject.transform);
|
|
|
|
|
_room.layer = LayerMask.NameToLayer("AlreadyBuild");
|
2025-10-08 16:31:53 +08:00
|
|
|
}
|
|
|
|
|
}
|