예제 #1
0
        private bool JudgeCanDrag(int view_index_, int model_width, ENUM_ITEM_DIRECTION neighbour_dir)
        {
            int neighbour_index = -1;

            switch (neighbour_dir)
            {
            case ENUM_ITEM_DIRECTION.E_UP:
                neighbour_index = CartoonUtil.GetUpIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;

            case ENUM_ITEM_DIRECTION.E_DOWN:
                neighbour_index = CartoonUtil.GetDownIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;

            case ENUM_ITEM_DIRECTION.E_LEFT:
                neighbour_index = CartoonUtil.GetLeftIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;

            case ENUM_ITEM_DIRECTION.E_RIGHT:
                neighbour_index = CartoonUtil.GetRightIndex(view_index_, model_width, this.anchor_w_size, this.anchor_h_size);
                break;
            }

            if (-1 == neighbour_index)
            {
                return(false);
            }

            return(CanBeExchanged(neighbour_index));
        }
예제 #2
0
    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;
    }
예제 #3
0
    public override List <int> SetAnchorPosAndReturnOccupyIndex(Vector2 anchor_pos_, int index_, int w_, int h_)
    {
        if (ENUM_ITEM_DIRECTION.E_LEFT == this.m_dir)
        {
            if (index_ % w_ <= w_ - this.m_model.m_width_unit)
            {
                this.Item_index = CartoonUtil.GetRightIndex(index_, this.m_model.m_width_unit, w_, h_);
                this.m_rect.anchoredPosition = new Vector2(anchor_pos_.x + (this.m_model.m_width_unit - 1) * (this.m_rect.sizeDelta.x / this.m_model.m_width_unit), anchor_pos_.y);

                List <int> ret = new List <int>();

                ret.Add(this.Item_index);
                ret.Add(index_);



                this.Tail_index = ret.Last();
                return(ret);
            }
            Debug.LogError(string.Format("序号{0} 指向左侧的转动长方形,位置摆放错误", index_));
        }
        else if (ENUM_ITEM_DIRECTION.E_UP == this.m_dir)
        {
            if (index_ / w_ <= h_ - this.m_model.m_width_unit)
            {
                this.Item_index = CartoonUtil.GetDownIndex(index_, this.m_model.m_width_unit, w_, h_);
                this.m_rect.anchoredPosition = new Vector2(anchor_pos_.x, anchor_pos_.y - (this.m_model.m_width_unit - 1) * (this.m_rect.sizeDelta.x / this.m_model.m_width_unit));

                List <int> ret = new List <int>();

                ret.Add(this.Item_index);
                ret.Add(index_);


                this.Tail_index = ret.Last();
                return(ret);
            }
        }
        else if (ENUM_ITEM_DIRECTION.E_RIGHT == this.m_dir)
        {
            if (index_ % w_ <= w_ - this.m_model.m_width_unit)
            {
                this.Item_index = index_;
                this.m_rect.anchoredPosition = anchor_pos_;

                List <int> ret = new List <int>();


                ret.Add(this.Item_index);
                ret.Add(CartoonUtil.GetRightIndex(index_, this.m_model.m_width_unit, w_, h_));


                this.Tail_index = ret.Last();
                return(ret);
            }
        }
        else if (ENUM_ITEM_DIRECTION.E_DOWN == this.m_dir)
        {
            if (index_ / w_ <= h_ - this.m_model.m_width_unit)
            {
                this.Item_index = index_;
                this.m_rect.anchoredPosition = anchor_pos_;

                List <int> ret = new List <int>();

                ret.Add(this.Item_index);
                ret.Add(CartoonUtil.GetDownIndex(index_, this.m_model.m_width_unit, w_, h_));


                this.Tail_index = ret.Last();
                return(ret);
            }
        }

        return(null);
    }