import { Vec2, v2 } from "cc";
import { NpkImage } from "../../Tool/NPKImage";
/// 地块类型
export enum MapTileType {
  /// 赫顿玛尔
  HeDunMaEr = 0,
  /// 时间广场
  ShiJianGuangChang,
  /// 兽人峡谷
  ShouRenXiaGu,
  /// 超时空漩涡
  ChaoShiKongXuanWo,
  /// 恐怖的栖息地
  KongBuDeQiXiDi,
  /// 红色魔女之森
  HongSeMoNvZhiSen,

  /// 月光酒馆
  YueGuangJiuGuan,
  /// 亡命杀阵
  WangMingShaZhen,
  /// 皇家娱乐
  HuangJaiYuLe,
  /// 黑暗都市
  HeiAnDuShi,
  /// 哈林的命运硬币（左边）
  HaLinMingYunYinBi,
  /// 第九隔离区
  DiJiuGeLiQu,

  /// 决斗场
  JueDouChang,
  /// 腐坏街道
  FuHuaiJieDao,
  /// 溢血的地下城
  YiXueDeDiXiaChen,
  /// 普雷·伊西斯
  PuLeiYiXiSi,
  /// 沉重的礼拜堂
  ChenZhongDeLiBaiTang,
  /// 螺旋王国
  LuoXuanWangGuo,

  /// 海上列车
  HaiShangLieChe,
  /// 暗黑神殿
  AnHeiShenDian,
  /// 痛苦地下城
  TongKuDiXiaChen,
  /// 无底坑道
  WuDiKenDao,
  /// 切斯特小镇的命运硬币（右边）
  XiaoZhenMingYunYinBi,
  /// 记忆之地
  JiYiZhiDi,
}

export const MapTileTypes = [
  /// 赫顿玛尔
  MapTileType.HeDunMaEr,
/// 时间广场
MapTileType.ShiJianGuangChang,
/// 兽人峡谷
MapTileType.ShouRenXiaGu,
/// 超时空漩涡
MapTileType.ChaoShiKongXuanWo,
/// 恐怖的栖息地
MapTileType.KongBuDeQiXiDi,
/// 红色魔女之森
MapTileType.HongSeMoNvZhiSen,

/// 月光酒馆
MapTileType.YueGuangJiuGuan,
/// 亡命杀阵
MapTileType.WangMingShaZhen,
/// 皇家娱乐
MapTileType.HuangJaiYuLe,
/// 黑暗都市
MapTileType.HeiAnDuShi,
/// 哈林的命运硬币（左边）
MapTileType.HaLinMingYunYinBi,
/// 第九隔离区
MapTileType.DiJiuGeLiQu,

/// 决斗场
MapTileType.JueDouChang,
/// 腐坏街道
MapTileType.FuHuaiJieDao,
/// 溢血的地下城
MapTileType.YiXueDeDiXiaChen,
/// 普雷·伊西斯
MapTileType.PuLeiYiXiSi,
/// 沉重的礼拜堂
MapTileType.ChenZhongDeLiBaiTang,
/// 螺旋王国
MapTileType.LuoXuanWangGuo,

/// 海上列车
MapTileType.HaiShangLieChe,
/// 暗黑神殿
MapTileType.AnHeiShenDian,
/// 痛苦地下城
MapTileType.TongKuDiXiaChen,
/// 无底坑道
MapTileType.WuDiKenDao,
/// 切斯特小镇的命运硬币（右边）
MapTileType.XiaoZhenMingYunYinBi,
/// 记忆之地
MapTileType.JiYiZhiDi,
];

/// 地块方向
export enum MapTileDirection {
  /// 横
  horizontal = 24,
  /// 竖
  vertical = 25,
  /// 角落
  nook = 26,
}

/// 地块的数据
export class MapTileData {
  /// 坐标
  location: Vec2;
  /// npk路径
  npkPath: NpkImage;
  /// 地块背景index
  backgroundIndex: number;
  /// 地块方向
  direction: MapTileDirection;
  /// 怪物相关数据

  /// 列车选择许可
  trainsSelectLicense: boolean;
  /// 决斗场选择许可
  duelSelectLicense: boolean;
  /// 占领许可
  occupyLicense: boolean;

