示例#1
0
    void onMoveNotify(NetWork.Msg msg)
    {
        Table.MoveNotify notify = (Table.MoveNotify)msg.body;
        Table.Move       mv     = notify.move;

        if (game.is_red == false)
        {
            Debug.Log("move notify not red");
            mv.srow = 11 - mv.srow;
            mv.drow = 11 - mv.drow;
        }

        int index = (mv.srow - 1) * 9 + mv.scol - 1;
        // 遍历棋子,找到
        GameObject cm = cms[index];

        Single  r       = 0.89f;
        Vector3 old_pos = cm.transform.position;
        Vector3 pos     = new Vector3(old_pos.x + (mv.dcol - mv.scol) * r, old_pos.y + (mv.drow - mv.srow) * -r, 0);

        cm.transform.position = pos;
        game.Move(mv.srow, mv.scol, mv.drow, mv.dcol);

        selected_me.row = 0;
    }
示例#2
0
    void onMoveNotify(NetWork.Msg msg)
    {
        Table.MoveNotify notify = (Table.MoveNotify)msg.body;
        Table.Move       mv     = notify.move;

        // 干掉目标棋子
        for (int i = 0; i < chesses.Count; ++i)
        {
            if (chesses[i].row == mv.drow && chesses[i].col == mv.dcol && chesses[i].visiable)
            {
                chesses[i].visiable = false;
                chesses[i].o.SetActive(false);
                break;
            }
        }
        // 移动待源棋子
        for (int i = 0; i < chesses.Count; ++i)
        {
            if (chesses[i].row == mv.srow && chesses[i].col == mv.scol && chesses[i].visiable)
            {
                chesses[i].row = mv.drow;
                chesses[i].col = mv.dcol;
                chesses[i].o.transform.localPosition = GetPos(mv.drow, mv.dcol);
                break;
            }
        }
        // select_1 select_2设置
        select_1.transform.localPosition = GetPos(mv.srow, mv.scol);
        select_2.transform.localPosition = GetPos(mv.drow, mv.dcol);
        select_1.SetActive(true);
        select_2.SetActive(true);
        selected_me.row = 0;

        game.Move(mv.srow, mv.scol, mv.drow, mv.dcol);
    }
示例#3
0
    void onMoveNotify(NetWork.Msg msg)
    {
        Debug.Log("onMoveNotify....");
        Table.MoveNotify notify = (Table.MoveNotify)msg.body;
        Table.Move       mv     = notify.move;


        if (game.is_red == false)
        {
            mv.srow = 11 - mv.srow;
            mv.drow = 11 - mv.drow;
            mv.scol = 10 - mv.scol;
            mv.dcol = 10 - mv.dcol;
        }

        Single     r         = 0.89f;
        int        src_index = (mv.srow - 1) * 9 + mv.scol - 1;
        GameObject src_cm    = cms[src_index];
        Vector3    old_pos   = src_cm.transform.position;
        Vector3    pos       = new Vector3(old_pos.x + (mv.dcol - mv.scol) * r, old_pos.y + (mv.drow - mv.srow) * -r, 0);

        src_cm.transform.position = pos;

        int        dst_index = (mv.drow - 1) * 9 + mv.dcol - 1;
        GameObject dst_cm    = cms[dst_index];

        if (dst_cm != null)
        {
            hide_selector(dst_cm);
        }
        cms [dst_index] = src_cm;
        cms [src_index] = null;
        if (game.IsRedCM(mv.srow, mv.scol))
        {
            show_selector(red_move_src, mv.srow, mv.scol);
            show_selector(red_move_dst, mv.drow, mv.dcol);
            hide_selector(black_move_src);
            hide_selector(black_move_dst);
        }
        else
        {
            show_selector(black_move_src, mv.srow, mv.scol);
            show_selector(black_move_dst, mv.drow, mv.dcol);
            hide_selector(red_move_src);
            hide_selector(red_move_dst);
        }
        //恢复设置一下
        selected_me.row = 0;
        selected_me.col = 0;
        is_selected     = false;
        hide_selector(selected_me_obj);
        game.Move(mv.srow, mv.scol, mv.drow, mv.dcol);
        Debug.Log("!!!!!!  OnMouseDown ismyturn====>" + game.IsMyTurn().ToString());
        //Move中有改变
        //game.ChangeMyTurn ();
    }
示例#4
0
    void onMoveNotify(NetWork.Msg msg)
    {
        Table.MoveNotify notify = (Table.MoveNotify)msg.body;
        Table.Move       mv     = notify.move;


        if (game.is_red == false)
        {
            mv.srow = 11 - mv.srow;
            mv.drow = 11 - mv.drow;
            mv.scol = 10 - mv.scol;
            mv.dcol = 10 - mv.dcol;
        }

        Single     r         = 0.89f;
        int        src_index = (mv.srow - 1) * 9 + mv.scol - 1;
        GameObject src_cm    = cms[src_index];
        Vector3    old_pos   = src_cm.transform.position;
        Vector3    pos       = new Vector3(old_pos.x + (mv.dcol - mv.scol) * r, old_pos.y + (mv.drow - mv.srow) * -r, 0);

        src_cm.transform.position = pos;

        int dst_index = (mv.drow - 1) * 9 + mv.dcol - 1;

        Debug.Log("dst index: " + dst_index);
        GameObject dst_cm = cms[dst_index];

        if (dst_cm != null)
        {
            hide_selector(dst_cm);
        }
        cms [dst_index] = src_cm;
        cms [src_index] = null;
        if (game.IsRedCM(mv.srow, mv.scol))
        {
            show_selector(red_move_src, mv.srow, mv.scol);
            show_selector(red_move_dst, mv.drow, mv.dcol);
            hide_selector(black_move_src);
            hide_selector(black_move_dst);
        }
        else
        {
            show_selector(black_move_src, mv.srow, mv.scol);
            show_selector(black_move_dst, mv.drow, mv.dcol);
            hide_selector(red_move_src);
            hide_selector(red_move_dst);
        }
        selected_me.row = 0;
        hide_selector(selected_me_obj);
        game.Move(mv.srow, mv.scol, mv.drow, mv.dcol);
    }