Пример #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
        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
    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
    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);
                }
            }
        }