Esempio n. 1
0
 public bool XiaQi(Pos p, bool flag = true)
 {
     if (curState != gState.gaming)
     {
         return(false);
     }
     if (AddQi(p, curTurn, flag))
     {
         if (flag)
         {
             if (_curTurn == qiType.white && whiteCount >= 5) //判断
             {
                 if (isWin(p))
                 {
                     gResultDel?.Invoke(gResult.whiteWin);
                 }
             }
             if (curTurn == qiType.black && blackCount >= 5)
             {
                 if (isWin(p))
                 {
                     gResultDel?.Invoke(gResult.blackWin);
                 }
             }
             _curTurn = qiType.white == _curTurn ? qiType.black : qiType.white;
             if (whiteCount + blackCount > 81)
             {
                 gResultDel?.Invoke(gResult.noWin);
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
    bool XiaQi(Pos p, Wuziqi.qiType qtype)
    {
        if (wzq.AddQi(p, qtype))
        {
            GameObject oo = null;
            if (qtype == Wuziqi.qiType.white)
            {
                oo = GameObject.Instantiate(whiteQ) as GameObject;
            }
            else
            {
                oo = GameObject.Instantiate(blackQ) as GameObject;
            }
            int idx = Wuziqi.indexOf(p.x, p.y);
            if (idx == -1)
            {
                return(false);
            }
            oo.transform.SetParent(qiTrans);

            oo.transform.localPosition = zero + new Vector2((idx % 9) * 60, (idx / 9) * 60);
            return(true);
        }
        return(false);
    }
Esempio n. 3
0
    private void Start()
    {
        wzq = new WZQGame();
        wzq.gStateChangeDe = onGameStateChange;
        wzq.gResultDel     = onGameResult;
        wzq.gameStart(Wuziqi.qiType.white);
        myturn = Wuziqi.qiType.white;
        WzqAI.GetIns().SetGame(wzq);

        Debug.Log("3215=" + WzqAI.caculateQ(new int[] { 3, 2, 1, 5 }));
    }
Esempio n. 4
0
 /// <summary>
 /// 游戏开始
 /// </summary>
 /// <param name="firstTurn"></param>
 public void gameStart(Wuziqi.qiType firstTurn)
 {
     this.firstTurn = firstTurn;
     this.curState  = gState.gaming;
     this._curTurn  = firstTurn;
 }