Exemplo n.º 1
0
        private void FillList(int amount, List <Control> controls,
                              List <Control> allControls, Playertype playerType, Panel board, Random random)
        {
            for (int i = 0; i < amount; i++)
            {
                PictureBox newPlayer = new PictureBox()
                {
                    Height   = 20,
                    Width    = 20,
                    Location = new Point(random.Next(0, 240), random.Next(0, 240))
                };

                switch (playerType)
                {
                case Playertype.Human:
                    newPlayer.Image = Image.FromFile("resources/human.png");
                    break;

                case Playertype.Soldier:
                    newPlayer.Image = Image.FromFile("resources/soldier.png");
                    break;

                case Playertype.Zombie:
                    newPlayer.Image = Image.FromFile("resources/zombie.png");
                    break;
                }

                newPlayer.Invalidate();

                controls.Add(newPlayer);
                allControls.Add(newPlayer);
                board.Controls.Add(newPlayer);
            }
        }
Exemplo n.º 2
0
        public void AIMove(Playertype AIPlayer)
        {
            GameAI AI = new GameAI(GameboardRows, GameboardColumns);

            switch (AIPlayer)
            {
            case (Playertype.Random):
                AI.RandomPlayer(Gameboard, CurrentPlayer);
                return;

            case (Playertype.Easy):
                AI.EasyPlayer(Gameboard, CurrentPlayer);
                return;

            case (Playertype.Hard):
                AI.HardPlayer(Gameboard, CurrentPlayer);
                return;

            case (Playertype.NeuralNet):
                AI.NeuralNetPlayer(Gameboard, CurrentPlayer);
                return;

            default:
                AI.RandomPlayer(Gameboard, CurrentPlayer);
                return;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Determines the winner by being told who has lost
 /// </summary>
 /// <param name="loser">The player who lost THE GAME</param>
 /// <returns></returns>
 public static Winner DetermineWinner(Playertype loser)
 { 
     Winner result;
     if (loser==Playertype.Human)
     {
         result = Winner.AI;
     }
     else
     {
         result = Winner.player;
     }
     return result;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor method for the EnemyGrid class. 
        /// Creates an EnemyGrid object and initializes with RadarTile.fog in every RadarTile
        /// to emulate the fog of war.
        /// </summary>
        /// <param name="Playertype">whether you want to create the Radartile for the player or the AI opponent.</param>
        public EnemyGrid(Playertype Playertype)
            : base(Playertype, 0)
        {

            this.cursorPosition.Col = this.cursorPosition.Row = 5;
            for (int i = 0; i < radartile.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < radartile.GetLength(1); j++)
                {
                    radartile[i, j] = RadarTile.fog;
                }
            }
            this.Redraw();
        }
Exemplo n.º 5
0
    private void RequestStartGameCallback(JSONObject incomingJson)
    {
        string status = incomingJson.GetField("status").str;

        if (status == "success")
        {
            uiManager.ShowPopup(string.Format("Game will start in {0} seconds", startGameDelay), uiManager.popupDuration);

            StartCoroutine(StartGameAfter(startGameDelay));

            int raw_playertype = (int)incomingJson.GetField("playertype").i;

            if (raw_playertype == 1)
            {
                playertype = Playertype.Cop;
            }
            else if (raw_playertype == 2)
            {
                playertype = Playertype.Criminal;
            }

            SetPlayerTypes(incomingJson.GetField("playerlist"));


            StopUpdatingRoomData();
        }
        else if (status == "not_enough_players")
        {
            uiManager.ShowPopup("There are not enough players in this room.", uiManager.popupDuration);
        }
        else if (status == "already_starting")
        {
            uiManager.ShowPopup("The game is already starting.", uiManager.popupDuration);
        }
        else if (status == "failed")
        {
            Debug.Log("Room deleted");
            uiManager.ShowPopup("This room doesn't exist anymore", uiManager.popupDuration);
            uiManager.PreviousScreen(uiScreenHome);

            StopUpdatingRoomData();
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// constructor for the abstract grid class
 /// </summary>
 /// <param name="PLAYERTYPE">whether the grid to be created is for a human or nonhuman player</param>
 /// <param name="cursorLeftStart">where to position the grid</param>
 public Grid(Playertype PLAYERTYPE, int cursorLeftStart)
 {
     this._PLAYERTYPE = PLAYERTYPE;
     this.CursorLeftStart = cursorLeftStart;
 }
Exemplo n.º 7
0
    private void UpdateRoomDataCallback(JSONObject incomingJson)
    {
        string status = incomingJson.GetField("status").str;

        if (status == "success")
        {
            // Create game object with right variables
            JSONObject playerlistJson = incomingJson.GetField("playerlist");
            game.players = new List <Player>();
            bool kicked = true;
            foreach (JSONObject playerJson in playerlistJson)
            {
                Player newPlayer = new Player
                {
                    name   = playerJson.GetField("name").str,
                    ip     = playerJson.GetField("ip").str,
                    isHost = playerJson.GetField("is_host").b
                };
                if (newPlayer.name == playerName && newPlayer.ip == playerIp)
                {
                    kicked = false;

                    if (newPlayer.isHost)
                    {
                        isHost = true;
                    }
                }
                game.players.Add(newPlayer);
            }

            if (kicked)
            {
                StopUpdatingRoomData();

                uiManager.ShowPopup("You have been kicked from this room", uiManager.popupDuration);
                uiManager.PreviousScreen(uiScreenHome);
            }

            if (incomingJson.GetField("starting").b == true)
            {
                float delay = incomingJson.GetField("delay").f;
                Debug.Log("Time before start: " + delay.ToString());
                uiManager.ShowPopup(string.Format("Game will start in {0} seconds", delay), uiManager.popupDuration);

                uiManager.DismissBottomOverlay();
                uiManager.DeactivateScreen(uiManager.currentScreen);

                int playertypeInt = (int)incomingJson.GetField("playertype").i;

                if (playertypeInt == 1)
                {
                    playertype = Playertype.Cop;
                }
                else if (playertypeInt == 2)
                {
                    playertype = Playertype.Criminal;
                }

                SetPlayerTypes(playerlistJson);

                StartCoroutine(StartGameAfter(delay));

                StopUpdatingRoomData();
            }

            updateRoomData.Invoke();
        }
        else if (status == "failed")
        {
            Debug.Log("Room deleted");
            uiManager.ShowPopup("This room doesn't exist anymore", uiManager.popupDuration);
            uiManager.PreviousScreen(uiScreenHome);

            StopUpdatingRoomData();
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// call the base class constructor to create the homegrid. 
 /// </summary>
 /// <param name="playertype">the horizontal location on the cli where the grid should be drawn</param>
 public HomeGrid(Playertype playertype)
     : base(playertype, 50)
 {
    
 }
Exemplo n.º 9
0
 public void EmptyPiece()
 {
     isActive  = false;
     player    = Playertype.Empty;
     pieceType = PieceType.Empty;
 }
Exemplo n.º 10
0
 public void SetCurrentPlayer(Playertype player)
 {
     currentPlayer     = player;
     currentMoveIndex  = null;
     currentPieceIndex = null;
 }