예제 #1
0
 void FixedUpdate()
 {
     if (equipHoe)
     {
         currentState = PossibleState.FARMING;
     }
     else if (equipRod)
     {
         currentState = PossibleState.FISHING;
     }
     else
     {
         currentState = PossibleState.NONE;
     }
 }
예제 #2
0
 public void SetOpenedForcibly()
 {
     State = PossibleState.OpenedForcibly;
     OnDoorModified();
 }
예제 #3
0
 public void SetOpenForTooLong()
 {
     State = PossibleState.OpenForTooLong;
     OnDoorModified();
 }
예제 #4
0
 public void LockDoor()
 {
     State = PossibleState.Locked;
     OnDoorModified();
 }
예제 #5
0
 // Methods to change Door's state
 public void OpenDoor()
 {
     State = PossibleState.Open;
     OnDoorModified();
 }
예제 #6
0
파일: Program.cs 프로젝트: matyjb/Hexapawn
        public static bool Game(Board board, bool computerMove)
        {
            Console.Clear();
            Console.WriteLine(board.ToString());
            PossibleState actualstate = new PossibleState(board, new Move[] { });
            Move          m           = new Move(0, 0);

            if (computerMove)
            {
                if (CheckWin(board) == 1)
                {
                    Console.WriteLine("Player wins");
                    return(false);
                }

                bool isMirror = false;
                foreach (var item in possibleStates)
                {
                    if (item.BoardEquals(board, out isMirror))
                    {
                        actualstate = item;
                        break;
                    }
                }
                m = actualstate.GetMove();
                if (isMirror)
                {
                    board[m.From / 3, 2 - m.From % 3] = 0;
                    board[m.To / 3, 2 - m.To % 3]     = 2;
                }
                else
                {
                    board[m.From / 3, m.From % 3] = 0;
                    board[m.To / 3, m.To % 3]     = 2;
                }
            }
            else
            {
                if (CheckWin(board) == 2)
                {
                    Console.WriteLine("Computer wins");
                    return(true);
                }
                Console.Write("From: "); int x = Convert.ToInt32(Console.ReadLine());
                Console.Write("To:   "); int y = Convert.ToInt32(Console.ReadLine());

                // TODO: check if valid move

                board[x / 3, x % 3] = 0;
                board[y / 3, y % 3] = 1;
            }
            if (CheckDraw(board))
            {
                return(false);
            }
            //check pawns amount
            int Bamount = 0;
            int Wamount = 0;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (board[i, j] == 2)
                    {
                        Bamount++;
                    }
                    if (board[i, j] == 1)
                    {
                        Wamount++;
                    }
                }
            }
            if (Bamount == 0)
            {
                return(false);              //computer lost all pawns
            }
            if (Wamount == 0)
            {
                return(true);              //computer wins - player has no pawns
            }
            //
            bool result = Game(board, !computerMove);

            if (result && computerMove)
            {
                //computer won and it is his move
                actualstate.RewardMove(m);
            }
            return(result);
        }