Exemplo n.º 1
0
 public void updatePlayer(Player p, Point currentP, int direction, int isShot, int health, int coins, int points)
 {
     p.setCurrentP(currentP);
     p.setDirection(direction);
     p.setIsShot(isShot);
     p.setHealth(health);
     p.setCoins(coins);
     p.setPoints(points);
 }
Exemplo n.º 2
0
        private void updateMap(string msg)
        {
            msg = msg.Substring(2);
            string[] splittedValues = msg.Split(':');
            if (isFirstDecode)
            {
                for (int i = 0; i < splittedValues.Length-1; i++)
                {
                    string[] tokens = splittedValues[i].Split(';');
                    Point p = new Point(int.Parse(tokens[1].Split(',')[0]), int.Parse(tokens[1].Split(',')[1]));
                    if ((i) != playerNum)
                    {
                        Player player = new Player(p, tokens[0], int.Parse(tokens[2]));
                        player.updatePlayer(player, p, int.Parse(tokens[2]), int.Parse(tokens[3]), int.Parse(tokens[4]), int.Parse(tokens[5]), int.Parse(tokens[6]));
                        playerList.Add(player);
                        grid[p.Y, p.X] = player;
                    }
                    else
                    {
                        me.updatePlayer(me, p, int.Parse(tokens[2]), int.Parse(tokens[3]), int.Parse(tokens[4]), int.Parse(tokens[5]), int.Parse(tokens[6]));
                        grid[p.Y, p.X] = me;
                    }
                }

            }
            else{
                for (int i = 0; i < splittedValues.Length - 1; i++)
                {
                    string[] tokens = splittedValues[i].Split(';');
                    Point p = new Point(int.Parse(tokens[1].Split(',')[0]), int.Parse(tokens[1].Split(',')[1]));
                    if ((i + 1) != playerNum)
                    {
                        playerList.ElementAt(i).updatePlayer(playerList.ElementAt(i+1), p, int.Parse(tokens[2]), int.Parse(tokens[3]), int.Parse(tokens[4]), int.Parse(tokens[5]), int.Parse(tokens[6]));
                        grid[p.Y, p.X] = playerList.ElementAt(i);
                    }
                    else
                    {
                        me.updatePlayer(me, p, int.Parse(tokens[2]), int.Parse(tokens[3]), int.Parse(tokens[4]), int.Parse(tokens[5]), int.Parse(tokens[6]));
                        grid[p.Y, p.X] = me;
                    }
                }
            }
            displayGrid(grid);
        }