Esempio n. 1
0
    public void chessDone(BLOKUSChessDoneInfo chessDoneInfo)
    {
        lock (CHESS_DONE_LOCK) {
            Debug.Log("show dao************************************************************");
            Square oweSquare = (Square)allSquare[chessDoneInfo.squareName];

            if (oweSquare.color != CurrentColor)
            {
                return;
            }

            int oldRF = oweSquare.rotationFlag;
            int oldSF = oweSquare.symmetryFlag;
            oweSquare.rotationFlag = chessDoneInfo.rotationFlag;
            oweSquare.symmetryFlag = chessDoneInfo.symmetryFlag;
            int x = chessDoneInfo.x;
            int y = chessDoneInfo.y;
            oweSquare.set(x + 0.5f, -(y + 0.5f));
            Destroy(currentCenter);
            print("实例化");
            currentCenter = Instantiate(currentCenterPrefab, new Vector2((float)(x + 0.5), -(float)(y + 0.5)), Quaternion.identity); //中心 图片转换
            GameObject.Find("BlokusUIController").GetComponent <BlokusUIController>().playChessDoneMusic();
            updateChess(x, y, chessDoneInfo.model, oweSquare.color);
            isSelect = false;
            changeCurrentColor();
            //GameObject.Find("Canvas").GetComponent<ChoosePanel>().setPanelColor();//切换画板

            if (firstFour > 0)
            {
                firstFour--;
            }
            oweSquare.rotationFlag = oldRF;
            oweSquare.symmetryFlag = oldSF;
        }
    }
Esempio n. 2
0
 public static MessageBean formatChessDoneMessage(BLOKUSChessDoneInfo chessDoneInfoTemp) {
     MessageBean message = new MessageBean();
     message.operationCode = OperationCode.CHESS_DONE;
     message.statusCode = StatusCode.SUCCESS;
     message.data = ProtobufHelper.SerializerToBytes(chessDoneInfoTemp);
     return message;
 }
Esempio n. 3
0
    private void judgeAround(int x, int y)
    {
        bool judgeSuccess = false;
        int  lastX        = x;
        int  lastY        = y;

        if (judgeOverall(x, y))
        {
            judgeSuccess = true;
        }
        else
        {
            foreach (ChessPoint point in getAroundPoints(x, y))
            {
                if (judgeOverall(point.x, point.y))
                {
                    judgeSuccess = true;
                    lastX        = point.x;
                    lastY        = point.y;
                    break;
                }
            }
        }

        if (judgeSuccess)
        {
            MessageBean         message       = MessageFormater.formatChessDoneMessage(lastX, lastY, CurrentSquareName, CurrentSquare.rotationFlag, CurrentSquare.symmetryFlag, CurrentSquare.model);
            BLOKUSChessDoneInfo chessDoneInfo = ProtobufHelper.DederializerFromBytes <BLOKUSChessDoneInfo>(message.data);
            GameObject.Find("BlokusUIController").GetComponent <BlokusUIController>().tryChess(chessDoneInfo);
            //  chessDone(chessDoneInfo);
        }
    }
Esempio n. 4
0
 private void chessDone(MessageBean message)
 {
     if (message.statusCode == StatusCode.SUCCESS)
     {
         BLOKUSChessDoneInfo bLOKUSChessDoneInfo = ProtobufHelper.DederializerFromBytes <BLOKUSChessDoneInfo>(message.data);
         GameObject.Find("BlokusController").SendMessage("chessDone", bLOKUSChessDoneInfo);
     }
 }
Esempio n. 5
0
    public static MessageBean formatChessDoneMessage(int x, int y, string currentSquareName, int rotationFlag, int symmetryFlag, int[,] model) {

        MessageBean message = new MessageBean();
        message.operationCode = OperationCode.CHESS_DONE;
        message.statusCode = StatusCode.SUCCESS;

        BLOKUSChessDoneInfo chessDoneInfo = new BLOKUSChessDoneInfo();
        chessDoneInfo.x = x;
        chessDoneInfo.y = y;
        chessDoneInfo.squareName = currentSquareName;
        chessDoneInfo.rotationFlag = rotationFlag;
        chessDoneInfo.symmetryFlag = symmetryFlag;
        chessDoneInfo.model = getModelBytes(model);
        message.data = ProtobufHelper.SerializerToBytes(chessDoneInfo);
        return message;
    }
Esempio n. 6
0
 internal void chessDoneOutSide(BLOKUSChessDoneInfo chessDoneInfoTemp, bool sure)
 {
     Destroy(currentCenterTemp);
     Destroy(tempSquare);
     if (sure)
     {
         lock (SURE_LOCK) {
             if (CurrentColor == myColor)
             {
                 GameObject.Find("Canvas").GetComponent <ChoosePanel>().DestoryBtn();
                 NetManager.Instance.TransferMessage(MessageFormater.formatChessDoneMessage(chessDoneInfoTemp));
                 chessDone(chessDoneInfoTemp);
             }
         }
     }
 }
Esempio n. 7
0
    public void tryChess(BLOKUSChessDoneInfo chessDoneInfo)
    {
        Square oweSquare = (Square)allSquare[chessDoneInfo.squareName];
        int    oldRF     = oweSquare.rotationFlag;
        int    oldSF     = oweSquare.symmetryFlag;

        oweSquare.rotationFlag = chessDoneInfo.rotationFlag;
        oweSquare.symmetryFlag = chessDoneInfo.symmetryFlag;
        int x = chessDoneInfo.x;
        int y = chessDoneInfo.y;

        Destroy(tempSquare);
        tempSquare = oweSquare.trySet(x + 0.5f, -(y + 0.5f));
        Destroy(currentCenterTemp);
        print("实例化");
        currentCenterTemp = Instantiate(tempCenterPrefab, new Vector2((float)(x + 0.5), -(float)(y + 0.5)), Quaternion.identity);

        oweSquare.rotationFlag = oldRF;
        oweSquare.symmetryFlag = oldSF;
    }
 public void tryChess(BLOKUSChessDoneInfo chessDoneInfo)
 {
     chessDoneInfoTemp = chessDoneInfo;
     myBlokusController.tryChess(chessDoneInfo);
     confirmDialog.SetActive(true);
 }