コード例 #1
0
ファイル: Playing.cs プロジェクト: isoundy000/chess_client
    void OnMouseDown()
    {
        if (!game.IsMyTurn())
        {
            return;
        }
        Debug.Log("!!!!!!  OnMouseDown ismyturn====>" + game.IsMyTurn().ToString());
        RowCol rowCol = GetRowCol(Input.mousePosition);

        // 选中的是自己的子
        if (game.IsMyCM(rowCol.row, rowCol.col))
        {
            selected_me.row = rowCol.row;
            selected_me.col = rowCol.col;
            is_selected     = true;
            show_selector(selected_me_obj, selected_me.row, selected_me.col);
            click_ogg.Play();
            Debug.Log(String.Format("select {0} {1}", rowCol.row, rowCol.col));
            return;
        }
        if (!is_selected)
        {
            return;
        }
        if (selected_me.row == 0)
        {
            return;
        }

        // 选了子,检查能不能走
        if (!game.CanMove(selected_me.row, selected_me.col, rowCol.row, rowCol.col))
        {
            return;
        }

        Table.MoveReq req = new Table.MoveReq();
        req.move      = new Table.Move();
        req.move.srow = selected_me.row;
        req.move.scol = selected_me.col;
        req.move.drow = rowCol.row;
        req.move.dcol = rowCol.col;

        if (game.is_red == false)
        {
            req.move.srow = 11 - req.move.srow;
            req.move.drow = 11 - req.move.drow;
            req.move.scol = 10 - req.move.scol;
            req.move.dcol = 10 - req.move.dcol;
        }
        Debug.Log(String.Format("move src{0} {1} dst{2} {3}", req.move.srow, req.move.scol, req.move.drow, req.move.dcol));
        network.WriteMsg("Table.MoveReq", req);
        //发送之后置空不是必然嘛。
        selected_me.row = 0;
        selected_me.col = 0;
        //应该等同步消息接收完成之后在转换方式
        //game.ChangeMyTurn ();
    }
コード例 #2
0
    private void onClick(BaseEventData arg0)
    {
        if (!game.IsMyTurn())
        {
            return;
        }
        PointerEventData e = arg0 as PointerEventData;

        Debug.Log(String.Format("click {0}", e.position));

        RowCol rowCol = GetRowCol(e.position);

        if (rowCol.row <= 0 || rowCol.row > 10 || rowCol.col <= 0 || rowCol.col > 9)
        {
            return;
        }

        // 选中的是自己的子
        if (game.IsMyCM(rowCol.row, rowCol.col))
        {
            select_1.transform.localPosition = GetPos(rowCol.row, rowCol.col);
            select_1.SetActive(true);
            select_2.SetActive(false);
            selected_me = rowCol;
            //click_ogg.Play ();
            Debug.Log(String.Format("select {0} {1}", rowCol.row, rowCol.col));
            return;
        }

        if (selected_me.row == 0)
        {
            return;
        }

        // 选了子,检查能不能走
        if (!game.CanMove(selected_me.row, selected_me.col, rowCol.row, rowCol.col))
        {
            return;
        }

        Table.MoveReq req = new Table.MoveReq();
        req.move        = new Table.Move();
        req.move.srow   = selected_me.row;
        req.move.scol   = selected_me.col;
        req.move.drow   = rowCol.row;
        req.move.dcol   = rowCol.col;
        selected_me.row = 0;

        Debug.Log(String.Format("move src{0} {1} dst{2} {3}", req.move.srow, req.move.scol, req.move.drow, req.move.dcol));
        network.WriteMsg("Table.MoveReq", req);
    }
コード例 #3
0
    void OnMouseDown()
    {
        if (!game.IsMyTurn())
        {
            return;
        }

        RowCol rowCol = GetRowCol(Input.mousePosition);

        // 选中的是自己的子
        if (game.IsMyCM(rowCol.row, rowCol.col))
        {
            selected_me.row = rowCol.row;
            selected_me.col = rowCol.col;
            show_selector(selected_me_obj, selected_me.row, selected_me.col);
            click_ogg.Play();
            Debug.Log(String.Format("select {0} {1}", rowCol.row, rowCol.col));
            return;
        }

        if (selected_me.row == 0)
        {
            return;
        }

        // 选了子,检查能不能走
        if (!game.CanMove(selected_me.row, selected_me.col, rowCol.row, rowCol.col))
        {
            return;
        }

        Table.MoveReq req = new Table.MoveReq();
        req.move      = new Table.Move();
        req.move.srow = selected_me.row;
        req.move.scol = selected_me.col;
        req.move.drow = rowCol.row;
        req.move.dcol = rowCol.col;

        if (game.is_red == false)
        {
            req.move.srow = 11 - req.move.srow;
            req.move.drow = 11 - req.move.drow;
            req.move.scol = 10 - req.move.scol;
            req.move.dcol = 10 - req.move.dcol;
        }
        Debug.Log(String.Format("move src{0} {1} dst{2} {3}", req.move.srow, req.move.scol, req.move.drow, req.move.dcol));
        network.WriteMsg("Table.MoveReq", req);
    }
コード例 #4
0
    void OnMouseDown()
    {
        if (!game.IsMyTurn())
        {
            return;
        }

        RowCol rowCol = GetRowCol(Input.mousePosition);

        // 选中的是自己的子
        if (game.IsMyCM(rowCol.row, rowCol.col))
        {
            selected_me.row = rowCol.row;
            selected_me.col = rowCol.col;
            selected_me_obj.transform.SetPositionAndRotation(GetPos(rowCol.row, rowCol.col), Quaternion.identity);
            click_ogg.Play();
            Debug.Log(String.Format("select {0} {1}", rowCol.row, rowCol.col));
            return;
        }

        if (selected_me.row == 0)
        {
            return;
        }

        // 选了子,检查能不能走
        if (!game.CanMove(selected_me.row, selected_me.col, rowCol.row, rowCol.col))
        {
            return;
        }

        Table.MoveReq req = new Table.MoveReq();
        req.move      = new Table.Move();
        req.move.srow = selected_me.row;
        req.move.scol = selected_me.col;
        req.move.drow = rowCol.row;
        req.move.dcol = rowCol.col;

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

        network.WriteMsg("Table.MoveReq", req);
    }