124 lines
3.9 KiB
C#
124 lines
3.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public enum CellType
|
|
{
|
|
/// <summary>
|
|
/// 无效格
|
|
/// </summary>
|
|
None = 0,
|
|
|
|
/// <summary>
|
|
/// 移动
|
|
/// </summary>
|
|
Move = 1,
|
|
|
|
/// <summary>
|
|
/// 阻挡
|
|
/// </summary>
|
|
Obstacle = 2,
|
|
|
|
/// <summary>
|
|
/// 隐藏
|
|
/// </summary>
|
|
Hide = 4,
|
|
|
|
/// <summary>
|
|
/// 有角色占据(运行时动态变化时产生)
|
|
/// </summary>
|
|
HadRole = 8,
|
|
|
|
/// <summary>
|
|
/// 安全区
|
|
/// </summary>
|
|
Safe = 16,
|
|
|
|
/// <summary>
|
|
/// 摆摊区域
|
|
/// </summary>
|
|
Stall = 32,
|
|
|
|
Audio = 64, //音效
|
|
Trigger = 128, //触发
|
|
Monster = 256 //怪物
|
|
}
|
|
|
|
//[Flags]
|
|
//public enum CellLayer
|
|
//{
|
|
// None = 0, //无效格子
|
|
// Move = 1, //移动
|
|
// Obstacle = 2, //阻挡
|
|
// Hide = 4, //隐藏
|
|
// Safe = 16, //安全区
|
|
// Stall = 32, //摆摊
|
|
// Audio = 64, //音效
|
|
// Trigger = 128, //触发
|
|
// Monster = 256 //怪物
|
|
//}
|
|
/// <summary>
|
|
/// 区域颜色
|
|
/// </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
|
|
{
|
|
public static Color None = new Color(0xb0 / 255f, 0xb0 / 255f, 0xb0 / 255f,0.5f); // 浅灰色 (#b0b0b0)
|
|
public static Color Move = new Color(0x00 / 255f, 0xff / 255f, 0x00 / 255f,0.5f); // 鲜绿色 (#00ff00)
|
|
public static Color Obstacle = new Color(0xff / 255f, 0x00 / 255f, 0x00 / 255f,0.5f); // 鲜红色 (#ff0000)
|
|
public static Color Hide = new Color(0x80 / 255f, 0x00 / 255f, 0xff / 255f,0.5f); // 深紫色 (#8000ff)
|
|
public static Color Safe = new Color(0x00 / 255f, 0xff / 255f, 0xff / 255f, 0.5f); // 亮青色 (#00ffff)
|
|
public static Color Stall = new Color(0xff / 255f, 0x80 / 255f, 0x00 / 255f, 0.5f); // 鲜橙色 (#ff8000)
|
|
|
|
public static Color GetColor(CellType cellType)
|
|
{
|
|
Color color = Color.clear; // 初始化为黑色,如果没有匹配类型时返回
|
|
|
|
if (cellType == CellType.None) return CellTypeColors.None;
|
|
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)
|
|
{
|
|
if (cellType.HasFlag(CellType.Hide)) color += CellTypeColors.Hide * 0.8f;
|
|
}
|
|
else if (UICellEditor.Instance.editorGrid == CellType.Safe)
|
|
{
|
|
if (cellType.HasFlag(CellType.Safe)) color += CellTypeColors.Safe * 0.8f;
|
|
}
|
|
else if (UICellEditor.Instance.editorGrid == CellType.Stall)
|
|
{
|
|
if (cellType.HasFlag(CellType.Stall)) color += CellTypeColors.Stall * 0.8f;
|
|
}
|
|
// 确保颜色值不超过1
|
|
color.r = Mathf.Clamp01(color.r);
|
|
color.g = Mathf.Clamp01(color.g);
|
|
color.b = Mathf.Clamp01(color.b);
|
|
color.a = 0.5f; // 确保不透明
|
|
return color;
|
|
}
|
|
public static string GetAreaStr(int barrier)
|
|
{
|
|
string areaStr = " ";
|
|
CellType cellType = (CellType)(barrier & 0xffff);
|
|
if (cellType == CellType.None)
|
|
{
|
|
areaStr = "无效格子";
|
|
return areaStr;
|
|
}
|
|
if (cellType.HasFlag(CellType.Move)) areaStr += "可移动";
|
|
if (cellType.HasFlag(CellType.Obstacle)) areaStr += "|阻隔点";
|
|
if (cellType.HasFlag(CellType.Safe)) areaStr += "|安全区";
|
|
if (cellType.HasFlag(CellType.Stall)) areaStr += "|摆摊区";
|
|
if (cellType.HasFlag(CellType.Hide)) areaStr += "|半隐区";
|
|
return areaStr;
|
|
}
|
|
} |