private Tuple <int> checkEffectedPlayers() { int colPos = explosionMatrix[explosionStep, 0]; int rowPos = explosionMatrix[explosionStep, 1]; //// Check if the player was caught in the blast //if (colPos == myOwner.playerX && rowPos == myOwner.playerY) //{ // if (myOwner.playerState == "Shield") // { // myOwner.playerState = null; // } // else // { // myOwner.myLivesAndScore.ReduceLives(1); // myOwner.myLivesAndScore.ChangeScore(50, false); // } //} // Check if all players were caught in the blast. for (int i = 0; i < GameWindow.ReturnPlayerList().Count; i++) { PlayerController tempPlayer = GameWindow.ReturnPlayerList()[i]; if (colPos == tempPlayer.playerX && rowPos == tempPlayer.playerY) { //MessageBox.Show(string.Format("{0} was caught in the blast!", tempPlayer.playerName)); if (tempPlayer.playerState == "Shield") { //MessageBox.Show(string.Format("{0} was shielded.", tempPlayer.playerName)); tempPlayer.playerState = null; tempPlayer.UpdatePlayerStatus("null"); } else { tempPlayer.myLivesAndScore.ReduceLives(1); tempPlayer.myLivesAndScore.ChangeScore(50, false); // Grant the player points for causing other players to lose lives. myOwner.myLivesAndScore.ChangeScore(50, true); } } } return(new Tuple <int>(0)); }
public void PlayerMoveToCell() { playerDirection(); relativePosition = pathCells[0].TransformToAncestor(localGameGrid).Transform(new Point(0, 0)); //MessageBox.Show(String.Format("MY NEW POINTS ARE X: {0}, Y: {1} ", relativePosition.X, relativePosition.Y)); TranslateTransform translateTransform1 = new TranslateTransform(relativePosition.X, relativePosition.Y); playerTileAnimOverlay.RenderTransform = translateTransform1; playerTile.RenderTransform = translateTransform1; // Update the player's position in the list for (int i = 0; i < GameWindow.ReturnPlayerList().Count; i++) { if (GameWindow.ReturnPlayerList()[i].playerName == playerName) { GameWindow.ReturnPlayerList()[i].playerPosition = relativePosition; Console.WriteLine(string.Format("{0} found at position: {1} {2}.", playerName, relativePosition.X / 64, relativePosition.Y / 64)); // Prevent players from occupying the same tile. // if (relativePosition == GameWindow.ReturnPlayerList()[i].playerPosition && GameWindow.ReturnPlayerList()[i].playerName != playerName) { return; } } } //Debug.WriteLine("New Player x = {0}, New Player y = {1}", playerX, playerY); localGameGrid.Children.Remove(playerTile); localGameGrid.Children.Remove(playerTileAnimOverlay); localGameGrid.Children.Add(playerTileAnimOverlay); localGameGrid.Children.Add(playerTile); playerX = Convert.ToInt32(relativePosition.X) / tileSize; playerY = Convert.ToInt32(relativePosition.Y) / tileSize; pathCells.RemoveAt(0); }
private void setPlayerPos(int gridStartPos) { playerTileAnimOverlay = new PlayerUserControl(); playerTileAnimOverlay.UpdateDirection(true); playerTile = new Rectangle(); playerTile.Height = tileSize; playerTile.Width = tileSize; Grid.SetColumn(playerTile, 0); Grid.SetRow(playerTile, 0); Grid.SetZIndex(playerTile, 10); //set the layering position of the playerTile - can use Grid.SetZIndex or Canvas.SetZIndex(object,int layer) Grid.SetZIndex(playerTileAnimOverlay, 11); //------------------------------------------------------------------------------------------------ //-------------------------------| PLAYER 1 |------------------------------- //------------------------------------------------------------------------------------------------ if (gridStartPos == 0) { relativePosition = new Point(64, 64); playerColour = Colors.Silver; playerImage = "PlayerRight1.png"; Debug.WriteLine("%%% Player {0}: player X: {1}, player Y: {2} /n", gridStartPos + 1, playerX, playerY); } //------------------------------------------------------------------------------------------------ //-------------------------------| PLAYER 2 |------------------------------- //------------------------------------------------------------------------------------------------ else if (gridStartPos == 1) { if (GameWindow.ReturnNumberOfPlayer() == 6) { // Become PLAYER 3 relativePosition = new Point(1344, 384); playerImage = "PlayerRight1.png"; playerTileAnimOverlay.UpdateDirection(false); } else { // Stay as PLAYER 2 relativePosition = new Point(1344, 64); playerImage = "PlayerRight1.png"; } playerColour = Colors.Red; Debug.WriteLine("%%% Player {0}: player X: {1}, player Y: {2} /n", gridStartPos + 1, playerX, playerY); } //------------------------------------------------------------------------------------------------ //-------------------------------| PLAYER 3 |------------------------------- //------------------------------------------------------------------------------------------------ else if (gridStartPos == 2) { if (GameWindow.ReturnNumberOfPlayer() == 6) { // Becomes PLAYER 5 relativePosition = new Point(64, 704); playerImage = "PlayerRight1.png"; } else { // Stay as PLAYER 3 relativePosition = new Point(1344, 704); playerImage = "PlayerRight1.png"; } playerColour = Colors.Blue; Debug.WriteLine("%%% Player {0}: player X: {1}, player Y: {2} /n", gridStartPos + 1, playerX, playerY); } //------------------------------------------------------------------------------------------------ //-------------------------------| PLAYER 4 |------------------------------- //------------------------------------------------------------------------------------------------ else if (gridStartPos == 3) { if (GameWindow.ReturnNumberOfPlayer() == 6) { // BECOMES PLAYER 6 relativePosition = new Point(64, 384); playerImage = "PlayerRight1.png"; } else { // Stay as PLAYER 4 relativePosition = new Point(64, 704); playerImage = "PlayerRight1.png"; } Debug.WriteLine("%%% Player {0}: player X: {1}, player Y: {2} /n", gridStartPos + 1, playerX, playerY); playerColour = Colors.Yellow; } //------------------------------------------------------------------------------------------------ //-------------------------------| PLAYER 5 |------------------------------- //------------------------------------------------------------------------------------------------ else if (gridStartPos == 4) { relativePosition = new Point(1344, 64); playerColour = (Color)ColorConverter.ConvertFromString("#FFAC02FB"); playerImage = "PlayerRight1.png"; Debug.WriteLine("%%% Player {0}: player X: {1}, player Y: {2} /n", gridStartPos + 1, playerX, playerY); } //------------------------------------------------------------------------------------------------ //-------------------------------| PLAYER 6 |------------------------------- //------------------------------------------------------------------------------------------------ else if (gridStartPos == 5) { relativePosition = new Point(1344, 704); playerColour = Colors.Green; playerImage = "PlayerRight1.png"; //Debug.WriteLine("%%% Player {0}: player X: {1}, player Y: {2} /n", gridStartPos + 1, playerX, playerY); } else { return; } // Update the player's position in the list for (int i = 0; i < GameWindow.ReturnPlayerList().Count; i++) { if (GameWindow.ReturnPlayerList()[i].playerName == playerName) { GameWindow.ReturnPlayerList()[i].playerPosition = relativePosition; MessageBox.Show(string.Format("{0} found at position: {1}.", playerName, relativePosition)); } } //playerTile.Fill = new ImageBrush(new BitmapImage(new Uri(@"./Resources/" + playerImage, UriKind.Relative))); playerX = (int)relativePosition.X / tileSize; playerY = (int)relativePosition.Y / tileSize; playerTile.Fill = new SolidColorBrush(Colors.Transparent); localGameGrid.Children.Add(playerTileAnimOverlay); localGameGrid.Children.Add(playerTile); }