70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
|
||
|
|
public enum RoomType
|
||
|
|
{
|
||
|
|
EmptyRoom = 0,
|
||
|
|
PlaceholderRoom = 1,
|
||
|
|
BugStatueRoom = 2,
|
||
|
|
BlankRoom = 3,
|
||
|
|
}
|
||
|
|
|
||
|
|
[System.Serializable]
|
||
|
|
public class DungeonDataclass
|
||
|
|
{
|
||
|
|
public int positionX;
|
||
|
|
public int positionY;
|
||
|
|
public RoomType roomType;
|
||
|
|
public int id;
|
||
|
|
public int roomSize;
|
||
|
|
}
|
||
|
|
|
||
|
|
[CreateAssetMenu(fileName = "DungeonHomeSO", menuName = "GameData/DungeonHomeSO")]
|
||
|
|
public class DungeonHomeSO : ScriptableObject
|
||
|
|
{
|
||
|
|
public List<DungeonDataclass> dungeonDataclassList;
|
||
|
|
|
||
|
|
|
||
|
|
public List<DungeonDataclass> return_all_data()
|
||
|
|
{
|
||
|
|
return dungeonDataclassList;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void add_data(int position_x, int position_y, RoomType room_type, int id)
|
||
|
|
{
|
||
|
|
dungeonDataclassList.Add(new DungeonDataclass
|
||
|
|
{
|
||
|
|
positionX = position_x,
|
||
|
|
positionY = position_y,
|
||
|
|
roomType = room_type,
|
||
|
|
id = id
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public DungeonDataclass get_data_by_id(int id)
|
||
|
|
{
|
||
|
|
foreach (DungeonDataclass item in dungeonDataclassList)
|
||
|
|
{
|
||
|
|
if (item.id == id)
|
||
|
|
{
|
||
|
|
return item;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return null; // 找不到则返回null
|
||
|
|
}
|
||
|
|
|
||
|
|
public void remove_data_by_id(int id)
|
||
|
|
{
|
||
|
|
foreach (DungeonDataclass item in dungeonDataclassList)
|
||
|
|
{
|
||
|
|
if (item.id == id)
|
||
|
|
{
|
||
|
|
dungeonDataclassList.Remove(item);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|