コード例 #1
0
 /// <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>());
 }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
    /// <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);
    }