예제 #1
0
 void Start()
 {
     ask       = GameObject.Find("Ask").GetComponent <Ask>();
     lives     = 5;
     sp        = GameObject.Find("SPlayer").GetComponent <SecondPlayer>();
     blockOnMe = false;
 }
예제 #2
0
 void Start()
 {
     fp           = GameObject.Find("FPlayer").GetComponent <FirstPlayer>();
     sp           = GameObject.Find("SPlayer").GetComponent <SecondPlayer>();
     isAsking     = false;
     makingChoice = false;
     rightAnswer  = false;
 }
        public ActionResult <Spel> Post(SecondPlayer secondPlayer)
        {
            var gameToUpdate = _userContext.Spels.SingleOrDefault(s => s.Token == secondPlayer.Token);

            if (gameToUpdate != null)
            {
                gameToUpdate.spelerZwartToken = secondPlayer.spelerZwartToken;
                _userContext.SaveChanges();
            }
            return(gameToUpdate);
        }
예제 #4
0
        public void RestartGame(int i_SizeOfBoard)
        {
            GameBoard.InitializeTheFirstDefaultMoves(GameBoard, GameBoard.NumOFColumns);
            FirstPlayer.PlayerActivity  = true;
            SecondPlayer.PlayerActivity = true;
            FirstPlayer.ListOfSquares.Clear();
            SecondPlayer.ListOfSquares.Clear();

            FirstPlayer.InitializeFirstMovesForFirstPlayer(i_SizeOfBoard);
            SecondPlayer.InitializeFirstMovesForSecondPlayer(i_SizeOfBoard);
            bool start = IsMoveExist();
        }
예제 #5
0
        public string ReturnDeskAsRawText()
        {
            var deskStatement = "";

            deskStatement += Width + ";";
            deskStatement += Height + ";";
            deskStatement += (CurrentWhiteTurn ? "1" : "0") + ";";
            deskStatement += FirstPlayer.ReturnPlayerAsRawText() + ";";
            deskStatement += SecondPlayer.ReturnPlayerAsRawText() + ";";
            foreach (var cell in Cells)
            {
                deskStatement += cell.ReturnCellAsRawText() + ",";
            }

            deskStatement = deskStatement.Substring(0, deskStatement.Length - 1);
            return(deskStatement);
        }
예제 #6
0
        private string PrepareDebugInfo()
        {
            const int labelWidth = -20;

            var main = $"Turn: {Turn}, Score: {Score}, With risk: {WithRisk}, Finished: {Finished}";

            var firstPlayerLabel  = $"First Player{(FirstPlayerTurns ? "(!)" : "")}";
            var secondPlayerLabel = $"Second Player{(FirstPlayerTurns ? "" : "(!)")}";

            var firstPlayer  = $"{firstPlayerLabel + ": ",labelWidth}{FirstPlayer.Join()}";
            var secondPlayer = $"{secondPlayerLabel + ": ",labelWidth}{SecondPlayer.Join()}";
            var deck         = $"{"Deck: ",labelWidth}{Deck}";

            var table = $"{"Table: ",labelWidth}" +
                        $"{string.Join(" ", Table.Select(colorAndRank => $"[{colorAndRank.Key.Name} {colorAndRank.Value}]"))}";

            return(string.Join("\n", main, firstPlayer, secondPlayer, table, deck));
        }
예제 #7
0
파일: Game.cs 프로젝트: Skreet2k/PSUTI
        public ActionEnum[] DoAction(FightAction action)
        {
            var resultActions = new ActionEnum[2];
            var botAction     = DoRandomBotAction();

            resultActions[0] = GameProcess(action, botAction);
            resultActions[1] = GameProcess(botAction, action);
            if (resultActions[0] == ActionEnum.Hit)
            {
                SecondPlayer.Hit();
            }
            if (resultActions[1] == ActionEnum.Hit)
            {
                FirstPlayer.Hit();
            }
            CheckWinner();
            return(resultActions);
        }
예제 #8
0
파일: Board.cs 프로젝트: dendy1/tictactoe
    private void OnCellClicked(Cell cell)
    {
        if (GameState != GameState.Running || _blockCells || cell.CellState != CellState.Empty)
        {
            return;
        }

        if (CurrentPlayer.PlayerType == PlayerType.Computer)
        {
            _blockCells = true;
        }

        PlaceMark(cell);

        if (CurrentPlayerWins(cell))
        {
            Win();

            CurrentPlayer.Sit();
            if (CurrentPlayer == FirstPlayer)
            {
                SecondPlayer.Death();
            }
            else
            {
                FirstPlayer.Death();
            }

            return;
        }

        if (GameLogic.IsDraw(Cells, boardSize))
        {
            Draw();
            FirstPlayer.Sit();
            SecondPlayer.Sit();
            return;
        }

        CurrentPlayer.Attack();
        ChangePlayer();
    }
