private void Dragging(CartoonLongRotateView view_, CartoonRotate model_)
    {
        int exchanged_index = -1;

        switch (view_.m_dir)
        {
        case ENUM_ITEM_DIRECTION.E_LEFT:
            exchanged_index = CartoonUtil.GetLeftIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;

        case ENUM_ITEM_DIRECTION.E_UP:
            exchanged_index = CartoonUtil.GetUpIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;

        case ENUM_ITEM_DIRECTION.E_RIGHT:
            exchanged_index = CartoonUtil.GetRightIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;

        case ENUM_ITEM_DIRECTION.E_DOWN:
            exchanged_index = CartoonUtil.GetDownIndex(view_.Item_index, model_.m_width_unit, this.anchor_w_size, this.anchor_h_size);
            break;
        }

        if (-1 == exchanged_index)
        {
            return;
        }

        if (false == this.CanBeExchanged(exchanged_index))
        {
            return;
        }

        AnchorPos exchanged    = this.m_anchor_positions[exchanged_index];
        int       exchanged_id = exchanged.cur_ocuppied_cartoon_item_id;

        CartoonFixedView exchange_view = m_cartoon_views[exchanged_id];
        CartoonFixed     exchange_item = m_cartoon.m_cartoon_items[exchanged_id];

        //我的钉子点不动,尾巴被替换
        int my_tail_index = view_.Tail_index;
        int my_id         = model_.m_item_id;

        //来我的位置
        this.ChangeAnchorPos(exchange_view, exchange_item, my_tail_index, m_anchor_positions[my_tail_index].m_pos);

        //目的地记录换成我
        m_anchor_positions[exchanged_index].cur_ocuppied_cartoon_item_id = my_id;
        //我的anchor记录换成目的地的
        view_.Tail_index = exchanged_index;
    }
Beispiel #2
0
        //private bool CanDrag(CartoonLongRotateView view_, CartoonRotate model_, ENUM_ROTATE_DIR r_dir_)
        //{

        //    switch (view_.m_dir)
        //    {
        //        case ENUM_ITEM_DIRECTION.E_LEFT:
        //            {
        //                switch (r_dir_)
        //                {
        //                    case ENUM_ROTATE_DIR.E_CLOCKWISE:
        //                        {
        //                            //up
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_UP);
        //                        }
        //                    case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
        //                        {
        //                            //down
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_DOWN);
        //                        }
        //                }
        //            }
        //            break;
        //        case ENUM_ITEM_DIRECTION.E_UP:
        //            {
        //                switch (r_dir_)
        //                {
        //                    case ENUM_ROTATE_DIR.E_CLOCKWISE:
        //                        {
        //                            //right
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_RIGHT);
        //                        }
        //                    case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
        //                        {
        //                            //left
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_LEFT);
        //                        }
        //                }
        //            }
        //            break;
        //        case ENUM_ITEM_DIRECTION.E_RIGHT:
        //            {
        //                switch (r_dir_)
        //                {
        //                    case ENUM_ROTATE_DIR.E_CLOCKWISE:
        //                        {
        //                            //down
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_DOWN);
        //                        }
        //                    case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
        //                        {
        //                            //up
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_UP);
        //                        }
        //                }
        //            }
        //            break;
        //        case ENUM_ITEM_DIRECTION.E_DOWN:
        //            {
        //                switch (r_dir_)
        //                {
        //                    case ENUM_ROTATE_DIR.E_CLOCKWISE:
        //                        {
        //                            //left
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_LEFT);
        //                        }
        //                    case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
        //                        {
        //                            //right
        //                            return JudgeCanDrag(view_.Item_index, model_.m_width_unit, ENUM_ITEM_DIRECTION.E_RIGHT);
        //                        }
        //                }
        //            }
        //            break;

        //    }

        //    return false;
        //}


        private bool CanDrag(CartoonLongRotateView view_, CartoonRotate model_, ENUM_ROTATE_DIR r_dir_)
        {
            switch (view_.m_dir)
            {
            case ENUM_ITEM_DIRECTION.E_LEFT:
            {
                switch (r_dir_)
                {
                case ENUM_ROTATE_DIR.E_CLOCKWISE:
                {
                    //up
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_UP));
                }

                case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
                {
                    //down
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_DOWN));
                }
                }
            }
            break;

            case ENUM_ITEM_DIRECTION.E_UP:
            {
                switch (r_dir_)
                {
                case ENUM_ROTATE_DIR.E_CLOCKWISE:
                {
                    //right
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_RIGHT));
                }

                case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
                {
                    //left
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_LEFT));
                }
                }
            }
            break;

            case ENUM_ITEM_DIRECTION.E_RIGHT:
            {
                switch (r_dir_)
                {
                case ENUM_ROTATE_DIR.E_CLOCKWISE:
                {
                    //down
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_DOWN));
                }

                case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
                {
                    //up
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_UP));
                }
                }
            }
            break;

            case ENUM_ITEM_DIRECTION.E_DOWN:
            {
                switch (r_dir_)
                {
                case ENUM_ROTATE_DIR.E_CLOCKWISE:
                {
                    //left
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_LEFT));
                }

                case ENUM_ROTATE_DIR.E_ANTI_CLOCKWISE:
                {
                    //right
                    return(JudgeCanDrag(view_, ENUM_ITEM_DIRECTION.E_RIGHT));
                }
                }
            }
            break;
            }

            return(false);
        }
