コード例 #1
0
        public BoardData(Chess[] tortoise, Chess[] hare)
        {
            Tortoise = 0;
            for (int i = 0; i < Setting.MaxEdgeCount - 1; ++i)
            {
                if (!tortoise[i].GoalArrived) Tortoise |= 1u << (tortoise[i].Y * Setting.MaxEdgeCount + tortoise[i].X);
            }

            Hare = 0;
            for (int i = 0; i < Setting.MaxEdgeCount - 1; ++i)
            {
                if (!hare[i].GoalArrived) Hare |= 1u << (hare[i].Y * Setting.MaxEdgeCount + hare[i].X);
            }
        }
コード例 #2
0
        private void WaitUserInput(Chess[] nowChess)
        {
            if (TouchControl.IsClick())
            {
                _errorSound = false;
                ChessButtonClickMove(nowChess, _goalbutton, _goalChessButtonCount);
                ChessButtonClickMove(nowChess, _chessbutton, _totalChessButtonCount);
                ChessClickMove(nowChess);

                if (_errorSound) _clickError.Play();
            }
        }
コード例 #3
0
        private void WaitComputerMove(Chess[] nowChess)
        {
            if (TouchControl.IsClick())
            {
                _clickError.Play();
            }

            if (_computerAITask == null)
            {
                ComputerStartToCompute();
            }
            else if (_computerAITask.IsCompleted)
            {
                _click.Play();
                ComputerMove(nowChess);
            }
        }
コード例 #4
0
        private void InitChess(Game game, ulong chessMap, Chess[] chess, Texture2D chessTexture, Chess.Type chessType )
        {
            int index = 0;
            while (chessMap != 0)
            {
                ulong oneChess = (chessMap & ((~chessMap)+1));
                int position = BoardData.GetOneChessPosition(oneChess);
                _chessbutton[position].HaveChess = true;
                chessMap &= ~(ulong)oneChess;

                chess[index] = new Chess(game, chessTexture, new DrawState(
                    game, new Vector4(0.025f + (1.0f / Setting.MaxEdgeCount) * (position % Setting.MaxEdgeCount),
                        0.025f + (1.0f / Setting.MaxEdgeCount) * (position / Setting.MaxEdgeCount),
                        (1.0f / Setting.MaxEdgeCount) - 0.02f, (1.0f / Setting.MaxEdgeCount) - 0.01f),
                    Color.White), position % Setting.MaxEdgeCount, position / Setting.MaxEdgeCount, chessType);
                AddComponent(chess[index]);
                ++index;
            }
        }
コード例 #5
0
        private void ComputerMove(Chess[] nowChess)
        {
            Tuple<int, Chess.Action> move = _computerAITask.Result;
            for (int i = 0; i < Setting.MaxEdgeCount - 1; ++i)
            {
                if (nowChess[i].X == move.Item1 % Setting.MaxEdgeCount && nowChess[i].Y == move.Item1 / Setting.MaxEdgeCount)
                {
                    ChessMove(nowChess[i], _chessbutton[nowChess[i].Y * Setting.MaxEdgeCount + nowChess[i].X],
                        move.Item2);
                }
            }

            TurnTheTurn();
            if (_players[(int)NowTurn] == Player.Computer) NowState = BoardState.Animation;
            else NowState = BoardState.WaitIO;
            _computerAITask = null;
        }
コード例 #6
0
 private void ChessMove(Chess moveChess, ChessButton moveOut, Chess.Action chessAction)
 {
     moveOut.HaveChess = false;
     moveChess.Move(chessAction);
     if (!moveChess.GoalArrived)
         _chessbutton[moveChess.Y * Setting.MaxEdgeCount + moveChess.X].HaveChess = true;
 }
コード例 #7
0
        private void ChessClickMove(Chess[] nowChess)
        {
            for (int i = 0; i < Setting.MaxEdgeCount - 1; i++)
            {
                if (nowChess[i].IsHit() && !nowChess[i].GoalArrived)
                {
                    _click.Play();
                    _errorSound = false;
                    CleanAllChessButtonAnimation(_goalbutton, _goalbuttonHover, _goalChessButtonCount);
                    CleanAllChessButtonAnimation(_chessbutton, _chessbuttonHover, _totalChessButtonCount);

                    _chessbutton[nowChess[i].Y * Setting.MaxEdgeCount + nowChess[i].X].ClearAllAndAddState(0.5f,
                        new DrawState(Game,
                            _chessbutton[nowChess[i].Y * Setting.MaxEdgeCount + nowChess[i].X].State.CurrentState.Bounds,
                            Color.PowderBlue));
                    UpdatePossibleMoveButton(i, _chessbutton, nowChess[i].GetAllPossibleMove());
                    UpdatePossibleMoveButton(i, _goalbutton, nowChess[i].GetAllGoalMove());
                }
            }
        }
コード例 #8
0
        private void ChessButtonClickMove(Chess[] nowChess,
            ChessButton[] chessButtons, int totalButtonCount)
        {
            for (int i = 0; i < totalButtonCount; ++i)
            {
                if (chessButtons[i].IsHit() && chessButtons[i].WantToGo != -1)
                {
                    _click.Play();
                    _errorSound = false;
                    Chess chess = nowChess[chessButtons[i].WantToGo];
                    ChessMove(chess, _chessbutton[chess.Y * Setting.MaxEdgeCount + chess.X],
                        chessButtons[i].WantToGoAction);
                    CleanAllChessButtonAnimation(_goalbutton, _goalbuttonHover, _goalChessButtonCount);
                    CleanAllChessButtonAnimation(_chessbutton, _chessbuttonHover, _totalChessButtonCount);

                    TurnTheTurn();
                    NowState = BoardState.Animation;
                    NoMove = false;
                }
                else if (chessButtons[i].IsHit())
                {
                    _errorSound = true;
                }
            }
        }
コード例 #9
0
 private void CheckPass(Chess[] nowChess)
 {
     List<Tuple<int, Chess.Action>> possibleMove = new List<Tuple<int, Chess.Action>>();
     bool turnOther = true;
     for (int i = 0; i < Setting.MaxEdgeCount - 1; ++i)
     {
         if (nowChess[i].GetAllGoalMove().Count > 0)
         {
             turnOther = false;
             break;
         }
         possibleMove.AddRange(nowChess[i].GetAllPossibleMove());
     }
     if (turnOther)
     {
         foreach (var possible in possibleMove)
         {
             if (!_chessbutton[possible.Item1].HaveChess)
             {
                 turnOther = false;
                 break;
             }
         }
     }
     if (turnOther)
     {
         TurnTheTurn();
         NoMove = true;
     }
 }
コード例 #10
0
 private bool CheckChessVictory(Chess[] chess)
 {
     bool allGoalArrived = true;
     for (int i = 0; i < Setting.MaxEdgeCount - 1; ++i)
     {
         allGoalArrived &= chess[i].GoalArrived;
     }
     return allGoalArrived;
 }