예제 #9
0
        private void computersTurn()
        {
            Tuple <Card, Card> computerCards = SecondPlayer.ComputersMove(GameBoard);
            Tuple <int, int>   firstIndexes  = computerCards.Item1.CardLocation.getCellIndexes();
            Tuple <int, int>   secondIndexes = computerCards.Item2.CardLocation.getCellIndexes();
            Button             firstButton   = (Button)this.Controls.Find("Cell_" + firstIndexes.Item1 + firstIndexes.Item2, false).First();
            Button             secondButton  = (Button)this.Controls.Find("Cell_" + secondIndexes.Item1 + secondIndexes.Item2, false).First();

            firstButton.Text       = (firstButton.Tag as Cell).HoldsCard.Letter + string.Empty;
            firstButton.BackColor  = FirstPlayer.Turn ? firstPlayerLabel.BackColor : secondPlayerLabel.BackColor;
            firstButton.Font       = new Font("Ariel", 14);
            secondButton.Text      = (secondButton.Tag as Cell).HoldsCard.Letter + string.Empty;
            secondButton.BackColor = firstButton.BackColor;
            secondButton.Font      = new Font("Ariel", 14);
            firstButton.Refresh();
            System.Threading.Thread.Sleep(1000);
            secondButton.Refresh();
            System.Threading.Thread.Sleep(2000);
            checkPair(firstButton, secondButton);
        }
예제 #10
0
파일: Board.cs 프로젝트: dendy1/tictactoe
    public void InitializePlayers(bool firstPlayerHuman, bool secondPlayerHuman)
    {
        if (!FirstPlayer)
        {
            CreateFirstPlayer();
        }
        if (!SecondPlayer)
        {
            CreateSecondPlayer();
        }

        if (firstPlayerHuman)
        {
            FirstPlayer.Initialize("Player 1", PlayerType.Human, CellState.Cross);
        }
        else
        {
            FirstPlayer.Initialize("Computer 1", PlayerType.Computer, CellState.Cross);
        }

        if (secondPlayerHuman)
        {
            SecondPlayer.Initialize("Player 2", PlayerType.Human, CellState.Nought);
        }
        else
        {
            SecondPlayer.Initialize("Computer 2", PlayerType.Computer, CellState.Nought);
        }

        CurrentPlayer = FirstPlayer;

        GameState = GameState.Stop;

        Debug.Log($"FirstPlayer : {FirstPlayer}");
        Debug.Log($"SecondPlayer : {SecondPlayer}");
    }
예제 #11
0
 public void SwitchTurns()
 {
     FirstPlayer.SwitchActivation();
     SecondPlayer.SwitchActivation();
 }
예제 #12
0
 // Use this for initialization
 void Start()
 {
     firstPlayer  = FindObjectOfType <FirstPlayer> ();
     secondPlayer = FindObjectOfType <SecondPlayer> ();
 }
예제 #13
0
 private void ResetPlayers()
 {
     FirstPlayer.Clear();
     SecondPlayer.Clear();
 }
예제 #14
0
 private void ResetPlayers()
 {
     FirstPlayer.Reset();
     SecondPlayer.Reset();
 }
예제 #15
0
        public bool PlayTurn(int sourceIndex, int targetIndex)
        {
            if (!CurrentPlayer.ValidateTurn(GameDice, GameBoard, sourceIndex, targetIndex))
            {
                return(false);
            }

            if (FirstPlayer.IsPlayerTurn)
            {
                if (FirstPlayer.PlayTurn(sourceIndex, targetIndex, GameBoard))
                {
                    IsTurnStart = false;
                    FirstPlayer.Turns--;
                    if (FirstPlayer.Turns == 0)
                    {
                        SwapTurns();
                    }
                    else if (!GameDice.IsDouble)
                    {
                        if (sourceIndex - targetIndex == GameDice.FirstDice)
                        {
                            GameDice.DisableFirstDice();
                        }
                        else
                        {
                            GameDice.DisableSecondDice();
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (SecondPlayer.PlayTurn(sourceIndex, targetIndex, GameBoard))
                {
                    IsTurnStart = false;
                    SecondPlayer.Turns--;
                    if (SecondPlayer.Turns == 0)
                    {
                        SwapTurns();
                    }
                    else if (!GameDice.IsDouble)
                    {
                        int gameMove;
                        if (sourceIndex == GameBoard.BarSource)
                        {
                            gameMove = targetIndex + 1;
                        }
                        else
                        {
                            gameMove = targetIndex - sourceIndex;
                        }
                        if (gameMove == GameDice.FirstDice)
                        {
                            GameDice.DisableFirstDice();
                        }
                        else
                        {
                            GameDice.DisableSecondDice();
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }