コード例 #1
0
    /// <summary>
    /// 放开建筑处理
    /// </summary>
    public bool MoveBuildUp()
    {
        if (m_ExchangeTouch && m_ExchangeTouch != this)
        {
            m_ExchangeTouch.m_posMapGrid    = m_orgPosMapGrid;
            m_ExchangeTouch.m_orgPosMapGrid = m_ExchangeTouch.m_posMapGrid;
            m_ExchangeTouch.UpdateChildmGridWhenUp();

            m_orgPosMapGrid = m_posMapGrid;
            UpdateChildmGridWhenUp();
            SetPosByGrid(true);
            if (!m_ExchangeTouch.MyCore().IsDeckRoom)
            {
                CreateStair(m_Core);
            }
            m_ExchangeTouch = null;
            GenerateDeck();
            return(true);
        }


        bool bCanPut = PutCanvasM.CheckCanTempPut(m_Core, m_posMapGrid);

        if (bCanPut)
        {
            m_orgPosMapGrid = m_posMapGrid;
            UpdateChildmGridWhenUp();
            SetPosByGrid(true);
        }
        else
        {
            m_posMapGrid = m_orgPosMapGrid;
            UpdateChildmGridWhenUp();
            MoveShipBuilding(m_posMapGrid);
            SetPosByGrid(true);
        }
        if (!MyCore().IsDeckRoom)
        {
            CreateStair(m_Core);
        }
        GenerateDeck();
        return(true);
    }
コード例 #2
0
    /// <summary>
    /// 移动建筑处理
    /// </summary>
    public void MoveBuild()
    {
        Int2    curMouseMoveGrid = GetMousePosGrid();
        Vector3 gridPos          = GetMouseGridPos() - m_v3TouchDownOffset;

        SetCenterByGridPos(gridPos);
        Int2 offsetGrid = curMouseMoveGrid - m_TouchDownGrid;
        Int2 iNew       = new Int2(m_TouchDownRoomGrid.Unit + offsetGrid.Unit * MapGrid.m_UnitRoomGridNum, m_TouchDownRoomGrid.Layer + offsetGrid.Layer);

        //判断是否移出界外
        if (curMouseMoveGrid == new Int2(-1, -1) ||
            m_Core.IsDeckRoom == false && iNew.Layer + m_Core.GetSize().Layer - 1 >= RoomMap.DeckRoomTopLayer && m_Core.m_type == ShipBuildType.BuildRoom)
        {
            m_LastMouseMoveGrid = curMouseMoveGrid;
            return;
        }
        if (RoomMap.CheckAllInMap(m_Core, iNew))
        {
            m_posMapGrid = iNew;
        }
        if (m_LastMouseMoveGrid != curMouseMoveGrid)
        {
            Int2 mapGrid = new Int2(curMouseMoveGrid.Unit * MapGrid.m_UnitRoomGridNum, curMouseMoveGrid.Layer);
            DoRoomExchange(mapGrid);             //同shape房间置换
            bool bCanPutTemp = PutCanvasM.CheckCanTempPut(m_Core, m_posMapGrid);
            if (bCanPutTemp)
            {
                MoveShipBuilding(m_posMapGrid);
            }
            if (m_Core.m_type == ShipBuildType.BuildRoom && !m_Core.IsDeckRoom)
            {
                GenerateDeckWithOutThis();
            }
            UpdateMyGridColor(bCanPutTemp);
        }
        m_LastMouseMoveGrid = curMouseMoveGrid;
        m_posPreMapGrid     = m_posMapGrid;
    }