Beispiel #1
0
        public string MakeMove(int move, string makeMove)
        {
            switch (gamePlayer)
            {
            case playerType.X:
                if (playerX.MakeMove(gameArray, move))
                {
                    gameArray[move] = "X";
                    makeMove        = "X";
                    gamePlayer      = IsPlaying(playerType.X);
                }
                break;

            case playerType.O:
                if (playerX.MakeMove(gameArray, move))
                {
                    gameArray[move] = "O";
                    makeMove        = "O";
                    gamePlayer      = IsPlaying(playerType.O);
                }
                break;

            default:
                break;
            }

            return(makeMove);
        }
Beispiel #2
0
 public Board(int boardSize, playerType player)
 {
     this.boardSize    = boardSize;
     this.battleGround = new Ship[boardSize, boardSize];
     this.player       = player;
     createBoard();
 }
Beispiel #3
0
 public Game(int i_BoardSize, playerType i_PlayerType)
 {
     m_FirstPlayer  = getDataPlayer(colorType.X, playerType.Manual, true, false);
     m_SecondPlayer = getSecondPlayer(m_SecondPlayer, false, i_PlayerType);
     m_BoardSize    = i_BoardSize;
     InitNewGame();
 }
Beispiel #4
0
 public Player(string i_Name, playerType i_Type, colorType i_Color, bool i_CurrentTurn)
 {
     m_CurrentTurn = i_CurrentTurn;
     m_Name        = i_Name;
     m_Type        = i_Type;
     m_Color       = i_Color;
 }
Beispiel #5
0
 internal player(string QQ, string FromGroup, WhoIsSpy Match)
 {
     qq             = QQ;
     this.FromGroup = FromGroup;
     match          = Match;
     PlayerType     = playerType.normal;
     Described      = false;
 }
Beispiel #6
0
 public Player GetPlayer(playerType type)
 {
     if (type == playerType.NUTUAL)
     {
         return(null);
     }
     return(players[(int)type]);
 }
Beispiel #7
0
 public void MakePlayer(playerType p)
 {
     playerName = p.playerName;
     speed      = p.speed;
     dashTime   = p.dashTime;
     dashSpeed  = p.dashSpeed;
     currSpeed  = speed;
     gun.SetCurrentGun(this, p.gun);
 }
Beispiel #8
0
 public void resetRound()   // czyscimy na koniec rundy
 {
     votedOnMe.Clear();
     myVotes  = 0;
     result   = 0;
     type     = playerType.unsign;
     cards[0] = -1;
     cards[1] = -1;
     cards[2] = -1;
 }
Beispiel #9
0
 public PropertyData(playerType playertype, string textureName, int atk, int hp, int maxhp, atkType atktype, CharType charType)
 {
     this.playertype  = playertype;
     this.textureName = textureName;
     this.atk         = atk;
     this.hp          = hp;
     this.maxhp       = maxhp;
     this.atktype     = atktype;
     this.charType    = charType;
 }
Beispiel #10
0
 // get a player from the list of players
 public Player GetPlayer(playerType type)
 {
     foreach (Player player in _players)
     {
         if (player.type == type)
         {
             return(player);
         }
     }
     return(null);
 }
 public Player(string name, playerType type)
 {
     if (name.Length == 0)
     {
         throw new Exception("A player's name may not be blank.");
     }                                                             //maybe make it "[]" instead
     else
     {
         this.name = name;
     }
     this.type = type;
 }
Beispiel #12
0
	void Start () {
		if (SystemInfo.deviceType == DeviceType.Desktop) {
			PlayerObj = DesktopObj;
			assignType = playerType.desktop;
			spawnPoint = DesktopSpawn;
		}
		if (SystemInfo.deviceType == DeviceType.Handheld) {
			PlayerObj = MobileObj;
			assignType = playerType.mobile;
			spawnPoint = MobileSpawn;
		}
		player = Instantiate (PlayerObj, spawnPoint.position, spawnPoint.rotation) as GameObject;
	}
Beispiel #13
0
        public void SetName(playerType type, string goName)
        {
            switch (type)
            {
            case playerType.ONE_P:
                name.text = $"1P {goName}";
                break;

            case playerType.TWO_P:
                name.text = $"2P {goName}";
                break;
            }
        }
        public playerType IsPlaying(playerType pt)
        {
            if (pt == playerType.X)
            {
                pt = playerType.O;
            }
            else
            {
                pt = playerType.X;
            }

            return(pt);
        }