  constructor({
    /// 坐标
    location,
    /// 背景index
    backgroundIndex,
    /// 地块方向
    direction,
    /// 占领许可
    occupyLicense,
    /// 列车选择许可
    trainsSelectLicense,
    /// 决斗场选择许可
    duelSelectLicense,
  }: {
    location: Vec2;
    backgroundIndex?: number;
    direction: MapTileDirection;
    occupyLicense?: boolean;
    trainsSelectLicense?: boolean;
    duelSelectLicense?: boolean;
  }) {
    this.location = location;
    this.npkPath = NpkImage.board;
    this.backgroundIndex = backgroundIndex;
    this.direction = direction;

    this.trainsSelectLicense = trainsSelectLicense ?? true;
    this.duelSelectLicense = duelSelectLicense ?? true;
    this.occupyLicense = occupyLicense ?? true;
  }
}

export class MapTileFactory {
  static getData(type: MapTileType): MapTileData {
    switch (type) {
      /// 赫顿玛尔
      case MapTileType.HeDunMaEr:
        return MapTileFactory.HeDunMaErData;
      /// 时间广场
      case MapTileType.ShiJianGuangChang:
        return MapTileFactory.ShiJianGuangChangData;
      /// 兽人峡谷
      case MapTileType.ShouRenXiaGu:
        return MapTileFactory.ShouRenXiaGuData;
      /// 超时空漩涡
      case MapTileType.ChaoShiKongXuanWo:
        return MapTileFactory.ChaoShiKongXuanWoData;
      /// 恐怖的栖息地
      case MapTileType.KongBuDeQiXiDi:
        return MapTileFactory.KongBuDeQiXiDiData;
      /// 红色魔女之森
      case MapTileType.HongSeMoNvZhiSen:
        return MapTileFactory.HongSeMoNvZhiSenData;
      /// 月光酒馆
      case MapTileType.YueGuangJiuGuan:
        return MapTileFactory.YueGuangJiuGuanData;
      /// 亡命杀镇子
      case MapTileType.WangMingShaZhen:
        return MapTileFactory.WangMingShaZhenData;
      /// 皇家娱乐
      case MapTileType.HuangJaiYuLe:
        return MapTileFactory.HuangJaiYuLeData;
      /// 黑暗都市
      case MapTileType.HeiAnDuShi:
        return MapTileFactory.HeiAnDuShiData;
      /// 哈林的命运硬币（左边）
      case MapTileType.HaLinMingYunYinBi:
        return MapTileFactory.HaLinMingYunYinBiData;
      /// 第九隔离区
      case MapTileType.DiJiuGeLiQu:
        return MapTileFactory.DiJiuGeLiQuData;
      /// 决斗场
      case MapTileType.JueDouChang:
        return MapTileFactory.JueDouChangData;
      /// 腐坏街道
      case MapTileType.FuHuaiJieDao:
        return MapTileFactory.FuHuaiJieDaoData;
      /// 溢血的地下城
      case MapTileType.YiXueDeDiXiaChen:
        return MapTileFactory.YiXueDeDiXiaChenData;
      /// 普雷·伊西斯
      case MapTileType.PuLeiYiXiSi:
        return MapTileFactory.PuLeiYiXiSiData;
      /// 沉重的礼拜堂
      case MapTileType.ChenZhongDeLiBaiTang:
        return MapTileFactory.ChenZhongDeLiBaiTangData;
      /// 螺旋王国
      case MapTileType.LuoXuanWangGuo:
        return MapTileFactory.LuoXuanWangGuoData;
      /// 海上列车
      case MapTileType.HaiShangLieChe:
        return MapTileFactory.HaiShangLieCheData;
      /// 暗黑神殿
      case MapTileType.AnHeiShenDian:
        return MapTileFactory.AnHeiShenDianData;
      /// 痛苦地下城
      case MapTileType.TongKuDiXiaChen:
        return MapTileFactory.TongKuDiXiaChenData;
      /// 无底坑道
      case MapTileType.WuDiKenDao:
        return MapTileFactory.WuDiKenDaoData;
      /// 切斯特小镇的命运硬币（右边）
      case MapTileType.XiaoZhenMingYunYinBi:
        return MapTileFactory.XiaoZhenMingYunYinBiData;
      /// 记忆之地
      case MapTileType.JiYiZhiDi:
        return MapTileFactory.JiYiZhiDiData;
    }
  }

  // 赫顿玛尔
  private static HeDunMaErData = new MapTileData({
    location: v2(475, -448),
    direction: MapTileDirection.nook,
    duelSelectLicense: false,
    occupyLicense: false,
  });

  /// 时间广场 (55,34)
  private static ShiJianGuangChangData = new MapTileData({
    location: v2(420, -414),
    direction: MapTileDirection.horizontal,
  });

