Esempio n. 1
0
    //熊减防一直往前走
    public static List <MapGrid> GetFrontPath(MapGrid start, MapGrid end, WalkDir curdir)
    {
        List <MapGrid> list = new List <MapGrid>();

        if (start == null)
        {
            return(list);
        }
        int flag  = curdir == WalkDir.WALKLEFT?-1:1;
        int layer = start.GridPos.Layer;
        int unit  = start.GridPos.Unit;
        //list.Add(start);
        MapGrid next = start;

        do
        {
            list.Add(next);
            unit += flag;
            next  = MapGrid.GetMG(layer, unit);
        }while (next != null && next.Type != GridType.GRID_HOLE && next.Type != GridType.GRID_WALL && (!next.IsAttackStations() || next.CheckIdleAttackStation()));
        while (list.Count > 0)
        {
            if (!list[list.Count - 1].IsAttackStations())
            {
                list.RemoveAt(list.Count - 1);
            }
            else
            {
                break;
            }
        }
        return(list);
    }