コード例 #1
0
ファイル: Game.cs プロジェクト: psmon/chessgo
    public void SwapDolPos(VectorDol leftPos, VectorDol rightPos)
    {
        PlayDol left  = Dols.getPlayDolByIdx(leftPos.x, leftPos.y);
        PlayDol right = Dols.getPlayDolByIdx(rightPos.x, rightPos.y);

        if (left != null && right != null)
        {
            Vector3 oriPos = left.transform.position;
            //left.transform.position = right.transform.position;

            left.move_ani(right.transform.position);

            right.transform.position = oriPos;

            VectorDol temp = new VectorDol();
            temp.setPos(left.GetDolPos());

            left.SetDolPos(right.GetDolPos());
            right.SetDolPos(temp);
        }

        curPlayDol = left;
        WebDataRes chkRes = new WebDataRes();

        chkRes.pid = "CheckGame";
        packetList.Enqueue(chkRes.ToString());
    }
コード例 #2
0
    public void offLineInit()
    {
        firstBplayDols         = new DolsInfo();
        firstBplayDols.isBlack = true;
        firstBplayDols.isMe    = true;

        firstWplayDols         = new DolsInfo();
        firstWplayDols.isBlack = false;
        firstWplayDols.isMe    = false;

        for (int i = 0; i < 8; i++)
        {
            var addData = new VectorDol();
            addData.x = i;
            addData.y = 7;
            firstBplayDols.list.Add(addData);

            addData   = new VectorDol();
            addData.x = i;
            addData.y = 0;
            firstWplayDols.list.Add(addData);
        }

        InitDols();
    }
コード例 #3
0
ファイル: Game.cs プロジェクト: psmon/chessgo
    void FixedUpdate()
    {
        if (PlayDol.isRunAnimation == true)
        {
            return;
        }

        if (isNetworkPlay && isOffLineMode == false)
        {
            if (globalTimeLeft < 0)
            {
                //GameOver();
                if (isOffLineMode == false)
                {
                }

                GameResultInfo gameResultInfo = new GameResultInfo();

                if (myPlyScore > otherPlyScore)
                {
                    gameResultInfo.winnerColor = isMyDolColorBlack == true ? 2 : 1;
                    gameResultInfo.wiinerScore = myPlyScore;
                    gameResultInfo.loseScore   = otherPlyScore;
                    gameResultInfo.wiinnerIsme = true;
                    showResult("You Win", true);
                    ws.Send(gameResultInfo.ToString());
                }
                else if (myPlyScore < otherPlyScore)
                {
                    gameResultInfo.winnerColor = isMyDolColorBlack == true ? 1 : 2;
                    gameResultInfo.wiinerScore = otherPlyScore;
                    gameResultInfo.loseScore   = myPlyScore;
                    gameResultInfo.wiinnerIsme = false;
                    showResult("You Lost", true);
                    ws.Send(gameResultInfo.ToString());
                }
                else
                {
                    gameResultInfo.winnerColor = isMyDolColorBlack == true ? 2 : 1;
                    gameResultInfo.wiinerScore = myPlyScore;
                    gameResultInfo.loseScore   = otherPlyScore;
                    gameResultInfo.wiinnerIsme = true;
                    showResult("Drawgame", true);
                    ws.Send(gameResultInfo.ToString());
                }

                globalTimeLeft = gameInfo.totalTimeBank + 10;
            }
            else
            {
                globalTimeLeft         -= Time.fixedDeltaTime;
                txtTotalRemainTime.text = string.Format("RemainTime:{0}", (int)globalTimeLeft);
            }

            if (isMyTurn)
            {
                if (0 < privateTimeLeft)
                {
                    privateTimeLeft    -= Time.fixedDeltaTime;
                    txtPrivateTime.text = string.Format("You,Limit:{0}", (int)privateTimeLeft);
                }
                else
                {
                    if (Game.selectedDol != null)
                    {
                        Game.selectedDol.indicatorOff();
                    }

                    Game.selectedDol = null;
                    Game.targetDol   = null;
                    Dols.SetOffAllCanMove();
                    MoveInfoReq moveInfoReq = new MoveInfoReq();
                    VectorDol   nullPos     = new VectorDol();
                    nullPos.x = -1;
                    moveInfoReq.source.setPos(nullPos);
                    moveInfoReq.target.setPos(nullPos);
                    send(moveInfoReq.ToString());
                    privateTimeLeft = gameInfo.privateTimeBank;
                }
            }
            else
            {
                if (0 < privateTimeLeft)
                {
                    privateTimeLeft    -= Time.fixedDeltaTime;
                    txtPrivateTime.text = string.Format("He,Limit:{0}", (int)privateTimeLeft);
                }
                else
                {
                    privateTimeLeft = gameInfo.privateTimeBank;
                }
            }
        }

        ProcessPackets();
    }
コード例 #4
0
ファイル: PlayDol.cs プロジェクト: psmon/chessgo
 public void SetDolPos(VectorDol pos)
 {
     dolPos.x = pos.x;
     dolPos.y = pos.y;
 }
