114 lines
3.3 KiB
C#
114 lines
3.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Tilemaps;
|
|
|
|
// [Obsolete("a TerrainGridSystem Map is used instead of this class")]
|
|
// public class UMap
|
|
// {
|
|
// private Grid _grid;
|
|
// private Tilemap _tilemap;
|
|
// private GameObject _gameObject;
|
|
// private MapData _mapData;
|
|
// private MeshRenderer _groundMeshRenderer;
|
|
//
|
|
//
|
|
// private UMap()
|
|
// {
|
|
// }
|
|
//
|
|
// public Tilemap Tilemap => _tilemap;
|
|
// public Grid Grid => _grid;
|
|
// public GameObject GameObject => _gameObject;
|
|
// public MapData MapData => _mapData;
|
|
//
|
|
// public static UMap Create(GameObject go, MapData data)
|
|
// {
|
|
// const string ERROR_PRE = "Create Map Instance Error: ";
|
|
// if (go == null)
|
|
// {
|
|
// DebugUtil.LogError(ERROR_PRE + "no GameObject");
|
|
// return null;
|
|
// }
|
|
//
|
|
// var grid = go.GetComponentInChildren<Grid>();
|
|
// if (grid == null)
|
|
// {
|
|
// DebugUtil.LogError(ERROR_PRE + "GameObject has no Grid Component");
|
|
// return null;
|
|
// }
|
|
//
|
|
// var tilemap = grid.GetComponentInChildren<Tilemap>();
|
|
// if (tilemap == null)
|
|
// {
|
|
// DebugUtil.LogError(ERROR_PRE + "GameObject has no TileMap Compoment");
|
|
// return null;
|
|
// }
|
|
//
|
|
// var meshRenderer = go.GetComponentInChildren<MeshRenderer>();
|
|
// if (meshRenderer == null)
|
|
// {
|
|
// DebugUtil.LogError(ERROR_PRE + "GameObject has no MeshRenderer Compoment");
|
|
// //return null;
|
|
// }
|
|
// var map = new UMap
|
|
// {
|
|
// _grid = grid,
|
|
// _tilemap = tilemap,
|
|
// _gameObject = go,
|
|
// _mapData = data,
|
|
// _groundMeshRenderer = meshRenderer
|
|
// };
|
|
// map.GameObject.name = GetMapFileName(map);
|
|
// return map;
|
|
// }
|
|
//
|
|
// public bool Contains(GameObject go)
|
|
// {
|
|
// if (go == null)
|
|
// {
|
|
// return false;
|
|
// }
|
|
// var current = go;
|
|
// while (current != _gameObject)
|
|
// {
|
|
// var parent = current.transform.parent;
|
|
// if (parent == null)
|
|
// {
|
|
// return false;
|
|
// }
|
|
// current = parent.gameObject;
|
|
// }
|
|
// return true;
|
|
// }
|
|
//
|
|
// public void SetGroundTexture(Texture texture)
|
|
// {
|
|
// _groundMeshRenderer.sharedMaterial.mainTexture = texture;
|
|
// }
|
|
//
|
|
// public void SetGroundSortingLayer(int order)
|
|
// {
|
|
// _groundMeshRenderer.sortingOrder = order;
|
|
// }
|
|
//
|
|
// public MapBlockData? GetBlockData(Vector2Int position)
|
|
// {
|
|
// return _mapData.GetBlockData(position);
|
|
// }
|
|
//
|
|
// public bool CheckPosition(Vector2Int position)
|
|
// {
|
|
// return _mapData.CheckPosition(position);
|
|
// }
|
|
//
|
|
//
|
|
// public static string GetMapFileName(UMap uMap)
|
|
// {
|
|
// return GetMapFileName(uMap.MapData.name, uMap.MapData.id);
|
|
// }
|
|
// public static string GetMapFileName(string name, int id)
|
|
// {
|
|
// return string.Format($"{name}_{id}");
|
|
// }
|
|
//}
|