示例#1
0
    private void OnClickGird(Coord co, MapView.GridType type)
    {
        MapView.GridType beforeType = MapView.GridType.Empty;
        if (mHasStartCo && co.Equals(mStartCo))
        {
            beforeType = MapView.GridType.StartPoint;
        }
        else if (mHasEndCo && co.Equals(mEndCo))
        {
            beforeType = MapView.GridType.EndPoint;
        }
        else if (MapManager.Instant.IsBlock(co))
        {
            beforeType = MapView.GridType.Block;
        }

        switch (beforeType)
        {
        case MapView.GridType.Empty:
            OnSetGridType(co, type);
            break;

        case MapView.GridType.Block:
            if (type == MapView.GridType.Empty)
            {
                OnSetGridType(co, type);
            }
            break;

        case MapView.GridType.EndPoint:
            if (type == MapView.GridType.Block)
            {
                mHasEndCo = false;
            }
            else
            {
                OnSetGridType(co, type);
            }
            break;

        case MapView.GridType.StartPoint:
            if (type == MapView.GridType.Block)
            {
                mHasStartCo = false;
            }
            else
            {
                OnSetGridType(co, type);
            }
            break;

        default:
            break;
        }
    }
示例#2
0
    private void OnSetGridType(Coord co, MapView.GridType type)
    {
        switch (type)
        {
        case MapView.GridType.Empty:
            MapManager.Instant.SetBlock(co, true);
            break;

        case MapView.GridType.Block:
            MapManager.Instant.SetBlock(co, false);
            break;

        case MapView.GridType.StartPoint:
            mHasStartCo = true;
            mStartCo    = co;
            break;

        case MapView.GridType.EndPoint:
            mHasEndCo = true;
            mEndCo    = co;
            break;

        default:
            break;
        }

        view.RefreshBlock();
        if (mHasStartCo)
        {
            view.SetStartPoint(mStartCo);
        }
        else
        {
            view.HideStartPoint();
        }
        if (mHasEndCo)
        {
            view.SetEndPoint(mEndCo);
        }
        else
        {
            view.HideEndPoint();
        }
    }