  /// 兽人峡谷 (52,34)
  private static ShouRenXiaGuData = new MapTileData({
    location: v2(368, -380),
    direction: MapTileDirection.horizontal,
  });

  /// 超时空漩涡 (53,34)
  private static ChaoShiKongXuanWoData = new MapTileData({
    location: v2(315, -346),
    backgroundIndex: 32,
    direction: MapTileDirection.horizontal,
  });

  /// 恐怖的栖息地 (52,34)
  private static KongBuDeQiXiDiData = new MapTileData({
    location: v2(262, -312),
    direction: MapTileDirection.horizontal,
  });

  /// 红色魔女之森 (52,34)
  private static HongSeMoNvZhiSenData = new MapTileData({
    location: v2(209, -278),
    direction: MapTileDirection.horizontal,
  });

  // 月光酒馆(69,44)
  private static YueGuangJiuGuanData = new MapTileData({
    location: v2(140, -234),
    direction: MapTileDirection.nook,
    duelSelectLicense: false,
    occupyLicense: false,
  });

  /// 亡命杀镇 (53,34)
  private static WangMingShaZhenData = new MapTileData({
    location: v2(209, -198),
    direction: MapTileDirection.vertical,
  });

  /// 皇家娱乐(53,34)
  private static HuangJaiYuLeData = new MapTileData({
    location: v2(262, -164),
    direction: MapTileDirection.vertical,
  });

  /// 黑暗都市
  private static HeiAnDuShiData = new MapTileData({
    location: v2(315, -130),
    direction: MapTileDirection.vertical,
  });
  /// 哈林的命运硬币（左边）
  private static HaLinMingYunYinBiData = new MapTileData({
    location: v2(368, -96),
    backgroundIndex: 34,
    direction: MapTileDirection.vertical,
    duelSelectLicense: false,
    occupyLicense: false,
  });
  /// 第九隔离区
  private static DiJiuGeLiQuData = new MapTileData({
    location: v2(421, -62),
    direction: MapTileDirection.vertical,
  });

  // 决斗场(54,44)
  private static JueDouChangData = new MapTileData({
    location: v2(475, -18),
    direction: MapTileDirection.nook,
    duelSelectLicense: false,
    occupyLicense: false,
  });

  /// 腐坏街道(53,34)
  private static FuHuaiJieDaoData = new MapTileData({
    location: v2(544, -62),
    direction: MapTileDirection.horizontal,
  });

  /// 溢血的地下城(53,34)
  private static YiXueDeDiXiaChenData = new MapTileData({
    location: v2(597, -96),
    direction: MapTileDirection.horizontal,
  });

  /// 普雷·伊西斯
  private static PuLeiYiXiSiData = new MapTileData({
    location: v2(650, -130),
    backgroundIndex: 33,
    direction: MapTileDirection.horizontal,
  });

  /// 沉重的礼拜堂
  private static ChenZhongDeLiBaiTangData = new MapTileData({
    location: v2(703, -164),
    direction: MapTileDirection.horizontal,
  });

  /// 螺旋王国
  private static LuoXuanWangGuoData = new MapTileData({
    location: v2(756, -198),
    direction: MapTileDirection.horizontal,
  });

  // 海上列车(69,44)
  private static HaiShangLieCheData = new MapTileData({
    location: v2(808, -234),
    direction: MapTileDirection.nook,
    trainsSelectLicense: false,
    duelSelectLicense: false,
    occupyLicense: false,
  });

  /// 暗黑神殿
  private static AnHeiShenDianData = new MapTileData({
    location: v2(756, -278),
    direction: MapTileDirection.vertical,
  });

  /// 痛苦地下城
  private static TongKuDiXiaChenData = new MapTileData({
    location: v2(703, -312),
    direction: MapTileDirection.vertical,
  });

  /// 无底坑道
  private static WuDiKenDaoData = new MapTileData({
    location: v2(650, -346),
    direction: MapTileDirection.vertical,
  });

  /// 切斯特小镇的命运硬币（右边）
  private static XiaoZhenMingYunYinBiData = new MapTileData({
    location: v2(597, -380),
    backgroundIndex: 34,
    direction: MapTileDirection.vertical,
    duelSelectLicense: false,
    occupyLicense: false,
  });

  /// 记忆之地
  private static JiYiZhiDiData = new MapTileData({
    location: v2(544, -414),
    direction: MapTileDirection.vertical,
  });
}
