Ejemplo n.º 1
0
 private void CheckAmmo()
 {
     lblPlayerShots.Text   = PlayerOne.PlayerShots.ToString();
     lblOpponentShots.Text = ComputerPlayer.ComputerShots.ToString();
     cmdShoot.Enabled      = PlayerOne.HasAmmo();
     cmdShotgun.Enabled    = PlayerOne.ShotgunAvailable();
 }
Ejemplo n.º 2
0
    private void Awake()
    {
        playerOne = gameObject.GetComponent <PlayerOne>();
        rb        = GetComponent <Rigidbody2D>();

        numberOfJumps = 2;
    }
Ejemplo n.º 3
0
    public override void Interact(PlayerOne player)
    {
        if (player.heldObject == null)
        {
            OnPickUp();
            //turn off all colliders

            Collider2D[] terrainCollider = GetComponentsInChildren <Collider2D>();
            foreach (Collider2D collider in terrainCollider)
            {
                if (collider.gameObject.name != "Cat(Clone)")
                {
                    collider.enabled = false;
                }
            }


            player.PickUp(this);
            this.isBeingHeld = true;
        }
        else if (player.heldObject == this)
        {
            OnPutDown();

            Collider2D[] terrainCollider = GetComponentsInChildren <Collider2D>();
            foreach (Collider2D collider in terrainCollider)
            {
                collider.enabled = true;
            }


            player.PutDownHeldObject();
            this.isBeingHeld = false;
        }
    }
