121 lines
4.0 KiB
C#
121 lines
4.0 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,
|
|
}
|
|
|
|
[Flags]
|
|
public enum CellLayer
|
|
{
|
|
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(0x80 / 255f, 0x80 / 255f, 0x80 / 255f); // 灰色 (#808080)
|
|
public static Color Move = new Color(0x33 / 255f, 0xcc / 255f, 0x33 / 255f); // 绿色 (#33cc33)
|
|
public static Color Obstacle = new Color(0xff / 255f, 0x00 / 255f, 0x00 / 255f); // 红色 (#ff4d4d)
|
|
public static Color Hide = new Color(0x33 / 255f, 0x33 / 255f, 0x33 / 255f); // 深灰色 (#333333)
|
|
public static Color HadRole = new Color(0xb3 / 255f, 0x33 / 255f, 0xb3 / 255f); // 紫色 (#b333b3)
|
|
public static Color Safe = new Color(0x00 / 255f, 0xff / 255f, 0xff / 255f); // 青色 (#00ffff)
|
|
public static Color Stall = new Color(0xff / 255f, 0xff / 255f, 0x99 / 255f); // 浅黄色 (#ffff99)
|
|
public static Color Water = new Color(0x00 / 255f, 0x4c / 255f, 0xb3 / 255f); // 水蓝色 (#004cb3)
|
|
public static Color Snow = new Color(0xff / 255f, 0xff / 255f, 0xff / 255f); // 白色 (#ffffff)
|
|
public static Color Sand = new Color(0xff / 255f, 0xcc / 255f, 0x66 / 255f); // 沙黄色 (#ffcc66)
|
|
public static Color Stone = new Color(0x66 / 255f, 0x66 / 255f, 0x66 / 255f); // 深灰色 (#666666)
|
|
public static Color Wood = new Color(0x8B / 255f, 0x45 / 255f, 0x13 / 255f); // 棕色 (#8B4513)
|
|
public static Color Grass = new Color(0x00 / 255f, 0xff / 255f, 0xff / 255f); // 青色 (#00ffff)
|
|
public static Color Dirt = new Color(0xff / 255f, 0x49 / 255f, 0x00 / 255f); // 浅棕色 (#FF4900)
|
|
|
|
public static Color GetColor(CellType cellType)
|
|
{
|
|
Color color = Color.clear; // 初始化为黑色,如果没有匹配类型时返回
|
|
|
|
if (cellType == CellType.None) return CellTypeColors.None;
|
|
if (true)
|
|
{
|
|
if (cellType.HasFlag(CellType.Move)) color += CellTypeColors.Move;
|
|
}
|
|
else if (true)
|
|
{
|
|
if (cellType.HasFlag(CellType.Safe)) color += CellTypeColors.Safe;
|
|
}
|
|
else if (true)
|
|
{
|
|
if (cellType.HasFlag(CellType.Stall)) color += CellTypeColors.Stall;
|
|
}
|
|
if (cellType.HasFlag(CellType.Obstacle)) color += CellTypeColors.Obstacle;
|
|
// 将颜色归一化,以避免颜色超出范围,先不归一化
|
|
//color /= 7.0f; // 7 是 CellType 的数量
|
|
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 += "|摆摊区";
|
|
return areaStr;
|
|
}
|
|
} |