/// <summary> /// 获取移动到目标位置所占领的房间 /// </summary> /// <param name="TargetPos">目的位置</param> public static List <RoomGrid> GetMovetoRoomGrid(CanvasCore core, Int2 TargetPos) { if (core.Data != null) { List <RoomGrid> l = new List <RoomGrid>(); ShapeType shape = core.GetPutRoomShape(); if (shape != null) { Dictionary <Int2, ShapeValue> lshape = shape.GetShapeData(TargetPos); foreach (Int2 Pos in lshape.Keys) { RoomGrid r = RoomMap.FindRoomGrid(Pos, XYSYS.RoomGrid); if (r != null) { l.Add(r); } } } else { RoomGrid r = RoomMap.FindRoomGrid(TargetPos, XYSYS.MapGrid); if (r != null) { l.Add(r); } } return(l); } return(new List <RoomGrid>()); }
/// <summary> /// 获取地图数据 /// </summary> /// <param name="TargetPos">目的位置</param> public List <Int2> GetMovetoRoomMapData(Int2 TargetPos) { List <Int2> l = new List <Int2>(); ShapeType shape = GetPutRoomShape(); if (shape != null) { Dictionary <Int2, ShapeValue> lshape = shape.GetShapeData(TargetPos); foreach (Int2 Pos in lshape.Keys) { if (lshape[Pos].DownMap == 1) { if (l.Contains(Pos) == false) { l.Add(Pos); } } if (lshape[Pos].UpMap == 1) { Int2 UpPos = new Int2(Pos.Unit, Pos.Layer + 1); if (l.Contains(UpPos) == false) { l.Add(UpPos); } } } } return(l); }
/// <summary> /// 加入一个房间。从仓库中加载。或加载方案 /// </summary> /// <param name="Core">核心结构</param> /// <param name="TargetPos">格子坐标</param> public static void AddNewCore(CanvasCore Core, Int2 TargetPos) { if (Core == null) { return; } ShipPlan P = ShipPlanDC.GetCurShipPlan(); if (P == null) { return; } ShipPutInfo Info = P.GetShipBuildInfo(Core); if (Info == null) { return; } if (Core.IsNewCreate) { Info.SetBuildPostion(TargetPos); P.AddShipBuildInfo(Info, Core.m_type); TouchMoveManager.MoveToShip(Core); Core.IsNewCreate = false; } // if (Core.m_type == ShipBuildType.BuildRoom) { if (Core.IsDeckRoom == false) { ShapeType Shape = Info.GetPutRoomShape(); if (Shape == null) { return; } RoomMap.OpenCanvans(Shape.GetShapeData(new Int2(Info.cxMapGrid, Info.cyMapGrid)), Core.m_ID); //设置甲板区域 RoomMap.UpdateDeckRoomGrid(); //更新金库房间 if (Info.IsGoldBuild() == true) { RoomMap.UpdateGoldRoomGrid(Core.GetPutRoomGridPos()); } } else { RoomMap.AddDeckBuild(Core.m_ID, Core.GetPutRoomGridPos()); } } else { RoomMap.AddMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core)); } }
public List <Int2> GetPutRoom() { List <Int2> lPutRoom = new List <Int2>(); if (m_Shape != null) { Dictionary <Int2, ShapeValue> l = m_Shape.GetShapeData(new Int2(m_cx, m_cy)); lPutRoom.AddRange(l.Keys); } return(lPutRoom); }
/// <summary> /// 判断移动到目标位置,是否有出界 /// </summary> /// <param name="posMapGrid">目的位置</param> public static bool CheckAllInMap(CanvasCore core, Int2 posMapGrid) { if (core.Data != null) { ShapeType shape = core.GetPutRoomShape(); if (shape != null) { Dictionary <Int2, ShapeValue> lshape = shape.GetShapeData(posMapGrid); foreach (Int2 posRoomGrid in lshape.Keys) { RoomGrid r = RoomMap.FindRoomGrid(posRoomGrid, XYSYS.RoomGrid); if (r == null) { return(false); } } } } return(true); }
/// <summary> /// 获取移动到目标位置所占领的房间位置 /// </summary> /// <param name="posMapGrid">目的位置</param> public static Dictionary <RoomGrid, int> GetMovetoRoomGridPosition(CanvasCore core, Int2 posMapGrid) { Dictionary <RoomGrid, int> l = new Dictionary <RoomGrid, int>(); if (core.Data == null) { return(l); } ShapeType shape = core.GetPutRoomShape(); if (core.Data.type == (int)ShipBuildType.Soldier) { RoomGrid r = RoomMap.FindRoomGrid(posMapGrid, XYSYS.MapGrid); if (r != null) { l.Add(r, (int)PutPosition.Soldier); } } else if (core.Data.type == (int)ShipBuildType.BuildStair) { RoomGrid r = RoomMap.FindRoomGrid(posMapGrid, XYSYS.MapGrid); if (r != null) { l.Add(r, (int)PutPosition.Stair); } } else if (shape != null) { Dictionary <Int2, ShapeValue> lshape = shape.GetShapeData(posMapGrid); foreach (Int2 Pos in lshape.Keys) { int position = lshape[Pos].Position; RoomGrid r = RoomMap.FindRoomGrid(Pos, XYSYS.RoomGrid); if (r != null) { l.Add(r, position); } } } return(l); }
/// <summary> /// 获取移动到目标位置所占领的房间位置 /// </summary> /// <param name="TargetPos">目的位置</param> public List <Int2> GetMovetoRoomGridPos(Int2 TargetPos) { List <Int2> l = new List <Int2>(); ShapeType shape = GetPutRoomShape(); if (shape != null) { Dictionary <Int2, ShapeValue> lshape = shape.GetShapeData(TargetPos); foreach (Int2 Pos in lshape.Keys) { l.Add(Pos); } } else { //如果没有形状态则本格子就是其形状态 Int2 posSoldier = new Int2(TargetPos.Unit / MapGrid.m_UnitRoomGridNum, TargetPos.Layer); l.Add(posSoldier); } return(l); }