예제 #1
0
    /// <summary>
    /// 新增船只建筑,兵,加入。
    /// </summary>
    public static void JointShipBuild(TouchMove touch)
    {
        if (touch == null || touch.MyCore() == null)
        {
            Debug.LogError("船只摆设数据加入有误,请调查");
            return;
        }

        if (CheckHaveBuild(touch.MyCore()) == false)
        {
            m_Build.Add(touch);
            if (!touch.MyCore().IsNewCreate)
            {
                PutCanvasM.AddNewCore(touch.MyCore(), touch.m_posMapGrid);
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 设置移动到船上
    /// </summary>
    public static void MoveToShip(CanvasCore Core)
    {
        TouchMove tm = GetShipBuild(Core);

        if (tm != null)
        {
            tm.MyCore().IsNewCreate = false;
        }
    }
예제 #3
0
    /// <summary>
    /// 获取建筑对应的gird位置.
    /// </summary>
    /// <returns>The all build grid position.</returns>
    public static List <TouchMove> GetAllBuildOutShape()
    {
        List <TouchMove> tmList = new List <TouchMove>();

        for (int i = 0; i < m_Build.Count; i++)
        {
            TouchMove tm = m_Build[i];
            if (tm && tm.MyCore() != null && tm.MyCore().m_type != ShipBuildType.BuildStair)
            {
                List <Int2> l = tm.MyCore().GetPutRoomGridPos();
                foreach (Int2 item in l)
                {
                    if (item.Layer >= RoomMap.RealMapSize.Layer || item.Unit >= RoomMap.RealMapSize.Unit)
                    {
                        tmList.Add(tm);
                    }
                }
            }
        }
        return(tmList);
    }
예제 #4
0
    public static List <TouchMove> GetDeckBuildListInMaxLayer()
    {
        List <TouchMove> tmList = new List <TouchMove>();

        for (int i = 0; i < m_Build.Count; i++)
        {
            TouchMove tm = m_Build[i];
            if (tm && tm.MyCore() != null && tm.MyCore().m_type == ShipBuildType.BuildRoom &&
                !tm.MyCore().IsDeckRoom)
            {
                List <Int2> l = tm.MyCore().GetPutRoomGridPos();
                foreach (Int2 item in l)
                {
                    if (item.Layer == RoomMap.RealMapSize.Layer - 1)
                    {
                        tmList.Add(tm);
                    }
                }
            }
        }
        return(tmList);
    }
예제 #5
0
    /// <summary>
    /// 添加编辑建筑配件
    /// </summary>
    /// <returns></returns>
    private static void AddBuildingEditPlugin(TouchMove touch)
    {
        if (touch == null)
        {
            return;
        }
        GameObject selectEffectParent = null;

        selectEffectParent = new GameObject("SelectEffectParent");
        selectEffectParent.transform.parent        = touch.gameObject.transform.parent;
        selectEffectParent.transform.localPosition = new Vector3(0, 0, -1);
        selectEffectParent.transform.localRotation = touch.gameObject.transform.parent.localRotation;
        if (touch.MyCore().m_type == ShipBuildType.Soldier)
        {
            selectEffectParent.transform.localPosition = new Vector3(-RoomGrid.m_width / 2.0f, 0, -1);
        }
        else if (touch.MyCore().m_type == ShipBuildType.BuildStair)
        {
            selectEffectParent.transform.localPosition = new Vector3(0, RoomGrid.m_heigth / 2.0f + 0.3f, -1);
        }
        touch.SetPlugin(selectEffectParent);
    }
예제 #6
0
    public static void PutDownNewBuild()
    {
        TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove();

        if (null != curTouchMove)
        {
            if (curTouchMove.MyCore().IsNewCreate)
            {
                bool canput = curTouchMove.MoveBuildUp();
                if (canput == false)
                {
                    curTouchMove.DestroyShipBuild();
                }
            }
        }
    }
예제 #7
0
 /// <summary>
 /// 房间置换
 /// </summary>
 void DoRoomExchange(Int2 mapGrid)
 {
     if (m_Core.m_type == ShipBuildType.BuildStair)
     {
         return;
     }
     if (!m_Core.IsNewCreate)
     {
         TouchMove tmCurExchange = m_ExchangeTouch;
         if (null != tmCurExchange)
         {
             if (m_ExchangeTouch.MyCore().IsDeckRoom == MyCore().IsDeckRoom&& m_ExchangeTouch.MyCore().m_type == ShipBuildType.BuildRoom && MyCore().m_type == ShipBuildType.BuildRoom)
             {
                 PutCanvasM.ExchangeRoom(m_ExchangeTouch.MyCore(), m_ExchangeTouch.m_orgPosMapGrid, MyCore(), m_orgPosMapGrid);
             }
             else
             {
                 m_ExchangeTouch.MoveShipBuilding(m_ExchangeTouch.m_orgPosMapGrid);
                 MoveShipBuilding(m_orgPosMapGrid);
             }
         }
         CanvasCore core = RoomMap.FindCanvasCore(mapGrid, m_Core.m_type);
         if (core != null && core.m_ID != m_Core.m_ID)
         {
             bool b = PutCanvasM.CheckExchange(m_Core, core);
             if (b)
             {
                 TouchMove tmNew = PutCanvasM.GetTouchMoveByCore(core);
                 if (tmNew != null)
                 {
                     m_ExchangeTouch = tmNew;
                     if (m_ExchangeTouch.MyCore().IsDeckRoom == MyCore().IsDeckRoom&& m_ExchangeTouch.MyCore().m_type == ShipBuildType.BuildRoom && MyCore().m_type == ShipBuildType.BuildRoom)
                     {
                         PutCanvasM.ExchangeRoom(m_ExchangeTouch.MyCore(), m_orgPosMapGrid, MyCore(), m_posMapGrid);
                     }
                     else
                     {
                         m_ExchangeTouch.MoveShipBuilding(m_orgPosMapGrid);
                         MoveShipBuilding(m_posMapGrid);
                     }
                     if (m_ExchangeTouch != tmCurExchange)
                     {
                         m_ExchangeTouch.ExchangeAnimation(m_orgPosMapGrid);
                     }
                 }
             }
             else
             {
                 m_ExchangeTouch = null;
             }
         }
         else
         {
             m_ExchangeTouch = null;
         }
         if (null != tmCurExchange && m_ExchangeTouch != tmCurExchange)
         {
             //MoveShipBuilding (m_posMapGrid);
             tmCurExchange.MoveShipBuilding(tmCurExchange.m_orgPosMapGrid);
             tmCurExchange.ResetExchangePos();
         }
     }
 }
예제 #8
0
    void OnMouseDown()
    {
        if (PutCanvasM.CanOperate == false)
        {
            return;
        }

        RaycastHit hit;

        if (WndManager.IsHitNGUI(out hit))//当点击到UI时不做处理
        {
            return;
        }
        if (Input.touchCount >= 2)
        {
            return;
        }
        m_bMouseDown       = true;
        m_bLongTouch       = false;
        m_bTouchMoveChange = true;
        m_fMouseDownTime   = Time.time;
        m_vtotalmouseDelta = Vector2.zero;
        m_vlastFirstTouch  = GetTouchPos(0);
        m_isDrag           = false;
        if (SystemInfo.deviceType == DeviceType.Desktop)
        {
            m_v3MouseTouchDown = Input.mousePosition;
        }
        else
        {
            m_v3MouseTouchDown = Input.GetTouch(0).position;
        }

        //获取按下时画布格子
        Vector3 m_v3TouchScreenPos = new Vector3(m_v3MouseTouchDown.x, m_v3MouseTouchDown.y, -Camera.main.transform.position.z);
        Vector3 m_v3TouchWorldPos  = Camera.main.ScreenToWorldPoint(m_v3TouchScreenPos);
        Vector3 v3dLocalPos        = BattleEnvironmentM.World2LocalPos(m_v3TouchWorldPos);

        m_roomGridTouchDown = RoomMap.FindRoomGrid(v3dLocalPos);
        if (m_roomGridTouchDown == null)
        {
            return;
        }
        m_curClickType = RoomMap.PickupShipBuildType(m_roomGridTouchDown, v3dLocalPos, m_roomGridTouchDown.mPosRoomGrid.Layer);

        CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom();

        if (TouchMove.g_bSetParaing == true)
        {
            return;
        }

        TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove();

        if (null != curTouchMove)
        {
            //如果当前选中的是房间,新选中的不管是什么都不做变更
            //如果当前选中的不是房间,但是新选中的对象和当前选中的一样则也不变量。
            if (curTouchMove.IsContainsRoomGrid(m_roomGridTouchDown))
            {
                TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByRoomGrid(m_roomGridTouchDown, m_curClickType);
                if (curTouchMove.MyCore().m_type == ShipBuildType.BuildRoom ||
                    selNewTouchMov != null && selNewTouchMov == curTouchMove)
                {
                    curTouchMove.PlayEditSelectAnimationEnd();                                     //恢复上个房间内陷阱/角色 动画
                    curTouchMove.OnMouseDown();
                    m_bTouchMoveChange = false;
                }
            }
            PutCanvasM.ClearNoLinkList();
        }
        else
        {
            //判断选中物件是否在上次保存失败的物件上,如果是则直接选择
            bool bInNoLinkList = false;
            if (buildRoomCoreTouchDown != null)
            {
                TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByCore(buildRoomCoreTouchDown);
                if (null == selNewTouchMov)
                {
                    List <CanvasCore> childCores = m_roomGridTouchDown.GetOtherBuild();
                    for (int i = 0; i < childCores.Count; i++)
                    {
                        selNewTouchMov = PutCanvasM.GetTouchMoveByCore(childCores[i]);
                        break;
                    }
                }
                if (null != selNewTouchMov && PutCanvasM.NoLinkListContain(selNewTouchMov.MyCore()))
                {
                    PutCanvasM.ClearNoLinkList();
                    TouchMoveManager.SetCurTouchMove(selNewTouchMov);
                    selNewTouchMov.PlayEditSelectAnimationEnd();                     //恢复上个房间内陷阱/角色 动画
                    selNewTouchMov.OnMouseDown();
                    m_bTouchMoveChange = false;
                    bInNoLinkList      = true;
                }
            }
            if (bInNoLinkList == false)
            {
                PutCanvasM.ClearNoLinkList();
            }
        }
    }
예제 #9
0
    void OnMouseUp()
    {
        if (!m_bMouseDown || PutCanvasM.CanOperate == false)
        {
            return;
        }
        m_bMouseDown = false;
        bool bCancelSel = false;
//        MainCameraM.s_Instance.EnableDrag(true);
        TouchMove selNewTouchMov = null;

        if (TouchMove.g_bSetParaing == true)
        {
            SetPara();
            return;
        }
        if (m_bTouchMoveChange)
        {
            if (m_roomGridTouchDown != null)
            {
                bCancelSel     = true;
                selNewTouchMov = PutCanvasM.GetTouchMoveByRoomGrid(m_roomGridTouchDown, m_curClickType);
                if (null == selNewTouchMov)
                {
                    CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom();
                    selNewTouchMov = PutCanvasM.GetTouchMoveByCore(buildRoomCoreTouchDown);
                }
                if (selNewTouchMov)
                {
                    CanvasCore selCanvasCore = selNewTouchMov.MyCore();
                    bCancelSel = false;
                    TouchMove selOldeTouchMove = TouchMoveManager.GetCurTouchMove();
                    selNewTouchMov.PlayEditSelectAnimation();//点选时播放房间内陷阱动画
                    TouchMoveManager.SetCurTouchMove(selNewTouchMov);
                    selNewTouchMov.MoveWithRoom(selCanvasCore);
                }
                if (bCancelSel)
                {
                    TouchMoveManager.SetCurTouchMove(null);
                }
            }
        }
        else
        {
            selNewTouchMov = TouchMoveManager.GetCurTouchMove();
        }
        if (selNewTouchMov)
        {
            if (selNewTouchMov.MoveBuildUp())
            {
                //TouchMoveManager.ShowCanvas(false);
                PutCanvasM.ShowRoomGridUI(true);
            }
            else
            {
                PutCanvasM.ShowRoomGridUI(true);
            }
        }
        else
        {
            TouchMoveManager.SetCurTouchMove(null);
            //TouchMoveManager.ShowCanvas(false);
            PutCanvasM.ShowRoomGridUI(true);
        }
    }
예제 #10
0
    /// <summary>
    /// 确认房间是否可置换
    /// </summary>
    public static bool CheckExchange(CanvasCore coreSrc, CanvasCore coreExchange)
    {
        if (coreSrc == null || coreExchange == null)
        {
            return(false);
        }
        if (coreSrc.m_ID == coreExchange.m_ID)
        {
            return(false);
        }
        if (coreSrc.m_type == ShipBuildType.BuildStair)
        {
            return(false);
        }
        if (coreSrc.m_type != coreExchange.m_type)
        {
            return(false);
        }
        if (coreSrc.Data == null || coreExchange.Data == null)
        {
            return(false);
        }
        if (coreSrc.m_type == ShipBuildType.Soldier)
        {
            return(true);
        }
        if (coreSrc.Data.m_DeckRoom != coreExchange.Data.m_DeckRoom)
        {
            return(false);
        }
        TouchMove tmSrc      = PutCanvasM.GetTouchMoveByCore(coreSrc);
        TouchMove tmExchange = PutCanvasM.GetTouchMoveByCore(coreExchange);

        if (tmSrc == null || tmExchange == null)
        {
            return(false);
        }
        if (tmSrc.m_orgPosMapGrid.Layer + tmExchange.MyCore().GetSize().Layer - 1 >= RoomMap.DeckRoomTopLayer)
        {
            return(false);
        }

        List <RoomGrid> listRoomGridSrc       = RoomMap.GetPutRoomGrid(coreSrc);
        List <RoomGrid> listMovetoRoomGridSrc = RoomMap.GetMovetoRoomGrid(coreSrc, tmSrc.m_posMapGrid);

        if (listRoomGridSrc.Count != listMovetoRoomGridSrc.Count)
        {
            return(false);
        }
        List <RoomGrid> listRoomGridExchange     = RoomMap.GetPutRoomGrid(coreExchange);
        List <RoomGrid> listMoveRoomGridExchange = RoomMap.GetMovetoRoomGrid(coreExchange, tmSrc.m_orgPosMapGrid);

        if (listRoomGridExchange.Count != listMoveRoomGridExchange.Count)
        {
            return(false);
        }

        int nMoveToCount = listMovetoRoomGridSrc.Count;
        int nMoveCnt     = 0;

        for (nMoveCnt = 0; nMoveCnt < nMoveToCount; nMoveCnt++)
        {
            RoomGrid roomGrid = listMovetoRoomGridSrc[nMoveCnt];
            if (listMoveRoomGridExchange.Contains(roomGrid))
            {
                return(false);
            }
            CanvasCore buildCore = roomGrid.GetBuildRoom();
            if (buildCore.m_ID != RoomGrid.EMPTYGRIDID && buildCore.m_ID != coreSrc.m_ID && buildCore.m_ID != coreExchange.m_ID)
            {
                return(false);
            }
            if (buildCore.m_ID == RoomGrid.EMPTYGRIDID)
            {
                List <CanvasCore> childrenCore = roomGrid.GetOtherBuild();
                foreach (CanvasCore childCore in childrenCore)
                {
                    if (childCore.m_type == ShipBuildType.Soldier)
                    {
                        return(false);
                    }
                }
            }
        }
        nMoveToCount = listMoveRoomGridExchange.Count;
        for (nMoveCnt = 0; nMoveCnt < nMoveToCount; nMoveCnt++)
        {
            RoomGrid roomGrid = listMoveRoomGridExchange[nMoveCnt];
            if (listMovetoRoomGridSrc.Contains(roomGrid))
            {
                return(false);
            }
            CanvasCore buildCore = roomGrid.GetBuildRoom();
            if (buildCore.m_ID != RoomGrid.EMPTYGRIDID && buildCore.m_ID != coreExchange.m_ID && buildCore.m_ID != coreSrc.m_ID)
            {
                return(false);
            }
        }

        return(true);//ShipPutInfo.CheckExchangeRoom(core1.Data ,core2.Data);
    }