コード例 #5
0
    public static int checkGame(PlayDol selectedDol, bool isPreCheck = false, int chkDolType = 1)
    {
        int            score  = 0;
        List <PlayDol> result = new List <PlayDol>();

        VectorDol selectPost = selectedDol.GetDolPos();
        int       selDolType = isPreCheck == false?selectedDol.GetMyDolType() : chkDolType;

        //LeftCechk...
        List <PlayDol> removeDols = new List <PlayDol>();

        for (int idx = selectPost.x - 1; -1 < idx; idx--)
        {
            PlayDol curDol = getPlayDolByIdx(idx, selectPost.y);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                break;
            }

            if (idx == selectPost.x - 1)
            {
                if (curDol.GetMyDolType() == selDolType)
                {
                    break;
                }
            }

            if (selDolType != curDol.GetMyDolType())
            {
                removeDols.Add(curDol);
            }

            if (selDolType == curDol.GetMyDolType())
            {
                if (removeDols.Count > 0)
                {
                    score += removeDols.Count;
                    foreach (PlayDol removedol in removeDols)
                    {
                        if (isPreCheck == false)
                        {
                            removedol.SetDolColor(0);
                        }
                    }
                }
                break;
            }
        }

        //RightCheck
        removeDols = new List <PlayDol>();
        for (int idx = selectPost.x + 1; idx < 8; idx++)
        {
            PlayDol curDol = getPlayDolByIdx(idx, selectPost.y);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                break;
            }

            if (idx == selectPost.x + 1)
            {
                if (curDol.GetMyDolType() == selDolType)
                {
                    break;
                }
            }

            if (selDolType != curDol.GetMyDolType())
            {
                removeDols.Add(curDol);
            }

            if (selDolType == curDol.GetMyDolType())
            {
                if (removeDols.Count > 0)
                {
                    score += removeDols.Count;
                    foreach (PlayDol removedol in removeDols)
                    {
                        if (isPreCheck == false)
                        {
                            removedol.SetDolColor(0);
                        }
                    }
                }
                break;
            }
        }

        //Upcheck
        removeDols = new List <PlayDol>();
        for (int idy = selectPost.y + 1; idy < 8; idy++)
        {
            PlayDol curDol = getPlayDolByIdx(selectPost.x, idy);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                break;
            }

            if (idy == selectPost.y + 1)
            {
                if (curDol.GetMyDolType() == selDolType)
                {
                    break;
                }
            }

            if (selDolType != curDol.GetMyDolType())
            {
                removeDols.Add(curDol);
            }

            if (selDolType == curDol.GetMyDolType())
            {
                if (removeDols.Count > 0)
                {
                    score += removeDols.Count;
                    foreach (PlayDol removedol in removeDols)
                    {
                        if (isPreCheck == false)
                        {
                            removedol.SetDolColor(0);
                        }
                    }
                }
                break;
            }
        }

        //DownCheck
        removeDols = new List <PlayDol>();
        for (int idy = selectPost.y - 1; -1 < idy; idy--)
        {
            PlayDol curDol = getPlayDolByIdx(selectPost.x, idy);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                break;
            }

            if (idy == selectPost.y - 1)
            {
                if (curDol.GetMyDolType() == selDolType)
                {
                    break;
                }
            }

            if (selDolType != curDol.GetMyDolType())
            {
                removeDols.Add(curDol);
            }

            if (selDolType == curDol.GetMyDolType())
            {
                if (removeDols.Count > 0)
                {
                    score += removeDols.Count;
                    foreach (PlayDol removedol in removeDols)
                    {
                        if (isPreCheck == false)
                        {
                            removedol.SetDolColor(0);
                        }
                    }
                }
                break;
            }
        }
        return(score);
    }
コード例 #6
0
    public static List <PlayDol> canMoveDolList(PlayDol selectedDol, bool justGetData = false)
    {
        List <PlayDol> result     = new List <PlayDol>();
        VectorDol      selectPost = selectedDol.GetDolPos();

        //LeftCechk...
        for (int idx = selectPost.x - 1; -1 < idx; idx--)
        {
            bool    canMove = false;
            PlayDol curDol  = getPlayDolByIdx(idx, selectPost.y);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                canMove = true;
                if (justGetData == false)
                {
                    curDol.SetOnCanMove();
                }

                result.Add(curDol);
            }
            if (canMove == false)
            {
                break;
            }
        }

        //RightCheck
        for (int idx = selectPost.x + 1; idx < 8; idx++)
        {
            bool    canMove = false;
            PlayDol curDol  = getPlayDolByIdx(idx, selectPost.y);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                canMove = true;
                if (justGetData == false)
                {
                    curDol.SetOnCanMove();
                }
                result.Add(curDol);
            }
            if (canMove == false)
            {
                break;
            }
        }

        //Upcheck
        for (int idy = selectPost.y + 1; idy < 8; idy++)
        {
            bool    canMove = false;
            PlayDol curDol  = getPlayDolByIdx(selectPost.x, idy);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                canMove = true;
                if (justGetData == false)
                {
                    curDol.SetOnCanMove();
                }
                result.Add(curDol);
            }

            if (canMove == false)
            {
                break;
            }
        }

        //DownCheck
        for (int idy = selectPost.y - 1; -1 < idy; idy--)
        {
            bool    canMove = false;
            PlayDol curDol  = getPlayDolByIdx(selectPost.x, idy);
            if (curDol == null)
            {
                break;
            }

            if (curDol.GetMyDolType() == 0)
            {
                canMove = true;
                if (justGetData == false)
                {
                    curDol.SetOnCanMove();
                }
                result.Add(curDol);
            }

            if (canMove == false)
            {
                break;
            }
        }
        return(result);
    }