Ejemplo n.º 4
0
 public override void Interact(PlayerOne player)
 {
     if (player.heldObject == null || player.heldObject == this)
     {
         // normal holdable interaction
         base.Interact(player);
     }
     else
     {
         var cat = player.heldObject.GetComponent <CatBehavior>();
         if (cat == null)
         {
             throw new System.InvalidOperationException("tried to put something other than cat in box");
         }
         // fake the player putting down the cat
         var catInteraction    = cat.GetComponent <CatInteraction>();
         var catSpriteRenderer = cat.GetComponent <SpriteRenderer>();
         catInteraction.Interact(player);
         catInteraction.OnPickUp();
         catInteraction.isBeingHeld = true;
         cat.transform.SetParent(this.transform);
         cat.transform.localPosition       = Vector3.up * Random.Range(.5f, .9f) + Vector3.right * Random.Range(-.15f, .15f);
         catSpriteRenderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
         catSpriteRenderer.sortingOrder    = this.GetComponent <SpriteRenderer>().sortingOrder + 1;
         this.cats.Add(cat);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Activate the Play of the game, switches players after every turn, verifies if their is a tie.
        /// </summary>
        /// <returns>Winner</returns>
        public Player Play()
        {
            int counter = 1;

            while (!CheckForWinner(Board))
            {
                Board.DisplayBoard();

                if (PlayerOne.IsTurn)
                {
                    PlayerOne.TakeTurn(Board);
                    counter++;
                    SwitchPlayer();
                }
                else
                {
                    PlayerTwo.TakeTurn(Board);
                    counter++;
                    SwitchPlayer();
                }

                CheckForWinner(Board);

                if (counter >= 9)
                {
                    return(Winner);
                }

                Console.Clear();
            }

            Board.DisplayBoard();

            return(Winner);
        }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        rb = GetComponent <Rigidbody> ();
        if (rb != null)
        {
            rb.velocity = new Vector3(-1, 0) * iSpeed;
            curSpeed    = iSpeed;
        }
        GameObject p1Score = GameObject.Find("P1Score");

        p1Text    = p1Score.GetComponent <Text> ();
        playerOne = GameObject.Find("Player").GetComponent <PlayerOne>();
        GameObject p2Score = GameObject.Find("P2Score");

        p2Text    = p2Score.GetComponent <Text> ();
        playerTwo = GameObject.Find("PlayerTwo").GetComponent <PlayerTwo>();
        if (playerTwo == null)
        {
            playerComp = GameObject.Find("PlayerTwo").GetComponent <PlayerComp> ();
            playerTwo  = new PlayerTwo();
        }
        else
        {
            playerComp = new PlayerComp();
        }
        clearScore();
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Create new players and launch the Fighting method
        /// </summary>
        /// <returns>Returns True if the player wants to continue playing</returns>
        public static bool CreatePlayers()
        {
            Console.WriteLine(" Enter the first Character/Player Name ");
            string nameOne = Console.ReadLine();

            Console.WriteLine(" Enter the first player Damage per attack points from 1 - 10 ");
            string damagePlayerOne = Console.ReadLine();
            int    damageIntOne    = int.Parse(damagePlayerOne);

            // Making a new instance of Player one
            PlayerOne playerOne = new PlayerOne(nameOne, damageIntOne);

            Console.WriteLine(" Enter the second Character/Player Name ");
            string nameTwo = Console.ReadLine();

            // Making a new instance of Player two
            PlayerTwo playerTwo = new PlayerTwo(nameTwo);

            StartFighting(playerOne, playerTwo);

            // After the round is finished this will execute to ask the user to play again
            Console.WriteLine(" Do you want to start a new fight? Type 'Y' for Yes or 'N' for No");
            string keepFighting     = Console.ReadLine();
            char   keepFightingChar = char.Parse(keepFighting);

            bool fightOn;

            fightOn = char.ToUpper(keepFightingChar) == 'Y';

            return(fightOn);
        }
Ejemplo n.º 8
0
        private void GenGame()
        {
            GameField = new TicTacToeField[3, 3];

            for (int x = 0; x <= 2; x++)
            {
                for (int y = 0; y <= 2; y++)
                {
                    GameField[x, y] = new TicTacToeField();
                }
            }

            if (PlayerOne == null)
            {
                PlayerOne = new TikTakToe.TicTacToePlayer(this, "Player 1 - x", "x");
            }

            if (PlayerTwo == null)
            {
                PlayerTwo = new TikTakToe.TicTacToePlayer(this, "Player 2 - o", "o");
            }

            PlayerOne.NewTry();
            PlayerTwo.NewTry();
            AllPlayers.Clear();
            AllPlayers.Add(PlayerOne);
            AllPlayers.Add(PlayerTwo);
        }
Ejemplo n.º 9
0
 public void LoadContent()
 {
     DebugUtility.LoadFont();
     Arena.LoadArena();
     PlayerOne.LoadCharacter();
     Bomb.LoadBomb();
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Create a new empty game instance.
        /// </summary>
        public GameInstance()
        {
            // create players
            players = new List <Player>();
            players.Add(new Player(this));
            players.Add(new Player(this));
            PlayerList = new ReadOnlyCollection <Player>(players);

            // assign opponents
            PlayerOne.SetOpponent(PlayerTwo);
            PlayerTwo.SetOpponent(PlayerOne);

            // prepare saving original decklists
            decklists = new Dictionary <Player, List <SimpleCard> >();

            // prepare mulligan phase
            mulligans        = new Dictionary <Player, Dictionary <Card, bool> >();
            mulliganComplete = new Dictionary <Player, bool>();

            // finalize preparations
            foreach (Player player in players)
            {
                decklists.Add(player, new List <SimpleCard>());
                mulligans.Add(player, new Dictionary <Card, bool>());
                mulliganComplete.Add(player, false);
            }

            // update game state
            state = GameState.Loading;
        }
Ejemplo n.º 11
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log(gameObject.name);
        PlayerOne playerOne = collision.GetComponent <PlayerOne>();
        PlayerTwo playerTwo = collision.GetComponent <PlayerTwo>();

        if (gameObject.CompareTag("BlueWaterfall"))
        {
            Debug.Log(collision.gameObject.name + " : " + gameObject.name + " : ");
            if (collision.gameObject.CompareTag("player 1"))
            {
                playerOne.color = "blue";
                collision.gameObject.GetComponent <Animator>().Play("Base Layer.PlayerTwoLeft");
            }
            if (collision.gameObject.CompareTag("player 2"))
            {
                playerTwo.color = "blue";
                collision.gameObject.GetComponent <Animator>().Play("Base Layer.Player2ColorChange");
            }
        }
        else
        {
            if (collision.gameObject.CompareTag("player 1"))
            {
                playerOne.color = "pink";
                collision.gameObject.GetComponent <Animator>().Play("Base Layer.PlayerOneLeft");
            }
            if (collision.gameObject.CompareTag("player 2"))
            {
                playerTwo.color = "pink";
                collision.gameObject.GetComponent <Animator>().Play("Base Layer.SoftBoiPink");
            }
        }
    }
Ejemplo n.º 12
0
        private void Play()
        {
            if (Deck.Cards.Count % 2 == 0)
            {
                while (PlayerOne.Hand.Any() && PlayerTwo.Hand.Any())
                {
                    Card plyerOneCurrentCard = PlayerOne.TakeCurrentCard();
                    Card plyerTwoCurrentCard = PlayerOne.TakeCurrentCard();

                    switch (CompareCards(plyerOneCurrentCard, plyerTwoCurrentCard))
                    {
                    case TurnResult.PlayerOneWon:
                        PlayerOne.ScorePile.Add(plyerOneCurrentCard);
                        PlayerOne.ScorePile.Add(plyerTwoCurrentCard);
                        break;

                    case TurnResult.PlayerTwoWon:
                        PlayerTwo.ScorePile.Add(plyerOneCurrentCard);
                        PlayerTwo.ScorePile.Add(plyerTwoCurrentCard);
                        break;

                    default:
                        PlayerOne.ScorePile.Add(plyerOneCurrentCard);
                        PlayerTwo.ScorePile.Add(plyerTwoCurrentCard);
                        break;
                    }
                }
            }
            else
            {
                throw new Exception("Invalid card count.");
            }
        }
Ejemplo n.º 13
0
 public void ChangeToOtherPlayersTurn()
 {
     if (_state is PlayerTurn)
     {
         if (((PlayerTurn)_state).Player.Equals(PlayerOne))
         {
             if (!PlayerOne.IsOutOfCards())
             {
                 SetState(new PlayerTurn(PlayerTwo));
             }
             else
             {
                 SetState(new EndRound(PlayerTwo));
             }
         }
         else
         {
             if (!PlayerTwo.IsOutOfCards())
             {
                 SetState(new PlayerTurn(PlayerOne));
             }
             else
             {
                 SetState(new EndRound(PlayerOne));
             }
         }
     }
 }
Ejemplo n.º 14
0
        public void IsItWin(string[,] gameBg, PlayerOne playerOne, PlayerTwo playerTwo)
        {
            playerOne.PlayerCheckerCount = 0;
            playerTwo.PlayerCheckerCount = 0;

            //checks the array for playerOne checkers
            foreach (var checker in gameBg)
            {
                if (checker == "X " || checker == "kX")
                {
                    //adds one everytime it finds a checker
                    playerOne.PlayerCheckerCount++;
                }
                //checks the array for playerTwo checkers
                else if (checker == "O " || checker == "kO")
                {
                    //adds one everytime it finds a checker
                    playerTwo.PlayerCheckerCount++;
                }
            }
            //if no playerOne checkers found
            if (playerOne.PlayerCheckerCount == 0)
            {
                //set win to true
                win = true;
            }
            //if no playerTwo checkers found
            else if (playerTwo.PlayerCheckerCount == 0)
            {
                //set win to true
                win = true;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// An attempt to jump start the game when no player can act and the game is not yet over.
        /// Plays one card each from their closed stacks on hand to respective open stack.
        /// </summary>
        public void Draw()
        {
            // Stale mate, players pick up the respective stack. Two cards are needed to do a draw.
            if ((PlayerOne.Hand.Cards.Count + PlayerTwo.Hand.Cards.Count) < 2)
            {
                while (LeftStack.Cards.Count > 0)
                {
                    PlayerOne.PickUpCard(LeftStack.DrawCard());
                }
                while (RightStack.Cards.Count > 0)
                {
                    PlayerTwo.PickUpCard(RightStack.DrawCard());
                }
            }

            // If one player has an empty hand, and the other player has more than one card on hand
            // the player without a card will draw one from the other players hand.
            if (PlayerOne.Hand.Cards.Count == 0 && PlayerTwo.Hand.Cards.Count > 1)
            {
                PlayerOne.Hand.Cards.Push(PlayerTwo.Hand.DrawCard());
            }

            else if (PlayerTwo.Hand.Cards.Count == 0 && PlayerOne.Hand.Cards.Count > 1)
            {
                PlayerTwo.Hand.Cards.Push(PlayerOne.Hand.DrawCard());
            }

            LeftStack.AddCard(PlayerOne.Hand.DrawCard(), true);
            RightStack.AddCard(PlayerTwo.Hand.DrawCard(), true);
        }
Ejemplo n.º 16
0
 public void Draw(string[,] gameBg, PlayerOne playerOne, PlayerTwo playerTwo)
 {
     Console.Clear();
     //sets window size
     Console.SetWindowSize(200, 45);
     Console.WriteLine("        1    2    3    4    5    6    7    8          ");
     Console.WriteLine("           _____     _____     _____     _____");
     Console.WriteLine("     |:::::     :::::     :::::     :::::     |       ");
     Console.WriteLine("    H|:::::  {0} :::::  {1} :::::  {2} :::::  {3} |H         {4}'s STATS", gameBg[2, 3], gameBg[2, 5], gameBg[2, 7], gameBg[2, 9], playerOne.PlayerName);
     Console.WriteLine("     |:::::_____:::::_____:::::_____:::::_____|          Move Count:{0}", playerOne.PlayerTurnCount);
     Console.WriteLine("     |     :::::     :::::     :::::     :::::|          Score:{0}", playerOne.PlayerScore);
     Console.WriteLine("    G|  {0} :::::  {1} :::::  {2} :::::  {3} :::::|G  ", gameBg[3, 2], gameBg[3, 4], gameBg[3, 6], gameBg[3, 8]);
     Console.WriteLine("     |_____:::::_____:::::_____:::::____ :::::|");
     Console.WriteLine("     |:::::     :::::     :::::     :::::     |          {0}'s STATS", playerTwo.PlayerName);
     Console.WriteLine("    F|:::::  {0} :::::  {1} :::::  {2} :::::  {3} |F         Move Count:{4}", gameBg[4, 3], gameBg[4, 5], gameBg[4, 7], gameBg[4, 9], playerTwo.PlayerTurnCount);
     Console.WriteLine("     |:::::_____:::::_____:::::_____:::::_____|          Score:{0}", playerTwo.PlayerScore);
     Console.WriteLine("     |     :::::     :::::     :::::     :::::|       ");
     Console.WriteLine("    E|  {0} :::::  {1} :::::  {2} :::::  {3} :::::|E  ", gameBg[5, 2], gameBg[5, 4], gameBg[5, 6], gameBg[5, 8]);
     Console.WriteLine("     |_____:::::_____:::::_____:::::____ :::::|");
     Console.WriteLine("     |:::::     :::::     :::::     :::::     |       ");
     Console.WriteLine("    D|:::::  {0} :::::  {1} :::::  {2} :::::  {3} |D", gameBg[6, 3], gameBg[6, 5], gameBg[6, 7], gameBg[6, 9]);
     Console.WriteLine("     |:::::_____:::::_____:::::_____:::::_____|       ");
     Console.WriteLine("     |     :::::     :::::     :::::     :::::|       ");
     Console.WriteLine("    C|  {0} :::::  {1} :::::  {2} :::::  {3} :::::|C  ", gameBg[7, 2], gameBg[7, 4], gameBg[7, 6], gameBg[7, 8]);
     Console.WriteLine("     |_____:::::_____:::::_____:::::____ :::::|");
     Console.WriteLine("     |:::::     :::::     :::::     :::::     |       ");
     Console.WriteLine("    B|:::::  {0} :::::  {1} :::::  {2} :::::  {3} |B", gameBg[8, 3], gameBg[8, 5], gameBg[8, 7], gameBg[8, 9]);
     Console.WriteLine("     |:::::_____:::::_____:::::_____:::::_____|       ");
     Console.WriteLine("     |     :::::     :::::     :::::     :::::|       ");
     Console.WriteLine("    A|  {0} :::::  {1} :::::  {2} :::::  {3} :::::|A  ", gameBg[9, 2], gameBg[9, 4], gameBg[9, 6], gameBg[9, 8]);
     Console.WriteLine("     |_____:::::_____:::::_____:::::____ :::::|");
     Console.WriteLine("        1    2    3    4    5    6    7    8");
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Activate the Play of the game
        /// </summary>
        /// <returns>Winner</returns>
        public Player Play()
        {
            Player Draw = new Player();

            Draw.Name = "Its a draw!";
            int turnCount = -1;

            PlayerOne.Marker = "X";
            PlayerTwo.Marker = "O";


            while (CheckForWinner(Board) == false)
            {
                turnCount++;
                if (PlayerOne.IsTurn == true)
                {
                    PlayerOne.TakeTurn(Board);
                }
                if (PlayerTwo.IsTurn == true)
                {
                    PlayerTwo.TakeTurn(Board);
                }
                Board.DisplayBoard();
                if (turnCount == 9 && CheckForWinner(Board) == false)
                {
                    Winner = Draw;
                    return(Winner);
                }
                SwitchPlayer();
                NextPlayer();
            }
            return(Winner);
        }
Ejemplo n.º 18
0
        public void Render(GameTime gameTime)
        {
            Arena.DisplayArena(this);
            PlayerOne.DisplayCharacter(this);
            int?IndexToRemove = null;

            for (int i = 0; i < Bombs.Count; i++)
            {
                if (Bombs[i].BombExploded)
                {
                    IndexToRemove = i;
                }
            }
            if (IndexToRemove != null)
            {
                Bombs.RemoveAt((int)IndexToRemove);
            }

            foreach (Bomb bomb in Bombs)
            {
                bomb.DisplayBomb(this);
            }
            if (DisplayDebug)
            {
                DebugUtility.DisplayDebugInfo(this, PlayerOne, Arena.Blocks.FirstOrDefault(), Color.White);
            }
        }
Ejemplo n.º 19
0
        private async Task PlayCurrentRound()
        {
            if (_cancellationToken.IsCancellationRequested)
            {
                return;
            }
            if (PlayerOne.PlayerType != RockPaperScissors.Common.Enums.PlayerType.HumanPlayer)
            {
                _nextPlayerOneMove = PlayerOne.GetNextMove(Game.Rules);
            }
            MoveModel move = Game.Rules.MoveList.FirstOrDefault(i => i.RuleValue == _nextPlayerOneMove);
            string    nextPlayerOneMoveDescription = move.Description;


            if (PlayerTwo.PlayerType != RockPaperScissors.Common.Enums.PlayerType.HumanPlayer)
            {
                _nextPlayerTwoMove = PlayerTwo.GetNextMove(Game.Rules);
            }
            move = Game.Rules.MoveList.FirstOrDefault(i => i.RuleValue == _nextPlayerTwoMove);
            string nextPlayerTwoMoveDescription = move.Description;

            await TurnCountDown();

            if (_cancellationToken.IsCancellationRequested)
            {
                return;
            }
            PlayerOneChoice = nextPlayerOneMoveDescription;
            PlayerTwoChoice = nextPlayerTwoMoveDescription;
            DisplayWinningMove(_nextPlayerOneMove.Value, _nextPlayerTwoMove.Value);

            await DecideNextAction();
        }
Ejemplo n.º 20
0
    private void BonusLifeGainCheck()
    {
        Player p1 = PlayerOne.GetComponent <Player>();

        if (p1.GetScore() > scoreNeededForExtraLife_p1)
        {
            scoreNeededForExtraLife_p1 += scoreNeededIncrease;
            if (p1.GetCurrentLives() < 6)
            {
                p1.GainLife();
            }
        }

        if (PlayerTwo.activeSelf)
        {
            Player p2 = PlayerTwo.GetComponent <Player>();
            if (p2.GetScore() > scoreNeededForExtraLife_p2)
            {
                scoreNeededForExtraLife_p2 += scoreNeededIncrease;
                if (p2.GetCurrentLives() < 6)
                {
                    p2.GainLife();
                }
            }
        }
    }
Ejemplo n.º 21
0
 /// <summary>
 /// Başlangıç kartlarını çeker
 /// </summary>
 public void DrawFirstCards()
 {
     for (var i = 0; i < StartingCardCount; i++)
     {
         PlayerOne.DrawCard();
         PlayerTwo.DrawCard();
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Activate the Play of the game
        /// </summary>
        /// <returns>Winner</returns>
        public Player Play()
        {
            //TODO: Complete this method and utilize the rest of the class structure to play the game.

            /*
             * Complete this method by constructing the logic for the actual playing of Tic Tac Toe.
             *
             * A few things to get you started:
             * 1. A turn consists of a player picking a position on the board with their designated marker.
             * 2. Display the board after every turn to show the most up to date state of the game
             * 3. Once a Winner is determined, display the board one final time and return a winner
             *
             * Few additional hints:
             *  Be sure to keep track of the number of turns that have been taken to determine if a draw is required
             *  and make sure that the game continues while there are unmarked spots on the board.
             *
             * Use any and all pre-existing methods in this program to help construct the method logic.
             */

            Board.DisplayBoard();
            int counter = 0;

            do
            {
                //Console.WriteLine("# of turns: " + counter);
                if (PlayerOne.IsTurn == true)
                {
                    PlayerOne.TakeTurn(Board);
                    Board.DisplayBoard();
                    SwitchPlayer();
                    counter++;
                }
                else
                {
                    PlayerTwo.TakeTurn(Board);
                    Board.DisplayBoard();
                    SwitchPlayer();
                    counter++;
                }
            } while (counter < 9 && CheckForWinner(Board) == false);
            if (CheckForWinner(Board) == true && PlayerOne.IsTurn == false)
            {
                Console.WriteLine("Player one wins");
                Board.DisplayBoard();
                return(PlayerOne);
            }
            else if (CheckForWinner(Board) == true && PlayerTwo.IsTurn == false)
            {
                Console.WriteLine("Player two wins");
                Board.DisplayBoard();
                return(PlayerTwo);
            }
            else
            {
                Console.WriteLine("cats game");
            }
            return(null);
        }
Ejemplo n.º 23
0
    protected virtual void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerOne playerone = collision.gameObject.GetComponent <PlayerOne>();

        if (playerone)
        {
            playerone.Damage();
        }
    }
Ejemplo n.º 24
0
 private void Start()
 {
     player             = GameManager.playerone;
     statemovetoplayer  = new CameraState_MoveToPlayer(this);
     statefollowplayer  = new CameraState_FollowPlayer(this);
     statecamerastopped = new CameraState_Stopped(this);
     statecamerashaking = new CameraState_Shake(this);
     State = statemovetoplayer;
 }
Ejemplo n.º 25
0
    private void Awake()
    {
        PlayerOne = FindObjectOfType <PlayerOne>();

        for (int i = 0; i < hearts.Length; i++)
        {
            hearts[i] = transform.GetChild(i);
        }
    }
Ejemplo n.º 26
0
        public void RunGameLoop()
        {
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo keyInfo = Console.ReadKey();
                    if (keyInfo.Key == ConsoleKey.Y)
                    {
                        PlayerOne.MoveUp();
                    }

                    if (keyInfo.Key == ConsoleKey.S)
                    {
                        PlayerOne.MoveDown(Console.WindowHeight);
                    }

                    if (keyInfo.Key == ConsoleKey.UpArrow)
                    {
                        PlayerTwo.MoveUp();
                    }

                    if (keyInfo.Key == ConsoleKey.DownArrow)
                    {
                        PlayerTwo.MoveDown(Console.WindowHeight);
                    }
                }

                Physics.MoveBall(Console.WindowWidth, Console.WindowHeight);

                if (HasPlayerOneScored())
                {
                    ResetBallPosition(Console.WindowWidth, Console.WindowHeight);
                    Ball.RightDirection = false;
                    Ball.UpDirection    = true;
                    PlayerOne.Score++;
                    ConsoleBoard.PrintPlayerScoredMessage(PlayerOne);
                    Console.ReadKey();
                }

                if (HasPlayerTwoScored())
                {
                    ResetBallPosition(Console.WindowWidth, Console.WindowHeight);
                    Ball.RightDirection = true;
                    Ball.UpDirection    = true;
                    PlayerTwo.Score++;
                    ConsoleBoard.PrintPlayerScoredMessage(PlayerTwo);
                    Console.ReadKey();
                }
                Console.Clear();
                ConsoleBoard.DrawPlayerOne(PlayerOne);
                ConsoleBoard.DrawPlayerTwo(PlayerTwo, Console.WindowWidth);
                ConsoleBoard.DrawBall(Ball);
                ConsoleBoard.PrintScore(PlayerOne, PlayerTwo);
                Thread.Sleep(60);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Activate the Play of the game
        /// Chris morto helped alot with this method - i was super close !
        /// </summary>
        /// <returns>Winner</returns>
        public Player Play()
        {
            int    turns  = 0;
            Player player = null;

            Board.DisplayBoard();

            while (Winner == null && turns < 9)
            {
                if (PlayerOne.IsTurn)
                {
                    player = PlayerOne;
                    PlayerOne.TakeTurn(Board);
                }
                if (PlayerTwo.IsTurn)
                {
                    player = PlayerTwo;
                    PlayerTwo.TakeTurn(Board);
                }
                //reshow board with changes
                Console.Clear();
                Board.DisplayBoard();
                //check for winner
                bool win = CheckForWinner(Board);
                //comes back true or false
                if (win)
                {
                    Winner = player;
                    turns++;
                }
                if (win == false)
                {
                    turns++;
                    SwitchPlayer();
                }
                Console.WriteLine($"Turns : {turns}");
            }
            return(Winner);


            //TODO: Complete this method and utilize the rest of the class structure to play the game.

            /*
             * Complete this method by constructing the logic for the actual playing of Tic Tac Toe.
             *
             * A few things to get you started:
             * 1. A turn consists of a player picking a position on the board with their designated marker.
             * 2. Display the board after every turn to show the most up to date state of the game
             * 3. Once a Winner is determined, display the board one final time and return a winner
             *
             * Few additional hints:
             *  Be sure to keep track of the number of turns that have been taken to determine if a draw is required
             *  and make sure that the game continues while there are unmarked spots on the board.
             *
             * Use any and all pre-existing methods in this program to help construct the method logic.
             */
        }
Ejemplo n.º 28
0
 private void Awake()
 {
     Application.targetFrameRate = 50;
     QualitySettings.vSyncCount  = 0;
     playerone = GameObject.Find("Player").GetComponent <PlayerOne>();
     statecontroller_comboplayerone = GameObject.Find("HitBoxes").GetComponent <ComboController>();
     statecontroller_playerone      = playerone.GetComponent <StateController>();
     //statecontroller_flyingbot = GameObject.Find("MurderBot").GetComponent<StateController_Flyingbot>();
 }
        public void KeysArentAcceptedWhenLocked()
        {
            INonNpc npc = new PlayerOne();
            for (int i = 1; i < 172; i++)
            {
                var key = (Key)i;

                Assert.AreEqual(false, npc.KeyStroke(key));
            }
        }
Ejemplo n.º 30
0
        public void WritePiecesInRow(int row)
        {
            var piecesOfPlayersInARow = PlayerOne.GetPiecesOfRow(row);

            piecesOfPlayersInARow.AddRange(PlayerTwo.GetPiecesOfRow(row));
            foreach (var piece in piecesOfPlayersInARow)
            {
                Table[piece.Position.Item1, piece.Position.Item2] = piece;
            }
        }
Ejemplo n.º 31
0
        public PlayerInformation GetUnitInformationForPlayers(List <string> comparisonInfo)
        {
            try
            {
                List <UnitWithStat> PlayerOne;
                List <UnitWithStat> PlayerTwo;

                Player PlayerOneHelp;
                Player PlayerTwoHelp;

                var helper = Authenticate();

                string unitDefId = comparisonInfo[2];
                //var helper = Authenticate();
                var codesToRequest = new List <string>()
                {
                    comparisonInfo[0], comparisonInfo[1]
                };
                var codesToRequest2 = new List <string>()
                {
                    comparisonInfo[0], comparisonInfo[1]
                };
                List <List <UnitWithStat> > playerOneandTwo = GetPlayerOneAndTwo(codesToRequest);
                List <Player> playerOneandTwoHelp           = GetPlayerOneAndTwoFromHelp(codesToRequest2);

                PlayerOne = playerOneandTwo[0];
                PlayerTwo = playerOneandTwo[1];

                PlayerOneHelp = playerOneandTwoHelp[0];
                PlayerTwoHelp = playerOneandTwoHelp[1];

                List <UnitWithStat> unitDataToReturn = new List <UnitWithStat>();
                List <Roster>       rosterToReturn   = new List <Roster>();

                unitDataToReturn.Add(PlayerOne.Where(x => x.DefId == unitDefId).First());
                unitDataToReturn.Add(PlayerTwo.Where(x => x.DefId == unitDefId).First());

                rosterToReturn.Add(PlayerOneHelp.Roster.Where(x => x.DefId == unitDefId).First());
                rosterToReturn.Add(PlayerTwoHelp.Roster.Where(x => x.DefId == unitDefId).First());

                PlayerInformation pinfo = new PlayerInformation()
                {
                    PlayerNames = new List <string>()
                    {
                        PlayerOneHelp.Name, PlayerTwoHelp.Name
                    }, UnitStatList = unitDataToReturn, RosterList = rosterToReturn, UnitInfo = helper.FetchGearTiersForUnits(unitDefId)[0].unitTierList
                };
                return(pinfo);
            }
            catch (Exception ex)
            {
                _logger.LogCritical(LoggingEvents.GetUnitInformationForPlayers, ex, "GetUnitInformationForPlayers Exception");
                return(new PlayerInformation());
            }
        }
 public void KeysArentAccepted()
 {
     INonNpc npc = new PlayerOne();
     for (int i = 1; i < 172; i ++)
     {
         var key = (Key) i;
         npc.OpenControls();
         if (key != Key.W && key != Key.E && key != Key.R)
             Assert.AreEqual(false, npc.KeyStroke(key));
     }
 }
        public void KeysAreBound()
        {
            INonNpc npc = new PlayerOne();

            npc.OpenControls();
            Assert.AreEqual(true, npc.KeyStroke(Key.W));
            Assert.AreEqual(Pick.Rock, npc.Pick);

            npc.OpenControls();
            Assert.AreEqual(true, npc.KeyStroke(Key.E));
            Assert.AreEqual(Pick.Paper, npc.Pick);

            npc.OpenControls();
            Assert.AreEqual(true, npc.KeyStroke(Key.R));
            Assert.AreEqual(Pick.Scissors, npc.Pick);
        }
 public void PlayerSlot()
 {
     INonNpc npc = new PlayerOne();
     Assert.AreEqual(1,npc.Slot);
 }
Ejemplo n.º 35
0
    int fight(PlayerOne hero)
    {
        int roll1 = rollDice(6);
        int roll2 = rollDice(6);
        int roll3 = rollDice(6);

        int max = Mathf.Max(roll1, roll2);

        Debug.Log("Hero rolled: " + roll1.ToString() + " and " + roll2.ToString() + " Max: " + max.ToString() + "    Zombie rolled" + roll3.ToString());
        if(max > roll3 && roll1 == roll2)
        {
            Debug.Log("Zombie should die");
            return 1;//Zombie should die
        }
        else if(max > roll3)
        {
            Debug.Log("Fended Off");
            return 0;//Fended off nothing changes
        }
        else
        {
            Debug.Log("Hero should lose 1 health");
            return -1;//Hero lost and should take wound
        }
    }