Beispiel #15
0
    /* called at the start of every player's turn. This function is called by
     *  Tank.cs
     */
    void BeginTurn(playerType player)
    {
        switch (player)
        {
        case playerType.P1:
            P1.GetComponent <Tank>().StartTurn();
            currentTurn = playerType.P1;
            break;

        case playerType.P2:
            P2.GetComponent <Tank>().StartTurn();
            currentTurn = playerType.P2;
            break;
        }
    }
        public void AnnounceWinner(playerType player)
        {
            string piece = "";

            if (player == playerType.X)
            {
                piece = "X";
            }
            else if (player == playerType.O)
            {
                piece = "O";
            }

            MessageBox.Show("Player " + piece + " won!");
            System.Windows.Forms.Application.Exit();
        }
        public Player(Point pntlocation, double dblBank, NumericUpDown betControl, playerType type, Strategy strategy, CountMethod method)
        {
            // Since the game is limited to one split (two hands), just set them up now
            hands = new Hand[2];
            hands[0] = new Hand(new Point(0, 0));
            hands[1] = new Hand(new Point(50, 0));

            // Player specific variables
            location = pntlocation;
            bank = dblBank;
            plyrStrategy = strategy;
            plyrMethod = method;
            plyrType = type;
            plyrBet = betControl;

            // Start out with one hand, they may split pairs to get two
            numberOfHands = 1;
        }
Beispiel #18
0
        private Player getSecondPlayer(Player i_SecondPlayer, bool i_CurrentTurn, playerType i_PlayerType)
        {
            bool inCorrectData = true;

            while (inCorrectData)
            {
                if (i_PlayerType == playerType.Manual)
                {
                    i_SecondPlayer = getDataPlayer(colorType.O, playerType.Manual, i_CurrentTurn, true);
                    inCorrectData  = false;
                }
                else
                {
                    i_SecondPlayer = new Player(Utils.Constants.k_ComputerName, playerType.Computer, colorType.O, i_CurrentTurn);
                    inCorrectData  = false;
                }
            }
            return(i_SecondPlayer);
        }
Beispiel #19
0
        public void AnnounceWinner(playerType player)
        {
            string piece = "";

            if (player == playerType.X)
            {
                piece = "X";
            }
            else if (player == playerType.O)
            {
                piece = "O";
            }

            Console.SetCursorPosition(10, 18);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("Player " + piece + " won!");
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(0, 0);
        }
Beispiel #20
0
    void playerTurnStart(GameObject[,] chessboard)
    {
        playerType ptype = players[playerTurn].playertype;

        for (int i = 0; i < chessboard.GetLength(0); ++i)
        {
            for (int j = 0; j < chessboard.GetLength(1); ++j)
            {
                if (chessboard[i, j].GetComponent <NPC>().playertype == ptype)
                {
                    chessboard[i, j].GetComponent <chessUI>().blocker.SetActive(false);
                }
                else
                {
                    chessboard[i, j].GetComponent <chessUI>().blocker.SetActive(true);
                }
            }
        }
    }
Beispiel #21
0
        //character constructor takes game information
        public Character(playerType pType, int playerNumber, Rectangle playerRectangle, Texture2D spriteSheet, SoundEffect attackSound, SoundEffect jumpSound)
        {
            //setting preliminary values
            health            = 20;
            spdScale          = 4;
            xSpd              = 0.0f;
            ySpd              = 0.0f;
            dir               = 1;
            attacked          = false;
            isInvulnerable    = false;
            frameWaitSet      = false;
            currentFrameCount = 24;
            //animation preliminary values
            imageHeight  = 64;
            imageWidth   = 64;
            imageYOffset = 64;
            //twelve for fps looks good for now, can be changed later as needed
            fps          = 12;
            timePerFrame = 1 / fps;
            //sound
            this.attackSound = attackSound;
            this.jumpSound   = jumpSound;

            //set the spritesheet
            this.spriteSheet = spriteSheet;
            //set the rectangle
            this.playerRectangle = playerRectangle;
            //create the hitbox manager
            hitBox = new HitboxManager();
            //set the player type
            this.pType = pType;

            groundY = playerRectangle.Y;

            //set the preliminary staes
            pState = playerState.moveState;
            mState = moveFSM.idle;
            jState = jumpState.grounded;
            //set the player number
            this.playerNumber = playerNumber;
        }
