Files
HX_MapEditor/Assets/Scripts/Map/MapDefine.cs

123 lines
3.8 KiB
C#
Raw Normal View History

2025-06-15 20:14:45 +08:00
using System;
using UnityEngine;
public enum CellType
{
/// <summary>
/// <20><>Ч<EFBFBD><D0A7>
/// </summary>
None = 0,
/// <summary>
/// <20>ƶ<EFBFBD>
/// </summary>
Move = 1,
/// <summary>
/// <20>
/// </summary>
Obstacle = 2,
/// <summary>
/// <20><><EFBFBD><EFBFBD>
/// </summary>
Hide = 4,
/// <summary>
/// <20>н<EFBFBD>ɫռ<C9AB>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>̬<EFBFBD>仯ʱ<E4BBAF><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
HadRole = 8,
/// <summary>
/// <20><>ȫ<EFBFBD><C8AB>
/// </summary>
Safe = 16,
/// <summary>
/// <20><>̯<EFBFBD><CCAF><EFBFBD><EFBFBD>
/// </summary>
Stall = 32,
Audio = 64, //<2F><>Ч
Trigger = 128, //<2F><><EFBFBD><EFBFBD>
Monster = 256 //<2F><><EFBFBD><EFBFBD>
}
2025-06-19 01:31:00 +08:00
//[Flags]
//public enum CellLayer
//{
// None = 0, //<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
// Move = 1, //<2F>ƶ<EFBFBD>
// Obstacle = 2, //<2F>
// Hide = 4, //<2F><><EFBFBD><EFBFBD>
// Safe = 16, //<2F><>ȫ<EFBFBD><C8AB>
// Stall = 32, //<2F><>̯
// Audio = 64, //<2F><>Ч
// Trigger = 128, //<2F><><EFBFBD><EFBFBD>
// Monster = 256 //<2F><><EFBFBD><EFBFBD>
//}
2025-06-15 20:14:45 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
/// </summary>
public class AreaColor
{
public static Color Monster = Color.red;
public static Color Npc = Color.yellow;
public static Color Stall = Color.magenta;
public static Color Relive = Color.green;
public static Color Audio = Color.white;
public static Color Trans = Color.blue;
public static Color Born = Color.green;
}
public class CellTypeColors
{
2025-06-19 01:31:00 +08:00
public static Color None = new Color(0xb0 / 255f, 0xb0 / 255f, 0xb0 / 255f,0); // dz<><C7B3>ɫ (#b0b0b0)
public static Color Move = new Color(0x00 / 255f, 0xff / 255f, 0x00 / 255f); // <20><><EFBFBD><EFBFBD>ɫ (#00ff00)
public static Color Obstacle = new Color(0xff / 255f, 0x00 / 255f, 0x00 / 255f); // <20>ʺ<EFBFBD>ɫ (#ff0000)
public static Color Hide = new Color(0x80 / 255f, 0x00 / 255f, 0xff / 255f); // <20><><EFBFBD><EFBFBD>ɫ (#8000ff)
public static Color Safe = new Color(0x00 / 255f, 0xff / 255f, 0xff / 255f); // <20><><EFBFBD><EFBFBD>ɫ (#00ffff)
public static Color Stall = new Color(0xff / 255f, 0x80 / 255f, 0x00 / 255f); // <20>ʳ<EFBFBD>ɫ (#ff8000)
2025-06-15 20:14:45 +08:00
public static Color GetColor(CellType cellType)
{
Color color = Color.clear; // <20><>ʼ<EFBFBD><CABC>Ϊ<EFBFBD><CEAA>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
if (cellType == CellType.None) return CellTypeColors.None;
2025-06-19 01:31:00 +08:00
if (cellType.HasFlag(CellType.Move)) color += CellTypeColors.Move * 0.6f;
if (cellType.HasFlag(CellType.Obstacle)) color += CellTypeColors.Obstacle * 0.6f;
if(UICellEditor.Instance == null) return color;
if (UICellEditor.Instance.editorGrid == CellType.Hide)
2025-06-15 20:14:45 +08:00
{
2025-06-19 01:31:00 +08:00
if (cellType.HasFlag(CellType.Hide)) color += CellTypeColors.Hide * 0.8f;
2025-06-15 20:14:45 +08:00
}
2025-06-19 01:31:00 +08:00
else if (UICellEditor.Instance.editorGrid == CellType.Safe)
2025-06-15 20:14:45 +08:00
{
2025-06-19 01:31:00 +08:00
if (cellType.HasFlag(CellType.Safe)) color += CellTypeColors.Safe * 0.8f;
2025-06-15 20:14:45 +08:00
}
2025-06-19 01:31:00 +08:00
else if (UICellEditor.Instance.editorGrid == CellType.Stall)
2025-06-15 20:14:45 +08:00
{
2025-06-19 01:31:00 +08:00
if (cellType.HasFlag(CellType.Stall)) color += CellTypeColors.Stall * 0.8f;
2025-06-15 20:14:45 +08:00
}
2025-06-19 01:31:00 +08:00
// ȷ<><C8B7><EFBFBD><EFBFBD>ɫֵ<C9AB><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
color.r = Mathf.Clamp01(color.r);
color.g = Mathf.Clamp01(color.g);
color.b = Mathf.Clamp01(color.b);
color.a = 1f; // ȷ<><C8B7><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>
2025-06-15 20:14:45 +08:00
return color;
}
public static string GetAreaStr(int barrier)
{
string areaStr = " ";
CellType cellType = (CellType)(barrier & 0xffff);
if (cellType == CellType.None)
{
areaStr = "<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>";
return areaStr;
}
if (cellType.HasFlag(CellType.Move)) areaStr += "<22><><EFBFBD>ƶ<EFBFBD>";
if (cellType.HasFlag(CellType.Obstacle)) areaStr += "|<7C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
if (cellType.HasFlag(CellType.Safe)) areaStr += "|<7C><>ȫ<EFBFBD><C8AB>";
if (cellType.HasFlag(CellType.Stall)) areaStr += "|<7C><>̯<EFBFBD><CCAF>";
return areaStr;
}
}