Exemple #1
0
    //电脑走棋
    public void DianNaoZouQi()
    {
        ResultData data = ChineseChessHandler.GetInstant().GetZoufa(Fen);

        log.Log(data.result);
        log.Log(data.caneat);
        log.Log(data.moves.Count);
        if (data.result)
        {
            Fen.noteatcount++;
            MoveData move = data.moves[0];
            if (data.caneat)
            {
                GameObject obj = QiziMap.GetGameObject(move.end.x.ToString() + move.end.y.ToString());
                obj.SetActive(false);
                QiziMap.RemoveGameObject(move.end.x.ToString() + move.end.y.ToString());
                Fen.noteatcount = 0;
            }
            MoveQizi(move);
            Fen.moves.Insert(0, move);
            Fen[move.end]   = Fen[move.start];
            Fen[move.start] = Qizi.KONGZI;
            Fen.current     = Fen.current ^ 0x0003;
            Fen.count++;
        }
    }
Exemple #2
0
    public void CheckAndMove(PointData end)
    {
        PointData start = Fen.selected;
        MoveData  move  = new MoveData();

        move.start = start;
        move.end   = end;
        if (move.end == PointData.NgData)
        {
            //恢复坐标
            move.end = start;
            MoveQizi(move);
            return;
        }

        FenData f = GetFenDataClone();

        f.moves.Insert(0, move);
        ResultData data = ChineseChessHandler.GetInstant().CheckZoufa(f);

        if (data.result)
        {
            Fen.noteatcount++;
            if (data.caneat)
            {
                GameObject obj = QiziMap.GetGameObject(move.end.x.ToString() + move.end.y.ToString());
                obj.SetActive(false);
                QiziMap.RemoveGameObject(move.end.x.ToString() + move.end.y.ToString());
                Fen.noteatcount = 0;
            }
            MoveQizi(move);
            Fen.moves.Insert(0, move);
            Fen[move.end]   = Fen[move.start];
            Fen[move.start] = Qizi.KONGZI;
            Fen.current     = Fen.current ^ 0x0003;
            Fen.count++;
            HidenRoad();
        }
        else
        {
            //恢复坐标
            move.end = start;
            MoveQizi(move);
        }
    }