Beispiel #3
0
        private bool CanTurnAround(CartoonSquareRotateView view_, CartoonRotate model_, ENUM_ROTATE_DIR r_dir_)
        {
            int pre_idx = view_.Item_index - 1;

            while (pre_idx > 0)
            {
                if (this.m_anchor_positions[pre_idx].cur_ocuppied_cartoon_item_id != model_.m_item_id)
                {
                    //发现了前面的块

                    int          path      = 0;
                    CartoonFixed pre_model = this.m_cartoon.m_cartoon_items[this.m_anchor_positions[pre_idx].cur_ocuppied_cartoon_item_id];

                    List <int> pre_video_exits = new List <int>();
                    pre_video_exits.AddRange(pre_model.Video_entrance_2_exit.Values);
                    List <int> pre_door_indexes = pre_model.DoorIndexCopy;

                    List <int> cur_video_entrances = new List <int>();
                    cur_video_entrances.AddRange(model_.Video_entrance_2_exit.Keys);
                    List <int> cur_door_indexes = model_.DoorIndexCopy;

                    if (ENUM_ROTATE_DIR.E_CLOCKWISE == r_dir_)
                    {
                        CartoonUtil.ClockwiseRotate(cur_door_indexes);
                    }
                    else
                    {
                        CartoonUtil.AntiClockwiseRotate(cur_door_indexes);
                    }

                    //前一个块,有向右的出口3, 4 则本块8,7位必须有视频
                    //右侧两出口
                    int pre_right_out_3 = pre_door_indexes[2];
                    int pre_right_out_4 = pre_door_indexes[3];
                    if (pre_video_exits.Contains(pre_right_out_3))
                    {
                        //前一个块,有出口3
                        //检查本块是否有入口8的视频
                        int cur_left_in_8 = cur_door_indexes[7];
                        if (cur_video_entrances.Contains(cur_left_in_8))
                        {
                            ++path;
                        }
                    }
                    if (pre_video_exits.Contains(pre_right_out_4))
                    {
                        //前一个块,有出口4
                        //检查本块是否有入口7的视频
                        int cur_left_in_7 = cur_door_indexes[6];
                        if (cur_video_entrances.Contains(cur_left_in_7))
                        {
                            ++path;
                        }
                    }

                    //前一个块,有向上的出口1,2 则本块6,5位必须有视频

                    //上方两出口
                    int pre_up_out_1 = pre_door_indexes[0];
                    int pre_up_out_2 = pre_door_indexes[1];
                    if (pre_video_exits.Contains(pre_up_out_1))
                    {
                        //前一个块,有出口3
                        //检查本块是否有入口8的视频
                        int cur_down_in_6 = cur_door_indexes[5];
                        if (cur_video_entrances.Contains(cur_down_in_6))
                        {
                            ++path;
                        }
                    }
                    if (pre_video_exits.Contains(pre_up_out_2))
                    {
                        //前一个块,有出口4
                        //检查本块是否有入口7的视频
                        int cur_down_in_5 = cur_door_indexes[4];
                        if (cur_video_entrances.Contains(cur_down_in_5))
                        {
                            ++path;
                        }
                    }

                    //前一个块,有向下的出口6, 5 则本块1,2位必须有视频

                    //下方两出口
                    int pre_down_out_6 = pre_door_indexes[5];
                    int pre_down_out_5 = pre_door_indexes[4];
                    if (pre_video_exits.Contains(pre_down_out_6))
                    {
                        //前一个块,有出口3
                        //检查本块是否有入口8的视频
                        int cur_up_in_1 = cur_door_indexes[0];
                        if (cur_video_entrances.Contains(cur_up_in_1))
                        {
                            ++path;
                        }
                    }
                    if (pre_video_exits.Contains(pre_down_out_5))
                    {
                        //前一个块,有出口4
                        //检查本块是否有入口7的视频
                        int cur_up_in_2 = cur_door_indexes[1];
                        if (cur_video_entrances.Contains(cur_up_in_2))
                        {
                            ++path;
                        }
                    }

                    return(path > 0);
                }

                --pre_idx;
            }



            return(true);
        }