예제 #1
0
파일: PlayDol.cs 프로젝트: psmon/chessgo
    void onSelectDol()
    {
        if (Game.isOffLineMode == false)
        {
            if (Game.isMyTurn == false)
            {
                return;
            }

            if (mydolType == 1 && Game.isMyDolColorBlack == true)
            {
                return;
            }

            if (mydolType == 2 && Game.isMyDolColorBlack == false)
            {
                return;
            }
        }
        else
        {
            if (mydolType == 1 && Game.isMyDolColorBlack == true)
            {
                return;
            }

            if (mydolType == 2 && Game.isMyDolColorBlack == false)
            {
                return;
            }
        }

        /*
         * if (Game.lastMovedDol != null)
         * {
         *  if (Game.lastMovedDol.name == this.name)
         *  {
         *      Debug.Log(string.Format("DuplicatedBound - SelectedDol:{0}", this));
         *      return;
         *  }
         * }*/

        Game.selectedDol             = this;
        indicator.transform.position = transform.position;
        indicator.SetActive(true);


        Dols.SetOffAllCanMove();
        Dols.canMoveDolList(this);

        Debug.Log(string.Format("Bound - SelectedDol:{0}", this));
    }
예제 #2
0
파일: PlayDol.cs 프로젝트: psmon/chessgo
    void onMoveDol()
    {
        if (Game.selectedDol != null && Game.targetDol != null && mydolType == 0)
        {
            Game.lastMovedDol = Game.selectedDol;
            Debug.Log(string.Format("Bound - SwapDol:{0} {1}", Game.selectedDol.name, Game.targetDol.name));

            //SwapDolPos(ref Game.selectedDol, ref Game.targetDol);

            MoveInfoReq moveInfoReq = new MoveInfoReq();
            moveInfoReq.source.setPos(Game.selectedDol.dolPos);
            moveInfoReq.target.setPos(Game.targetDol.dolPos);

            if (Game.isOffLineMode == false)
            {
                Game.send(moveInfoReq.ToString());
            }
            else
            {
                MoveInfoRes moveInfoRes = new MoveInfoRes();
                moveInfoRes.source.setPos(Game.selectedDol.dolPos);
                moveInfoRes.target.setPos(Game.targetDol.dolPos);

                Game.sendLocalData("MoveInfoRes", moveInfoRes.ToString());

                TurnInfo turnInfo = new TurnInfo();

                if (Game.local_turn == Game.selectedDol.GetMyDolType())
                {
                    turnInfo.isMe = false;
                }
                else
                {
                    turnInfo.isMe = true;
                }

                turnInfo.isBlack = Game.selectedDol.GetMyDolType() == 1 ? true : false;
                Game.sendLocalData("TurnInfo", turnInfo.ToString());
                Game.local_turn        = Game.local_turn == 2 ? 1 : 2;
                Game.isMyDolColorBlack = Game.selectedDol.GetMyDolType() == 1 ? true : false;
            }


            Game.selectedDol = null;
            Game.targetDol   = null;

            Dols.SetOffAllCanMove();
            indicator.SetActive(false);
        }
    }
예제 #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();
    }