Beispiel #22
0
        public void DisplayGrid(playerType player)
        {
            string piece = "";

            if (player == playerType.X)
            {
                piece = "X";
            }
            else if (player == playerType.O)
            {
                piece = "O";
            }

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(12, 3);
            Console.Write("TIC TAC TOE GAME!");
            Console.SetCursorPosition(10, 15);
            Console.Write("Player " + piece + "'s turn!");
            Console.SetCursorPosition(10, 16);
            Console.Write("Press a number shown above to occupy that space!");
            Console.SetCursorPosition(0, 0);
        }
        public bool IsWinner(string[] currentBoard, playerType player)
        {
            int    piecesInCombo = 0;
            string piece         = " ";
            bool   isWinner      = false;

            if (player == playerType.X)
            {
                piece = "X";
            }
            if (player == playerType.O)
            {
                piece = "O";
            }

            for (int x = 0; x < winningCombos.GetLength(0); x++)
            {
                for (int y = 0; y < winningCombos.GetLength(1); y++)
                {
                    if (currentBoard[WinningCombos[x, y]] == piece)
                    {
                        piecesInCombo++;
                    }
                }
                if (piecesInCombo < 3)
                {
                    piecesInCombo = 0;
                }
            }

            if (piecesInCombo >= 3)
            {
                isWinner = true;
            }

            return(isWinner);
        }
Beispiel #24
0
        public void setTyp(playerType a)      // procedura ustawiajaca typ gracza

        {
            type = a;
        }
Beispiel #25
0
 private void AnnounceWinner(playerType player)
 {
     tttUI.AnnounceWinner(player);
 }
Beispiel #26
0
 public GamePlayer(string nick, playerType type)
 {
     _nickname = nick;
         _playerType = type;
 }
 public Player()
 {
     name      = "";
     this.type = playerType.Computer;
 }
Beispiel #28
0
 private void DisplayGrid(playerType player)
 {
     tttUI.DisplayGrid(player);
 }
Beispiel #29
0
 private void buttonAgainstFriend_Click(object sender, EventArgs e)
 {
     m_PlayerType = playerType.Manual;
     this.Close();
 }
Beispiel #30
0
        // update gracza po msg:&id_gracza, &karta, &ch_flag/g_flag

        public void updatePlayer(int ownCard, playerType type)
        {
            this.type     = type;
            this.cards[0] = ownCard;
        }
Beispiel #31
0
 private Player getDataPlayer(colorType i_color, playerType i_type, bool i_CurrentTurn, bool i_SecondPlayer)
 {
     return(new Player(null, i_type, i_color, i_CurrentTurn));
 }
Beispiel #32
0
 private playerType IsPlaying(playerType pt)
 {
     return(tttLogic.IsPlaying(pt));
 }
Beispiel #33
0
        public void Play()
        {
            string[] resetGameArray = { "7", "8", "9", "4", "5", "6", "1", "2", "3" };
            bool     runGame        = true;
            int      move           = 0;

            DisplayWelcome();

            do
            {
                DisplayGrid(gamePlayer);
                DisplayBoardGrid(gameArray);

                switch (gamePlayer)
                {
                case playerType.X:
                    move = playerX.MakeMove(gameArray);
                    if (move >= 0)
                    {
                        gameArray[move] = "X";
                        gamePlayer      = IsPlaying(playerType.X);
                    }
                    break;

                case playerType.O:

                    move = playerO.MakeMove(gameArray);
                    if (move >= 0)
                    {
                        gameArray[move] = "O";
                        gamePlayer      = IsPlaying(playerType.O);
                    }
                    break;

                default:
                    break;
                }

                // Player X wins.
                if (gameBoard.IsWinner(gameArray, playerType.X))
                {
                    AnnounceWinner(playerType.X);
                    runGame = false;
                }
                // Player Y wins.
                else if (gameBoard.IsWinner(gameArray, playerType.O))
                {
                    AnnounceWinner(playerType.O);
                    runGame = false;
                }
                // Tie.
                else if (IsTie(gameBoard.IsFull(gameArray),
                               gameBoard.IsWinner(gameArray, gamePlayer),
                               gameBoard.IsWinner(gameArray, gamePlayer)))
                {
                    runGame = false;
                }

                // Resets within the method to prevent recursion.  When the
                // method finishes, so does the app.
                if (!runGame)
                {
                    DisplayBoardGrid(gameArray);
                    gameArray  = resetGameArray;
                    gamePlayer = playerType.X;
                    runGame    = PlayAgain();
                }
            } while (runGame);
        }